Merge "Special-case redlink URLs to load preferred editor"

This commit is contained in:
jenkins-bot 2019-05-28 23:21:28 +00:00 committed by Gerrit Code Review
commit 795e7b13fb
2 changed files with 18 additions and 8 deletions

View file

@ -315,8 +315,10 @@ class VisualEditorHooks {
private static function getPreferredEditor( User $user, WebRequest $req ) {
$config = MediaWikiServices::getInstance()->getConfigFactory()
->makeConfig( 'visualeditor' );
// On dual-edit-tab wikis, the edit page must mean the user wants wikitext
if ( !$config->get( 'VisualEditorUseSingleEditTab' ) ) {
$isRedLink = $req->getBool( 'redlink' );
// On dual-edit-tab wikis, the edit page must mean the user wants wikitext,
// unless following a redlink
if ( !$config->get( 'VisualEditorUseSingleEditTab' ) && !$isRedLink ) {
return 'wikitext';
}
switch ( $user->getOption( 'visualeditor-tabs' ) ) {
@ -330,7 +332,9 @@ class VisualEditorHooks {
// May have got here by switching from VE
// TODO: Make such an action explicitly request wikitext
// so we can use getLastEditor here instead.
return 'wikitext';
return $isRedLink ?
self::getLastEditor( $user, $req ) :
'wikitext';
}
return null;
}

View file

@ -452,22 +452,28 @@
}
function getPreferredEditor() {
// On dual-edit-tab wikis, the edit page must mean the user wants wikitext
if ( !mw.config.get( 'wgVisualEditorConfig' ).singleEditTab ) {
// This logic matches VisualEditorHooks::getPreferredEditor
// !!+ casts '0' to false
var isRedLink = !!+uri.query.redlink;
// On dual-edit-tab wikis, the edit page must mean the user wants wikitext,
// unless following a redlink
if ( !mw.config.get( 'wgVisualEditorConfig' ).singleEditTab && !isRedLink ) {
return 'wikitext';
}
switch ( tabPreference ) {
case 'remember-last':
return getLastEditor();
case 'prefer-ve':
return 'visualeditor';
case 'prefer-wt':
return 'wikitext';
case 'remember-last':
return getLastEditor();
case 'multi-tab':
// 'multi-tab'
// TODO: See VisualEditor.hooks.php
return 'wikitext';
return isRedLink ?
getLastEditor() :
'wikitext';
}
return null;
}