Gerrit Patch Uploader has uploaded a new change for review. https://gerrit.wikimedia.org/r/295658
Change subject: Edit stash: Support CodeEditor ...................................................................... Edit stash: Support CodeEditor Use .textSelection( 'getContents' ) instead of .val() for '#wpTextbox1' and '#wpSummary'. The the normalization of the line endings and the dependency to '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(-) git pull ssh://gerrit.wikimedia.org:29418/mediawiki/core refs/changes/58/295658/1 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: newchange Gerrit-Change-Id: I26f7021a2a02cf719c9e5f44787b95cfc3239959 Gerrit-PatchSet: 1 Gerrit-Project: mediawiki/core Gerrit-Branch: master Gerrit-Owner: Gerrit Patch Uploader <gerritpatchuploa...@gmail.com> _______________________________________________ MediaWiki-commits mailing list MediaWiki-commits@lists.wikimedia.org https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits