Extension:CharInsert

From mediawiki.org
Jump to navigation Jump to search
This page is a translated version of the page Extension:CharInsert and the translation is 84% complete.
Other languages:
Deutsch • ‎English • ‎Türkçe • ‎русский • ‎العربية • ‎中文 • ‎日本語
MediaWiki 拡張機能マニュアル
OOjs UI icon advanced.svg
CharInsert
リリースの状態: 安定
実装 タグ , ページの操作 , 自分のウィキ
説明 JavaScript の文字挿入ボックスを作成できるようにする。
作者 Brion Vibber (Brion VIBBERトーク)
最新バージョン continuous updates
互換性ポリシー リリースブランチ
MediaWiki 1.25+
PHP 5.4+
ライセンス GNU 一般公衆利用許諾書 2.0 以降
ダウンロード
<charinsert>
translatewiki.net で翻訳を利用できる場合は、CharInsert 拡張機能の翻訳にご協力ください

使用状況とバージョン マトリクスを確認してください。

問題点 未解決のタスク · バグを報告

CharInsert 拡張機能は JavaScript リンクの作成を有効にする拡張機能です。クリックされたときに、あらかじめ定義されたテキストがテキストボックスに挿入されます。

These links are usually used in MediaWiki:Edittools (example on this wiki) system message.

構文

<charinsert> タグを使用し、挿入できるようにしたい文字またはタグの空白区切りのリストを指定します。

場所を定義するためにタグ内部で + 記号を使用できます:

  • 選択したテキストを挿入する、または
  • テキストが選択されていない場合はカーソルを設置する。

You have to enclose templates and spaces inside <nowiki>:

<charinsert><nowiki>== + ==</nowiki> <nowiki>{{stub}}</nowiki></charinsert>

使用法とサンプル出力

Individual characters

Individual characters are just listed between the "charinsert" tags.

<charinsert>Á á Ć ć É é Í í Ĺ ĺ Ń ń Ó ó Ŕ ŕ Ś ś Ú ú Ý ý Ź ź</charinsert>

results in

Á á Ć ć É é Í í Ĺ ĺ Ń ń Ó ó Ŕ ŕ Ś ś Ú ú Ý ý Ź ź

入力や編集のフィールドが存在しないため、リンクをクリックしても効果がないことにご注意ください。

Combined characters

Combined characters are listed between the "charinsert" tags and connected by the "+" sign.

<charinsert>“+” ‘+’ «+» ‹+› „+“ ‚+‘ [[+]] {{+}}</charinsert>

results in

“” ‘’ «» ‹› „“ ‚‘ [[]] {{}}

Clicking the links will have no effect since there is no input or edit field.

注記

  • Generated JavaScript links also work in other areas around edit window, e.g. in MediaWiki:Copyrightwarning or MediaWiki:Newarticletext, on the page preloaded with Inputbox, and even from the text preview.
  • They can also be used in MediaWiki:Uploadtext to insert image description templates.
  • Unlike toolbar buttons on top, this extension doesn't provide a way to specify inserted "sample text".
  • Use &#10; to add new lines (\n).
  • Enclose white spaces in nowiki tags when needed.
  • Add <charinsert></charinsert> tags into MediaWiki:Edittools.

インストール

Due to bug T88922 the tool bar provided by CharInsert does not work on special page "Upload" when used on MediaWiki 1.27.x. Use the version provided for MediaWiki 1.28+ but note that some Gadgets may not work as expected without further update.
  • ダウンロードして、ファイルを extensions/ フォルダー内の CharInsert という名前のディレクトリ内に配置します。
  • 以下のコードを LocalSettings.php の末尾に追加します:
    wfLoadExtension( 'CharInsert' );
    
  • If you use the gadget Edittools, update its code to the latest version (≥ May 27, 2016)
  • Yes 完了 – ウィキの「Special:Version」に移動して、拡張機能が正しくインストールされたことを確認します。

MediaWiki 1.24 以前を稼働させている利用者へ:

上記の手順では、wfLoadExtension() を使用してこの拡張機能をインストールする新しい方法を記載しています。 この拡張機能をこれらの過去のバージョン (MediaWiki 1.24 以前) にインストールする必要がある場合は、wfLoadExtension( 'CharInsert' ); の代わりに以下を使用する必要があります:

require_once "$IP/extensions/CharInsert/CharInsert.php";

高度なインストール

重要: You must have Extension:Gadgets for this to work.

スタイル

Charinsert-sample-edittools-box.png

To give the charinsert lists additional styling, wrap the contents of your Edittools between <div class="mw-charinsert-buttons"> and </div> and add styling for them to your MediaWiki:Common.css. This site (www.mediawiki.org) does that to make the links appear like buttons (as shown in the screenshot to the side). The below stylesheet was used for that, copy it to your MediaWiki:Common.css to apply the same styling.

 
/**
 * Styling for links generated by [[MediaWiki:Edittools]]
 * @source https://www.mediawiki.org/wiki/Extension:CharInsert#Styling
 * @updated 2020-03-17
 */
