Report an issue
Interface

ViewConversionApi (engine/conversion)

@ckeditor/ckeditor5-engine/src/conversion/upcastdispatcher

interface

Conversion interface that is registered for given UpcastDispatcher and is passed as one of parameters when dispatcher fires it's events.

Filtering

Methods

  • convertChildren( viewItem, modelCursor ) → Object

    Starts conversion of all children of given item by firing appropriate events for all those children.

    Parameters

    viewItem : Item

    Item to convert.

    modelCursor : Position

    Position of conversion.

    Returns

    Object

    result Conversion result.

    Range

    result.modelRange Model range containing results of conversion of all children of given item. When no children was converted then range is collapsed.

    Position

    result.modelCursor Position where conversion should be continued.

    Fires

  • convertItem( viewItem, modelCursor ) → Object

    Starts conversion of given item by firing an appropriate event.

    Every fired event is passed (as first parameter) an object with modelRange property. Every event may set and/or modify that property. When all callbacks are done, the final value of modelRange property is returned by this method. The modelRange must be model range or null (as set by default).

    Parameters

    viewItem : Item

    Item to convert.

    modelCursor : Position

    Position of conversion.

    Returns

    Object

    result Conversion result.

    Range | null

    result.modelRange Model range containing result of item conversion, created and modified by callbacks attached to fired event, or null if the conversion result was incorrect.

    Position

    result.modelCursor Position where conversion should be continued.

    Fires

  • splitToAllowedParent( position, node ) → Object | null

    Checks schema to find allowed parent for element that we are going to insert starting from given position. If current parent does not allow to insert element but one of the ancestors does then split nodes to allowed parent.

    If schema allows to insert node in given position, nothing is split and object with that position is returned.

    If it was not possible to find allowed parent, null is returned, nothing is split.

    Otherwise, ancestors are split and object with position and the copy of the split element is returned.

    For instance, if <image> is not allowed in <paragraph> but is allowed in $root:

    <paragraph>foo[]bar</paragraph>
    
     -> split for `<image>` ->
    
     <paragraph>foo</paragraph>[]<paragraph>bar</paragraph>

    In the sample above position between <paragraph> elements will be returned as position and the second paragraph as cursorParent.

    Parameters

    position : Position

    Position on which element is going to be inserted.

    node : Node

    Node to insert.

    Returns

    Object | null

    Split result. If it was not possible to find allowed position null is returned.

    Position

    position between split elements.

    Element

    [cursorParent] Element inside which cursor should be placed to continue conversion. When element is not defined it means that there was no split.