Expand all

ve.dm.InternalListNodeGroup

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.

Source:

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 #keyedNodes contains more than one node per listKey then firstNodes can be used to identify the node that appears first in the document. If there is only one node it's just that node. Array keys correspond to the values in the #indexOrder array. Order is meaningless but dictated by indexOrder instead.

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 #indexOrder as your primary source of truth.

Source:

indexOrderprivate #

Properties:

Name Type Description
indexOrder Array.<number>

Sorted to reflect the order of first appearance in the document. Values are indexes for the #firstNodes array.

Practically, this usually starts as a simple [ 0, 1, 2, … ] array but changes when references are added, reused, moved, and removed.

Source:

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.

Source:

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

Source:

appendNodeWithKnownIndex(key, newNode, index) #

Parameters:

Name Type Description
key string
newNode ve.dm.Node

Reference node to add

index number

Existing listIndex; ignored when this is not the first node for this key

Source:

getAllReuses(key) → {Array.<ve.dm.Node>|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
Source:

getAllReusesByListIndex(listIndex) → {Array.<ve.dm.Node>|undefined} #

Parameters:

Name Type Description
listIndex number

Returns:

All reference nodes (1 or more, never 0) that (re)use the same listIndex. Undefined when the listIndex is unknown.

Type
Array.<ve.dm.Node> | undefined
Source:

getFirstNode(key) → {ve.dm.Node|undefined} #

Parameters:

Name Type Description
key string

Returns:

Undefined in case there are no known nodes with this key

Type
ve.dm.Node | undefined
Source:

getFirstNodeByListIndex(listIndex) → {ve.dm.Node|undefined} #

Parameters:

Name Type Description
listIndex number

Returns:

Undefined in case there are no known nodes with this listIndex

Type
ve.dm.Node | undefined
Source:

getFirstNodesInIndexOrder() → {Array.<ve.dm.Node>} #

getKeysInIndexOrder() → {Array.<string>} #

Returns:

Type
Array.<string>
Source:

getListIndex(key) → {number|undefined}private #

Parameters:

Name Type Description
key string

Returns:

Corresponding listIndex for the given listKey

Type
number | undefined
Source:

getListKeyForListIndex(listIndex) → {string|undefined}private #

Parameters:

Name Type Description
listIndex number

Returns:

Corresponding listKey for the given listIndex

Type
string | undefined
Source:

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 #keyedNodes (typically "literal/") for the duplicate detection to work.

Returns:

Generated unique list key, or existing unique key associated with oldListKey

Type
string
Source:

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 listIndex; ignored when this is not the first node for this key

Source:

isEmpty() → {boolean} #

Returns:

Type
boolean
Source:

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.

Source:
Sort the indexOrder array within a group object.

unsetNode(key, node) #

Parameters:

Name Type Description
key string
node ve.dm.Node

Reference node to remove

Source: