mirror of
https://gerrit.wikimedia.org/r/mediawiki/extensions/VisualEditor
synced 2024-11-29 08:34:54 +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,
|
"VisualEditorRestbaseURL": false,
|
||||||
"VisualEditorFullRestbaseURL": false,
|
"VisualEditorFullRestbaseURL": false,
|
||||||
|
"VisualEditorAllowLossySwitching": true,
|
||||||
"VisualEditorAvailableNamespaces": {
|
"VisualEditorAvailableNamespaces": {
|
||||||
"User": true,
|
"User": true,
|
||||||
"File": true,
|
"File": true,
|
||||||
|
|
|
@ -942,6 +942,7 @@ class VisualEditorHooks {
|
||||||
'rebaserUrl' => $coreConfig->get( 'VisualEditorRebaserURL' ),
|
'rebaserUrl' => $coreConfig->get( 'VisualEditorRebaserURL' ),
|
||||||
'restbaseUrl' => $coreConfig->get( 'VisualEditorRestbaseURL' ),
|
'restbaseUrl' => $coreConfig->get( 'VisualEditorRestbaseURL' ),
|
||||||
'fullRestbaseUrl' => $coreConfig->get( 'VisualEditorFullRestbaseURL' ),
|
'fullRestbaseUrl' => $coreConfig->get( 'VisualEditorFullRestbaseURL' ),
|
||||||
|
'allowLossySwitching' => $coreConfig->get( 'VisualEditorAllowLossySwitching' ),
|
||||||
'feedbackApiUrl' => $veConfig->get( 'VisualEditorFeedbackAPIURL' ),
|
'feedbackApiUrl' => $veConfig->get( 'VisualEditorFeedbackAPIURL' ),
|
||||||
'feedbackTitle' => $veConfig->get( 'VisualEditorFeedbackTitle' ),
|
'feedbackTitle' => $veConfig->get( 'VisualEditorFeedbackTitle' ),
|
||||||
'sourceFeedbackTitle' => $veConfig->get( 'VisualEditorSourceFeedbackTitle' ),
|
'sourceFeedbackTitle' => $veConfig->get( 'VisualEditorSourceFeedbackTitle' ),
|
||||||
|
|
|
@ -63,11 +63,12 @@ mw.libs.ve.SwitchConfirmDialog.static.actions = [
|
||||||
mw.libs.ve.SwitchConfirmDialog.prototype.getSetupProcess = function ( data ) {
|
mw.libs.ve.SwitchConfirmDialog.prototype.getSetupProcess = function ( data ) {
|
||||||
return mw.libs.ve.SwitchConfirmDialog.super.prototype.getSetupProcess.apply( this, arguments )
|
return mw.libs.ve.SwitchConfirmDialog.super.prototype.getSetupProcess.apply( this, arguments )
|
||||||
.next( function () {
|
.next( function () {
|
||||||
|
var
|
||||||
|
config = mw.config.get( 'wgVisualEditorConfig' ),
|
||||||
|
canSwitch = config.fullRestbaseUrl || config.allowLossySwitching;
|
||||||
if ( data && data.mode ) {
|
if ( data && data.mode ) {
|
||||||
this.actions.setMode( data.mode );
|
this.actions.setMode( data.mode );
|
||||||
} else if (
|
} else if ( canSwitch ) {
|
||||||
mw.config.get( 'wgVisualEditorConfig' ).fullRestbaseUrl
|
|
||||||
) {
|
|
||||||
this.actions.setMode( 'restbase' );
|
this.actions.setMode( 'restbase' );
|
||||||
} else {
|
} else {
|
||||||
this.actions.setMode( 'simple' );
|
this.actions.setMode( 'simple' );
|
||||||
|
|
|
@ -2355,6 +2355,8 @@ ve.init.mw.ArticleTarget.prototype.switchToFallbackWikitextEditor = function ()
|
||||||
*/
|
*/
|
||||||
ve.init.mw.ArticleTarget.prototype.switchToVisualEditor = function () {
|
ve.init.mw.ArticleTarget.prototype.switchToVisualEditor = function () {
|
||||||
var dataPromise, windowManager, switchWindow,
|
var dataPromise, windowManager, switchWindow,
|
||||||
|
config = mw.config.get( 'wgVisualEditorConfig' ),
|
||||||
|
canSwitch = config.fullRestbaseUrl || config.allowLossySwitching,
|
||||||
target = this;
|
target = this;
|
||||||
|
|
||||||
if ( !this.edited ) {
|
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
|
// 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.
|
// the server can't switch for us because that's not supported.
|
||||||
if (
|
if ( !canSwitch ) {
|
||||||
!mw.config.get( 'wgVisualEditorConfig' ).fullRestbaseUrl
|
|
||||||
) {
|
|
||||||
windowManager = new OO.ui.WindowManager();
|
windowManager = new OO.ui.WindowManager();
|
||||||
switchWindow = new mw.libs.ve.SwitchConfirmDialog();
|
switchWindow = new mw.libs.ve.SwitchConfirmDialog();
|
||||||
$( document.body ).append( windowManager.$element );
|
$( document.body ).append( windowManager.$element );
|
||||||
|
|
|
@ -205,7 +205,7 @@
|
||||||
* @return {jQuery.Promise} Abortable promise resolved with a JSON object
|
* @return {jQuery.Promise} Abortable promise resolved with a JSON object
|
||||||
*/
|
*/
|
||||||
requestParsoidData: function ( pageName, options ) {
|
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,
|
section = options.section !== undefined ? options.section : null,
|
||||||
useRestbase = ( conf.fullRestbaseUrl || conf.restbaseUrl ) && section === null,
|
useRestbase = ( conf.fullRestbaseUrl || conf.restbaseUrl ) && section === null,
|
||||||
switched = false,
|
switched = false,
|
||||||
|
@ -235,16 +235,11 @@
|
||||||
ve.track( 'trace.apiLoad.enter', { mode: 'visual' } );
|
ve.track( 'trace.apiLoad.enter', { mode: 'visual' } );
|
||||||
|
|
||||||
if ( !useRestbase && options.wikitext !== undefined ) {
|
if ( !useRestbase && options.wikitext !== undefined ) {
|
||||||
fullDocExpand = section !== null;
|
|
||||||
// Non-RESTBase custom wikitext parse
|
// Non-RESTBase custom wikitext parse
|
||||||
if ( fullDocExpand ) {
|
data.paction = 'parse';
|
||||||
data.paction = 'parse';
|
data.stash = true;
|
||||||
data.stash = true;
|
switched = true;
|
||||||
switched = true;
|
fromEditedState = options.modified;
|
||||||
fromEditedState = options.modified;
|
|
||||||
} else {
|
|
||||||
data.paction = 'parsefragment';
|
|
||||||
}
|
|
||||||
data.wikitext = options.wikitext;
|
data.wikitext = options.wikitext;
|
||||||
data.section = options.section;
|
data.section = options.section;
|
||||||
data.oldid = options.oldId;
|
data.oldid = options.oldId;
|
||||||
|
|
Loading…
Reference in a new issue