We have this code to insert the placeholder translation to target document:
https://github.com/wikimedia/mediawiki-extensions-ContentTranslation/blob/master/modules/ve-cx/init/ve.init.mw.CXTarget.js#L511
ve.init.mw.CXTarget.prototype.gotPlaceholderTranslation = function ( placeholder, data ) { var pasteDoc, newCursorRange, docLen, fragmentRange, surfaceModel = this.getSurface().getModel(), cxid = placeholder.getModel().getAttribute( 'cxid' ), fragment = surfaceModel.getLinearFragment( placeholder.getModel().getOuterRange(), true /* noAutoSelect */ ); pasteDoc = ve.dm.converter.getModelFromDom( ve.createDocumentFromHtml( data ) ); docLen = pasteDoc.getInternalList().getListNode().getOuterRange().start; fragment.insertContent( [ { type: 'cxSection', attributes: { style: 'section', cxid: cxid } }, // Put a temporary paragraph inside the section so the cursor has somewhere // sensible to go, preventing scrollCursorIntoView from triggering a jump { type: 'paragraph' }, { type: '/paragraph' }, { type: '/cxSection' } ] ); fragment .collapseToStart().adjustLinearSelection( 1, 3 ) .insertDocument( pasteDoc, new ve.Range( 1, docLen - 1 ) ); fragmentRange = fragment.getSelection().getCoveringRange(); // Select first content offset within new content newCursorRange = new ve.Range( surfaceModel.getDocument().data.getNearestContentOffset( fragmentRange.start, 1 ) ); if ( fragmentRange.containsRange( newCursorRange ) ) { surfaceModel.setLinearSelection( newCursorRange ); } };
When the translation of section is as given below, an internal error is thrown from ve.dm.TreeModifier
<section id="cxTargetSection22"> <figure data-cx="{"adapted":true,"imageSource":"//upload.wikimedia.org/wikipedia/commons/thumb/a/a3/Gimchi.jpg/175px-Gimchi.jpg","resource":"./File:Gimchi.jpg"}" id="mwbA" typeof="mw:Image/Thumb"> <a href="./படிமம்:Gimchi.jpg" id="mwbQ"> <img data-file-height="1512" data-file-type="bitmap" data-file-width="2016" height="131" id="mwbg" resource="./படிமம்:Gimchi.jpg" src="//upload.wikimedia.org/wikipedia/commons/thumb/a/a3/Gimchi.jpg/175px-Gimchi.jpg" srcset="//upload.wikimedia.org/wikipedia/commons/thumb/a/a3/Gimchi.jpg/350px-Gimchi.jpg 2x, //upload.wikimedia.org/wikipedia/commons/thumb/a/a3/Gimchi.jpg/263px-Gimchi.jpg 1.5x" width="175"></img> </a> <figcaption id="mwbw"> <span class="cx-segment" data-segmentid="107"> <a class="cx-link" data-cx="{"adapted":true,"targetTitle":{"title":"கிம்ச்சி","pagelanguage":"ta","thumbnail":{"source":"https://upload.wikimedia.org/wikipedia/commons/thumb/f/f8/Various_kimchi.jpg/80px-Various_kimchi.jpg","width":80,"height":53}},"sourceTitle":{"title":"Kimchi","pagelanguage":"en","thumbnail":{"source":"https://upload.wikimedia.org/wikipedia/commons/thumb/f/f8/Various_kimchi.jpg/80px-Various_kimchi.jpg","width":80,"height":53},"terms":{"description":["Korean vegetable dish"]}}}" data-linkid="108" href="கிம்ச்சி" id="mwcA" rel="mw:WikiLink" title="கிம்ச்சி">Kimchi</a> ஒரு மிகவும் பொதுவான பக்க dish உள்ள கொரியா.</span> </figcaption> </figure>
From ve.dm.TreeModifier.prototype.processInsert:479 is throwing this error:
Error: Expected closing for article but got closing for cxBlockImageNode
This is happening for all sections with block images. Sections with paragraphs and different kind of contents are working fine though.