media-embed/utils
@ckeditor/ckeditor5-media-embed/src/utils
Filtering
Functions
-
createMediaFigureElement( writer, registry, url, options = { [options.elementName], [options.useSemanticWrapper], [options.renderForEditingView] } ) → ContainerElement
module:media-embed/utils~createMediaFigureElement
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 : Object
-
Properties
[ options.elementName ] : String
[ options.useSemanticWrapper ] : Boolean
[ options.renderForEditingView ] : Boolean
Returns
-
getSelectedMediaModelWidget( selection ) → Element | null
module:media-embed/utils~getSelectedMediaModelWidget
Returns a selected media element in the model, if any.
-
getSelectedMediaViewWidget( selection ) → Element | null
module:media-embed/utils~getSelectedMediaViewWidget
Returns a media widget editing view element if one is selected.
-
insertMedia( model, url, [ insertRange ], findOptimalPosition )
module:media-embed/utils~insertMedia
Creates a media element and inserts it into the model.
Note: This method will use
model.insertContent()
logic of inserting content if noinsertPosition
is passed.Parameters
model : Model
url : String
An URL of an embeddable media.
[ insertRange ] : Range
The range to insert the media. If not specified, the default behavior of
model.insertContent()
will be applied.findOptimalPosition : Boolean
If true it will try to find optimal position to insert media without breaking content in which a selection is.
-
isMediaWidget( viewElement ) → Boolean
module:media-embed/utils~isMediaWidget
Checks if a given view element is a media widget.
-
toMediaWidget( viewElement, writer, label ) → Element
module:media-embed/utils~toMediaWidget
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
Every day, we work hard to keep our documentation complete. Have you spotted an outdated information? Is something missing? Please report it via our issue tracker.