Report an issue
Module

media-embed/utils

@ckeditor/ckeditor5-media-embed/src/utils

module

Filtering

Functions

  • createMediaFigureElement( writer, registry, url, options = { [options.useSemanticWrapper], [options.renderForEditingView] } ) → ContainerElement

    static

    Creates a view element representing the media. Either "semantic" one for the data pipeline:

    <figure class="media">
        <oembed url="foo"></oembed>
    </figure>

    or "non-semantic" (for the editing view pipeline):

    <figure class="media">
        <div data-oembed-url="foo">[ non-semantic media preview for "foo" ]</div>
    </figure>

    Parameters

    writer : DowncastWriter
    registry : MediaRegistry
    url : String
    options : Object
    Properties
    [ options.useSemanticWrapper ] : String
    [ options.renderForEditingView ] : String

    Returns

    ContainerElement
  • getSelectedMediaModelWidget( selection ) → Element | null

    static

    Returns a selected media element in the model, if any.

    Parameters

    selection : Selection

    Returns

    Element | null
  • getSelectedMediaViewWidget( selection ) → Element | null

    static

    Returns a media widget editing view element if one is selected.

    Parameters

    selection : Selection | DocumentSelection

    Returns

    Element | null
  • insertMedia( model, url, [ insertPosition ] )

    static

    Creates a media element and inserts it into the model.

    Note: This method will use model.insertContent() logic of inserting content if no insertPosition is passed.

    Parameters

    model : Model
    url : String

    An URL of an embeddable media.

    [ insertPosition ] : Position

    Position to insert media. If not specified, the default behavior of model.insertContent() will be applied.

  • isMediaWidget( viewElement ) → Boolean

    static

    Checks if a given view element is a media widget.

    Parameters

    viewElement : Element

    Returns

    Boolean
  • toMediaWidget( viewElement, writer, label ) → Element

    static

    Converts a given Element to a media embed widget:

    • Adds a custom property allowing to recognize the media widget element.
    • Calls the toWidget function with the proper element's label creator.

    Parameters

    viewElement : Element
    writer : DowncastWriter

    An instance of the view writer.

    label : String

    The element's label.

    Returns

    Element