Extension:CodeMirror

From mediawiki.org
This page is a translated version of the page Extension:CodeMirror and the translation is 68% complete.
Not to be confused with CodeEditor .
MediaWiki 拡張機能マニュアル
CodeMirror
リリースの状態: 安定
実装 ユーザー インターフェイス
説明 ウィキテキスト エディターに構文強調を提供する
作者 Pavel Astakhov (pastakhovトーク)
最新バージョン 5.0.0
互換性の方針 MediaWiki とともにリリースされるスナップショット。 master には後方互換性がありません。
MediaWiki 1.32+
PHP 5.3+
データベースの変更 いいえ
ライセンス GNU 一般公衆利用許諾書 2.0 以降
ダウンロード
  • $wgCodeMirrorConflictingGadgets
  • $wgCodeMirrorV6
  • $wgCodeMirrorTemplateFoldingNamespaces
  • $wgCodeMirrorLineNumberingNamespaces
Quarterly downloads 338 (Ranked 16th)
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 toolbarVisualEditor 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編集モードでは、行番号はどちらのエディタでも自動的に表示されます。

この機能は、ほとんどのウィキでテンプレート名前空間に対して、また一部のウィキではすべての名前空間に対して有効になっています (ロードマップ設定を参照)。

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という名前のディレクトリ内に配置します。
    開発者とコード寄稿者は、上記の代わりに以下を使用してGitからインストールします:cd extensions/
    git clone https://gerrit.wikimedia.org/r/mediawiki/extensions/CodeMirror
  • 以下のコードを LocalSettings.php ファイルの末尾に追加します:
    wfLoadExtension( 'CodeMirror' );
    
  • 必要に応じて設定します。
  • Yes 完了 – ウィキの「Special:Version」に移動して、拡張機能が正しくインストールされたことを確認します。


Vagrantでのインストール:

  • Vagrant を使用している場合は、vagrant roles enable codemirror --provisionでインストールしてください。

設定

配色と書式のカスタマイズ方法は Meta help page を参考にしてください。 ウィキテキストの構文強調には、独自のスタイルを使用できます。 古いスタイルはこちらで入手可能です。 common.css に自分のスタイルを配置する必要があります。

以下のコードを LocalSettings.php の末尾に追加します。

# CodeMirrorの使用をデフォルトで有効にし、ユーザーが無効にできるようにした。
$wgDefaultUserOptions['usecodemirror'] = true;

Additional configuration:

$wgCodeMirrorLineNumberingNamespaces
Restrict line numbering to specific namespaces. Defaults to null, which enables it for all namespaces. Set to [] to disable everywhere.
$wgCodeMirrorV6
Temporary feature flag to control the migration to CodeMirror 6 (phab:T259059).
$wgCodeMirrorConflictingGadgets
An array of gadget names that, if enabled, will prevent CodeMirror from loading. Defaults to wikEd.

拡張機能の統合

This functionality is subject to change following the CodeMirror 6 upgrade.

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.

実装予定


関連項目