Expand all

ve.dm.InternalList

Constructor

new ve.dm.InternalList(doc) #

DataModel meta item.

Parameters:

Name Type Description
doc ve.dm.Document

Document model

Mixes in:
Source:
DataModel meta item.

Properties

documentprivate #

Properties:

Name Type Description
document ve.dm.Document

The document this internal list is in a 1:1 relationship with

Source:

groupsChangedprivate #

Properties:

Name Type Description
groupsChanged Array.<string>

Array of group names; array index is meaningless

Source:

itemHtmlQueueprivate #

Properties:

Name Type Description
itemHtmlQueue Array.<string>

Array of HTML strings. Emptied after #convertToData is called.

Source:

keyIndexesprivate #

Properties:

Name Type Description
keyIndexes Object.<string, number>

Internal item index, keyed by "listGroup/listKey"

Source:

listNodeprivate #

Properties:

Name Type Description
listNode ve.dm.InternalListNode | null

The corresponding data model node this meta item belongs to. Lazy-initialized via #getListNode.

Source:

nodesprivate #

Properties:

Name Type Description
nodes Object.<string, ve.dm.InternalListNodeGroup>

Keyed by group name

Source:

Methods

addNode(listGroup, listKey, listIndex, node) #

Add a node.

Parameters:

Name Type Description
listGroup string
listKey string
listIndex number

New item index, or an existing one to replace an item

node ve.dm.Node

Reference node to add

Source:
Add a node.

clone([doc]) → {ve.dm.InternalList} #

Clone this internal list.

Parameters:

Name Type Attributes Description
doc ve.dm.Document optional

The new list's document. Defaults to this list's document.

Returns:

Type
ve.dm.InternalList
Source:
Clone this internal list.

convertToData(converter, doc) → {Array.<ve.dm.LinearData.Item>} #

Converts stored item HTML into linear data.

Each item is an InternalItem, and they are wrapped in an InternalList. If there are no items an empty array is returned.

Stored HTML is deleted after conversion.

Parameters:

Name Type Description
converter ve.dm.ModelFromDomConverter
doc HTMLDocument

Document to create nodes in

Returns:

Linear model data

Type
Array.<ve.dm.LinearData.Item>
Source:
Converts stored item HTML into linear data.

getDocument() → {ve.dm.Document} #

Gets the internal list's document model

Returns:

Document model

Type
ve.dm.Document
Source:
Gets the internal list's document model

getItemInsertion(listGroup, listKey, data) → {Object} #

Generate a transaction for inserting a new internal item node

Parameters:

Name Type Description
listGroup string
listKey string
data Array.<ve.dm.LinearData.Item>

Linear model data

Returns:

Object containing the transaction (or null if none required) and the new item's index within the list

Type
Object
Source:
Generate a transaction for inserting a new internal item node

getItemNode(index) → {ve.dm.InternalItemNode|undefined} #

Get the item node from a specific index.

Parameters:

Name Type Description
index number

Item index, use #getKeyIndex to map group and key to an index

Returns:

Type
ve.dm.InternalItemNode | undefined
Source:
Get the item node from a specific index.

getItemNodeCount() → {number} #

Get the number it internal items in the internal list.

Returns:

Type
number
Source:
Get the number it internal items in the internal list.

getKeyIndex(listGroup, listKey) → {number|undefined}private #

Get the internal item index of a group key if it already exists

Parameters:

Name Type Description
listGroup string
listKey string

Returns:

The index of the group key, or undefined if it doesn't exist yet

Type
number | undefined
Source:
Get the internal item index of a group key if it already exists

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

Returns:

List group names with the "mwReference/" prefix

Type
Array.<string>
Source:

getListNode() → {ve.dm.InternalListNode} #

Get the list node

Returns:

List node

Type
ve.dm.InternalListNode
Source:
Get the list node

getNextUniqueNumber() → {number} #

Get the next number in a monotonically increasing series.

Returns:

One higher than the return value of the previous call, or 0 on the first call

Type
number
Source:
Get the next number in a monotonically increasing series.

getNodeGroup(listGroup) → {ve.dm.InternalListNodeGroup|undefined} #

Get the node group object for a specified group name.

Parameters:

Name Type Description
listGroup string

Name of the group

Returns:

Node group object, containing nodes and key order array

Type
ve.dm.InternalListNodeGroup | undefined
Source:
Get the node group object for a specified group name.

getNodeGroups() → {Object.<string, ve.dm.InternalListNodeGroup>} #

Get all node groups.

Returns:

Node groups, keyed by group name

Type
Object.<string, ve.dm.InternalListNodeGroup>
Source:
Get all node groups.

markGroupAsChanged(listGroup)private #

Mark a node group as having been changed since the last transaction.

Parameters:

Name Type Description
listGroup string

Name of group which has changed

Source:
Mark a node group as having been changed since the last transaction.

merge(list, commonLength) → {Object} #

Merge another internal list into this one.

This function updates the state of this list, and returns a mapping from indexes in list to indexes in this, as well as a set of ranges that should be copied from list's linear model into this list's linear model by the caller.

Parameters:

Name Type Description
list ve.dm.InternalList

Internal list to merge into this list

commonLength number

The number of elements, counted from the beginning, that the lists have in common

Returns:

mapping is an object mapping indexes in list to indexes in this; newItemRanges is an array of ranges of internal nodes in list's document that should be copied into our document

Type
Object
Source:
Merge another internal list into this one.

onTransact()private #

Handle document transaction events

Fires:

Source:
Handle document transaction events

queueItemHtml(listGroup, listKey, html) → {Object} #

Queues up an item's html for parsing later.

If an item with the specified group and key already exists it will be ignored, unless the data already stored is an empty string.

Parameters:

Name Type Description
listGroup string
listKey string
html string

Item contents

Returns:

Object containing index of the item in the index-value store (and also its index in the internal list node), and a flag indicating if it is a new item.

Type
Object
Source:
Queues up an item's html for parsing later.

removeNode(listGroup, listKey, listIndex, node) #

Remove a node.

Parameters:

Name Type Description
listGroup string
listKey string
listIndex number
node ve.dm.Node

Reference node to remove

Source:
Remove a node.

Events

update(groupsChanged) #

Parameters:

Name Type Description
groupsChanged Array.<string>

List of groups changed since the last transaction

Source: