Extension:CharInsert - MediaWiki (original) (raw)

Languages:

MediaWiki extensions manual

CharInsert Release status: stable
Implementation Tag , Page action , MyWiki
Description Allows to create JavaScript character insert boxes.
Author(s) Brion Vibber (Brooke Vibbertalk)
Latest version continuous updates
Compatibility policy Snapshots releases along with MediaWiki. Master is not backward compatible.
License GNU General Public License 2.0 or later
Download Download extension Git [?]: Download Git master browse repository (Phabricator · GitHub) commit history repository contributors (GitHub) code review
Tags ‎<charinsert>
Hooks used BeforePageDisplay ParserFirstCallInit
Quarterly downloads 90 (Ranked 62nd)
Public wikis using 9,224 (Ranked 15th)
Translate the CharInsert extension if it is available at translatewiki.net
Issues Open tasks · Report a bug

The CharInsert extension allows the creation of JavaScript links that, when clicked, insert predefined text into a text box.

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

Use ‎<charinsert> tags with a space-separated list of characters or tags for which you wish to allow insertion.

You can use + sign inside a tag to define a place to:

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

== + == {{stub}}

Usage and sample output

[edit]

Individual characters

[edit]

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

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

results in

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

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

Combined characters

[edit]

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

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

results in

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

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

Overriding display text

[edit]

A different display text can be specified in the label attribute (if you use this, you should use separate <charinsert> tags for each character in order to specify different display texts).

A А Α

results in

Latin A Cyrillic А Greek Alpha

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

Advanced Installation

[edit]

**Important:**You must have Extension:Gadgets for this to work.

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.

/**

.mw-charinsert-buttons a { background-color: #cde !important; color: #000; border: thin #069 outset; padding: 0 1px 1px; font-weight: bold; font-size: 0.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: 0.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:

/**

.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: 0.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"):

...

2. Wrap each individual block of charinserts into ‎<p> tags like this:

...

Note Note:

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:

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:

Note 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

This extension is being used on one or more Wikimedia projects. This probably means that the extension is stable and works well enough to be used by such high-traffic websites. Look for this extension's name in Wikimedia's CommonSettings.php and InitialiseSettings.php configuration files to see where it's installed. A full list of the extensions installed on a particular wiki can be seen on the wiki's Special:Version page.
This extension is included in the following wiki farms/hosts and/or packages: Canasta Fandom Miraheze ShoutWiki Telepedia wiki.gg WikiForge This is not an authoritative list. Some wiki farms/hosts and/or packages may contain this extension even if they are not listed here. Always check with your wiki farms/hosts or bundle to confirm.