Extension:TemplateStylesExtender/zh

Category:GPL licensed extensions/zh
TemplateStylesExtender
Category:Stable extensions/zh
Category:Parser extensions/zh
描述 Extends Extension:TemplateStyles with new selectors
作者 Octfx留言
最新版本 2.0.0 (2025-06-02)
MediaWiki 1.43+Category:Extensions with manual MediaWiki version/zh
PHP >=8.0
Composer octfx/template-styles-extenderCategory:Extensions supporting Composer/zh
GNU通用公眾授權條款2.0或更新版本
下載 Category:Extensions in GitHub version control/zh
  • $wgTemplateStylesExtenderCustomPropertiesDeclaration
  • $wgTemplateStylesExtenderExtendCustomPropertiesValues
  • $wgTemplateStylesExtenderEnableUnscopingSupport
  • $wgTemplateStylesExtenderUnscopingPermission
Category:All extensions/zh
Category:Pages using deprecated NoteTA template#%20

TemplateStylesExtender扩展对:进行了扩展,支持新的选择器和匹配器。 TemplateStylesExtender is developed based on css-sanitizer 5.5.0, which is being used by MediaWiki 1.43.

功能

  • Declare CSS custom properties/variables
  • Use CSS custom properties/variables in most properties
  • Implement additional properties and values as listed below
Module Changes Upstream task
Basic User Interface Module Level 4 Added property: pointer-events T342271
Box Sizing Module Level 4 Backported for css-sanitizer 5.5.0 T375344
Cascading and Inheritance Level 5 Added value: revert-layer -
Color Module Level 4 Added: Alpha HEX notation T265675
Color Module Level 5 Added: Relative color, color() -
Containment Module Level 3 Added properties: contain, content-visibility -
Filter Effects Module Level 2 Added property: backdrop-filter -
Fonts Module Level 4 Added properties: font-optical-sizing, font-variation-settings, ascent-override, descent-override, font-display, line-gap-override -
Fonts Module Level 5 Added property: size-adjust -
Masking Module Level 1 Added property: -webkit-mask-image -
Ruby Annotation Layout Module Level 1 Added properties: ruby-align, ruby-position T277755
Scroll Snap Module Level 1 Added properties: scroll-margin, scroll-padding, scroll-snap-align, scroll-snap-stop, scroll-snap-type T271598
Values and Units Module Level 4 Added function: clamp() T394619

安裝

  • 下载,并将其放置在您extensions/中的TemplateStylesExtender目录内。
  • 将下列放置在您的LocalSettings.php 的底部:
    wfLoadExtension( 'TemplateStyles' );
    wfLoadExtension( 'TemplateStylesExtender' );
    
  • Yes 完成 – 在您的wiki上Special:Version,以验证已成功安装

Configuration 描述
$wgTemplateStylesExtenderCustomPropertiesDeclaration Allow CSS custom properties (CSS variables) to be declared as properties true
$wgTemplateStylesExtenderExtendCustomPropertiesValues Allow the CSS custom properties (CSS variables) to be used as values in all properties true
$wgTemplateStylesExtenderEnableUnscopingSupport Allows users with unscope permissions to unscope CSS by setting a wrapclass attribute. false
$wgTemplateStylesExtenderUnscopingPermission Specify a permission group that is allowed to unscope CSS. editinterface

注意CSS变量

当然:root选择器不起作用,因为模板样式会在前面加上.mw-parser-output

一种可行的修复方案是将整个内容包围在div中,并为其添加声明,例如

div#content-wrap {
   --padding: 10px
}

.content {
   padding: var( --padding )
}

Wikitext

<div id="content-wrap">
   <div class="content">
      The WikiText...
   </div>
</div>

CSS取消包围

例如:<templatestyles src="Foo/style.css" wrapclass="mediawiki" />会导致CSS被包围在.mediawiki中,而不是在.mw-parser-output中。

要在页面内包括这样的调用时,用户需要有editinterface权限才能够编辑。 你也可以选择调用一个包括了此样式的模板。

參見

Category:All extensions/zh Category:Extensions in GitHub version control/zh Category:Extensions included in Canasta/zh Category:Extensions included in Miraheze/zh Category:Extensions included in MyWikis/zh Category:Extensions included in WikiForge/zh Category:Extensions included in wiki.gg/zh Category:Extensions supporting Composer/zh Category:Extensions with manual MediaWiki version/zh Category:GPL licensed extensions/zh Category:Pages using deprecated NoteTA template Category:ParserFirstCallInit extensions/zh Category:Parser extensions/zh Category:Stable extensions/zh Category:TemplateStylesPropertySanitizer extensions/zh Category:TemplateStylesStylesheetSanitizer extensions/zh