mirror of
https://gerrit.wikimedia.org/r/mediawiki/extensions/VisualEditor
synced 2024-12-01 17:36:35 +00:00
07af0cab63
* Renamed getContent to getContentData * Renamed getText to getContentText * Added getElementData
45 lines
1.2 KiB
JavaScript
45 lines
1.2 KiB
JavaScript
/**
|
|
* Creates an es.DocumentModelLeafNode object.
|
|
*
|
|
* @class
|
|
* @abstract
|
|
* @constructor
|
|
* @extends {es.DocumentLeafNode}
|
|
* @extends {es.DocumentModelNode}
|
|
* @param {String} type Symbolic name of node type
|
|
* @param {Object} element Element object in document data
|
|
* @param {Integer} [length] Length of content data in document
|
|
*/
|
|
es.DocumentModelLeafNode = function( type, element, length ) {
|
|
// Inheritance
|
|
es.DocumentLeafNode.call( this );
|
|
es.DocumentModelNode.call( this, type, element, length );
|
|
|
|
// Properties
|
|
this.contentLength = length || 0;
|
|
};
|
|
|
|
/* Methods */
|
|
|
|
/**
|
|
* Gets a plain object representation of the document's data.
|
|
*
|
|
* @method
|
|
* @see {es.DocumentModelNode.getPlainObject}
|
|
* @see {es.DocumentModel.newFromPlainObject}
|
|
* @returns {Object} Plain object representation,
|
|
*/
|
|
es.DocumentModelLeafNode.prototype.getPlainObject = function() {
|
|
var obj = { 'type': this.type };
|
|
if ( this.element && this.element.attributes ) {
|
|
obj.attributes = es.copyObject( this.element.attributes );
|
|
}
|
|
obj.content = es.DocumentModel.getExpandedContentData( this.getContentData() );
|
|
return obj;
|
|
};
|
|
|
|
/* Inheritance */
|
|
|
|
es.extendClass( es.DocumentModelLeafNode, es.DocumentLeafNode );
|
|
es.extendClass( es.DocumentModelLeafNode, es.DocumentModelNode );
|