mirror of
https://gerrit.wikimedia.org/r/mediawiki/extensions/VisualEditor
synced 2024-11-29 08:34:54 +00:00
edcaaf9edc
Add a static.name property to ce nodes and make sure both ce and dm nodes always use the static.name property in constructors and registration calls. The result of this is that any given node type should now only appear once in the code as a string. Bug: 45701 Change-Id: Ibf31de16ab28ad58209c1443cd74f93dda278998
62 lines
1.6 KiB
JavaScript
62 lines
1.6 KiB
JavaScript
/*!
|
|
* VisualEditor ContentEditable LeafNode class.
|
|
*
|
|
* @copyright 2011-2013 VisualEditor Team and others; see AUTHORS.txt
|
|
* @license The MIT License (MIT); see LICENSE.txt
|
|
*/
|
|
|
|
/**
|
|
* ContentEditable leaf node.
|
|
*
|
|
* Leaf nodes can not have any children.
|
|
*
|
|
* @abstract
|
|
* @extends ve.ce.Node
|
|
* @mixins ve.LeafNode
|
|
* @constructor
|
|
* @param {ve.dm.LeafNode} model Model to observe
|
|
* @param {jQuery} [$element] Element to use as a container
|
|
*/
|
|
ve.ce.LeafNode = function VeCeLeafNode( model, $element ) {
|
|
// Mixin constructor
|
|
ve.LeafNode.call( this );
|
|
|
|
// Parent constructor
|
|
ve.ce.Node.call( this, model, $element );
|
|
|
|
// DOM Changes
|
|
if ( model.isWrapped() ) {
|
|
this.$.addClass( 've-ce-leafNode' );
|
|
}
|
|
};
|
|
|
|
/* Inheritance */
|
|
|
|
ve.inheritClass( ve.ce.LeafNode, ve.ce.Node );
|
|
|
|
ve.mixinClass( ve.ce.LeafNode, ve.LeafNode );
|
|
|
|
/* Methods */
|
|
|
|
/**
|
|
* Get annotated HTML fragments.
|
|
*
|
|
* @see ve.ce.ContentBranchNode.
|
|
*
|
|
* An HTML fragment can be:
|
|
* - an HTML string
|
|
* - a jQuery object
|
|
* - an array with an HTML string or jQuery object at index 0 and a ve.AnnotationSet at index 1,
|
|
* i.e. ['htmlstring', ve.AnnotationSet] or [$jQueryObj, ve.AnnotationSet]
|
|
*
|
|
* The default implementation should be fine in most cases. A subclass only needs to override this
|
|
* if the annotations aren't necessarily the same across the entire node (like in ve.ce.TextNode).
|
|
*
|
|
* @method
|
|
* @returns {Array} Array of HTML fragments, i.e.
|
|
* [ string | jQuery | [string|jQuery, ve.AnnotationSet] ]
|
|
*/
|
|
ve.ce.LeafNode.prototype.getAnnotatedHtml = function () {
|
|
return [ [ this.$, this.getModel().getAnnotations() ] ];
|
|
};
|