From abdcacd68a8b56f326df5b883a8bc731fee9ed8e Mon Sep 17 00:00:00 2001 From: Trevor Parscal Date: Tue, 11 Dec 2012 11:09:26 -0800 Subject: [PATCH] Move the cursor to the end of newly inserted links Inserted links happen when the cursor is not near a word, so we insert the target as text Change-Id: I06c2c425d28db7ca61f13c438e25cc9c75f391f4 --- modules/ve/ui/inspectors/ve.ui.LinkInspector.js | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/modules/ve/ui/inspectors/ve.ui.LinkInspector.js b/modules/ve/ui/inspectors/ve.ui.LinkInspector.js index a141485afc..1df920690d 100644 --- a/modules/ve/ui/inspectors/ve.ui.LinkInspector.js +++ b/modules/ve/ui/inspectors/ve.ui.LinkInspector.js @@ -154,7 +154,9 @@ ve.ui.LinkInspector.prototype.onClose = function ( remove ) { } if ( insert ) { // Insert default text and select it - fragment = fragment.insertContent( target, false ).adjustRange( -target.length ); + fragment = fragment.insertContent( target, false ); + // Move cursor to the end of the inserted content + selection = new ve.Range( this.initialSelection.start + target.length ); } if ( undo ) { // Go back to before we added an annotation in an onInitialize handler