mirror of
https://gerrit.wikimedia.org/r/mediawiki/extensions/VisualEditor
synced 2024-11-28 16:20:52 +00:00
5e7c14c868
Introduced the ve.AnnotationSet class to manage sets of annotations. This is a generalization of ve.OrderedHashSet, a class that manages a set using an array and an object keyed by hash. Converted everything that stores, tracks or passes around annotations to use ve.AnnotationSet. In particular, this means the linear model now contains AnnotationSets instead of hash-keyed objects. This allows us to maintain the order of annotations in the linear model, and will help fix bugs with annotation ordering and splitting. Change-Id: I50975b0a95f4cc33017a0b59fdede9ed1eff0124
26 lines
671 B
JavaScript
26 lines
671 B
JavaScript
/**
|
|
* VisualEditor AnnotationSet class.
|
|
*
|
|
* @copyright 2011-2012 VisualEditor Team and others; see AUTHORS.txt
|
|
* @license The MIT License (MIT); see LICENSE.txt
|
|
*/
|
|
|
|
ve.AnnotationSet = function ( annotations ) {
|
|
// Inheritance
|
|
ve.OrderedHashSet.call( this, ve.getHash, annotations );
|
|
};
|
|
|
|
ve.AnnotationSet.prototype.clone = function () {
|
|
return new ve.AnnotationSet( this );
|
|
};
|
|
|
|
ve.AnnotationSet.prototype.getAnnotationsOfType = function ( type ) {
|
|
return this.filter( 'type', type );
|
|
};
|
|
|
|
ve.AnnotationSet.prototype.hasAnnotationOfType = function ( type ) {
|
|
return this.containsMatching( 'type', type );
|
|
};
|
|
|
|
ve.extendClass( ve.AnnotationSet, ve.OrderedHashSet );
|