Extension:TemplateStylesExtender

From mediawiki.org
This page is a translated version of the page Extension:TemplateStylesExtender and the translation is 46% complete.
MediaWiki 拡張機能マニュアル
TemplateStylesExtender
リリースの状態: 安定
実装 パーサー拡張機能
説明 Extends Extension:TemplateStyles with new selectors
作者 Octfxトーク
最新バージョン 1.2.0 (2023-07-19)
MediaWiki 1.39+
PHP >=8.0
Composer octfx/template-styles-extender
ライセンス GNU 一般公衆利用許諾書 2.0 以降
ダウンロード

  • $wgTemplateStylesExtenderEnablePrefersColorScheme
  • $wgTemplateStylesExtenderEnableCssVars
  • $wgTemplateStylesExtenderEnableUnscopingSupport

The TemplateStylesExtender extension extends Extension:TemplateStyles with new selectors and matchers.

特徴

Add support for:

  • CSS variables:
    color: var( --color-base )
  • image-rendering
  • ruby-position
  • ruby-align
  • scroll-margin-* and scroll-padding-*
  • @media (prefers-color-scheme: dark/light) media queries
  • mask-image
  • clamp
  • revert / revert-layer
  • aspect-ratio

インストール

  • ダウンロードして、ファイルをextensions/フォルダー内のTemplateStylesExtenderという名前のディレクトリ内に配置します。
  • 以下のコードを LocalSettings.php ファイルの末尾に追加します:
    wfLoadExtension( 'TemplateStyles' );
    wfLoadExtension( 'TemplateStylesExtender' );
    
  • 必要に応じて設定します。
  • Yes 完了 – ウィキの「Special:Version」に移動して、拡張機能が正しくインストールされたことを確認します。

設定

キー 説明 既定値
$wgTemplateStylesExtenderEnablePrefersColorScheme Flag to enable @media (prefers-color-scheme: dark/light) media queries false true
$wgTemplateStylesExtenderEnableCssVars Flag to enable CSS vars false true
$wgTemplateStylesExtenderEnableUnscopingSupport Flag to enable unscoping of CSS by users with editinterface permissions true false

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.

関連項目