Use .textSelection( 'getContents' ) instead of .val() to get the value of #wpTextbox1

To allow gadgets like wikEd to use textSelection to return the latest value.

Bug: T135747
Change-Id: Ie353cf547dea6c100c5f01ab56c9b415be1ffdb8
This commit is contained in:
Alex Monk 2016-06-22 00:18:09 +01:00
parent 84503e0a81
commit 7f39d4e75d
2 changed files with 8 additions and 6 deletions

View file

@ -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 ) {

View file

@ -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