From f49bd60c6a971638caf7ae33d4de6107b87c50ca Mon Sep 17 00:00:00 2001 From: Hyperzlib Date: Mon, 9 Dec 2024 01:10:20 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E5=A4=8DMW=201.42=E6=94=AF=E6=8C=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- includes/ExtraFontWidget.php | 8 ++++++-- includes/FontFaceWidget.php | 11 +++++++++-- includes/MasonryWidget.php | 2 +- includes/Widgets.php | 4 +--- modules/offcanvasTOC/ext.isekai.offcanvasTOC.less | 2 +- 5 files changed, 18 insertions(+), 9 deletions(-) diff --git a/includes/ExtraFontWidget.php b/includes/ExtraFontWidget.php index 3f32393..f8b99e9 100644 --- a/includes/ExtraFontWidget.php +++ b/includes/ExtraFontWidget.php @@ -7,7 +7,12 @@ use PPFrame; class ExtraFontWidget { public static function create($text, $params, Parser $parser, PPFrame $frame) { - $existsFonts = $parser->extIsekaiWidgetsCache->get('extraFonts', INF, []); + /** @var \MediaWiki\Parser\ParserOutput */ + $out = $parser->getOutput(); + $existsFonts = $out->getExtensionData('IsekaiWidgets.extraFonts'); + if (!$existsFonts) { + $existsFonts = []; + } $content = $text = $parser->recursiveTagParseFully($text, $frame); if (empty($params['name'])) { @@ -22,7 +27,6 @@ class ExtraFontWidget { $content; } - $existsFonts = $parser->extIsekaiWidgetsCache->get('extraFonts', INF, []); if (!isset($existsFonts[$fontName])) { return '' . wfMessage('isekai-font-error-font-not-imported', $params['name'])->parse() . diff --git a/includes/FontFaceWidget.php b/includes/FontFaceWidget.php index 796b614..566cdcb 100644 --- a/includes/FontFaceWidget.php +++ b/includes/FontFaceWidget.php @@ -20,9 +20,16 @@ class FontFaceWidget { } $service = MediaWikiServices::getInstance(); + /** @var \MediaWiki\Parser\ParserOutput */ + $out = $parser->getOutput(); $fontName = 'extra-' . $params['name']; - $existsFonts = $parser->extIsekaiWidgetsCache->get('extraFonts', INF, []); + + $existsFonts = $out->getExtensionData('IsekaiWidgets.extraFonts'); + if (!$existsFonts) { + $existsFonts = []; + } + if (isset($existsFonts[$fontName])) { return '' . wfMessage('isekai-fontface-error-font-already-defined', $params['name'])->parse() . @@ -48,7 +55,7 @@ class FontFaceWidget { ".isekai-extra-font.font-{$fontId}{font-family:'{$fontName}'}"; $existsFonts[$fontName] = $fontId; - $existsFonts = $parser->extIsekaiWidgetsCache->set('extraFonts', $existsFonts); + $out->setExtensionData('IsekaiWidgets.extraFonts', $existsFonts); return [$css, "markerType" => 'nowiki']; } diff --git a/includes/MasonryWidget.php b/includes/MasonryWidget.php index b287cfb..886f37d 100644 --- a/includes/MasonryWidget.php +++ b/includes/MasonryWidget.php @@ -49,7 +49,7 @@ class MasonryWidget { $maxCol = max(1, $value); $colWidth = round(100 / $maxCol, 6); - $css .= "@media (min-width: {$width}px) { .isekai-masonry.max-col-{$breakpoint}-${maxCol} { --masonry-col-width: {$colWidth}%; } }"; + $css .= "@media (min-width: {$width}px) { .isekai-masonry.max-col-{$breakpoint}-{$maxCol} { --masonry-col-width: {$colWidth}%; } }"; } return Html::rawElement('style', [], $css); diff --git a/includes/Widgets.php b/includes/Widgets.php index b2a8e92..331b64b 100644 --- a/includes/Widgets.php +++ b/includes/Widgets.php @@ -8,13 +8,11 @@ use MediaWiki\Output\OutputPage; class Widgets { /** - * @param \Parser $parser + * @param Parser $parser * @return bool * @throws \MWException */ public static function onParserSetup(&$parser) { - $parser->extIsekaiWidgetsCache = new MapCacheLRU( 100 ); // 100 is arbitrary - $parser->setHook('createpage', [CreatePageWidget::class, 'create']); $parser->setHook('discoverbox', [DiscoverWidget::class, 'create']); $parser->setHook('feedlist', [FeedListWidget::class, 'create']); diff --git a/modules/offcanvasTOC/ext.isekai.offcanvasTOC.less b/modules/offcanvasTOC/ext.isekai.offcanvasTOC.less index 857e76e..16bbfef 100644 --- a/modules/offcanvasTOC/ext.isekai.offcanvasTOC.less +++ b/modules/offcanvasTOC/ext.isekai.offcanvasTOC.less @@ -4,7 +4,7 @@ opacity: 0; top: 0; right: 0; - z-index: 102; + z-index: 200; margin: 0; height: 100vh; min-width: 275px;