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 occurrence 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(listKey, newNode)private #

Parameters:

Name Type Description
listKey string
newNode ve.dm.Node

New node to append to the end of the list of nodes with the same key

Source:

appendNodeWithKnownIndex(listKey, newNode, listIndex) #

Parameters:

Name Type Description
listKey string
newNode ve.dm.Node

Reference node to add

listIndex number

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

Source:

buildReflistNumbering() → {Array.<ve.dm.InternalListNodeGroup.RefInfo>} #

Calculate the numbering that will be assigned to each reference in the internal list group.

Returns:

Type
Array.<ve.dm.InternalListNodeGroup.RefInfo>
Source:
Calculate the numbering that will be assigned to each reference in the internal list group.

getAllReuses(listKey) → {Array.<ve.dm.Node>|undefined} #

Parameters:

Name Type Description
listKey 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(listKey) → {ve.dm.Node|undefined} #

Parameters:

Name Type Description
listKey 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(listKey) → {number|undefined}private #

Parameters:

Name Type Description
listKey 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 Attributes Default Description
oldListKey string

Current list key (typically something like "auto/0") to associate the generated list key with

prefix string optional
"literal/:"

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(listKey, newNode, [listIndex]) #

Parameters:

Name Type Attributes Description
listKey string
newNode ve.dm.Node

Reference node to insert at document position

listIndex number optional

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

Source:

isEmpty() → {boolean} #

Returns:

Type
boolean
Source:

isKnownMainListKey(newListKey) → {boolean}private #

Parameters:

Name Type Description
newListKey string

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(listKey, node) #

Parameters:

Name Type Description
listKey string
node ve.dm.Node

Reference node to remove

Source:

Type Definitions

RefInfo #

Type:

Properties:

Name Type Attributes Description
internalListIndex number

list index of the ve.dm.InternalItemNode in a ve.dm.InternalList.

label string

Rendered footnote number including any sub-reference number.

mainListIndex number optional

List index of a sub-reference's parent, or omitted for a main reference.

topLevelNumber number

Main footnote number. For a sub-reference, this is the number of the parent.

subrefNumber number optional

Sub-reference footnote number, or omitted for a main reference.

subrefs Array.<ve.dm.InternalListNodeGroup.RefInfo> optional

Only included in the "buildReflistStructure" output flavor. This is a list of sub-references on a main ref, in document order.

Source: