Constructor
new ve.dm.InternalList(doc)
#
DataModel meta item.
Parameters:
| Name | Type | Description |
|---|---|---|
doc |
ve.dm.Document | Document model |
- Mixes in:
- Source:
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 |
- Source:
keyIndexesprivate
#
Properties:
| Name | Type | Description |
|---|---|---|
keyIndexes |
Object.<string, number> | Internal item index, keyed by "groupName/key" |
- Source:
keys
#
Properties:
| Name | Type | Description |
|---|---|---|
keys |
Array.<string> | Array index is meaningful and identical to the numbers in the
|
- Source:
listNodeprivate
#
Properties:
| Name | Type | Description |
|---|---|---|
listNode |
ve.dm.InternalListNode
|
null
|
The corresponding data model node this meta
item belongs to. Lazy-initialized via |
- Source:
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 | New item index, or an existing one to replace an item |
node |
ve.dm.Node | Reference node to add |
- Source:
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:
- Type
- ve.dm.InternalList
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 |
- Source:
Returns:
Linear model data
- Type
- Array.<ve.dm.LinearData.Item>
getDocument() → {ve.dm.Document}
#
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
getItemNode(index) → {ve.dm.InternalItemNode|undefined}
#
undefined}
#
Get the item node from a specific index.
Parameters:
| Name | Type | Description |
|---|---|---|
index |
number | Item index, use |
- Source:
Returns:
- Type
-
ve.dm.InternalItemNode
|
undefined
getItemNodeCount() → {number}
#
Get the number it internal items in the internal list.
- Source:
Returns:
- Type
- number
getKeyIndex(groupName, key) → {number|undefined}private
#
undefined}private
#
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
getListNode() → {ve.dm.InternalListNode}
#
Get the list node
- Source:
Returns:
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
getNodeGroup(groupName) → {ve.dm.InternalListNodeGroup|undefined}
#
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
getNodeGroups() → {Object.<string, ve.dm.InternalListNodeGroup>}
#
Get all node groups.
- Source:
Returns:
Node groups, keyed by group name
- Type
- Object.<string, ve.dm.InternalListNodeGroup>
getUniqueListKey(groupName, oldListKey, prefix) → {string}
#
Parameters:
| Name | Type | Description |
|---|---|---|
groupName |
string | Name of the group |
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
|
- Deprecated:
- please use `.getNodeGroup( … ).getUniqueListKey( … )` instead
- Source:
Returns:
Generated unique list key, or existing unique key associated with oldListKey
- Type
- string
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:
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
onTransact()private
#
Handle document transaction events
- Source:
Fires:
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
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 | Reference node to remove |
- Source: