From 95f41c176b729675773b099d2986bcbbd68e93ab Mon Sep 17 00:00:00 2001 From: Ed Sanders Date: Sat, 18 May 2013 16:41:58 +0100 Subject: [PATCH] Move selection to end of insertion after paste Assuming this was broken by changes to translateRange. Bug: 48603 Change-Id: Ia2a2120cb75aa86374b594ae3f484c5161028919 --- modules/ve/ce/ve.ce.Surface.js | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/modules/ve/ce/ve.ce.Surface.js b/modules/ve/ce/ve.ce.Surface.js index a94febace8..4185c91385 100644 --- a/modules/ve/ce/ve.ce.Surface.js +++ b/modules/ve/ce/ve.ce.Surface.js @@ -570,6 +570,7 @@ ve.ce.Surface.prototype.onPaste = function () { // Pasting into a range? Remove first. if ( !rangy.getSelection().isCollapsed ) { tx = ve.dm.Transaction.newFromRemoval( view.documentView.model, selection ); + selection = tx.translateRange( selection ); view.model.change( tx ); } @@ -614,7 +615,10 @@ ve.ce.Surface.prototype.onPaste = function () { view.documentView.documentNode.$.focus(); $window.scrollTop( scrollTop ); - view.model.change( tx, tx.translateRange( selection ).truncate( 0 ) ); + selection = tx.translateRange( selection ); + view.model.change( tx, new ve.Range( selection.start ) ); + // Move cursor to end of selection + view.model.change( null, new ve.Range( selection.end ) ); // Allow pasting again view.pasting = false;