jenkins-bot has submitted this change and it was merged. (
https://gerrit.wikimedia.org/r/374898 )
Change subject: Respect beta feature in new wikitext editor
......................................................................
Respect beta feature in new wikitext editor
Bug: T173480
Change-Id: I2ca5a33f09aefe0c3d31082270869a13cee14fc4
---
M CodeMirror.hooks.php
M resources/modules/ve-cm/ve.ui.CodeMirror.init.js
2 files changed, 28 insertions(+), 14 deletions(-)
Approvals:
jenkins-bot: Verified
Jforrester: Looks good to me, but someone else must approve
Kaldari: Looks good to me, approved
diff --git a/CodeMirror.hooks.php b/CodeMirror.hooks.php
index ef61fbf..dd2725e 100644
--- a/CodeMirror.hooks.php
+++ b/CodeMirror.hooks.php
@@ -3,7 +3,7 @@
class CodeMirrorHooks {
/**
- * Checks, if CodeMirror should be loaded on this page or not.
+ * Checks if CodeMirror is enabled for this user
*
* @param IContextSource $context The current ContextSource object
* @staticvar null|boolean $isEnabled Saves, if CodeMirror should be
loaded on this page or not
@@ -16,10 +16,9 @@
// Check, if we already checked, if page action is editing, if
not, do it now
if ( $isEnabled === null ) {
if ( !$wgCodeMirrorBetaFeature ) {
- $isEnabled = in_array( Action::getActionName(
$context ), [ 'edit', 'submit' ] );
+ $isEnabled = true;
} else {
- $isEnabled = in_array( Action::getActionName(
$context ), [ 'edit', 'submit' ] ) &&
- $wgCodeMirrorBetaFeature &&
+ $isEnabled = $wgCodeMirrorBetaFeature &&
ExtensionRegistry::getInstance()->isLoaded( 'BetaFeatures' ) &&
BetaFeatures::isFeatureEnabled(
$context->getUser(),
'codemirror-syntax-highlight' );
@@ -27,6 +26,18 @@
}
return $isEnabled;
+ }
+
+ /**
+ * Checks if CodeMirror for textarea wikitext editor should be loaded
on this page or not.
+ *
+ * @param IContextSource $context The current ContextSource object
+ * @staticvar null|boolean $isEnabled Saves, if CodeMirror should be
loaded on this page or not
+ * @return bool
+ */
+ private static function isCodeMirrorOnPage( IContextSource $context ) {
+ return in_array( Action::getActionName( $context ), [ 'edit',
'submit' ] ) &&
+ self::isCodeMirrorEnabled( $context );
}
/**
@@ -38,9 +49,10 @@
* @param Skin $skin
*/
public static function onBeforePageDisplay( OutputPage &$out, Skin
&$skin ) {
- if ( self::isCodeMirrorEnabled( $out->getContext() ) ) {
+ if ( self::isCodeMirrorOnPage( $out->getContext() ) ) {
$out->addModules( 'ext.CodeMirror' );
}
+ $out->addJsConfigVars( 'wgCodeMirrorEnabled',
self::isCodeMirrorEnabled( $out->getContext() ) );
}
/**
diff --git a/resources/modules/ve-cm/ve.ui.CodeMirror.init.js
b/resources/modules/ve-cm/ve.ui.CodeMirror.init.js
index 4708879..11a85e4 100644
--- a/resources/modules/ve-cm/ve.ui.CodeMirror.init.js
+++ b/resources/modules/ve-cm/ve.ui.CodeMirror.init.js
@@ -1,12 +1,14 @@
( function ( ve, mw ) {
- mw.libs.ve.targetLoader.addPlugin( function () {
- var i, target, index;
- for ( i in ve.init.mw ) {
- target = ve.init.mw[ i ];
- if ( target === ve.init.mw.DesktopArticleTarget ) {
- index = target.static.actionGroups[ 1
].include.indexOf( 'changeDirectionality' );
- target.static.actionGroups[ 1 ].include.splice(
index, 0, 'codeMirror' );
+ if ( mw.config.get( 'wgCodeMirrorEnabled' ) ) {
+ mw.libs.ve.targetLoader.addPlugin( function () {
+ var i, target, index;
+ for ( i in ve.init.mw ) {
+ target = ve.init.mw[ i ];
+ if ( target === ve.init.mw.DesktopArticleTarget
) {
+ index = target.static.actionGroups[ 1
].include.indexOf( 'changeDirectionality' );
+ target.static.actionGroups[ 1
].include.splice( index, 0, 'codeMirror' );
+ }
}
- }
- } );
+ } );
+ }
}( ve, mediaWiki ) );
--
To view, visit https://gerrit.wikimedia.org/r/374898
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: merged
Gerrit-Change-Id: I2ca5a33f09aefe0c3d31082270869a13cee14fc4
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/extensions/CodeMirror
Gerrit-Branch: master
Gerrit-Owner: Esanders <[email protected]>
Gerrit-Reviewer: Esanders <[email protected]>
Gerrit-Reviewer: Jforrester <[email protected]>
Gerrit-Reviewer: Kaldari <[email protected]>
Gerrit-Reviewer: Niharika29 <[email protected]>
Gerrit-Reviewer: jenkins-bot <>
_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits