Extension:CodeMirror/5/ja

This page is a translated version of the page Extension:CodeMirror/5 and the translation is 72% complete.
This page documents CodeMirror 5, the older version of CodeMirror. It is due to be removed by MediaWiki version 1.44 (release timeline ). For the documentation about the current version, see Extension:CodeMirror .
CodeEditor と混同しないでください。
MediaWiki 拡張機能マニュアル
CodeMirror/5
リリースの状態: 安定
実装 ユーザー インターフェイス
説明 ウィキテキスト エディターに構文強調を提供する
作者 Pavel Astakhov (pastakhovトーク)
最新バージョン 5.0.0
互換性の方針 MediaWiki とともにリリースされるスナップショット。 master には後方互換性がありません。
データベースの変更 いいえ
ライセンス GNU 一般公衆利用許諾書 2.0 以降
ダウンロード
  • $wgCodeMirrorV6
  • $wgCodeMirrorConflictingGadgets
  • $wgCodeMirrorTitleCompletion
  • $wgCodeMirrorDefaultPreferences
  • $wgCodeMirrorLineNumberingNamespaces
四半期ごとのダウンロード数 304 (Ranked 11th)
使用中の公開ウィキ 6,549 (Ranked 62nd)
translatewiki.net で翻訳を利用できる場合は、CodeMirror/5 拡張機能の翻訳にご協力ください
Vagrant role codemirror
問題点 未解決のタスク · バグを報告

CodeMirror 拡張機能は、MediaWiki のウィキテキスト エディターに構文強調を追加します。 編集ツールバーにこのようなアイコンのボタンが追加され、構文強調表示のオンとオフを切り替えることができます。 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)


機能

ブラケットマッチング

この機能は、カーソルが任意の括弧の間にある場合、最も内側の括弧のペアを強調表示し、カーソルが括弧の直下にある場合、対応する括弧を強調表示するものです。 ブラケットマッチングは、シンタックスハイライトがオンの場合、両方のエディターで、これらのエディターを使用しているすべてのネームスペースで有効になります。

行番号表示

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' );
    
  • 必要に応じて設定します。
  •   完了 – ウィキの「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. どこでも無効化できるよう[]
$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. See Extension:CodeMirror/6#Integration for documentation on CodeMirror 6.

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. (TT170001)
  • 自動補完 (TT95100)
  • コードの折りたたみ (TT166098)
  • ギャラリータグ内のハイライト表示(<gallery> foo | bar </gallery>)

関連項目