mediawiki-extensions-Visual.../modules/ve2/ce/ve.ce.Document.js
Trevor Parscal 46d26b9f22 Added getNodeFromOffset to ce
WARNING: This is not as fast as the implementation of getNodeFromOffset in dm

Change-Id: I5fbe9b6edc66169b9caaa6751fde1b7b752814d1
NOTE: ve.ce.getNodeFromOffset and ve.dm.getNodeFromOffset should be renamed to getBranchNodeFromOffset to clarify that they only return branch nodes.
2012-05-30 14:38:18 -07:00

30 lines
602 B
JavaScript

/**
* ContentEditable document.
*
* @class
* @extends {ve.Document}
* @constructor
* @param model {ve.dm.Document} Model to observe
*/
ve.ce.Document = function( model ) {
// Inheritance
ve.Document.call( this, new ve.ce.DocumentNode( model.getDocumentNode() ) );
// Properties
this.model = model;
};
/* Methods */
ve.ce.Document.prototype.getNodeFromOffset = function( offset ) {
var node = this.documentNode.getNodeFromOffset( offset );
if ( !node.canHaveChildren() ) {
node = node.getParent();
}
return node;
};
/* Inheritance */
ve.extendClass( ve.ce.Document, ve.Document );