Report an issue
Module

engine/conversion/downcast-selection-converters

@ckeditor/ckeditor5-engine/src/conversion/downcast-selection-converters

module

Filtering

Functions

  • clearAttributes() → function

    static

    Function factory that creates a converter which clears artifacts after the previous model selection conversion. It removes all empty view attribute elements and merges sibling attributes at all start and end positions of all ranges.

       <p><strong>^</strong></p>
    -> <p>^</p>
    
       <p><strong>foo</strong>^<strong>bar</strong>bar</p>
    -> <p><strong>foo^bar<strong>bar</p>
    
       <p><strong>foo</strong><em>^</em><strong>bar</strong>bar</p>
    -> <p><strong>foo^bar<strong>bar</p>

    This listener should be assigned before any converter for the new selection:

    modelDispatcher.on( 'selection', clearAttributes() );

    See convertCollapsedSelection which does the opposite by breaking attributes in the selection position.

    Returns

    function

    Selection converter.

  • convertCollapsedSelection() → function

    static

    Function factory that creates a converter which converts a collapsed model selection to a view selection. The converter consumes appropriate value from the consumable object, maps the model selection position to the view position and breaks attribute elements at the selection position.

    modelDispatcher.on( 'selection', convertCollapsedSelection() );

    An example of the view state before and after converting the collapsed selection:

       <p><strong>f^oo<strong>bar</p>
    -> <p><strong>f</strong>^<strong>oo</strong>bar</p>

    By breaking attribute elements like <strong>, the selection is in a correct element. Then, when the selection attribute is converted, broken attributes might be merged again, or the position where the selection is may be wrapped with different, appropriate attribute elements.

    See also clearAttributes which does a clean-up by merging attributes.

    Returns

    function

    Selection converter.

  • convertRangeSelection() → function

    static

    Function factory that creates a converter which converts a non-collapsed model selection to a view selection. The converter consumes appropriate value from the consumable object and maps model positions from the selection to view positions.

    modelDispatcher.on( 'selection', convertRangeSelection() );

    Returns

    function

    Selection converter.