From 47815e9d2b5174c6461eb7d3ed6240ab0e13ab6f Mon Sep 17 00:00:00 2001 From: Jon Robson Date: Thu, 28 Sep 2023 12:20:27 -0700 Subject: [PATCH] Change icon for supported skins when both VE and source edit icons are present This introduces an extension attribute EditIconSkins which allows extensions or skins to request the rendering of edit icons. This will be used by Minerva in I3c9d59f49f1b939981a7b2b450448db6736d5958 Bug: T346944 Change-Id: I401805224c0f387ac85b52b50c1f298b83c03a91 --- includes/Hooks.php | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/includes/Hooks.php b/includes/Hooks.php index 49c80d5438..4446e472d6 100644 --- a/includes/Hooks.php +++ b/includes/Hooks.php @@ -607,6 +607,14 @@ class Hooks implements $newViews = []; $wikiPageFactory = $services->getWikiPageFactory(); $isRemote = !$wikiPageFactory->newFromTitle( $title )->isLocal(); + + $skinHasEditIcons = in_array( + $skin->getSkinName(), + ExtensionRegistry::getInstance()->getAttribute( + 'VisualEditorIconSkins' + ) + ); + foreach ( $links['views'] as $action => $data ) { if ( $action === 'edit' ) { // Build the VisualEditor tab @@ -639,6 +647,7 @@ class Hooks implements 'text' => $veTabText, 'single-id' => $veTooltip, 'primary' => true, + 'icon' => $skinHasEditIcons ? 'edit' : null, 'class' => '', ]; @@ -690,6 +699,8 @@ class Hooks implements $userOptionsLookup->getOption( $user, 'visualeditor-tabs' ) === 'multi-tab' ) ) { + // Change icon + $editTab['icon'] = $skinHasEditIcons ? 'wikiText' : null; // Inject the VE tab before or after the edit tab if ( $config->get( 'VisualEditorTabPosition' ) === 'before' ) { // @phan-suppress-next-line PhanTypePossiblyInvalidDimOffset