mirror of
https://gerrit.wikimedia.org/r/mediawiki/extensions/VisualEditor
synced 2024-11-29 00:30:44 +00:00
00d86d69cb
Change-Id: I1238001949bae519d49428f98dcdd1428388aa0d
45 lines
1,010 B
JavaScript
45 lines
1,010 B
JavaScript
/**
|
|
* VisualEditor data model DocumentSlice class.
|
|
*
|
|
* @copyright 2011-2012 VisualEditor Team and others; see AUTHORS.txt
|
|
* @license The MIT License (MIT); see LICENSE.txt
|
|
*/
|
|
|
|
/**
|
|
* Document slice.
|
|
*
|
|
* @class
|
|
* @abstract
|
|
* @constructor
|
|
* @extends {ve.Node}
|
|
* @param {Array} data Balanced sliced data (will be deep copied internally)
|
|
* @param {ve.Range} [range] Original context within data
|
|
*/
|
|
ve.dm.DocumentSlice = function VeDmDocumentSlice( data, range ) {
|
|
// Properties
|
|
this.data = ve.copyArray( data );
|
|
this.range = range || new ve.Range( 0, data.length );
|
|
};
|
|
|
|
/* Methods */
|
|
|
|
/**
|
|
* Gets a deep copy of the sliced data.
|
|
*
|
|
* @method
|
|
* @returns {Array} Document data
|
|
*/
|
|
ve.dm.DocumentSlice.prototype.getData = function () {
|
|
return this.data.slice( this.range.start, this.range.end );
|
|
};
|
|
|
|
/**
|
|
* Gets a balanced version of the sliced data.
|
|
*
|
|
* @method
|
|
* @returns {Array} Document data
|
|
*/
|
|
ve.dm.DocumentSlice.prototype.getBalancedData = function () {
|
|
return this.data.slice( 0 );
|
|
};
|