Extends
Properties
canContainContentstatic
#
Whether this node type can contain content. The children of content container nodes must be content nodes.
Properties:
Type | Description |
---|---|
boolean |
- Source:
canSerializeAsContentstatic
#
For a non-content node type, whether this node type can be serialized in a content position (e.g. for round tripping). This value is ignored if isContent is true.
Properties:
Type | Description |
---|---|
boolean |
- Source:
For a non-content node type, whether this node type can be serialized in a content position (e.g.
childNodeTypesstatic
#
Array of allowed child node types for this node type.
An empty array means no children are allowed. null means any node type is allowed as a child.
Properties:
Type | Description |
---|---|
Array.<string>
|
null
|
- Source:
defaultAttributesstatic
#
Default attributes to set for newly created linear model elements. These defaults will be used
when creating a new element in ve.dm
.NodeFactory#getDataElement when there is no DOM node or
existing linear model element to base the attributes on.
This property is an object with attribute names as keys and attribute values as values. Attributes may be omitted, in which case they'll simply be undefined.
Properties:
Type | Description |
---|---|
Object |
- Source:
disallowedAnnotationTypesstatic
#
Array of annotation types which can't be applied to this node
Properties:
Type | Description |
---|---|
Array.<string> |
- Source:
handlesOwnChildrenstatic
#
Whether this node handles its own children. After converting a DOM node to a linear model node of this type, the converter checks this property. If it's false, the converter will descend into the DOM node's children, recursively convert them, and attach the resulting nodes as children of the linear model node. If it's true, the converter will not descend, and will expect the node's toDataElement() to have handled the entire DOM subtree.
The same is true when converting from linear model data to DOM: if this property is true, toDomElements() will be passed the node's data element and all of its children and will be expected to convert the entire subtree. If it's false, the converter will descend into the child nodes and convert each one individually.
If .static.childNodeTypes is set to [], this property is ignored and will be assumed to be true.
Properties:
Type | Description |
---|---|
boolean |
- Source:
hasSignificantWhitespacestatic
#
Whether this node type has significant whitespace. Only applies to content container nodes (i.e. can only be true if canContainContent is also true).
If a content node has significant whitespace, the text inside it is not subject to whitespace stripping and preservation.
Properties:
Type | Description |
---|---|
boolean |
- Source:
ignoreChildrenstatic
#
Whether this node's children should be ignored when iterating over the model, for example
content which is stored inline, but is actually conceptually out-of-band data, such as a
reference node which contains the reference content (like <ref>
tags in MediaWiki).
This property should not be used for data which isn't out-of-band but is less accessible in the view, e.g. content in table cells or image captions.
If true, this node will be treated as a leaf node even if it has children. Often used in combination with handlesOwnChildren.
Properties:
Type | Description |
---|---|
boolean |
- Source:
Whether this node's children should be ignored when iterating over the model, for example
content which is stored inline, but is actually conceptually out-of-band data, such as a
reference node which contains the reference content (like <ref>
tags in MediaWiki).
isAlignablestatic
#
Whether this node type is alignable.
Properties:
Type | Description |
---|---|
boolean |
- Source:
isCellablestatic
#
Whether this node type can behave as a table cell.
Properties:
Type | Description |
---|---|
boolean |
- Source:
isContentstatic
#
Whether this node type is a content node type. This means the node represents content, cannot have children, and can only appear as children of a content container node. Content nodes are also known as inline nodes.
Properties:
Type | Description |
---|---|
boolean |
- Source:
isDeletablestatic
#
Whether this node can be deleted. If false, ve.dm
.Transaction#newFromRemoval will silently
ignore any attepts to delete this node.
Properties:
Type | Description |
---|---|
boolean |
- Source:
isDiffedAsLeafstatic
#
Whether this node type behaves like a leaf when diffing.
Properties:
Type | Description |
---|---|
boolean |
- Source:
isDiffedAsListstatic
#
Whether this node type behaves like a list when diffing.
Properties:
Type | Description |
---|---|
boolean |
- Source:
isFocusablestatic
#
Whether this node type can be focused. Focusable nodes react to selections differently.
Properties:
Type | Description |
---|---|
boolean |
- Source:
isInternalstatic
#
Whether this node type is internal. Internal node types are ignored by the converter.
Properties:
Type | Description |
---|---|
boolean |
- Source:
isMetaDatastatic
#
Whether this node type is a metadata node. This means the node represents a leaf node that has no explicit view representation, and should be treated differently for the purposes of round-tripping, copy/paste etc.
Properties:
Type | Description |
---|---|
boolean |
- Source:
isUnwrappablestatic
#
Whether this node type can be unwrapped by user input (e.g. backspace to unwrap a list item)
Properties:
Type | Description |
---|---|
boolean |
- Source:
isWrappedstatic
#
Whether this node type has a wrapping element in the linear model. Most node types are wrapped, only special node types are not wrapped.
Properties:
Type | Description |
---|---|
boolean |
- Source:
parentNodeTypesstatic
#
Array of allowed parent node types for this node type.
An empty array means this node type cannot be the child of any node. null means this node type can be the child of any node type.
Properties:
Type | Description |
---|---|
Array.<string>
|
null
|
- Source:
suggestedParentNodeTypesstatic
#
Array of suggested parent node types for this node type.
These parent node types are allowed but the editor will avoid creating them.
An empty array means this node type should not be the child of any node. null means this node type can be the child of any node type.
Properties:
Type | Description |
---|---|
Array.<string>
|
null
|
- Source:
Methods
adjustLength(adjustment)
#
Adjust the length.
This should only be called after a relevant change to the document data. Calling this method will not change the document data.
Parameters:
Name | Type | Description |
---|---|---|
adjustment |
number | Amount to adjust length by |
- Source:
Throws:
-
Invalid adjustment error if resulting length is less than 0
- Type
- Error
canBeMergedWith(node) → {boolean}
#
Check if the node can be merged with another.
For two nodes to be mergeable, the two nodes must either be the same node or:
- Are comparable according to #compareForMerging (by default, have the same type)
- Have the same depth
- Have similar ancestry (each node upstream must have the same type)
Parameters:
Name | Type | Description |
---|---|---|
node |
ve.dm.Node | Node to consider merging with |
- Source:
Returns:
Nodes can be merged
- Type
- boolean
canContainContent()
#
- Source:
- See:
canHaveChildren()
#
- Source:
- See:
canHaveChildrenNotContent()
#
- Source:
- See:
canHaveSlugAfter() → {boolean}
#
Check if the node can have a slug after it.
- Source:
Returns:
Whether the node can have a slug after it
- Type
- boolean
canHaveSlugBefore() → {boolean}
#
Check if the node can have a slug before it.
- Source:
Returns:
Whether the node can have a slug before it
- Type
- boolean
compareAttributes(attributes) → {boolean}
#
Check if specific attributes match those in the node
Parameters:
Name | Type | Description |
---|---|---|
attributes |
Object | Node attributes to match |
- Source:
Returns:
Attributes sepcified match those in the node
- Type
- boolean
compareForMerging(otherNode) → {boolean}
#
Compare with another node for merging (see #canBeMergedWidth)
The default implementation just compares node types.
Parameters:
Name | Type | Description |
---|---|---|
otherNode |
ve.dm.Node | Other node to compare with |
- Source:
Returns:
Nodes are comparable
- Type
- boolean
Compare with another node for merging (see #canBeMergedWidth)
The default implementation just compares node types.
findMatchingAncestor(type, [attributes]) → {ve.dm.Node|null
}
#
null
}
#
Find the first ancestor with matching type and attribute values.
Parameters:
Name | Type | Attributes | Description |
---|---|---|---|
type |
string | Node type to match |
|
attributes |
Object |
optional |
Node attributes to match |
- Source:
Returns:
Ancestor with matching type and attribute values
- Type
-
ve.dm.Node
|
null
getAttribute(key) → {any}
#
Get the value of an attribute.
Return value is by reference if array or object.
Parameters:
Name | Type | Description |
---|---|---|
key |
string | Name of attribute to get |
- Inherited from:
- Source:
Returns:
Value of attribute, or undefined if no such attribute exists
- Type
- any
getAttributes([prefix]) → {Object}
#
Get a copy of all attributes.
Values are by reference if array or object, similar to using the getAttribute method.
Parameters:
Name | Type | Attributes | Description |
---|---|---|---|
prefix |
string |
optional |
Only return attributes with this prefix, and remove the prefix from them |
- Inherited from:
- Source:
Returns:
Attributes
- Type
- Object
getChildNodeTypes()
#
- Source:
- See:
getClonedElement(preserveGenerated, resetAttributes) → {Object}
#
Parameters:
Name | Type | Description |
---|---|---|
preserveGenerated |
boolean | Preserve internal.generated property of element |
resetAttributes |
boolean | Reset attributes for an empty clone, as defined in #static-resetForClone |
- Overrides:
- Source:
- See:
Returns:
Cloned element object
- Type
- Object
getElement() → {Object}
#
Get a reference to the linear model element.
- Inherited from:
- Source:
Returns:
Linear model element passed to the constructor, by reference
- Type
- Object
getHashObject() → {Object}
#
getLength()
#
- Source:
- See:
getOffset()
#
- Source:
- See:
getOriginalDomElements(store) → {Array.<HTMLElement>}
#
Get the DOM element(s) this model was originally converted from, if any.
Parameters:
Name | Type | Description |
---|---|---|
store |
ve.dm.HashValueStore | Hash value store where the DOM elements are stored |
- Inherited from:
- Source:
Returns:
DOM elements this model was converted from, empty if not applicable
- Type
- Array.<HTMLElement>
getOriginalDomElementsHash() → {string|undefined
}
#
undefined
}
#
Get the DOM element(s) this model was originally converted from, if any.
- Inherited from:
- Source:
Returns:
Store hash of DOM elements this model was converted from
- Type
-
string
|
undefined
getParentNodeTypes()
#
- Source:
- See:
getStore() → {ve.dm.HashValueStore}
#
Get a reference to the hash-value store used by the element.
- Overrides:
- Source:
Returns:
Hash-value store
- Type
- ve.dm.HashValueStore
getSuggestedParentNodeTypes()
#
- Source:
- See:
getType() → {string}
#
Get the symbolic name of this model's type.
- Inherited from:
- Source:
Returns:
Type name
- Type
- string
handlesOwnChildren()
#
- Source:
- See:
hasMatchingAncestor(type, [attributes]) → {boolean}
#
Check if the node has an ancestor with matching type and attribute values.
Parameters:
Name | Type | Attributes | Description |
---|---|---|---|
type |
string | Node type to match |
|
attributes |
Object |
optional |
Node attributes to match |
- Source:
Returns:
Node has an ancestor with matching type and attribute values
- Type
- boolean
hasSignificantWhitespace()
#
- Source:
- See:
isAlignable()
#
- Source:
- See:
isCellEditable()
#
- Source:
- See:
isCellable()
#
- Source:
- See:
isContent()
#
- Source:
- See:
isDiffComparable(other) → {boolean}
#
Check if this element is of the same type as another element for the purposes of diffing.
Elements which aren't of the same type will always be shown as removal and an insertion, whereas comarable elements will be shown as an attribute change.
Parameters:
Name | Type | Description |
---|---|---|
other |
Object | Another element |
- Inherited from:
- Source:
Returns:
Elements are of a comparable type
- Type
- boolean
isDiffedAsDocument()
#
- Source:
- See:
isDiffedAsLeaf()
#
- Source:
- See:
isDiffedAsList()
#
- Source:
- See:
isEditable() → {boolean}
#
Check whether this node can be edited by a context item
The default implementation always returns true. If your node type is uneditable in certain cases, you should override this function.
- Inherited from:
- Source:
Returns:
Whether this node is editable
- Type
- boolean
Check whether this node can be edited by a context item
The default implementation always returns true.
isFocusable()
#
- Source:
- See:
isInspectable() → {boolean}
#
Check whether this node can be inspected by a context item.
The default implementation always returns true. If your node type is uninspectable in certain cases, you should override this function.
- Inherited from:
- Source:
Returns:
Whether this node is inspectable
- Type
- boolean
isInternal()
#
- Source:
- See:
isMetaData()
#
- Source:
- See:
isSurfaceable() → {boolean}
#
Check if the node can be the root of a branch exposed in a ve.ce.Surface
- Source:
Returns:
Node can be the root of a surfaced branch
- Type
- boolean
isUnwrappable()
#
- Source:
- See:
isWrapped()
#
- Source:
- See:
matches(type, [attributes]) → {boolean}
#
Check if the node matches type and attribute values.
Parameters:
Name | Type | Attributes | Description |
---|---|---|---|
type |
string | Node type to match |
|
attributes |
Object |
optional |
Node attributes to match |
- Source:
Returns:
Node matches type and attribute values
- Type
- boolean
setLength(length)
#
Set the inner length of the node.
This should only be called after a relevant change to the document data. Calling this method will not change the document data.
Parameters:
Name | Type | Description |
---|---|---|
length |
number | Length of content |
- Source:
Fires:
Throws:
-
Invalid content length error if length is less than 0
- Type
- Error
shouldIgnoreChildren()
#
- Source:
- See:
suppressSlugType() → {string|null
}
#
null
}
#
A string identifier used to suppress slugs
If sequential nodes have the same non-null suppressSlugType, then no slug is shown, e.g. two floated images can return 'float' to suppress the slug between them.
- Source:
Returns:
Type
- Type
-
string
|
null
A string identifier used to suppress slugs
If sequential nodes have the same non-null suppressSlugType, then no slug is shown, e.g.
cloneElement(element, store, preserveGenerated, resetAttributes) → {Object}static
#
Get a clone of the node's document data element.
The attributes object will be deep-copied and the .internal.generated property will be removed if present.
Parameters:
Name | Type | Description |
---|---|---|
element |
Object | |
store |
ve.dm.HashValueStore | Hash-value store used by element |
preserveGenerated |
boolean | Preserve internal.generated property of element |
resetAttributes |
boolean | Reset attributes for an empty clone, as defined in #static-resetForClone |
- Source:
Returns:
Cloned element object
- Type
- Object
isHybridInline(domElements, converter) → {boolean}static
#
Determine if a hybrid element is inline and allowed to be inline in this context
We generate block elements for block tags and inline elements for inline tags; unless we're in a content location, in which case we have no choice but to generate an inline element.
Parameters:
Name | Type | Description |
---|---|---|
domElements |
Array.<HTMLElement> | DOM elements being converted |
converter |
ve.dm.Converter |
- Source:
Returns:
The element is inline
- Type
- boolean
Determine if a hybrid element is inline and allowed to be inline in this context
We generate block elements for block tags and inline elements for inline tags; unless we're in a content location, in which case we have no choice but to generate an inline element.
remapInternalListIndexes(dataElement, mapping, internalList)static
#
Remap the internal list indexes stored in a linear model data element.
The default implementation is empty. Nodes should override this if they store internal list indexes in attributes. To remap, do something like dataElement.attributes.foo = mapping[dataElement.attributes.foo];
Parameters:
Name | Type | Description |
---|---|---|
dataElement |
Object | Data element (opening) to remap. Will be modified. |
mapping |
Object | Object mapping old internal list indexes to new internal list indexes |
internalList |
ve.dm.InternalList | Internal list the indexes are being mapped into. Used for refreshing attribute values that were computed with getNextUniqueNumber(). |
- Source:
remapInternalListKeys(dataElement, internalList)static
#
Remap the internal list keys stored in a linear model data element.
The default implementation is empty. Nodes should override this if they store internal list keys in attributes.
Parameters:
Name | Type | Description |
---|---|---|
dataElement |
Object | Data element (opening) to remap. Will be modified. |
internalList |
ve.dm.InternalList | Internal list the keys are being mapped into. |
- Source:
resetAttributesForClone(clonedElement, store)static
#
Reset attributes for a cloned element.
This will be used when an element needs to have certain attributes cleared when creating a clone, e.g. when splitting a content branch node by pressing enter, some attributes are preserved (list style) but some are cleared (check list item state).
Parameters:
Name | Type | Description |
---|---|---|
clonedElement |
Object | Cloned element, modified in place |
store |
ve.dm.HashValueStore | Hash-value store used by element |
- Source:
sanitize(dataElement)static
#
Sanitize the node's linear model data, typically if it was generated from an external source (e.g. copied HTML)
Parameters:
Name | Type | Description |
---|---|---|
dataElement |
Object | Linear model element, modified in place |
- Source:
Events
attributeChange(key, oldValue, newValue)
#
Parameters:
Name | Type | Description |
---|---|---|
key |
string | |
oldValue |
any | |
newValue |
any |
- Source:
lengthChange(diff)
#
update()
#
- Source: