Debian Codegraph @

extensions/VisualEditor/lib/ve/src/ce/ve.ce.LeafNode.js

raw symbols SCIP
1 /*!
2 * VisualEditor ContentEditable LeafNode class.
3 *
4 * @copyright See AUTHORS.txt
5 */
6
7 /**
8 * ContentEditable leaf node.
9 *
10 * Leaf nodes can not have any children.
11 *
12 * @abstract
13 * @extends ve.ce.Node
14 * @mixes ve.LeafNode
15 *
16 * @constructor
17 * @param {ve.dm.LeafNode} model
18 * @param {Object} [config]
19 */
20 ve.ce.LeafNode = function VeCeLeafNode() {
21 // Mixin constructor
22 ve.LeafNode.call( this );
23
24 // Parent constructor
25 ve.ce.LeafNode.super.apply( this, arguments );
26 };
27
28 /* Inheritance */
29
30 OO.inheritClass( ve.ce.LeafNode, ve.ce.Node );
31
32 OO.mixinClass( ve.ce.LeafNode, ve.LeafNode );
33
34 /* Static Properties */
35
36 ve.ce.LeafNode.static.tagName = 'span';
37
38 /* Methods */
39
40 /**
41 * @inheritdoc
42 */
43 ve.ce.LeafNode.prototype.initialize = function () {
44 // Parent method
45 ve.ce.LeafNode.super.prototype.initialize.call( this );
46
47 if ( this.model.isWrapped() ) {
48 this.$element.addClass( 've-ce-leafNode' );
49 }
50 };
51
52 /**
53 * Get annotated HTML fragments.
54 *
55 * @see ve.ce.ContentBranchNode
56 *
57 * An HTML fragment can be:
58 * - a plain text string
59 * - a jQuery object
60 * - an array with a plain text string or jQuery object at index 0 and a ve.dm.AnnotationSet at index 1,
61 * i.e. ['textstring', ve.dm.AnnotationSet] or [$jQueryObj, ve.dm.AnnotationSet]
62 *
63 * The default implementation should be fine in most cases. A subclass only needs to override this
64 * if the annotations aren't necessarily the same across the entire node (like in ve.ce.TextNode).
65 *
66 * @return {Array} Array of HTML fragments, i.e.
67 * [ string | jQuery | [string|jQuery, ve.dm.AnnotationSet] ]
68 */
69 ve.ce.LeafNode.prototype.getAnnotatedHtml = function () {
70 return [ [ this.$element, this.getModel().getAnnotations() ] ];
71 };