All files / src/ce/nodes ve.ce.DocumentNode.js

93.75% Statements 15/16
100% Branches 0/0
66.66% Functions 2/3
93.75% Lines 15/16

Press n or j to go to the next uncovered block, b, p or k for the previous block.

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