Extension:TemplateStylesExtender/cs

Category:GPL licensed extensions/cs
Příručka k rozšířením MediaWiki
TemplateStylesExtender
Stav rozšíření: stabilníCategory:Stable extensions/cs
Implementace Rozšíření syntaktického analyzátoru Category:Parser extensions/cs
Popis Extends Extension:TemplateStyles with new selectors
Autoři Octfxdiskuse
Nejnovější verze 2.0.0 (2025-06-02)
MediaWiki 1.43+Category:Extensions with manual MediaWiki version
PHP >=8.0
Composer octfx/template-styles-extenderCategory:Extensions supporting Composer/cs
Licence GNU General Public License 2.0 nebo novější
Stáhnout Category:Extensions in GitHub version control/cs
  • $wgTemplateStylesExtenderCustomPropertiesDeclaration
  • $wgTemplateStylesExtenderExtendCustomPropertiesValues
  • $wgTemplateStylesExtenderEnableUnscopingSupport
  • $wgTemplateStylesExtenderUnscopingPermission
Category:All extensions/cs

Rozšíření TemplateStylesExtender rozšiřuje Extension:TemplateStyles o nové selektory a párovače. TemplateStylesExtender is developed based on css-sanitizer 5.5.0, which is being used by MediaWiki 1.43.

Funkce

  • 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

Installation

  • Download soubor/y a vložte je do adresáře pojmenovaného TemplateStylesExtender ve vaší složce extensions/.
  • Na konec vašeho souboru LocalSettings.php přidejte následující kód:
    wfLoadExtension( 'TemplateStyles' );
    wfLoadExtension( 'TemplateStylesExtender' );
    
  • Configure as required.
  • Yes Dokončeno – Přejděte na stránku Special:Version vaší wiki a zkontrolujte, zda bylo rozšíření úspěšně nainstalováno.

Configuration

Configuration Description Default
$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

Note CSS Vars

Currently using :root selectors won't work due to template styles prepending .mw-parser-output.

One possible fix is to wrap the entire content into a 'div' element and adding the declarations to this, e.g.

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

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

Wikitext

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

Unscoping of CSS

Example: <templatestyles src="Foo/style.css" wrapclass="mediawiki" /> results in the CSS being scoped to .mediawiki instead of .mw-parser-output.

Including such a call in a page essentially limits editing to users with the editinterface right. You can alternatively include a call to a template that includes the styles.

See also

Category:All extensions/cs Category:Extensions in GitHub version control/cs Category:Extensions included in Miraheze/cs Category:Extensions included in MyWikis/cs Category:Extensions included in WikiForge/cs Category:Extensions supporting Composer/cs Category:Extensions with manual MediaWiki version Category:GPL licensed extensions/cs Category:ParserFirstCallInit extensions/cs Category:Parser extensions/cs Category:Stable extensions/cs Category:TemplateStylesPropertySanitizer extensions/cs Category:TemplateStylesStylesheetSanitizer extensions/cs