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

nodesprivate #

Properties:

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

Keyed by group name

Source:

Methods

addNode(groupName, key, index, node) #

Add a node.

Parameters:

Name Type Description
groupName string

Item group

key string

Item name

index number

Item index

node ve.dm.Node

Item node

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.

Source:

Returns:

Clone of this internal

Type
ve.dm.InternalList
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.Converter
doc HTMLDocument

Document to create nodes in

Source:

Returns:

Linear model data

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

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

Gets the internal list's document model

Source:

Returns:

Document model

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

getItemInsertion(groupName, key, data) → {Object} #

Generate a transaction for inserting a new internal item node

Parameters:

Name Type Description
groupName string

Item group

key string

Item key

data Array.<ve.dm.LinearData.Item>

Linear model data

Source:

Returns:

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

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

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

Get the item node from a specific index.

Parameters:

Name Type Description
index number

Item index

Source:

Returns:

Item node

Type
ve.dm.InternalItemNode
Get the item node from a specific index.

getItemNodeCount() → {number} #

Get the number it internal items in the internal list.

Source:

Returns:

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

getKeyIndex(groupName, key) → {number|undefined} #

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

Parameters:

Name Type Description
groupName string

Item group

key string

Item name

Source:

Returns:

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

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

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

Get the list node

Source:

Returns:

List node

Type
ve.dm.InternalListNode
Get the list node

getNextUniqueNumber() → {number} #

Get the next number in a monotonically increasing series.

Source:

Returns:

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

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

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

Get the node group object for a specified group name.

Parameters:

Name Type Description
groupName string

Name of the group

Source:

Returns:

Node group object, containing nodes and key order array

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

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

Get all node groups.

Source:

Returns:

Node groups, keyed by group name

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

getUniqueListKey() #

Deprecated:
  • please use `.getNodeGroup( … ).getUniqueListKey( … )` instead
Source:

markGroupAsChanged(groupName)private #

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

Parameters:

Name Type Description
groupName 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

Source:

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
Merge another internal list into this one.

onTransact() #

Handle document transaction events

Source:

Fires:

Handle document transaction events

queueItemHtml(groupName, key, 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
groupName string

Item group

key string

Item key

html string

Item contents

Source:

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
Queues up an item's html for parsing later.

removeNode(groupName, key, index, node) #

Remove a node.

Parameters:

Name Type Description
groupName string

Item group

key string

Item name

index number

Item index

node ve.dm.Node

Item node

Source:
Remove a node.

sortGroupIndexes(group)private #

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.

Parameters:

Name Type Description
group ve.dm.InternalListNodeGroup
Source:
Sort the indexOrder array within a group object.

Events

update(groupsChanged) #

Parameters:

Name Type Description
groupsChanged Array.<string>

List of groups changed since the last transaction

Source: