Mooeypoo has uploaded a new change for review. https://gerrit.wikimedia.org/r/134563
Change subject: Adjust newNode range and fallback in MWImageModel ...................................................................... Adjust newNode range and fallback in MWImageModel When inserting a new node, get the proper fragment range and ask for the node from within the search loop. Also added a fallback for the case that the node wasn't found, and a caption cannot be added. Depends on I8c75c875caad48f28c3da3fe7cee395365c8814a Change-Id: Ic19d9b1cd2739435137f633de09a13b25a11a0cb --- M modules/ve-mw/dm/models/ve.dm.MWImageModel.js 1 file changed, 2 insertions(+), 3 deletions(-) git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/VisualEditor refs/changes/63/134563/1 diff --git a/modules/ve-mw/dm/models/ve.dm.MWImageModel.js b/modules/ve-mw/dm/models/ve.dm.MWImageModel.js index d2e102c..ea6d553 100644 --- a/modules/ve-mw/dm/models/ve.dm.MWImageModel.js +++ b/modules/ve-mw/dm/models/ve.dm.MWImageModel.js @@ -243,7 +243,6 @@ // Insert the new image coveredNodes = fragment - .collapseRangeToEnd() .insertContent( contentToInsert ) .getCoveredNodes(); @@ -254,6 +253,7 @@ coveredNodes[i].node.type === 'mwInlineImage' ) { newNodeRange = coveredNodes[i].nodeOuterRange; + newNode = coveredNodes[i].node; break; } } @@ -261,10 +261,9 @@ // Select the new node (without extras) newFragment = surfaceModel.getFragment( newNodeRange ); newFragment.select(); - newNode = newFragment.getSelectedNode(); // Check if there should be a caption - if ( newNode.getType() === 'mwBlockImage' ) { + if ( newNode && newNode.getType() === 'mwBlockImage' ) { if ( this.getCaptionDocument().data.getLength() > 4 ) { // Add contents of new caption -- To view, visit https://gerrit.wikimedia.org/r/134563 To unsubscribe, visit https://gerrit.wikimedia.org/r/settings Gerrit-MessageType: newchange Gerrit-Change-Id: Ic19d9b1cd2739435137f633de09a13b25a11a0cb Gerrit-PatchSet: 1 Gerrit-Project: mediawiki/extensions/VisualEditor Gerrit-Branch: master Gerrit-Owner: Mooeypoo <mor...@gmail.com> _______________________________________________ MediaWiki-commits mailing list MediaWiki-commits@lists.wikimedia.org https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits