Esanders has uploaded a new change for review. ( 
https://gerrit.wikimedia.org/r/374828 )

Change subject: Place cursor inside placeholder-translated content after click
......................................................................

Place cursor inside placeholder-translated content after click

Change-Id: I400935c093bd5a196ba10ca72ba702d835eea698
---
M modules/ui/mw.cx.ui.TranslationView.js
1 file changed, 8 insertions(+), 2 deletions(-)


  git pull 
ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/ContentTranslation 
refs/changes/28/374828/1

diff --git a/modules/ui/mw.cx.ui.TranslationView.js 
b/modules/ui/mw.cx.ui.TranslationView.js
index e25c151..59fc1cf 100644
--- a/modules/ui/mw.cx.ui.TranslationView.js
+++ b/modules/ui/mw.cx.ui.TranslationView.js
@@ -346,12 +346,13 @@
 };
 
 mw.cx.ui.TranslationView.prototype.gotPlaceholderTranslation = function ( 
placeholder, data ) {
-       var pasteDoc, tx1, tx2,
+       var pasteDoc, tx1, tx2, firstOffset, docLen,
                modelSurface = this.getSurface().getModel(),
                doc = modelSurface.documentModel,
                pRange = placeholder.getModel().getOuterRange();
 
        pasteDoc = ve.dm.converter.getModelFromDom( ve.createDocumentFromHtml( 
data ) );
+       docLen = pasteDoc.getInternalList().getListNode().getOuterRange().start;
        tx1 = ve.dm.TransactionBuilder.static.newFromRemoval( doc, pRange );
        tx2 = ve.dm.TransactionBuilder.static.newFromDocumentInsertion(
                doc,
@@ -359,12 +360,17 @@
                pasteDoc,
                new ve.Range(
                        1,
-                       
pasteDoc.getInternalList().getListNode().getOuterRange().start - 1
+                       docLen - 1
                )
        );
        tx2 = ve.dm.Change.static.rebaseTransactions( tx1, tx2 )[ 1 ];
        modelSurface.change( [ tx1, tx2 ] );
 
+       // Select first content offset within new content
+       firstOffset = modelSurface.getDocument().data.getNearestContentOffset( 
pRange.start, 1 );
+       if ( firstOffset > pRange.start && firstOffset < pRange.start + docLen 
) {
+               modelSurface.setLinearSelection( new ve.Range( firstOffset ) );
+       }
 };
 
 /**

-- 
To view, visit https://gerrit.wikimedia.org/r/374828
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: I400935c093bd5a196ba10ca72ba702d835eea698
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/extensions/ContentTranslation
Gerrit-Branch: master
Gerrit-Owner: Esanders <[email protected]>

_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits

Reply via email to