mirror of
https://gerrit.wikimedia.org/r/mediawiki/extensions/VisualEditor
synced 2024-09-25 03:08:42 +00:00
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:
parent
8a29eab7c6
commit
cf3b2a6765
|
@ -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 );
|
||||
};
|
||||
|
||||
|
|
|
@ -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];
|
||||
|
|
Loading…
Reference in a new issue