mediawiki-extensions-Visual.../modules/ve/ce/nodes/ve.ce.DocumentNode.js
Trevor Parscal a56e795f58 ve.Editor
Objectives:

* Split ve.Surface into ve.Editor and ve.ui.Surface
* Move actions, triggers and commands to ve.ui
* Move toolbar wrapping, floating, shadow and actions functionality to configurable options of ve.ui.Toolbar
* Make ve.ce.Surface and ve.ui.Surface inherit ve.Element and use this.$$ for iframe friendliness
* Make the toolbar separately initialized so it's possible to have a surface without one, as well as control where the toolbar is

Some change notes:

VisualEditor.php
* Added standalone module for mediawiki integrated unit testing

ve.ce.Surface.js
* Remove requirement to pass in an attached container to construct object
* Inherit ve.Element and use this.$$ instead of $
* Make getSelectionRect iframe friendly
* Move most of the initialize stuff to a new initialize method to be called after the surface is attached to the DOM

ve.init.mw.ViewPageTarget.js
* Merge toolbar functions into setup/teardown methods
* Add toolbar manually (since it's not added by the surface anymore)

ve.init.sa.Target.js
* Update new init procedure for editor, surface and toolbar separately
* Move toolbar floating stuff to ve.Toolbar

Change-Id: If91a9d6e76a8be8d1b5a2566394765a37d29a8a7
2013-05-15 10:39:12 -07:00

83 lines
1.8 KiB
JavaScript

/*!
* VisualEditor ContentEditable DocumentNode class.
*
* @copyright 2011-2013 VisualEditor Team and others; see AUTHORS.txt
* @license The MIT License (MIT); see LICENSE.txt
*/
/**
* ContentEditable document node.
*
* @class
* @extends ve.ce.BranchNode
* @constructor
* @param {ve.dm.DocumentNode} model Model to observe
* @param {ve.ui.Surface} surface Surface document is part of
* @param {Object} [config] Config options
*/
ve.ce.DocumentNode = function VeCeDocumentNode( model, surface, config ) {
// Parent constructor
ve.ce.BranchNode.call( this, model, config );
// Properties
this.surface = surface;
// DOM Changes
this.$.addClass( 've-ce-documentNode' );
this.$.attr( { 'contentEditable': 'true', 'spellcheck': 'true' } );
};
/* Inheritance */
ve.inheritClass( ve.ce.DocumentNode, ve.ce.BranchNode );
/* 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.
*
* @method
* @returns {number} Length of the entire node
*/
ve.ce.DocumentNode.prototype.getOuterLength = function () {
return this.length;
};
/**
* Get the surface the document is attached to.
*
* @method
* @returns {ve.ce.Surface} Surface the document is attached to
*/
ve.ce.DocumentNode.prototype.getSurface = function () {
return this.surface;
};
/**
* Disable editing.
*
* @method
*/
ve.ce.DocumentNode.prototype.disable = function () {
this.$.css( 'opacity', 0.5 ).attr( 'contentEditable', 'false' );
};
/**
* Enable editing.
*
* @method
*/
ve.ce.DocumentNode.prototype.enable = function () {
this.$.css( 'opacity', 1 ).attr( 'contentEditable', 'true' );
};
/* Registration */
ve.ce.nodeFactory.register( ve.ce.DocumentNode );