.mw-charinsert-buttons {
	border: 1px solid #aaa;
	margin-top: 10px;
	padding: 1px;
	font-size: 1.1em;
	text-align: center;
}
.mw-charinsert-buttons a {
	background-color: #cde !important;
	color: #000;
	border: thin #069 outset;
	padding: 0 1px 1px;
	font-weight: bold;
	font-size: .9em;
	text-decoration: none;
}
.mw-charinsert-buttons a:hover,
.mw-charinsert-buttons a:active {
	background-color: #bcd;
	border-style: inset;
}
.client-js .mw-edittools-section {
	display: inline;
}
.client-js .mw-edittools-section input[type="button"] {
	font-size: .9em;
	margin-left: 1px;
	padding-left: 1px;
	padding-right: 1px;
}

Alternatively, you can choose a style closer to the Wikimedia Design Style Guide and the WikimediaUI theme:

 
/**
 * Styling for links generated by [[MediaWiki:Edittools]] in WikimediaUI inspired theme.
 * @source https://www.mediawiki.org/wiki/Extension:CharInsert#Styling
 * @updated 2020-03-17
 */
.mw-charinsert-buttons {
	margin-top: 8px;
	border: 1px solid #c8ccd1;
	padding: 2px 4px 4px;
	font-size: 1.1em;
	text-align: center;
}
.mw-charinsert-buttons a {
	background-color: #f8f9fa !important;
	color: #202122;
	border: thin #36c outset;
	padding: 0 1px 2px;
	font-size: 0.9em;
	font-weight: bold;
	text-decoration: none;
}
.mw-charinsert-buttons a:hover {
	background-color: #fff;
    color: #404244;
}
.mw-charinsert-buttons a:active {
	background-color: #c8ccd1;
	border-style: inset;
}
.client-js .mw-edittools-section {
	display: inline;
}
.client-js .mw-edittools-section input[type="button"] {
	background-color: #f8f9fa;
	color: #202122;
	margin-left: 1px;
    border-radius: 2px;
	padding: 1px 6px;
	font-size: .9em;
    /* Apply pointer cursor to all interactive elements. */
    cursor: pointer;
}
.client-js .mw-edittools-section input[type="button"]:hover {
	background-color: #fff;
    color: #404244;
}
.client-js .mw-edittools-section input[type="button"]:active {
	background-color: #c8ccd1;
    color: #000;
}

スクリプト

If you have many CharInsert links, one could use JavaScript to put them in separate groups and allow dynamic switching with a dropdown menu. For example to separate diacritical characters from wikisyntax etc. Several sites (such as mediawiki.org, de.wikipedia.org and en.wikipedia.org) have done this. They all implemented it in different ways though. Documented below is the way it is done on mediawiki.org:

1. Wrap all the charinsert tags on MediaWiki:Edittools into a <div> container and give it a descriptive, unique, ID (for example "mw-edittools-charinsert"):

<div id="mw-edittools-charinsert" class="mw-charinsert-buttons" title="Click on the wanted special character.">
...
</div>
2. Wrap each individual block of charinserts into p tags like this:
<p class="mw-edittools-section" data-section-title="Wiki-Syntax" style="display: none;">
...
</p>
Note:
  • Don't change the word 'mw-edittools-section'
  • The text behind "data-section-title=" will identify this group in the dropdown menu.
  • Make sure there is one group without the 'style="display: none;"' directive: That will be the default choice in the dropdown menu. On this site, it is called 'Standard' while the other groups are named by the language for which the characters are significant.
3. Copy the contents of MediaWiki:Gadget-Edittools.js to an equally named page on your own wiki
4. Add the following code to your MediaWiki:Gadgets-definition:
* Edittools[ResourceLoader|default]|Edittools.js

English Wikipedia CharInsert menu

For implementing CharInsert menu like the one used on the English Wikipedia, either export gadgets: Charinsert-core, Charinsert-styles, and Charinsert and then import them on your own wiki through Special:Import or if you want to do it manually, copy the following four interface pages to your wiki:

* charinsert[ResourceLoader|default|peers=charinsert-styles]|charinsert.js
* charinsert-core[ResourceLoader|hidden|dependencies=jquery.textSelection,user,mediawiki.storage]|charinsert-core.js
* charinsert-styles[ResourceLoader|hidden|type=styles]|charinsert-styles.css
  • MediaWiki:Edittools (Wikipedia) - Only for users with JavaScript turned off or unsupported (which disables the WikiEditor extension too), therefore not really necessary or useful either. It only shows symbols/characters as simple text below the editor window, which can then be copy-pasted and thus be of some help to editors. Apparently, it does not get activated in English Wikipedia for disabled JavaScript.

Note: This particular English Wikipedia character set also contains templates, which will need to be defined separately, if they are to be used on your Wiki.

English Wikipedia Solution checked on: November 6, 2018