Jump to content

Extension:TemplateStylesExtender

From mediawiki.org
This page is a translated version of the page Extension:TemplateStylesExtender and the translation is 39% complete.
MediaWiki 拡張機能マニュアル
TemplateStylesExtender
リリースの状態: 安定
実装 パーサー拡張機能
説明 Extends Extension:TemplateStyles with new selectors
作者 Octfxトーク
最新バージョン 2.2.0
互換性の方針 master が後方互換性を維持しています。
MediaWiki >= 1.43.0
PHP >=8.0
データベースの変更 いいえ
Composer octfx/template-styles-extender
  • $wgTemplateStylesExtenderExtendCustomPropertiesValues
  • $wgTemplateStylesExtenderEnableUnscopingSupport
  • $wgTemplateStylesExtenderCustomPropertiesDeclaration
  • $wgTemplateStylesExtenderUnscopingPermission
ライセンス GNU 一般公衆利用許諾書 2.0 以降
ダウンロード

The TemplateStylesExtender extension extends Extension:TemplateStyles with new selectors and matchers. 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
モジュール Changes 上流のタスク
Basic User Interface Module Level 4 プロパティを追加: pointer-events T342271
Box Sizing Module Level 4 Backported for css-sanitizer 5.5.0 T375344
Cascading and Inheritance Level 5 値を追加: revert-layer -
Color Module Level 4 Added: Alpha HEX notation T265675
Color Module Level 5 追加: Relative color, color() -
Containment Module Level 3 プロパティを追加: contain, content-visibility -
Filter Effects Module Level 2 プロパティを追加: backdrop-filter -
Fonts Module Level 4 プロパティを追加: font-optical-sizing, font-variation-settings, ascent-override, descent-override, font-display, line-gap-override -
Fonts Module Level 5 プロパティを追加: size-adjust -
Masking Module Level 1 プロパティを追加: -webkit-mask-image -
Ruby Annotation Layout Module Level 1 プロパティを追加: ruby-align, ruby-position T277755
Scroll Snap Module Level 1 プロパティを追加: scroll-margin, scroll-padding, scroll-snap-align, scroll-snap-stop, scroll-snap-type T271598
Values and Units Module Level 4 関数を追加: clamp() T394619

インストール

  • ダウンロードして、ファイルをextensions/フォルダー内のTemplateStylesExtenderという名前のディレクトリ内に配置します。
  • 以下のコードを LocalSettings.php ファイルの末尾に追加します:
    wfLoadExtension( 'TemplateStyles' );
    wfLoadExtension( 'TemplateStylesExtender' );
    
  • 必要に応じて設定します。
  • Yes 完了 – ウィキの「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

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.

関連項目