2012-07-19 00:11:26 +00:00
|
|
|
/**
|
|
|
|
* VisualEditor content editable Document class.
|
|
|
|
*
|
|
|
|
* @copyright 2011-2012 VisualEditor Team and others; see AUTHORS.txt
|
|
|
|
* @license The MIT License (MIT); see LICENSE.txt
|
|
|
|
*/
|
|
|
|
|
2012-05-03 20:21:13 +00:00
|
|
|
/**
|
|
|
|
* ContentEditable document.
|
2012-05-14 22:05:09 +00:00
|
|
|
*
|
2012-05-03 20:21:13 +00:00
|
|
|
* @class
|
2012-05-10 04:11:09 +00:00
|
|
|
* @extends {ve.Document}
|
2012-05-03 20:21:13 +00:00
|
|
|
* @constructor
|
|
|
|
* @param model {ve.dm.Document} Model to observe
|
|
|
|
*/
|
2012-06-14 04:46:29 +00:00
|
|
|
ve.ce.Document = function( model, surface ) {
|
2012-05-10 04:11:09 +00:00
|
|
|
// Inheritance
|
2012-06-14 04:46:29 +00:00
|
|
|
ve.Document.call( this, new ve.ce.DocumentNode( model.getDocumentNode(), surface ) );
|
2012-05-10 04:11:09 +00:00
|
|
|
|
2012-05-03 20:21:13 +00:00
|
|
|
// Properties
|
2012-05-10 04:11:09 +00:00
|
|
|
this.model = model;
|
2012-05-03 20:21:13 +00:00
|
|
|
};
|
2012-05-10 04:11:09 +00:00
|
|
|
|
2012-05-30 21:38:02 +00:00
|
|
|
/* Methods */
|
|
|
|
|
|
|
|
ve.ce.Document.prototype.getNodeFromOffset = function( offset ) {
|
|
|
|
var node = this.documentNode.getNodeFromOffset( offset );
|
|
|
|
if ( !node.canHaveChildren() ) {
|
|
|
|
node = node.getParent();
|
|
|
|
}
|
|
|
|
return node;
|
|
|
|
};
|
|
|
|
|
2012-05-10 04:11:09 +00:00
|
|
|
/* Inheritance */
|
|
|
|
|
|
|
|
ve.extendClass( ve.ce.Document, ve.Document );
|