mirror of
https://gerrit.wikimedia.org/r/mediawiki/extensions/VisualEditor
synced 2024-11-16 19:09:29 +00:00
fdf30b1ac8
Created an IndexValueStore class which can store any object and return an integer index to its hash map. Linear data is now stored in ve.dm.LinearData instances. Two subclasses for element and meta data contain methods specific to those data types (ElementLinearData and MetaLinearData). The static methods in ve.dm.Document that inspected data at a given offset are now instance methods of ve.dm.ElementLinearData. AnnotationSets (which are no longer OrderedHashSets) have been moved to /dm and also have to be instantiated with a pointer the store. Bug: 46320 Change-Id: I249a5d48726093d1cb3e36351893f4bff85f52e2
52 lines
1.2 KiB
JavaScript
52 lines
1.2 KiB
JavaScript
/*!
|
|
* VisualEditor DataModel LeafNode class.
|
|
*
|
|
* @copyright 2011-2013 VisualEditor Team and others; see AUTHORS.txt
|
|
* @license The MIT License (MIT); see LICENSE.txt
|
|
*/
|
|
|
|
/**
|
|
* DataModel leaf node.
|
|
*
|
|
* Leaf nodes can not have any children.
|
|
*
|
|
* @abstract
|
|
* @extends ve.dm.Node
|
|
* @mixins ve.LeafNode
|
|
* @constructor
|
|
* @param {number} [length] Length of content data in document
|
|
* @param {Object} [element] Reference to element in linear model
|
|
*/
|
|
ve.dm.LeafNode = function VeDmLeafNode( length, element ) {
|
|
// Mixin constructor
|
|
ve.LeafNode.call( this );
|
|
|
|
// Parent constructor
|
|
ve.dm.Node.call( this, length, element );
|
|
};
|
|
|
|
/* Inheritance */
|
|
|
|
ve.inheritClass( ve.dm.LeafNode, ve.dm.Node );
|
|
|
|
ve.mixinClass( ve.dm.LeafNode, ve.LeafNode );
|
|
|
|
/* Static properties */
|
|
|
|
ve.dm.LeafNode.static.childNodeTypes = [];
|
|
|
|
/* Methods */
|
|
|
|
/**
|
|
* Get the annotations that apply to the node.
|
|
*
|
|
* Annotations are grabbed directly from the linear model, so they are updated live. If the linear
|
|
* model element doesn't have a .annotations property, an empty array is returned.
|
|
*
|
|
* @method
|
|
* @returns {number[]} Annotation set indexes in the index-value store
|
|
*/
|
|
ve.dm.LeafNode.prototype.getAnnotations = function () {
|
|
return this.element.annotations || [];
|
|
};
|