Report an issue
Class

MediaRegistry (media-embed)

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

class

A bridge between the raw media content provider definitions and the editor view content.

It helps translating media URLs to corresponding view elements.

Mostly used by the MediaEmbedEditing plugin.

Filtering

Properties

  • locale : Locale

    The locale Locale instance.

  • providerDefinitions : Array

    The media provider definitions available for the registry. Usually corresponding with the media configuration.

Methods

  • constructor( locale, config )

    Creates an instance of the MediaRegistry class.

    Parameters

    locale : Locale

    The localization services instance.

    config : MediaEmbedConfig

    The configuration of the media embed feature.

  • getMediaViewElement( writer, url, options = { [options.renderMediaPreview], [options.renderForEditingView] } ) → Element

    For the given media URL string and options, it returns the view element representing that media.

    Note: If no URL is specified, an empty view element is returned.

    Parameters

    writer : DowncastWriter

    The view writer used to produce a view element.

    url : String

    The URL to be translated into a view element.

    options : Object
    Properties
    [ options.renderMediaPreview ] : String
    [ options.renderForEditingView ] : String

    Returns

    Element
  • hasMedia( url ) → Boolean

    Checks whether the passed URL is representing a certain media type allowed in the editor.

    Parameters

    url : String

    The URL to be checked

    Returns

    Boolean
  • _getMedia( url ) → Media | null

    protected

    Returns a Media instance for the given URL.

    Parameters

    url : String

    The URL of the media.

    Returns

    Media | null

    The Media instance or null when there is none.

  • _getUrlMatches( url, pattern ) → Array | null

    private

    Tries to match url to pattern.

    Parameters

    url : String

    The URL of the media.

    pattern : RegExp

    The pattern that should accept the media URL.

    Returns

    Array | null