CoreMedia CKEditor 5 Plugins
    Preparing search index...

    This generic plugin lets you register attributes, that are meant to be bound to links only. It will take care to register corresponding up- and downcast, as well as listening to selection changes, similar as CKEditor's link feature does.

    To benefit from CKEditor's link feature, it is highly recommended that all model attributes start with link in their names.

    Configuration API

    To register attributes to handle as being part of links, you may call registerAttribute. To ease this process, a utility method getLinkAttributes exists, that may be invoked like this:

    getLinkAttributes(editor)?.registerAttribute({
    model: "linkCustomAttribute",
    view: "data-custom-attribute",
    });

    CKEditor Configuration

    As an alternative to configuring these attributes via API, you may also define corresponding attributes as part of the CKEditor Link Feature configuration – with an extended section attributes:

    const linkAttributesConfig: LinkAttributesConfig = {
    attributes: [
    { view: "title", model: "linkTitle" },
    { view: "data-xlink-actuate", model: "linkActuate" },
    ],
    };

    ClassicEditor.create(sourceElement, {
    plugins: [
    LinkAttributes,
    Link,
    // ...
    ],
    link: {
    defaultProtocol: "https://",
    ...linkAttributesConfig,
    },
    };

    Declaring this as a constant is recommended to get IDE support regarding the available fields and valid values. You will note that the type of the field model requires, that the value starts with link. This automatically triggers some behavior in the Link Plugin.

    Configuration as part of the CKEditor 5 Configuration section is highly recommended, when it is about attributes that are not yet handled by any dedicated plugin, that provides editing features for that attribute. If a plugin gets added, that handles the corresponding attribute, the configuration needs to be adapted accordingly.

    While this plugin does not depend on LinkEditing explicitly, it is best used with LinkEditing to be available. Otherwise, some clean-up tasks we implicitly rely on (like for all model attributes prefixed with link) won't work.

    Hierarchy

    • Plugin
      • LinkAttributes
    Index

    Constructors

    Properties

    Methods

    Constructors

    • Parameters

      • editor: Editor

      Returns LinkAttributes

    Properties

    pluginName: "LinkAttributes" = ...
    requires: (typeof TwoStepCaretMovement | typeof LinkCleanup)[] = ...

    Methods