class Range
The Range represents a fragment of a document that can contain nodes and parts of text nodes.
properties:
isCollapsed
read-only, boolean, true if the range is collapsed to one position (start == end)
commonAncestorContainer
read-only, Element, nearest container element that encloses as start as end positions.
endContainer
read-only, the Node within which the Range ends.
endOffset
read-only, end position in endContainer
startContainer
read-only, the Node within which the Range starts.
startOffset
read-only, start position in startContainer
start
read-only, pair of [startContainer, startOffset].
end
read-only, pair of [endContainer, endOffset].
methods:
setStart()
range.setStart(node,offset)
setEnd()
range.setEnd(node,offset)
setStartBefore()
range.setStartBefore(node)
Set start position so it will include start of the node.
setEndBefore()
range.setEndBefore(node)
Set end position so it will NOT include start of the node.
setStartAfter()
range.setStartAfter(node)
Set start position so it will NOT include start of the node.
setEndAfter()
range.setEndAfter(node)
Set start position so it will include end of the node.
selectNode()
range.selectNode(node)
Setup range to include start and end positions of the node.
selectNodeContents()
range.selectNodeContents(node)
Setup range to do not include start and end positions of the node but its content.
collapse()
range.collapse([toStart:bool])` - sets either end or start positions.
sets either:
- end = start, toStart is true, or
- start = end, otherwise.
cloneRange()
range.cloneRange():Range
returns copy of this range object.
Methods (Sciter specific):
nodes()
range.nodes():array<Node>
returns list of nodes covered by the range - all nodes that have either start or end inside the range.
applyMark()
highlight()
range.applyMark(name | [name1, name2,...]) // or
range.highlight(name | [name1, name2,...])
apply mark or marks to the range so it can be styles by CSS ::mark(name) {...}.
clearMark()
clearHighlight()
range.clearMark(name | [name1, name2,...]) // or
range.clearHighlight(name | [name1, name2,...])
removes given mark(s) from the range.
marks()
range.marks():[]
returns list (array) of mark names inside this range.
setToMark()
range.setToMark(name)
setups the range to start/end of character range having name mark set.