Merge "Add $wgCodeMirrorRTL to control rollout to RTL wikis"

This commit is contained in:
jenkins-bot 2024-04-15 13:57:44 +00:00 committed by Gerrit Code Review
commit 918b1bc295
2 changed files with 7 additions and 1 deletions

View file

@ -36,6 +36,10 @@
"value": null,
"description": "List of namespace IDs where line numbering should be enabled, or `null` to enable for all namespaces. Set to [] to disable everywhere.",
"public": true
},
"CodeMirrorRTL": {
"value": true,
"description": "Temporary feature flag to control rollout of CodeMirror on RTL wikis."
}
},
"MessagesDirs": {

View file

@ -28,6 +28,7 @@ class Hooks implements
private UserOptionsLookup $userOptionsLookup;
private array $conflictingGadgets;
private bool $useV6;
private bool $isSupportedRtlWiki;
/**
* @param UserOptionsLookup $userOptionsLookup
@ -40,6 +41,7 @@ class Hooks implements
$this->userOptionsLookup = $userOptionsLookup;
$this->useV6 = $config->get( 'CodeMirrorV6' );
$this->conflictingGadgets = $config->get( 'CodeMirrorConflictingGadgets' );
$this->isSupportedRtlWiki = $config->get( 'CodeMirrorRTL' );
}
/**
@ -74,7 +76,7 @@ class Hooks implements
// Disable CodeMirror if we're on an edit page with a conflicting gadget. See T178348.
return !$this->conflictingGadgetsEnabled( $extensionRegistry, $out->getUser() ) &&
// CodeMirror 5 on textarea wikitext editors doesn't support RTL (T170001)
( !$isRTL || $this->shouldUseV6( $out ) ) &&
( !$isRTL || ( $this->shouldUseV6( $out ) && $this->isSupportedRtlWiki ) ) &&
// Limit to supported content models that use wikitext.
// See https://www.mediawiki.org/wiki/Content_handlers#Extension_content_handlers
in_array( $out->getTitle()->getContentModel(), $contentModels );