diff --git a/modules/ve-mw/init/targets/ve.init.mw.DesktopArticleTarget.init.js b/modules/ve-mw/init/targets/ve.init.mw.DesktopArticleTarget.init.js index 06cbf5fec5..002ae5a872 100644 --- a/modules/ve-mw/init/targets/ve.init.mw.DesktopArticleTarget.init.js +++ b/modules/ve-mw/init/targets/ve.init.mw.DesktopArticleTarget.init.js @@ -550,8 +550,7 @@ }, activateVe: function () { - var wikitext = $( '#wpTextbox1' ).val(), - wikitextModified = wikitext !== initialWikitext; + var wikitext = $( '#wpTextbox1' ).textSelection( 'getContents' ); // Close any open jQuery.UI dialogs (e.g. WikiEditor's find and replace) if ( $.fn.dialog ) { @@ -560,7 +559,10 @@ if ( mw.config.get( 'wgAction' ) === 'submit' || - ( mw.config.get( 'wgAction' ) === 'edit' && wikitextModified ) || + ( + mw.config.get( 'wgAction' ) === 'edit' && + wikitext !== initialWikitext + ) || // switching from section editing must prompt because we can't // keep changes from that (yet?) $( 'input[name=wpSection]' ).val() @@ -718,7 +720,7 @@ urlSaysHideWelcome = 'hidewelcomedialog' in new mw.Uri( location.href ).query; if ( uri.query.action === 'edit' && $( '#wpTextbox1' ).length ) { - initialWikitext = $( '#wpTextbox1' ).val(); + initialWikitext = $( '#wpTextbox1' ).textSelection( 'getContents' ); } if ( init.isAvailable ) { diff --git a/modules/ve-mw/init/ve.init.mw.ArticleTargetLoader.js b/modules/ve-mw/init/ve.init.mw.ArticleTargetLoader.js index c0d04a8c8c..4c9db9ae8c 100644 --- a/modules/ve-mw/init/ve.init.mw.ArticleTargetLoader.js +++ b/modules/ve-mw/init/ve.init.mw.ArticleTargetLoader.js @@ -138,7 +138,7 @@ ve.track( 'trace.restbaseLoad.enter' ); if ( conf.fullRestbaseUrl && - $( '#wpTextbox1' ).val() && + $( '#wpTextbox1' ).textSelection( 'getContents' ) && !$( '[name=wpSection]' ).val() ) { switched = true; @@ -153,7 +153,7 @@ data: { title: pageName, oldid: oldid, - wikitext: $( '#wpTextbox1' ).val(), + wikitext: $( '#wpTextbox1' ).textSelection( 'getContents' ), stash: 'true' }, // Should be synchronised with ApiVisualEditor.php