Class

RangeParser (engine/dev-utils)

@ckeditor/ckeditor5-engine/src/dev-utils/view

class private

Private helper class used for converting ranges represented as text inside view text nodes.

Filtering

Methods

  • constructor( options = { [options.sameSelectionCharacters] } )

    Creates a range parser instance.

    Parameters

    options : Object

    The range parser configuration.

    Properties
    [ options.sameSelectionCharacters ] : Boolean

    When set to true, the selection inside the text is marked as { and } and the selection outside the text as [ and ]. When set to false, both are marked as [ and ].

    Defaults to false

  • parse( node, order ) → Array.<Range>

    Parses the view and returns ranges represented inside text nodes. The method will remove all occurrences of {, }, [ and ] from found text nodes. If a text node is empty after the process, it will be removed, too.

    Parameters

    node : Node

    The starting node.

    order : Array.<Number>

    The order of ranges. Each element should represent the desired position of the range after sorting. For example: [2, 3, 1] means that the first range will be placed as the second, the second as the third and the third as the first.

    Returns

    Array.<Range>

    An array with ranges found.

  • private

    _createRanges() → Array.<Range>

    Uses all found bracket positions to create ranges from them.

    Returns

    Array.<Range>
  • private

    _getPositions( node )

    Gathers positions of brackets inside the view tree starting from the provided node. The method will remove all occurrences of {, }, [ and ] from found text nodes. If a text node is empty after the process, it will be removed, too.

    Parameters

    node : Node

    Staring node.

  • private

    _sortRanges( ranges, rangesOrder ) → Array

    Sorts ranges in a given order. Range order should be an array and each element should represent the desired position of the range after sorting. For example: [2, 3, 1] means that the first range will be placed as the second, the second as the third and the third as the first.

    Parameters

    ranges : Array.<Range>

    Ranges to sort.

    rangesOrder : Array.<Number>

    An array with new range order.

    Returns

    Array

    Sorted ranges array.