diff --git a/CodeMirror.hooks.php b/CodeMirror.hooks.php index 5683ce7f..cde1824e 100644 --- a/CodeMirror.hooks.php +++ b/CodeMirror.hooks.php @@ -66,13 +66,16 @@ class CodeMirrorHooks { * @return boolean */ private static function isCodeMirrorEnabled( IContextSource $context ) { + global $wgCodeMirrorEnableFrontend; + // Check, if we already checked, if page action is editing, if not, do it now if ( is_null( self::$isEnabled ) ) { // edit can be 'edit' and 'submit' - self::$isEnabled = in_array( - Action::getActionName( $context ), - array( 'edit', 'submit' ) - ); + self::$isEnabled = $wgCodeMirrorEnableFrontend && + in_array( + Action::getActionName( $context ), + array( 'edit', 'submit' ) + ); } return self::$isEnabled; @@ -176,10 +179,12 @@ class CodeMirrorHooks { * @return bool Always true */ public static function onGetPreferences( User $user, &$defaultPreferences ) { - $defaultPreferences['usecodemirror'] = array( - 'type' => 'api', - 'default' => '1', - ); + if ( self::isCodeMirrorEnabled( RequestContext::getMain() ) ) { + $defaultPreferences['usecodemirror'] = array( + 'type' => 'api', + 'default' => '1', + ); + } return true; } } diff --git a/CodeMirror.php b/CodeMirror.php index 3e5d0f0d..9e4b64ef 100644 --- a/CodeMirror.php +++ b/CodeMirror.php @@ -71,3 +71,11 @@ $wgResourceModules['ext.CodeMirror.lib'] = $wgCodeMirrorResourceTemplate + array 'group' => 'ext.CodeMirror', 'targets' => array( 'mobile', 'desktop' ), ); + +// Configuration options + +/** + * Specify, if CodeMirror extension should integrate CodeMirror in MediaWiki's editor (or WikiEditor), or if + * it should work as a library provider for other extensions. + */ +$wgCodeMirrorEnableFrontend = true;