mirror of
https://gerrit.wikimedia.org/r/mediawiki/extensions/VisualEditor
synced 2024-11-16 02:51:50 +00:00
370070dfa2
* Fixed constructor of ve.ce.BranchNode which was calling the wrong method to perform an onSplice and with the wrong arguments * Removed/renamed events emitted from ve.ce.BranchNode.onSplice * Reintroduced .$ to all ce nodes * Ported over functionality for DOM node type variance used in headings, lists and list items * Moved the old ve.ce.Content guts to ve.ce.TextNode * Added getOffsetFromNode and getDataFromNode to ve.dm.DocumentFragment * Added setDocument and getDocument to dm nodes Change-Id: I185423ba2f1a858dde562cb2f5bc3852aec930db
70 lines
1.3 KiB
JavaScript
70 lines
1.3 KiB
JavaScript
/**
|
|
* Generic ContentEditable node.
|
|
*
|
|
* @class
|
|
* @abstract
|
|
* @constructor
|
|
* @extends {ve.Node}
|
|
* @param {ve.dm.Node} model Model to observe
|
|
* @param {jQuery} [$element] Element to use as a container
|
|
*/
|
|
ve.ce.Node = function( model, $element ) {
|
|
// Inheritance
|
|
ve.Node.call( this );
|
|
|
|
// Properties
|
|
this.model = model;
|
|
this.$ = $element || $( '<div></div>' );
|
|
this.parent = null;
|
|
};
|
|
|
|
/* Methods */
|
|
|
|
/**
|
|
* Gets a reference to the model this node observes.
|
|
*
|
|
* @method
|
|
* @returns {ve.dm.Node} Reference to the model this node observes
|
|
*/
|
|
ve.ce.Node.prototype.getModel = function() {
|
|
return this.model;
|
|
};
|
|
|
|
/**
|
|
* Gets a reference to this node's parent.
|
|
*
|
|
* @method
|
|
* @returns {ve.ce.Node} Reference to this node's parent
|
|
*/
|
|
ve.ce.Node.prototype.getParent = function() {
|
|
return this.parent;
|
|
};
|
|
|
|
/**
|
|
* Attaches node as a child to another node.
|
|
*
|
|
* @method
|
|
* @param {ve.ce.Node} parent Node to attach to
|
|
* @emits attach (parent)
|
|
*/
|
|
ve.ce.Node.prototype.attach = function( parent ) {
|
|
this.parent = parent;
|
|
this.emit( 'attach', parent );
|
|
};
|
|
|
|
/**
|
|
* Detaches node from it's parent.
|
|
*
|
|
* @method
|
|
* @emits detach (parent)
|
|
*/
|
|
ve.ce.Node.prototype.detach = function() {
|
|
var parent = this.parent;
|
|
this.parent = null;
|
|
this.emit( 'detach', parent );
|
|
};
|
|
|
|
/* Inheritance */
|
|
|
|
ve.extendClass( ve.ce.Node, ve.Node );
|