Niharika29 has uploaded a new change for review. ( 
https://gerrit.wikimedia.org/r/358494 )

Change subject: Add syntax highlight as a beta feature
......................................................................

Add syntax highlight as a beta feature

Bug: T165543
Change-Id: If7eb2dc3f7c00a91e5ca39ae564f63efa07bbead
---
M CodeMirror.hooks.php
M extension.json
M i18n/en.json
3 files changed, 40 insertions(+), 9 deletions(-)


  git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/CodeMirror 
refs/changes/94/358494/1

diff --git a/CodeMirror.hooks.php b/CodeMirror.hooks.php
index 6bbaa15..e4f83f9 100644
--- a/CodeMirror.hooks.php
+++ b/CodeMirror.hooks.php
@@ -11,17 +11,19 @@
         * @return bool
         */
        private static function isCodeMirrorEnabled( IContextSource $context ) {
-               global $wgCodeMirrorEnableFrontend;
+               global $wgCodeMirrorEnableFrontend, $wgCodeMirrorBetaFeature;
                static $isEnabled = null;
 
                // Check, if we already checked, if page action is editing, if 
not, do it now
                if ( $isEnabled === null ) {
-                       $isEnabled = $wgCodeMirrorEnableFrontend &&
-                               in_array(
-                                       Action::getActionName( $context ),
-                                       [ 'edit', 'submit' ]
-                               );
-               }
+                       $isEnabled =
+                               $wgCodeMirrorEnableFrontend &&
+                               in_array( Action::getActionName( $context ), [ 
'edit', 'submit' ] ) &&
+                               $wgCodeMirrorBetaFeature == true &&
+                               $wgCodeMirrorEnableFrontend == true &&
+                               class_exists( 'BetaFeatures' ) &&
+                               BetaFeatures::isFeatureEnabled( 
$context->getUser(), 'codemirror-syntax-highlight' );
+                       }
 
                return $isEnabled;
        }
@@ -144,4 +146,27 @@
                ];
        }
 
+       /**
+        * GetBetaFeaturePreferences hook handler
+        *
+        * @param User $user
+        * @param array $preferences
+        */
+       public function onGetBetaFeaturePreferences( User $user, &$preferences 
) {
+               global $wgCodeMirrorEnableFrontend, $wgCodeMirrorBetaFeature;
+               if ( $wgCodeMirrorEnableFrontend == true && 
$wgCodeMirrorBetaFeature == true ) {
+                       $imagesDir = '';
+                       $preferences['codemirror-syntax-highlight'] = [
+                               'label-message' => 'codemirror-beta-title',
+                               'desc-message' => 'codemirror-beta-desc',
+                               'screenshot' => [
+                                       'ltr' => '',
+                                       'rtl' => ''
+                               ],
+                               'info-link' => 
'https://meta.wikimedia.org/wiki/Community_Tech/Wikitext_editor_syntax_highlighting',
+                               'discussion-link' => 
'https://meta.wikimedia.org/wiki/Talk:Community_Tech/Wikitext_editor_syntax_highlighting'
+                       ];
+               }
+       }
+
 }
diff --git a/extension.json b/extension.json
index 9575060..cc62933 100644
--- a/extension.json
+++ b/extension.json
@@ -141,6 +141,9 @@
                ],
                "GetPreferences": [
                        "CodeMirrorHooks::onGetPreferences"
+               ],
+               "GetBetaFeaturePreferences": [
+                       "CodeMirrorHooks::onGetBetaFeaturePreferences"
                ]
        },
        "VisualEditorPluginModules": [
@@ -148,7 +151,8 @@
                "ext.CodeMirror.visualEditor"
        ],
        "config": {
-               "CodeMirrorEnableFrontend": true
+               "CodeMirrorEnableFrontend": true,
+               "CodeMirrorBetaFeature": true
        },
        "CodeMirrorTagModes": {
                "pre": "mw-tag-pre",
diff --git a/i18n/en.json b/i18n/en.json
index 4ed7044..9087119 100644
--- a/i18n/en.json
+++ b/i18n/en.json
@@ -5,5 +5,7 @@
                ]
        },
        "codemirror-desc": "Provides syntax highlighting in wikitext editor",
-       "codemirror-toggle-label": "Syntax highlighting"
+       "codemirror-toggle-label": "Syntax highlighting",
+       "codemirror-beta-title": "Syntax highlighting",
+       "codemirror-beta-desc": "Syntax highlighting makes editing easier by 
using color and shade to visually separate article text from the code for 
links, references and templates."
 }

-- 
To view, visit https://gerrit.wikimedia.org/r/358494
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: If7eb2dc3f7c00a91e5ca39ae564f63efa07bbead
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/extensions/CodeMirror
Gerrit-Branch: master
Gerrit-Owner: Niharika29 <nko...@wikimedia.org>

_______________________________________________
MediaWiki-commits mailing list
MediaWiki-commits@lists.wikimedia.org
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits

Reply via email to