diff --git a/VisualEditor.hooks.php b/VisualEditor.hooks.php index a484702db2..17f9016a5c 100644 --- a/VisualEditor.hooks.php +++ b/VisualEditor.hooks.php @@ -230,6 +230,19 @@ class VisualEditorHooks { return true; } + public static function onGetBetaPreferences( $user, &$preferences ) { + global $wgExtensionAssetsPath; + + $preferences['visualeditor-enable-experimental'] = array( + 'version' => '1.0', + 'label-message' => 'visualeditor-preference-experimental-label', + 'desc-message' => 'visualeditor-preference-experimental-description', + 'info-link' => 'visualeditor-preference-experimental-info-link', + 'discussion-link' => 'visualeditor-preference-experimental-discussion-link', + 'screenshot' => $wgExtensionAssetsPath . '/VisualEditor/logo-experimental.png', + ); + } + public static function onListDefinedTags( &$tags ) { $tags[] = 'visualeditor'; $tags[] = 'visualeditor-needcheck'; @@ -273,8 +286,9 @@ class VisualEditorHooks { 'namespaces' => $wgVisualEditorNamespaces, 'pluginModules' => $wgVisualEditorPluginModules, 'defaultUserOptions' => array( - 'enable' => $wgDefaultUserOptions['visualeditor-enable'], 'betatempdisable' => $wgDefaultUserOptions['visualeditor-betatempdisable'], + 'enable' => $wgDefaultUserOptions['visualeditor-enable'], + 'experimental' => $wgDefaultUserOptions['visualeditor-enable-experimental'], ), 'skins' => self::$supportedSkins, 'tabPosition' => $wgVisualEditorTabPosition, diff --git a/VisualEditor.i18n.php b/VisualEditor.i18n.php index 8e3b5f12c7..c9503f4a96 100644 --- a/VisualEditor.i18n.php +++ b/VisualEditor.i18n.php @@ -163,6 +163,8 @@ $messages['en'] = array( 'visualeditor-parameter-search-unknown' => 'Unknown parameter', 'visualeditor-preference-betatempdisable' => 'Temporarily disable VisualEditor while it is in beta', 'visualeditor-preference-enable' => 'Enable VisualEditor (only in the [[{{MediaWiki:visualeditor-mainnamespacepagelink}}|main]] and [[{{MediaWiki:visualeditor-usernamespacepagelink}}|user]] namespaces)', + 'visualeditor-preference-experimental-description' => 'Enable the latest features inside VisualEditor. As we develop tools and make changes for the editor, we make them available for testing ahead of general release. Please remember to always review your changes before saving when using experimental features.', + 'visualeditor-preference-experimental-label' => 'VisualEditor experimental features', 'visualeditor-reference-input-placeholder' => 'What do you want to reference?', 'visualeditor-referencelist-isempty' => 'There are no references with the group "$1" on this page.', 'visualeditor-referencelist-missingref' => 'This reference is defined in a template or other generated block, and for now can only be edited in source mode.', @@ -504,6 +506,8 @@ See [[w:LaTeX]].', 'visualeditor-preference-betatempdisable' => 'Label for the temporary user preference to disable VisualEditor while it is in beta.', 'visualeditor-preference-enable' => 'Label for the user preference to enable VisualEditor while it is in alpha (opt-in) mode. Links are in {{msg-mw|Visualeditor-mainnamespacepagelink}} and {{msg-mw|visualeditor-usernamespacepagelink}}.', + 'visualeditor-preference-experimental-description' => 'Description of VisualEditor experimental features', + 'visualeditor-preference-experimental-label' => 'Label for option to enable VisualEditor experimental features', 'visualeditor-reference-input-placeholder' => 'Placeholder text for reference search field: searches existing on-page references.', 'visualeditor-referencelist-isempty' => 'Message that appears in the references list when there are no references on the page of that group. diff --git a/VisualEditor.php b/VisualEditor.php index 6327d7e776..1253a1a760 100644 --- a/VisualEditor.php +++ b/VisualEditor.php @@ -48,6 +48,9 @@ $wgAPIModules['visualeditoredit'] = 'ApiVisualEditorEdit'; // Register Hooks $wgHooks['BeforePageDisplay'][] = 'VisualEditorHooks::onBeforePageDisplay'; $wgHooks['DoEditSectionLink'][] = 'VisualEditorHooks::onDoEditSectionLink'; +if ( array_key_exists( 'GetBetaFeaturePreferences', $wgHooks ) ) { + $wgHooks['GetBetaFeaturePreferences'][] = 'VisualEditorHooks::onGetBetaPreferences'; +} $wgHooks['GetPreferences'][] = 'VisualEditorHooks::onGetPreferences'; $wgHooks['ListDefinedTags'][] = 'VisualEditorHooks::onListDefinedTags'; $wgHooks['MakeGlobalVariablesScript'][] = 'VisualEditorHooks::onMakeGlobalVariablesScript'; @@ -58,6 +61,7 @@ $wgExtensionFunctions[] = 'VisualEditorHooks::onSetup'; // Set default values for new preferences $wgDefaultUserOptions['visualeditor-enable'] = 0; +$wgDefaultUserOptions['visualeditor-enable-experimental'] = 0; $wgDefaultUserOptions['visualeditor-betatempdisable'] = 0; // Register resource modules @@ -774,9 +778,6 @@ $wgVisualEditorUseChangeTagging = true; // but still disable VE for logged-out users (by setting this to false). $wgVisualEditorDisableForAnons = false; -// Whether to enable incomplete experimental code -$wgVisualEditorEnableExperimentalCode = false; - // Whether to show the "welcome to the beta" dialog the first time a user uses VisualEditor $wgVisualEditorShowBetaWelcome = false; diff --git a/logo-experimental.png b/logo-experimental.png new file mode 100644 index 0000000000..fc54ecb4c9 Binary files /dev/null and b/logo-experimental.png differ diff --git a/logo-experimental.svg b/logo-experimental.svg new file mode 100644 index 0000000000..3db886be48 --- /dev/null +++ b/logo-experimental.svg @@ -0,0 +1,80 @@ + + + +image/svg+xml \ No newline at end of file diff --git a/modules/ve-mw/init/ve.init.mw.Target.js b/modules/ve-mw/init/ve.init.mw.Target.js index 2b91421c82..26a1ef7aed 100644 --- a/modules/ve-mw/init/ve.init.mw.Target.js +++ b/modules/ve-mw/init/ve.init.mw.Target.js @@ -20,6 +20,8 @@ * revision id here. Defaults to loading the latest version (see #load). */ ve.init.mw.Target = function VeInitMwTarget( $container, pageName, revisionId ) { + var conf = mw.config.get( 'wgVisualEditorConfig' ); + // Parent constructor ve.init.Target.call( this, $container ); @@ -33,7 +35,9 @@ ve.init.mw.Target = function VeInitMwTarget( $container, pageName, revisionId ) this.submitUrl = ( new mw.Uri( mw.util.wikiGetlink( this.pageName ) ) ) .extend( { 'action': 'submit' } ); this.modules = [ - mw.config.get( 'wgVisualEditorConfig' ).enableExperimentalCode ? + ( mw.config.get( 'wgUserName' ) === null ? + conf.defaultUserOptions.experimental : + mw.user.options.get( 'visualeditor-enable-experimental', conf.defaultUserOptions.experimental ) ) ? 'ext.visualEditor.experimental' : 'ext.visualEditor.core', 'ext.visualEditor.data' ]