media-embed/utils
@ckeditor/ckeditor5-media-embed/src/utils
Filtering
Type Definitions
-
MediaOptions
module:media-embed/utils~MediaOptions
Functions
-
internal
createMediaFigureElement( writer, registry, url, options ) → ViewContainerElement
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 : ViewDowncastWriter
registry : MediaRegistry
url : string
options : MediaOptions
Returns
-
internal
getSelectedMediaModelWidget( selection ) → null | ModelElement
module:media-embed/utils~getSelectedMediaModelWidget
Returns a selected media element in the model, if any.
Parameters
selection : ModelSelection | ModelDocumentSelection
Returns
null | ModelElement
-
internal
getSelectedMediaViewWidget( selection ) → null | ViewElement
module:media-embed/utils~getSelectedMediaViewWidget
Returns a media widget editing view element if one is selected.
Parameters
selection : ViewDocumentSelection
Returns
null | ViewElement
-
internal
insertMedia( model, url, selectable, findOptimalPosition ) → void
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.
selectable : ModelSelectable
findOptimalPosition : boolean
If true it will try to find optimal position to insert media without breaking content in which a selection is.
Returns
void
-
Checks if a given view element is a media widget.
Parameters
viewElement : ViewElement
Returns
boolean
-
internal
toMediaWidget( viewElement, writer, label ) → ViewElement
module:media-embed/utils~toMediaWidget
Converts a given
ViewElement
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 : ViewElement
writer : ViewDowncastWriter
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 outdated information? Is something missing? Please report it via our issue tracker.
With the release of version 42.0.0, we have rewritten much of our documentation to reflect the new import paths and features. We appreciate your feedback to help us ensure its accuracy and completeness.