mirror of
https://gerrit.wikimedia.org/r/mediawiki/extensions/VisualEditor
synced 2024-11-26 15:21:51 +00:00
46d26b9f22
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.
30 lines
602 B
JavaScript
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 );
|