mirror of
https://gerrit.wikimedia.org/r/mediawiki/extensions/VisualEditor
synced 2024-11-29 00:30:44 +00:00
Merge "Special-case redlink URLs to load preferred editor"
This commit is contained in:
commit
795e7b13fb
|
@ -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;
|
||||
}
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue