Module

image/image/utils

@ckeditor/ckeditor5-image/src/image/utils

module

Filtering

Functions

  • getSelectedImageWidget( selection ) → Element | null

    static

    Returns an image widget editing view element if one is selected.

    Parameters

    selection : Selection | DocumentSelection

    Returns

    Element | null
  • insertImage( writer, model, [ attributes ] )

    static

    Handles inserting single file. This method unifies image insertion using findOptimalInsertionPosition method.

    model.change( writer => {
        insertImage( writer, model, { src: 'path/to/image.jpg' } );
    } );

    Parameters

    writer : Writer
    model : Model
    [ attributes ] : Object

    Attributes of inserted image

    Defaults to {}

  • isImage( modelElement ) → Boolean

    static

    Checks if the provided model element is an image.

    Parameters

    modelElement : Element

    Returns

    Boolean
  • isImageAllowed( model ) → Boolean

    static

    Checks if image can be inserted at current model selection.

    Parameters

    model : Model

    Returns

    Boolean
  • isImageWidget( viewElement ) → Boolean

    static

    Checks if a given view element is an image widget.

    Parameters

    viewElement : Element

    Returns

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

    static

    Converts a given Element to an image widget:

    • Adds a custom property allowing to recognize the image 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. It will be concatenated with the image alt attribute if one is present.

    Returns

    Element