Pasting a DocumentSlice sets the selection incorrectly

ve.dm.Document
* 2 of the 3 paths of getSlice still returned arrays instead of ve.dm.DocumentSlice objects

ve.ce.Surface
* Translate the range using the insertion transaction and truncate it, so the cursor ends up just after the pasted content

Change-Id: If7bae5e254ec84a847c1d3527f74d9c09c2d82b4
This commit is contained in:
Trevor Parscal 2012-12-07 14:49:11 -08:00
parent 8a29eab7c6
commit cf3b2a6765
2 changed files with 3 additions and 3 deletions

View file

@ -610,7 +610,7 @@ ve.ce.Surface.prototype.onPaste = function () {
);
}
view.documentView.documentNode.$.focus();
view.model.change( tx, new ve.Range( selection.start + pasteData.length ) );
view.model.change( tx, tx.translateRange( selection ).truncate( 0 ) );
}, 0 );
};

View file

@ -1366,11 +1366,11 @@ ve.dm.Document.prototype.getSlice = function ( range ) {
addOpenings = [],
addClosings = [];
if ( selection.length === 0 ) {
return [];
return new ve.dm.DocumentSlice( [] );
}
if ( selection.length === 1 && selection[0].range.equals( range ) ) {
// Nothing to fix up
return this.data.slice( range.start, range.end );
return new ve.dm.DocumentSlice( this.data.slice( range.start, range.end ) );
}
first = selection[0];