Extension:CodeMirror
![]() リリースの状態: 安定 |
|
---|---|
![]() |
|
実装 | ユーザー インターフェイス |
説明 | ウィキテキスト エディターに構文強調を提供する |
作者 | Pavel Astakhov (pastakhovトーク) |
最新バージョン | 4.0.0 |
互換性の方針 | MediaWikiとともにリリースされるスナップショット。 master には後方互換性がありません。 |
MediaWiki | 1.32+ |
PHP | 5.3+ |
データベースの変更 | いいえ |
ライセンス | GNU 一般公衆利用許諾書 2.0 以降 |
ダウンロード | |
|
|
Quarterly downloads | 348 (Ranked 33rd) |
Public wikis using | 6,549 (Ranked 62nd) |
translatewiki.net で翻訳を利用できる場合は、CodeMirror 拡張機能の翻訳にご協力ください | |
Vagrant role | codemirror |
問題点 | 未解決のタスク · バグを報告 |
CodeMirror 拡張機能は、MediaWiki のウィキテキスト エディターに構文強調を追加します。
It adds a button with the icon to the editing toolbar that allows for switching syntax highlighting on and off.
2010 WikiEditor toolbar と VisualEditor toolbar をサポートしています。
デフォルトの設定ではこの拡張機能は無効化されています。 有効化されると、標準のテキストエリアを CodeMirror library が提供するエディタで置換します。 無効化されると、その置換を取り消します。
この拡張機能で使用される色は、より高いコントラスト、アクセシビリティ、読みやすさを提供するために最適化されています。 The colors provide better access for people with limited vision as well as for users working in bright daylight conditions. (more information)
機能
ブラケットマッチング
この機能は、カーソルが任意の括弧の間にある場合、最も内側の括弧のペアを強調表示し、カーソルが括弧の直下にある場合、対応する括弧を強調表示するものです。 Bracket matching is active in both editors when syntax highlighting is turned on in any namespace using these editors.
-
ブラケットマッチング
行番号表示
wikitext編集モードでは、行番号はどちらのエディタでも自動的に表示されます。
-
2010年版wikitextエディタでの行番号の付け方
-
2017年版wikitextエディタでの行番号の付け方
Colorblind mode
For users who have difficulty distinguishing between colors, CodeMirror offers a colorblind-friendly mode. This feature can be activated on wikis with CodeMirror enabled by navigating to the Special:Preferences page.

With the colorblind-friendly scheme active, the colors of the following page elements change:
Headings, symbols, signatures, section names, magic words | #E4A400 |
Templates | #9C3A00 |
HTML tags, references, mathematical expressions | #56B4E9 |
Variables | #009E73 |
In addition, background highlights and colors are removed from all text and objects. Bolding and underlining behavior remains unaffected.
ブラウザの対応状況
MediaWikiがサポートするブラウザは全てサポートしています。
インストール方法
- 先にWikiEditor 拡張機能かVisualEditor 拡張機能のどちらかをインストールしておく必要があります。
- ダウンロードして、ファイルを
extensions/
フォルダー内のCodeMirror
という名前のディレクトリ内に配置します。 - 以下のコードを
LocalSettings.php
の末尾に追加します:wfLoadExtension( 'CodeMirror' );
- 必要に応じて設定します。
完了 – ウィキの「Special:Version」に移動して、拡張機能が正しくインストールされたことを確認します。
Vagrant installation:
- Vagrant を使用している場合は、
vagrant roles enable codemirror --provision
でインストールしてください。
設定
配色と書式のカスタマイズ方法は Meta help page を参考にしてください。 ウィキテキストの構文強調には、独自のスタイルを使用できます。 古いスタイルはこちらで入手可能です。 common.css に自分のスタイルを配置する必要があります。
以下のコードを LocalSettings.php の末尾に追加します。
# CodeMirrorの使用をデフォルトで有効にし、ユーザーが無効にできるようにした。
$wgDefaultUserOptions['usecodemirror'] = 1;
To enable additional features:
# Restrict line numbering to specific namespaces.
# Defaults to null, which enables it for all namespaces.
# Set to [] to disable everywhere.
$wgCodeMirrorLineNumberingNamespaces = [ NS_TEMPLATE ];
拡張機能の統合
MediaWiki拡張機能が新しいタグを追加し、CodeMirrorがその中のコンテンツを適切にハイライトすることを確認したい場合、拡張機能にCodeMirrorサポートを追加することができます。ここに2つの例があります。Cite拡張機能とPhpTags拡張機能です。
JavaScriptの統合
この拡張機能では、以下のフロントエンドフックが使用されています:
フック | パラメーター | |
---|---|---|
型 | 説明 | |
ext.CodeMirror.switch
|
真偽値 | CodeMirrorエディタが表示されるようになったかどうか |
jQuery オブジェクト | 現在の "エディタ "であり、通常の<textarea /> または.CodeMirror の要素である。
|
If you need to interact with the contents of a CodeMirror instance, use jQuery.plugin.textSelection.
実装予定
- Unfortunately, right-to-left content is not supported. (タスク T170001)
- 定義リストのハイライト表示( ;foo :bar ) (タスク T170042)
- 自動補完 (タスク T95100)
- コードの折りたたみ (タスク T166098)
- ギャラリータグ内のハイライト表示(<gallery> foo | bar </gallery>)
関連項目
- 不足している機能やバグについて: MediaWiki-extensions-CodeMirror
- User:Remember the dot/Syntax highlighter
- Extension:VisualEditor
- Extension:WikiEditor
- Extension:CodeEditor
- Community Tech/ウィキテキスト エディターの構文強調機能 - 色のカスタマイズに関する情報を含みます。
- c:Category:MediaWiki extension CodeMirror
![]() | この拡張機能は 1 つ以上のウィキメディアのプロジェクトで使用されています。 これはおそらく、この拡張機能が安定していて高いトラフィックのウェブサイトでも十分に動作することを意味します。 この拡張機能がインストールされている場所を確認するには、ウィキメディアの設定ファイル CommonSettings.php および InitialiseSettings.php 内で、この拡張機能の名前を探してください。 特定のウィキにインストールされている拡張機能の完全な一覧は、そのウィキの Special:Version ページにあります。 |
![]() | この拡張機能は以下のパッケージ/ウィキファームに含まれています: This is not an authoritative list. Some wiki farms/hosts may contain this extension even if they are not listed here. Always check with your wiki farms/hosts or bundle to confirm. |
- Stable extensions/ja
- User interface extensions/ja
- GPL licensed extensions/ja
- Extensions in Wikimedia version control/ja
- BeforePageDisplay extensions/ja
- GetPreferences extensions/ja
- ResourceLoaderGetConfigVars extensions/ja
- All extensions/ja
- Extensions used on Wikimedia/ja
- Extensions included in Canasta/ja
- Extensions included in Fandom/ja
- Extensions included in Miraheze/ja
- Extensions included in MyWikis/ja
- Extensions included in ProWiki/ja
- Extensions included in wiki.gg/ja
- Extensions included in WikiForge/ja
- Extensions included in Telepedia/ja
- Syntax highlighting extensions/ja