mirror of
https://gerrit.wikimedia.org/r/mediawiki/extensions/VisualEditor
synced 2024-11-24 06:24:08 +00:00
Merge "Refactor extraModules to $wgVisualEditorPreferenceModules"
This commit is contained in:
commit
38c0206c53
|
@ -339,22 +339,17 @@ class VisualEditorHooks {
|
|||
$wgVisualEditorTabMessages,
|
||||
$wgVisualEditorBrowserBlacklist,
|
||||
$wgVisualEditorSupportedSkins,
|
||||
$wgVisualEditorShowBetaWelcome;
|
||||
$wgVisualEditorShowBetaWelcome,
|
||||
$wgVisualEditorPreferenceModules;
|
||||
|
||||
$vars['wgVisualEditorConfig'] = array(
|
||||
'disableForAnons' => $wgVisualEditorDisableForAnons,
|
||||
'enableExperimentalCode' => $wgVisualEditorEnableExperimentalCode,
|
||||
'preferenceModules' => $wgVisualEditorPreferenceModules,
|
||||
'namespaces' => $wgVisualEditorNamespaces,
|
||||
'pluginModules' => $wgVisualEditorPluginModules,
|
||||
'defaultUserOptions' => array(
|
||||
'betatempdisable' => $wgDefaultUserOptions['visualeditor-betatempdisable'],
|
||||
'enable' => $wgDefaultUserOptions['visualeditor-enable'],
|
||||
'enable-experimental' => $wgDefaultUserOptions['visualeditor-enable-experimental'],
|
||||
// 'enable-language' => $wgDefaultUserOptions['visualeditor-enable-language'],
|
||||
// 'enable-mwalienextension' => $wgDefaultUserOptions['visualeditor-enable-mwalienextension'],
|
||||
'enable-mwmath' => $wgDefaultUserOptions['visualeditor-enable-mwmath'],
|
||||
// 'enable-mwhiero' => $wgDefaultUserOptions['visualeditor-enable-mwhiero'],
|
||||
// 'enable-mwsyntaxHighlight' => $wgDefaultUserOptions['visualeditor-enable-mwsyntaxHighlight'],
|
||||
),
|
||||
'blacklist' => $wgVisualEditorBrowserBlacklist,
|
||||
'skins' => $wgVisualEditorSupportedSkins,
|
||||
|
@ -363,6 +358,11 @@ class VisualEditorHooks {
|
|||
'showBetaWelcome' => $wgVisualEditorShowBetaWelcome,
|
||||
);
|
||||
|
||||
foreach ( $wgVisualEditorPreferenceModules as $pref => $module ) {
|
||||
$vars['wgVisualEditorConfig']['defaultUserOptions'][$pref] =
|
||||
$wgDefaultUserOptions[$pref];
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
|
|
@ -871,6 +871,17 @@ $wgResourceModules += array(
|
|||
// loaded. Other extensions that extend VisualEditor should add to this array.
|
||||
$wgVisualEditorPluginModules = array();
|
||||
|
||||
// Array of modules to load based on a preference. Keys are preference names, values are
|
||||
// ResourceLoader module names.
|
||||
$wgVisualEditorPreferenceModules = array(
|
||||
'visualeditor-enable-experimental' => 'ext.visualEditor.experimental',
|
||||
//'visualeditor-enable-language' => 'ext.visualEditor.language',
|
||||
//'visualeditor-enable-mwalienextension' => 'ext.visualEditor.mwalienextension',
|
||||
'visualeditor-enable-mwmath' => 'ext.visualEditor.mwmath',
|
||||
//'visualeditor-enable-mwhiero' => 'ext.visualEditor.mwhiero',
|
||||
//'visualeditor-enable-mwsyntaxhighlight' => 'ext.visualEditor.mwsyntaxhighlight'
|
||||
);
|
||||
|
||||
// URL to the Parsoid instance
|
||||
// MUST NOT end in a slash due to Parsoid bug
|
||||
$wgVisualEditorParsoidURL = 'http://localhost:8000';
|
||||
|
|
|
@ -16,21 +16,11 @@
|
|||
* @constructor
|
||||
*/
|
||||
ve.init.mw.ViewPageTarget = function VeInitMwViewPageTarget() {
|
||||
var i,
|
||||
len,
|
||||
prefName,
|
||||
var prefName,
|
||||
prefValue,
|
||||
browserWhitelisted,
|
||||
currentUri = new mw.Uri(),
|
||||
conf = mw.config.get( 'wgVisualEditorConfig' ),
|
||||
// language, mwalienextension and mwhiero are commented out in VisualEditorHooks::onGetBetaPreferences()
|
||||
extraModules = [
|
||||
'experimental',
|
||||
// 'language',
|
||||
// 'mwalienextension',
|
||||
// 'mwhiero',
|
||||
'mwmath'
|
||||
];
|
||||
conf = mw.config.get( 'wgVisualEditorConfig' );
|
||||
|
||||
// Parent constructor
|
||||
ve.init.mw.Target.call(
|
||||
|
@ -74,14 +64,13 @@ ve.init.mw.ViewPageTarget = function VeInitMwViewPageTarget() {
|
|||
*/
|
||||
this.sanityCheckPromise = null;
|
||||
|
||||
// Load additional modules
|
||||
for ( i = 0, len = extraModules.length; i < len; i++ ) {
|
||||
prefName = 'visualeditor-enable-' + extraModules[i];
|
||||
// Load preference modules
|
||||
for ( prefName in conf.preferenceModules ) {
|
||||
prefValue = mw.config.get( 'wgUserName' ) === null ?
|
||||
conf.defaultUserOptions[prefName] :
|
||||
mw.user.options.get( prefName, conf.defaultUserOptions[prefName] );
|
||||
if ( prefValue && prefValue !== '0' ) {
|
||||
this.modules.push( 'ext.visualEditor.' + extraModules[i] );
|
||||
this.modules.push( conf.preferenceModules[prefName] );
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue