Debian Codegraph @

extensions/VisualEditor/lib/ve/src/ce/nodes/ve.ce.DocumentNode.js

raw symbols SCIP
1 /*!
2 * VisualEditor ContentEditable DocumentNode class.
3 *
4 * @copyright See AUTHORS.txt
5 */
6
7 /**
8 * ContentEditable document node.
9 *
10 * @class
11 * @extends ve.ce.BranchNode
12 * @mixes ve.ce.ContentEditableNode
13 * @constructor
14 * @param {ve.dm.DocumentNode} model Model to observe
15 * @param {ve.ce.Surface} surface Surface document is part of
16 * @param {Object} [config] Configuration options
17 */
18 ve.ce.DocumentNode = function VeCeDocumentNode( model, surface, config ) {
19 // Properties
20 this.surface = surface;
21
22 // Parent constructor
23 ve.ce.DocumentNode.super.call( this, model, config );
24
25 // Mixin constructor
26 ve.ce.ContentEditableNode.call( this );
27
28 // Set root
29 this.setRoot( this );
30
31 // DOM changes
32 // TODO: Remove ve-ce-rootNode class
33 this.$element
34 .addClass( 've-ce-documentNode ve-ce-attachedRootNode ve-ce-rootNode' )
35 .attr( 'tabindex', 0 );
36 // Prevent Grammarly from polluting the DOM (T165746)
37 this.$element.attr( 'data-gramm', 'false' );
38
39 this.$element.attr( 'role', 'textbox' );
40 };
41
42 /* Inheritance */
43
44 OO.inheritClass( ve.ce.DocumentNode, ve.ce.BranchNode );
45 OO.mixinClass( ve.ce.DocumentNode, ve.ce.ContentEditableNode );
46
47 /* Events */
48
49 /* Static Properties */
50
51 ve.ce.DocumentNode.static.name = 'document';
52
53 /* Methods */
54
55 /**
56 * Get the outer length.
57 *
58 * For a document node is the same as the inner length, which is why we override it here.
59 *
60 * @return {number} Length of the entire node
61 */
62 ve.ce.DocumentNode.prototype.getOuterLength = function () {
63 return this.length;
64 };
65
66 /**
67 * Get the surface the document is attached to.
68 *
69 * @return {ve.ce.Surface} Surface the document is attached to
70 */
71 ve.ce.DocumentNode.prototype.getSurface = function () {
72 return this.surface;
73 };
74
75 /* Registration */
76
77 ve.ce.nodeFactory.register( ve.ce.DocumentNode );