We use cookies to make our website more effective. By using our website you agree to our privacy policy.

Namespace: sequences

sequences

Known issues:
<div>o[n]e<p>two</p></div> provides a problem in determining the "root"
element for a sequence.

// A picture of how sequences are derived from a node tree

2 text nodes "f" and "oo"
|
v
foo<u>ba<i>r</i> baz</u> qux
| | | | | | |
0 2 3 5 6 10 15

split (1, 1, 'split')
| u (3, 10, u)
| | i (5, 6, i)
| | |
foobar baz qux
TODO
  • - don't replace nested reusable containers
    - don't replace text resuable nodes
    - multi line sequences (array of sequences)
    - preserve boundaries

Members

VOID_CHARACTERstring

The private-use unicode character that denotes void elements in the
content string of a sequence. Void elements are line-breaking elements,
but unlike container elements, they contain no children.
TODO
  • Consider having a set of possible such private-use unicode characters
    that can be choosen from during the creation of a sequence. This would
    allow us to avoid conflicts in the case where private-use characters are
    already present as content in the DOM that is being sequenced.

Methods

create(boundaries){Sequences}

Creates a Sequence object from the nearest line breaking element that
contains the given boundaries or element.
Name Type Description
boundaries Element | Array.<Boundary>

hint(sequence, spans){string}

Prints a string demarking the given span in the given sequence.
Name Type Description
sequence Sequence
spans Array.<Span>

insertAfter(sequence, text, index){Sequence}

Inserts text into the sequence behind the given index.
Name Type Description
sequence Sequence
text string
index number

insertBefore(sequence, text, index){Sequence}

Inserts text into the sequence in front of the given index.
Name Type Description
sequence Sequence
text string
index number

is(obj){boolean}

Checks whether the given object is a sequence interface.
Name Type Description
obj Object

nestedSpans(spans, bounds){Array.<Span>}

Returns all spans that fall within the given bounds.
Name Type Description
spans Array.<Span>
bounds Span

remove(sequence, start, end){Sequence}

Removes a section of a sequence between the given offsets while
preserving offsets in relation to the content.
Name Type Description
sequence Sequence
start number
end number
comments powered by Disqus