Constructor
new ve.dm.InternalListNodeGroup()
#
Named, documented class for the individual items in the nodes property of the
ve.dm.InternalList class.
Practically, this represents a list of ve.dm.MWReferenceNode nodes that belong to the
same group.
Named, documented class for the individual items in the nodes property of the
ve.dm.InternalList class.
Properties
firstNodesprivate
#
Properties:
| Name | Type | Description |
|---|---|---|
firstNodes |
Array.<(ve.dm.Node|undefined)> | When Practically, this is the first occurence of a reused reference (with the same group and name) in a document. That document position dictates the reference's footnote number and the order in which references are rendered in their reference list. Note this is possibly a sparse array with elements missing in case initialization happened
out of order. Skip these and use |
indexOrderprivate
#
Properties:
| Name | Type | Description |
|---|---|---|
indexOrder |
Array.<number> | Sorted to reflect the order of first appearance in the
document. Values are indexes for the Practically, this usually starts as a simple [ 0, 1, 2, … ] array but changes when references are added, reused, moved, and removed. |
keyedNodesprivate
#
Properties:
| Name | Type | Description |
|---|---|---|
keyedNodes |
Object.<string, Array.<ve.dm.Node>> | Indexed by the internal listKey. Practically, one of these arrays can contain multiple elements when a reference (with the same group and same name) is reused. The arrays can never be empty. |
Methods
appendNode(key, newNode)
#
Parameters:
| Name | Type | Description |
|---|---|---|
key |
string | |
newNode |
ve.dm.Node | New node to append to the end of the list of nodes with the same key |
appendNodeWithKnownIndex(key, newNode, index)
#
Parameters:
| Name | Type | Description |
|---|---|---|
key |
string | |
newNode |
ve.dm.Node | Reference node to add |
index |
number | Existing index; ignored when this is not the first node for this key |
getAllReuses(key) → {Array.<ve.dm.Node>|undefined}
#
undefined}
#
Parameters:
| Name | Type | Description |
|---|---|---|
key |
string |
Returns:
All reference nodes (1 or more, never 0) that (re)use the same key. Undefined when the key is unknown.
- Type
-
Array.<ve.dm.Node>
|
undefined
getFirstNode(key) → {ve.dm.Node|undefined}
#
undefined}
#
Parameters:
| Name | Type | Description |
|---|---|---|
key |
string |
Returns:
Undefined in case there are no known nodes with this key
- Type
-
ve.dm.Node
|
undefined
getFirstNodesInIndexOrder() → {Array.<ve.dm.Node>}
#
getUniqueListKey(oldListKey, prefix) → {string}
#
Generate a unique, human-readable list key that can be used instead of an item's internal list key. Calls with the same oldListKey will return the same value again.
Practically, this is used to auto-generate unique names for previously unnamed references,
e.g. name=":0" and so on.
Parameters:
| Name | Type | Description |
|---|---|---|
oldListKey |
string | Current list key (typically something like "auto/0") to associate the generated list key with |
prefix |
string | Prefix for the generated key. Must match the prefix used in
|
Returns:
Generated unique list key, or existing unique key associated with oldListKey
- Type
- string
Generate a unique, human-readable list key that can be used instead of an item's internal list key.
insertNodeInDocumentOrder(key, newNode, [index])
#
Parameters:
| Name | Type | Attributes | Description |
|---|---|---|---|
key |
string | ||
newNode |
ve.dm.Node | Reference node to insert at document position |
|
index |
number |
optional |
Existing index; ignored when this is not the first node for this key |
isEmpty() → {boolean}
#
sortGroupIndexes()
#
Sort the indexOrder array within a group object.
Items are sorted by the start offset of their firstNode, unless that node has the 'placeholder' attribute, in which case it moved to the end of the list, where it should be ignored.
unsetNode(key, node)
#
Parameters:
| Name | Type | Description |
|---|---|---|
key |
string | |
node |
ve.dm.Node | Reference node to remove |