Extends
Constructor
new ve.ce.Document(model, surface)
#
Hierarchy
ContentEditable document.
Parameters:
Name | Type | Description |
---|---|---|
model |
ve.dm.Document | Model to observe |
surface |
ve.ce.Surface | Surface document is part of |
- Source:
Methods
getBranchNodeFromOffset(offset) → {ve.Node|null
}
#
null
}
#
Get a node at an offset.
Parameters:
Name | Type | Description |
---|---|---|
offset |
number | Offset to get node at |
- Inherited from:
- Source:
Returns:
Node at offset
- Type
-
ve.Node
|
null
getCoveredSiblingGroups(range) → {Array}
#
Get groups of sibling nodes covered by the given range.
Parameters:
Name | Type | Description |
---|---|---|
range |
ve.Range |
- Inherited from:
- Source:
Returns:
Array of objects. Each object has the following keys:
- nodes: Array of sibling nodes covered by a part of range
- parent: Parent of all of these nodes
- grandparent: parent's parent
- Type
- Array
getDir() → {string}
#
Get the document view directionality
- Source:
Returns:
Directionality (ltr/rtl)
- Type
- string
getDirectionalityFromRange(range) → {string}
#
Get the block directionality of some range
Uses the computed CSS direction value of the current node
Parameters:
Name | Type | Description |
---|---|---|
range |
ve.Range |
- Source:
Returns:
'rtl', 'ltr'
- Type
- string
Get the block directionality of some range
Uses the computed CSS direction value of the current node
getDocumentNode() → {ve.BranchNode}
#
Get the root of the document's node tree.
- Inherited from:
- Source:
Returns:
Root of node tree
- Type
- ve.BranchNode
getLang() → {string}
#
Get the document view language
- Source:
Returns:
Language code
- Type
- string
getNodeAndOffset(offset) → {ve.ce.NodeAndOffset}private
#
Calculate the DOM position corresponding to a DM offset
If there are multiple DOM locations, heuristically pick the best one for cursor placement
Parameters:
Name | Type | Description |
---|---|---|
offset |
number | Linear model offset |
- Source:
Returns:
Position
- Type
- ve.ce.NodeAndOffset
Throws:
-
Offset could not be translated to a DOM element and offset
- Type
- Error
Calculate the DOM position corresponding to a DM offset
If there are multiple DOM locations, heuristically pick the best one for cursor placement
getSlugAtOffset(offset) → {HTMLElement}
#
Get a slug at an offset.
Parameters:
Name | Type | Description |
---|---|---|
offset |
number | Offset to get slug at |
- Source:
Returns:
Slug at offset
- Type
- HTMLElement
nodeAttached(node)
#
Callback when a node is attached with ve.Node#setDocument
The node and all its children are guaranteed to be attached
Parameters:
Name | Type | Description |
---|---|---|
node |
ve.Node | The node attached |
- Inherited from:
- Source:
Fires:
Callback when a node is attached with ve.Node#setDocument
The node and all its children are guaranteed to be attached
nodeDetached(node)
#
Callback when a node is attached with ve.Node#setDocument
The node and all its children are guaranteed to be attached
Parameters:
Name | Type | Description |
---|---|---|
node |
ve.Node | The node detached |
- Inherited from:
- Source:
Fires:
Callback when a node is attached with ve.Node#setDocument
The node and all its children are guaranteed to be attached
rangeInsideOneLeafNode(range) → {boolean}
#
Test whether a range lies within a single leaf node.
Parameters:
Name | Type | Description |
---|---|---|
range |
ve.Range | The range to test |
- Inherited from:
- Source:
Returns:
Whether the range lies within a single node
- Type
- boolean
selectNodes(range, [mode]) → {Array}
#
Gets a list of nodes and the ranges within them that a selection of the document covers.
Parameters:
Name | Type | Attributes | Default | Description |
---|---|---|---|---|
range |
ve.Range | Range within document to select nodes |
||
mode |
string |
optional |
'leaves' | Type of selection to perform:
|
- Inherited from:
- Source:
Returns:
List of objects describing nodes in the selection and the ranges therein:
node
: Reference to a ve.Noderange
: ve.Range, missing if the entire node is coveredindex
: Index of the node in its parent, missing if node has no parentindexInNode
: If range is a zero-length range between two children of node, this is set to the index of the child following range (or tonode.children.length + 1
if range is between the last child and the end). If range is a zero-length range inside an empty non-content branch node, this is 0. Missing in all other cases.nodeRange
: Range covering the inside of the entire node, not including wrappernodeOuterRange
: Range covering the entire node, including wrapperparentOuterRange
: Outer range of node's parent. Missing if there is no parent or if indexInNode is set.
- Type
- Array
Throws:
setDir(dir)
#
Set the document view directionality
Parameters:
Name | Type | Description |
---|---|---|
dir |
string | Directionality (ltr/rtl) |
- Source:
setLang(lang)
#
Set the document view language
Parameters:
Name | Type | Description |
---|---|---|
lang |
string | Language code |
- Source:
Events
langChange()
#
Language or direction changed
- Source:
nodeAttached(node)
#
A node has been attached with ve.Node#setDocument . Its descendants are guaranteed to be attached too (and the event is emitted for descendants first, and for siblings in their order in the children list)
Parameters:
Name | Type | Description |
---|---|---|
node |
ve.Node | The node that has been attached |
- Inherited from:
- Source:
nodeDetached(node)
#
A node has been detached with ve.Node#setDocument . Its descendants are guaranteed to be detached too (and the event is emitted for descendants first, and for siblings in their order in the children list)
Parameters:
Name | Type | Description |
---|---|---|
node |
ve.Node | The node that has been detached |
- Inherited from:
- Source: