jenkins-bot has submitted this change and it was merged. Change subject: Edit stash: Support CodeEditor ......................................................................
Edit stash: Support CodeEditor Use .textSelection( 'getContents' ) instead of .val() for '#wpTextbox1' and '#wpSummary'. Then the normalization of line endings and dependency on 'jquery.getAttrs' is not necessary. Bug: T137861 Change-Id: I26f7021a2a02cf719c9e5f44787b95cfc3239959 --- M resources/Resources.php M resources/src/mediawiki.action/mediawiki.action.edit.stash.js 2 files changed, 14 insertions(+), 12 deletions(-) Approvals: Legoktm: Looks good to me, approved jenkins-bot: Verified diff --git a/resources/Resources.php b/resources/Resources.php index 90510fc..e31e77e 100644 --- a/resources/Resources.php +++ b/resources/Resources.php @@ -1417,7 +1417,6 @@ 'mediawiki.action.edit.styles', 'jquery.textSelection', 'jquery.byteLimit', - 'jquery.getAttrs', 'mediawiki.api', ], 'position' => 'top', diff --git a/resources/src/mediawiki.action/mediawiki.action.edit.stash.js b/resources/src/mediawiki.action/mediawiki.action.edit.stash.js index 2069ac5..2ae05dd 100644 --- a/resources/src/mediawiki.action/mediawiki.action.edit.stash.js +++ b/resources/src/mediawiki.action/mediawiki.action.edit.stash.js @@ -13,7 +13,11 @@ $form = $( '#editform' ), $text = $form.find( '#wpTextbox1' ), $summary = $form.find( '#wpSummary' ), - data = {}, + section = $form.find( '#wpSection' ).val(), + model = $form.find( '#model' ).val(), + format = $form.find( '#format' ).val(), + revId = $form.find( '#parentRevId' ).val(), + lastText = $text.textSelection( 'getContents' ), timer = null; // Send a request to stash the edit to the API. @@ -25,19 +29,19 @@ } api.getToken( 'csrf' ).then( function ( token ) { - data = $form.serializeObject(); + lastText = $text.textSelection( 'getContents' ); pending = api.post( { action: 'stashedit', token: token, title: mw.config.get( 'wgPageName' ), - section: data.wpSection, + section: section, sectiontitle: '', - text: data.wpTextbox1, - summary: data.wpSummary, - contentmodel: data.model, - contentformat: data.format, - baserevid: data.parentRevId + text: lastText, + summary: $summary.textSelection( 'getContents' ), + contentmodel: model, + contentformat: format, + baserevid: revId } ); } ); } @@ -45,9 +49,8 @@ // Check if edit body text changed since the last stashEdit() call or if no edit // stash calls have yet been made function isChanged() { - // Normalize line endings to CRLF, like $.fn.serializeObject does. - var newText = $text.val().replace( /\r?\n/g, '\r\n' ); - return newText !== data.wpTextbox1; + var newText = $text.textSelection( 'getContents' ); + return newText !== lastText; } function onEditorIdle() { -- To view, visit https://gerrit.wikimedia.org/r/295658 To unsubscribe, visit https://gerrit.wikimedia.org/r/settings Gerrit-MessageType: merged Gerrit-Change-Id: I26f7021a2a02cf719c9e5f44787b95cfc3239959 Gerrit-PatchSet: 2 Gerrit-Project: mediawiki/core Gerrit-Branch: master Gerrit-Owner: Gerrit Patch Uploader <gerritpatchuploa...@gmail.com> Gerrit-Reviewer: Aaron Schulz <asch...@wikimedia.org> Gerrit-Reviewer: Edokter <er...@darcoury.nl> Gerrit-Reviewer: Gerrit Patch Uploader <gerritpatchuploa...@gmail.com> Gerrit-Reviewer: Jack Phoenix <j...@countervandalism.net> Gerrit-Reviewer: Legoktm <legoktm.wikipe...@gmail.com> Gerrit-Reviewer: Ori.livneh <o...@wikimedia.org> Gerrit-Reviewer: jenkins-bot <> _______________________________________________ MediaWiki-commits mailing list MediaWiki-commits@lists.wikimedia.org https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits