Module

image/image/utils

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

module

Filtering

Functions

  • getSelectedImageWidget( selection ) → Element | null

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

    Parameters

    selection : Selection | DocumentSelection

    Returns

    Element | null
  • getViewImgFromWidget( figureView ) → Element

    Get view <img> element from the view widget (<figure>).

    Assuming that image is always a first child of a widget (ie. figureView.getChild( 0 )) is unsafe as other features might inject their own elements to the widget.

    The <img> can be wrapped to other elements, e.g. <a>. Nested check required.

    Parameters

    figureView : Element

    Returns

    Element
  • insertImage( model, [ attributes ], [ insertPosition ] )

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

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

    Parameters

    model : Model
    [ attributes ] : Object

    Attributes of inserted image

    Defaults to {}

    [ insertPosition ] : Position

    Position to insert the image. If not specified, the findOptimalInsertionPosition logic will be applied.

  • isImage( modelElement ) → Boolean

    Checks if the provided model element is an image.

    Parameters

    modelElement : Element

    Returns

    Boolean
  • isImageAllowed( model ) → Boolean

    Checks if image can be inserted at current model selection.

    Parameters

    model : Model

    Returns

    Boolean
  • isImageWidget( viewElement ) → Boolean

    Checks if a given view element is an image widget.

    Parameters

    viewElement : Element

    Returns

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

    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