2012-12-07 01:23:03 +00:00
|
|
|
/**
|
|
|
|
* 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}
|
2012-12-11 02:12:55 +00:00
|
|
|
* @param {Array} data Balanced sliced data (will be deep copied internally)
|
2012-12-07 01:23:03 +00:00
|
|
|
* @param {ve.Range} [range] Original context within data
|
|
|
|
*/
|
|
|
|
ve.dm.DocumentSlice = function VeDmDocumentSlice( data, range ) {
|
|
|
|
// Properties
|
2012-12-11 02:12:55 +00:00
|
|
|
this.data = ve.copyArray( data );
|
2012-12-07 01:23:03 +00:00
|
|
|
this.range = range || new ve.Range( 0, data.length );
|
|
|
|
};
|
|
|
|
|
|
|
|
/* Methods */
|
|
|
|
|
2012-12-11 02:12:55 +00:00
|
|
|
/**
|
2012-12-11 02:34:37 +00:00
|
|
|
* Gets a deep copy of the sliced data.
|
2012-12-11 02:12:55 +00:00
|
|
|
*
|
|
|
|
* @method
|
|
|
|
* @returns {Array} Document data
|
|
|
|
*/
|
2012-12-07 01:23:03 +00:00
|
|
|
ve.dm.DocumentSlice.prototype.getData = function () {
|
|
|
|
return this.data.slice( this.range.start, this.range.end );
|
|
|
|
};
|
|
|
|
|
2012-12-11 02:12:55 +00:00
|
|
|
/**
|
|
|
|
* Gets a balanced version of the sliced data.
|
|
|
|
*
|
|
|
|
* @method
|
|
|
|
* @returns {Array} Document data
|
|
|
|
*/
|
2012-12-07 01:23:03 +00:00
|
|
|
ve.dm.DocumentSlice.prototype.getBalancedData = function () {
|
|
|
|
return this.data.slice( 0 );
|
|
|
|
};
|