Catrope has uploaded a new change for review. https://gerrit.wikimedia.org/r/88906
Change subject: Put SyntaxHighlight behind its own preference ...................................................................... Put SyntaxHighlight behind its own preference Also generalize the way extra modules are loaded. Change-Id: I132fd400886db8c18a88deaeeef64cd00c6d0d3f --- M VisualEditor.hooks.php M VisualEditor.i18n.php M VisualEditor.php M modules/ve-mw/init/ve.init.mw.Target.js A screenshot-syntaxhighlight.png 5 files changed, 30 insertions(+), 7 deletions(-) git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/VisualEditor refs/changes/06/88906/1 diff --git a/VisualEditor.hooks.php b/VisualEditor.hooks.php index ab501fc..2a91217 100644 --- a/VisualEditor.hooks.php +++ b/VisualEditor.hooks.php @@ -240,6 +240,17 @@ 'discussion-link' => 'visualeditor-preference-experimental-discussion-link', 'screenshot' => $wgExtensionAssetsPath . '/VisualEditor/logo-experimental.png', ); + + $preferences['visualeditor-enable-syntaxhighlight'] = array( + 'version' => '0.1', + 'label-message' => 'visualeditor-preference-syntaxhighlight-label', + 'desc-message' => 'visualeditor-preference-syntaxhighlight-description', + // TODO: use message 'visualeditor-preference-syntaxhighlight-info-link', + 'info-link' => false, + // TOOD: use message 'visualeditor-preferenec-syntaxhighlight-discussion-link', + 'discussion-link' => false, + 'screenshot' => $wgExtensionAssetsPath . '/VisualEditor/screenshot-syntaxhighlight.png', + ); } public static function onListDefinedTags( &$tags ) { @@ -288,7 +299,8 @@ 'defaultUserOptions' => array( 'betatempdisable' => $wgDefaultUserOptions['visualeditor-betatempdisable'], 'enable' => $wgDefaultUserOptions['visualeditor-enable'], - 'experimental' => $wgDefaultUserOptions['visualeditor-enable-experimental'], + 'enable-experimental' => $wgDefaultUserOptions['visualeditor-enable-experimental'], + 'enable-syntaxhighlight' => $wgDefaultUserOptions['visualeditor-enable-syntaxhighlight'], ), 'skins' => $wgVisualEditorSupportedSkins, 'tabPosition' => $wgVisualEditorTabPosition, diff --git a/VisualEditor.i18n.php b/VisualEditor.i18n.php index a24bf06..6dee312 100644 --- a/VisualEditor.i18n.php +++ b/VisualEditor.i18n.php @@ -168,6 +168,8 @@ '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-preference-syntaxhighlight-description' => 'Enable editing of highlighted source code blocks in VisualEditor.', + 'visualeditor-preference-syntaxhighlight-label' => 'VisualEditor source code editing', 'visualeditor-reference-input-placeholder' => 'What do you want to reference?', 'visualeditor-referencelist-isempty' => 'There are no references with the group "$1" on this page to include in this list.', 'visualeditor-referencelist-isempty-default' => 'There are no references on this page to include in this list.', diff --git a/VisualEditor.php b/VisualEditor.php index 13a05cb..e2635fe 100644 --- a/VisualEditor.php +++ b/VisualEditor.php @@ -761,7 +761,7 @@ 've-mw/ui/styles/ve.ui.Icons-vector.css', ), ), - 'ext.visualEditor.syntaxHighlight' => $wgVisualEditorResourceTemplate + array( + 'ext.visualEditor.syntaxhighlight' => $wgVisualEditorResourceTemplate + array( 'scripts' => array( 'syntaxhighlight/ve.dm.MWSyntaxHighlightNode.js', 'syntaxhighlight/ve.ce.MWSyntaxHighlightNode.js', diff --git a/modules/ve-mw/init/ve.init.mw.Target.js b/modules/ve-mw/init/ve.init.mw.Target.js index fc45845..82eb2bc 100644 --- a/modules/ve-mw/init/ve.init.mw.Target.js +++ b/modules/ve-mw/init/ve.init.mw.Target.js @@ -20,7 +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' ); + var i, len, prefName, prefValue, conf = mw.config.get( 'wgVisualEditorConfig' ), + extraModules = [ 'experimental', 'syntaxhighlight' ]; // Parent constructor ve.init.Target.call( this, $container ); @@ -34,11 +35,9 @@ this.apiUrl = mw.util.wikiScript( 'api' ); this.submitUrl = ( new mw.Uri( mw.util.wikiGetlink( this.pageName ) ) ) .extend( { 'action': 'submit' } ); + this.modules = [ - ( 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.core', 'ext.visualEditor.data' ] .concat( @@ -47,6 +46,16 @@ ['ext.visualEditor.viewPageTarget.icons-raster', 'ext.visualEditor.icons-raster'] ) .concat( mw.config.get( 'wgVisualEditorConfig' ).pluginModules || [] ); + for ( i = 0, len = extraModules.length; i < len; i++ ) { + prefName = 'visualeditor-enable-' + extraModules[i]; + 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.pluginCallbacks = []; this.modulesReady = $.Deferred(); this.loading = false; diff --git a/screenshot-syntaxhighlight.png b/screenshot-syntaxhighlight.png new file mode 100644 index 0000000..8e65336 --- /dev/null +++ b/screenshot-syntaxhighlight.png Binary files differ -- To view, visit https://gerrit.wikimedia.org/r/88906 To unsubscribe, visit https://gerrit.wikimedia.org/r/settings Gerrit-MessageType: newchange Gerrit-Change-Id: I132fd400886db8c18a88deaeeef64cd00c6d0d3f Gerrit-PatchSet: 1 Gerrit-Project: mediawiki/extensions/VisualEditor Gerrit-Branch: master Gerrit-Owner: Catrope <roan.katt...@gmail.com> _______________________________________________ MediaWiki-commits mailing list MediaWiki-commits@lists.wikimedia.org https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits