Report an issue
Module

list/converters

@ckeditor/ckeditor5-list/src/converters

module

Filtering

Functions

  • cleanList( evt, data, conversionApi )

    static

    A view-to-model converter for <ul> and <ol> view elements that cleans the input view of garbage. This is mostly to clean whitespaces from between <li> view elements inside the view list element, however, also incorrect data can be cleared if the view was incorrect.

    Parameters

    evt : EventInfo

    An object containing information about the fired event.

    data : Object

    An object containing conversion input and a placeholder for conversion output and possibly other values.

    conversionApi : Object

    Conversion interface to be used by the callback.

  • cleanListItem( evt, data, conversionApi )

    static

    A view-to-model converter for <li> elements that cleans whitespace formatting from the input view.

    Parameters

    evt : EventInfo

    An object containing information about the fired event.

    data : Object

    An object containing conversion input and a placeholder for conversion output and possibly other values.

    conversionApi : Object

    Conversion interface to be used by the callback.

  • modelChangePostFixer( model, writer ) → Boolean

    static

    Post-fixer that reacts to changes on document and fixes incorrect model states.

    In an example below, there is a correct list structure. Then the middle element will be removed so the list structure will become incorrect:

    <listItem listType="bulleted" listIndent=0>Item 1</listItem>
    <listItem listType="bulleted" listIndent=1>Item 2</listItem>   <--- this is removed.
    <listItem listType="bulleted" listIndent=2>Item 3</listItem>

    List structure after the middle element removed:

    <listItem listType="bulleted" listIndent=0>Item 1</listItem>
    <listItem listType="bulleted" listIndent=2>Item 3</listItem>

    Should become:

    <listItem listType="bulleted" listIndent=0>Item 1</listItem>
    <listItem listType="bulleted" listIndent=1>Item 3</listItem>   <--- note that indent got post-fixed.

    Parameters

    model : Model

    The data model.

    writer : Writer

    The writer to do changes with.

    Returns

    Boolean

    true if any change has been applied, false otherwise.

  • modelIndentPasteFixer( evt, args )

    static

    A fixer for pasted content that includes list items.

    It fixes indentation of pasted list items so the pasted items match correctly to the context they are pasted into.

    Example:

    <listItem listType="bulleted" listIndent=0>A</listItem>
    <listItem listType="bulleted" listIndent=1>B^</listItem>
    // At ^ paste:  <listItem listType="bulleted" listIndent=4>X</listItem>
    //              <listItem listType="bulleted" listIndent=5>Y</listItem>
    <listItem listType="bulleted" listIndent=2>C</listItem>

    Should become:

    <listItem listType="bulleted" listIndent=0>A</listItem>
    <listItem listType="bulleted" listIndent=1>BX</listItem>
    <listItem listType="bulleted" listIndent=2>Y/listItem>
    <listItem listType="bulleted" listIndent=2>C</listItem>

    Parameters

    evt : EventInfo

    An object containing information about the fired event.

    args : Array

    Arguments of insertContent.

  • modelToViewPosition( view ) → function

    static

    Returns callback for model position to view position mapping for Mapper. The callback fixes positions between listItem elements that would be incorrectly mapped because of how list items are represented in model and view.

    Parameters

    view : View

    A view instance.

    Returns

    function
  • modelViewChangeIndent( model ) → function

    static

    A model-to-view converter for listIndent attribute change on listItem model element.

    Parameters

    model : Model

    Model instance.

    Returns

    function

    Returns a conversion callback.

  • modelViewChangeType( evt, data, conversionApi )

    static

    A model-to-view converter for type attribute change on listItem model element.

    This change means that <li> elements parent changes from <ul> to <ol> (or vice versa). This is accomplished by breaking view elements, changing their name and merging them.

    Parameters

    evt : EventInfo

    An object containing information about the fired event.

    data : Object

    Additional information about the change.

    conversionApi : Object

    Conversion interface.

  • modelViewInsertion( model ) → function

    static

    A model-to-view converter for listItem model element insertion.

    It creates a <ul><li></li><ul> (or <ol>) view structure out of a listItem model element, inserts it at the correct position, and merges the list with surrounding lists (if available).

    Parameters

    model : Model

    Model instance.

    Returns

    function

    Returns a conversion callback.

  • modelViewMergeAfter( evt, data, conversionApi )

    static

    A special model-to-view converter introduced by the list feature. This converter takes care of merging view lists after something is removed or moved from near them.

    Example:

    // Model:                        // View:
    <listItem>foo</listItem>         <ul><li>foo</li></ul>
    <paragraph>xxx</paragraph>       <p>xxx</p>
    <listItem>bar</listItem>         <ul><li>bar</li></ul>
    
    // After change:                 // Correct view guaranteed by this converter:
    <listItem>foo</listItem>         <ul>
    <listItem>bar</listItem>             <li>foo</li>
                                         <li>bar</li>
                                     </ul>

    Parameters

    evt : EventInfo

    An object containing information about the fired event.

    data : Object

    Additional information about the change.

    conversionApi : Object

    Conversion interface.

  • modelViewRemove( model ) → function

    static

    A model-to-view converter for listItem model element removal.

    Parameters

    model : Model

    Model instance.

    Returns

    function

    Returns a conversion callback.

  • modelViewSplitOnInsert( evt, data, conversionApi )

    static

    A special model-to-view converter introduced by the list feature. This converter is fired for insert change of every model item, and should be fired before the actual converter. The converter checks whether the inserted model item is a non-listItem element. If it is, and it is inserted inside a view list, the converter breaks the list so the model element is inserted to the view parent element corresponding to its model parent element.

    The converter prevents such situations:

    // Model:                        // View:
    <listItem>foo</listItem>         <ul>
    <listItem>bar</listItem>             <li>foo</li>
                                         <li>bar</li>
                                     </ul>
    
    // After change:                 // Correct view guaranteed by this converter:
    <listItem>foo</listItem>         <ul><li>foo</li></ul><p>xxx</p><ul><li>bar</li></ul>
    <paragraph>xxx</paragraph>       // Instead of this wrong view state:
    <listItem>bar</listItem>         <ul><li>foo</li><p>xxx</p><li>bar</li></ul>

    Parameters

    evt : EventInfo

    An object containing information about the fired event.

    data : Object

    Additional information about the change.

    conversionApi : Object

    Conversion interface.

  • viewModelConverter( evt, data, conversionApi )

    static

    A view-to-model converter that converts <li> view elements into listItem model elements.

    To set correct values of the listType and listIndent attributes the converter:

    • checks <li>'s parent,
    • stores and increases the conversionApi.store.indent value when <li>'s sub-items are converted.

    Parameters

    evt : EventInfo

    An object containing information about the fired event.

    data : Object

    An object containing conversion input and a placeholder for conversion output and possibly other values.

    conversionApi : Object

    Conversion interface to be used by the callback.

  • viewToModelPosition( model ) → function

    static

    The callback for view position to model position mapping for Mapper. The callback fixes positions between <li> elements that would be incorrectly mapped because of how list items are represented in model and view.

    Parameters

    model : Model

    Model instance.

    Returns

    function

    Returns a conversion callback.