Constructor
new ve.dm.TreeCursor(root, liveIgnoreNodes, [linearOffset])
#
DataModel TreeCursor - a tree walker that tracks the path to the current position.
Parameters:
Name | Type | Attributes | Description |
---|---|---|---|
root |
ve.dm.Node | A document node or a branch root within which to walk |
|
liveIgnoreNodes |
Array.<ve.dm.Node> | Live array of nodes to ignore (cross without counting) |
|
linearOffset |
number |
optional |
The first linear model offset inside root; default 0 |
- Source:
Methods
checkLinearOffset()
#
Validate this.linearOffset against this.node and this.offset
TODO: Improve the unit tests, then move this method to the unit testing framework
- Source:
Throws:
-
If this.linearOffset does not match this.node and this.offset
- Type
- Error
Validate this.linearOffset against this.node and this.offset
TODO: Improve the unit tests, then move this method to the unit testing framework
crossIgnoredNodes()
#
Cross any immediately following nodes that are in liveIgnoreNodes
- Source:
normalizeCursor([tooShort])
#
Skip past ignored nodes and text node boundaries
Parameters:
Name | Type | Attributes | Description |
---|---|---|---|
tooShort |
number |
optional |
Only step into text nodes longer than this |
- Source:
stepAtMost(maxLength) → {ve.dm.TreeCursor.Step|null
}
#
null
}
#
Take a single step in the walk, consuming no more than a given linear model length
A "single step" means either stepping across text content, or stepping over a node, or stepping into/out of a non-text node. (Steps into/out of text nodes happen transparently)
See https://phabricator.wikimedia.org/T162762 T162762} for the algorithm
Parameters:
Name | Type | Description |
---|---|---|
maxLength |
number | Maximum linear model length to step over (integer >= 1) |
- Source:
Returns:
The type of step taken, or null if there are no more steps
- Type
-
ve.dm.TreeCursor.Step
|
null
Take a single step in the walk, consuming no more than a given linear model length
A "single step" means either stepping across text content, or stepping over a node, or stepping into/out of a non-text node.
stepOut() → {Object|null
}
#
null
}
#
Step out of the current node (skipping past any uncrossed children or text within)
- Source:
Returns:
The step
- Type
-
Object
|
null
Type Definitions
Step
#
Type:
Properties:
Name | Type | Attributes | Description |
---|---|---|---|
type |
string | open|close|cross|crosstext |
|
length |
number | Linear length of the step (integer >= 1) |
|
path |
Array.<number> | Offset path from the root to the node containing the stepped item |
|
node |
ve.dm.Node
|
null
|
The node containing the stepped item |
|
offset |
number | The offset of the stepped item within its parent |
|
offsetLength |
number |
optional |
Number of characters 'crosstext' passed |
item |
ve.dm.Node |
optional |
The node stepped into/out of/across (absent for 'crosstext') |
- Source: