Module

media-embed/utils

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

module

Filtering

Type Definitions

Functions

  • createMediaFigureElement( writer, registry, url, options ) → ContainerElement

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

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

    or a "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 : MediaOptions

    Returns

    ContainerElement
  • getSelectedMediaModelWidget( selection ) → Element | null

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

    Parameters

    selection : Selection | DocumentSelection

    Returns

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

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

    Parameters

    selection : DocumentSelection

    Returns

    Element | null
  • insertMedia( model, url, selectable, findOptimalPosition ) → void

    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.

    selectable : Selectable
    findOptimalPosition : boolean

    If true it will try to find optimal position to insert media without breaking content in which a selection is.

    Returns

    void
  • isMediaWidget( viewElement ) → boolean

    Checks if a given view element is a media widget.

    Parameters

    viewElement : Element

    Returns

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

    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