Sign up (with export icon)

MediaStyleOptionDefinition

Api-interface iconinterface

The definition of a single media style option used by the media embed style feature.

To customize a built-in style, re-declare it with the same name — only the fields you set will be replaced; the rest are inherited from the built-in. To register a brand-new style, provide a fresh name and a complete definition (title, icon, and — unless isDefault: trueclassName).

import sideIcon from 'path/to/icon.svg';

const sideStyle = {
	name: 'side',
	title: 'Side media',
	icon: sideIcon,
	className: 'media-style-side'
};
Copy code

Each option registers a toggle button under the name 'mediaEmbed:{name}' in the UI component factory.

Properties

  • Chevron-right icon

    className : string | undefined

    The CSS class added to the view <figure> when this style is applied. Required for every non-default style — default styles are encoded as the absence of the mediaStyle attribute, so they intentionally have no class.

    Inherited from the built-in style with the matching name when not set.

  • Chevron-right icon

    icon : string | undefined

    The button icon. Either an SVG XML source string, or one of the keys in DEFAULT_ICONS ('inlineLeft', 'left', 'center', 'right', 'inlineRight') to use one of the icons shipped with the plugin.

    Required when defining a custom style. Inherited from the built-in style with the matching name when overriding a built-in.

  • Chevron-right icon

    isDefault : boolean | undefined

    When true, this style is the default state — applying it removes the mediaStyle attribute from the model element (no class is written to the view). Default styles must not define a className.

    Inherited from the built-in style with the matching name when not set.

  • Chevron-right icon

    name : string

    The unique style name. It is used to:

    • reference a built-in style or define a custom one,
    • store the chosen style in the model as the mediaStyle attribute,
    • register the toolbar button under 'mediaEmbed:{name}'.
  • Chevron-right icon

    title : string | undefined

    The button title. The title is wrapped in editor.t() at button creation, so titles that match keys in the official translation set will be localized automatically.

    Required when defining a custom style. Inherited from the built-in style with the matching name when overriding a built-in.