mirror of
https://gerrit.wikimedia.org/r/mediawiki/extensions/VisualEditor
synced 2024-11-29 00:30:44 +00:00
Merge "Allow switching from WTE to VE with changes in non-RESTBase mode"
This commit is contained in:
commit
8bd98a42af
|
@ -36,6 +36,7 @@
|
|||
},
|
||||
"VisualEditorRestbaseURL": false,
|
||||
"VisualEditorFullRestbaseURL": false,
|
||||
"VisualEditorAllowLossySwitching": true,
|
||||
"VisualEditorAvailableNamespaces": {
|
||||
"User": true,
|
||||
"File": true,
|
||||
|
|
|
@ -942,6 +942,7 @@ class VisualEditorHooks {
|
|||
'rebaserUrl' => $coreConfig->get( 'VisualEditorRebaserURL' ),
|
||||
'restbaseUrl' => $coreConfig->get( 'VisualEditorRestbaseURL' ),
|
||||
'fullRestbaseUrl' => $coreConfig->get( 'VisualEditorFullRestbaseURL' ),
|
||||
'allowLossySwitching' => $coreConfig->get( 'VisualEditorAllowLossySwitching' ),
|
||||
'feedbackApiUrl' => $veConfig->get( 'VisualEditorFeedbackAPIURL' ),
|
||||
'feedbackTitle' => $veConfig->get( 'VisualEditorFeedbackTitle' ),
|
||||
'sourceFeedbackTitle' => $veConfig->get( 'VisualEditorSourceFeedbackTitle' ),
|
||||
|
|
|
@ -63,11 +63,12 @@ mw.libs.ve.SwitchConfirmDialog.static.actions = [
|
|||
mw.libs.ve.SwitchConfirmDialog.prototype.getSetupProcess = function ( data ) {
|
||||
return mw.libs.ve.SwitchConfirmDialog.super.prototype.getSetupProcess.apply( this, arguments )
|
||||
.next( function () {
|
||||
var
|
||||
config = mw.config.get( 'wgVisualEditorConfig' ),
|
||||
canSwitch = config.fullRestbaseUrl || config.allowLossySwitching;
|
||||
if ( data && data.mode ) {
|
||||
this.actions.setMode( data.mode );
|
||||
} else if (
|
||||
mw.config.get( 'wgVisualEditorConfig' ).fullRestbaseUrl
|
||||
) {
|
||||
} else if ( canSwitch ) {
|
||||
this.actions.setMode( 'restbase' );
|
||||
} else {
|
||||
this.actions.setMode( 'simple' );
|
||||
|
|
|
@ -2355,6 +2355,8 @@ ve.init.mw.ArticleTarget.prototype.switchToFallbackWikitextEditor = function ()
|
|||
*/
|
||||
ve.init.mw.ArticleTarget.prototype.switchToVisualEditor = function () {
|
||||
var dataPromise, windowManager, switchWindow,
|
||||
config = mw.config.get( 'wgVisualEditorConfig' ),
|
||||
canSwitch = config.fullRestbaseUrl || config.allowLossySwitching,
|
||||
target = this;
|
||||
|
||||
if ( !this.edited ) {
|
||||
|
@ -2364,9 +2366,7 @@ ve.init.mw.ArticleTarget.prototype.switchToVisualEditor = function () {
|
|||
|
||||
// Show a discard-only confirm dialog, and then reload the whole page, if
|
||||
// the server can't switch for us because that's not supported.
|
||||
if (
|
||||
!mw.config.get( 'wgVisualEditorConfig' ).fullRestbaseUrl
|
||||
) {
|
||||
if ( !canSwitch ) {
|
||||
windowManager = new OO.ui.WindowManager();
|
||||
switchWindow = new mw.libs.ve.SwitchConfirmDialog();
|
||||
$( document.body ).append( windowManager.$element );
|
||||
|
|
|
@ -205,7 +205,7 @@
|
|||
* @return {jQuery.Promise} Abortable promise resolved with a JSON object
|
||||
*/
|
||||
requestParsoidData: function ( pageName, options ) {
|
||||
var start, apiXhr, restbaseXhr, apiPromise, restbasePromise, dataPromise, pageHtmlUrl, headers, data, fullDocExpand,
|
||||
var start, apiXhr, restbaseXhr, apiPromise, restbasePromise, dataPromise, pageHtmlUrl, headers, data,
|
||||
section = options.section !== undefined ? options.section : null,
|
||||
useRestbase = ( conf.fullRestbaseUrl || conf.restbaseUrl ) && section === null,
|
||||
switched = false,
|
||||
|
@ -235,16 +235,11 @@
|
|||
ve.track( 'trace.apiLoad.enter', { mode: 'visual' } );
|
||||
|
||||
if ( !useRestbase && options.wikitext !== undefined ) {
|
||||
fullDocExpand = section !== null;
|
||||
// Non-RESTBase custom wikitext parse
|
||||
if ( fullDocExpand ) {
|
||||
data.paction = 'parse';
|
||||
data.stash = true;
|
||||
switched = true;
|
||||
fromEditedState = options.modified;
|
||||
} else {
|
||||
data.paction = 'parsefragment';
|
||||
}
|
||||
data.paction = 'parse';
|
||||
data.stash = true;
|
||||
switched = true;
|
||||
fromEditedState = options.modified;
|
||||
data.wikitext = options.wikitext;
|
||||
data.section = options.section;
|
||||
data.oldid = options.oldId;
|
||||
|
|
Loading…
Reference in a new issue