Extension:CharInsert/zh

CharInsert扩展用于创建点击时即可插入指定文字到编辑框中的JavaScript链接.

这些链接通常被用于MediaWiki:Edittools的系统消息中（例如在此维基上）.

語法
在标签中列出你想要提供插入的字符或标签，用空格隔开.

你可以在標籤之間使用+符號去定義：


 * 插入到被選擇的文字上或
 * 如果没有文字被选择，则插入到光标所在处.

模板和含有空格的文字需要使用包住：



使用方法和輸出範例


单独的字符
单独的字符只需在charinsert标签中列出即可.

效果为：



成对的字符
成对的字符“charinsert”标签中列出时，使用“+”号连接.

效果为：



显示字样和插入文字不同
如果想要想让显示字样和插入文字不同，可以在 属性中指定. 如果要使用此功能，则每个字符上都要单独使用一个 标签.

效果为：

注释

 * Generated JavaScript links also work in other areas around edit window, e.g. in MediaWiki:Copyrightwarning or MediaWiki:Newarticletext, on the page preloaded with, 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  to add new lines (\n).
 * Enclose white spaces in  tags when needed.
 * Add  tags into MediaWiki:Edittools.

Advanced Installation
重要： You must have for this to work.

格式化


To give the charinsert lists additional styling, wrap the contents of your Edittools between  and  and add styling for them to your. 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 to apply the same styling.

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

脚本
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 container and give it a descriptive, unique, ID (for example "mw-edittools-charinsert") :
 * 2. Wrap each individual block of charinserts into tags like this:
 * 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 ' ' 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 :
 * * Edittools[ResourceLoader|default]|Edittools.js
 * 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 :
 * * 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:


 * MediaWiki:Gadget-charinsert-core.js (Wikipedia) - Main JavaScript file.
 * MediaWiki:Gadget-charinsert-styles.css (Wikipedia) - Creates surrounding boxes around the symbols/characters giving them the look of buttons.
 * MediaWiki:Gadget-charinsert.js (Wikipedia) - CharInsert loader.
 * MediaWiki:Gadget-charinsert (Wikipedia) - For the text shown in user preferences' gadgets section.

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.
 * In your MediaWiki:Gadgets-definition, add the following definitions:
 * 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.

 English Wikipedia Solution checked on: November 6, 2018