Autopatrolled, Editors
8,718
edits
m (→Customization) |
m |
||
(8 intermediate revisions by the same user not shown) | |||
Changes you make to your [[Special:MyPage/common.js|common.js]] page only take effect after you save the page, so to check that the changes you have made worked you should save your [[Special:MyPage/common.js|common.js]] page and try to edit some other wiki page. If you see the default toolbar when you edit a page that means that your edits "broke" your toolbar. Consult the [[#General Guidelines|#general guidelines]] for help debugging your code.
If the changes you made are not working, or if you would like assistance creating your own toolbar you can DM <code>kingofherdaz</code> on Discord for help.
== Basic ==
group: 'insert',
tools: {
label: 'Art infobox',
type: 'button',
group: 'insert',
tools: {
label: 'Artist Attribution',
type: 'button',
group: 'insert',
tools: {
label: 'Artist Page',
type: 'button',
group: 'insert',
tools: {
label: 'Break tag',
type: 'button',
group: 'insert',
tools: {
label: 'Category',
type: 'button',
group: 'insert',
tools: {
label: 'Code',
type: 'button',
group: 'insert',
tools: {
label: 'Columns',
type: 'button',
group: 'insert',
tools: {
label: 'Hidden text',
type: 'button',
group: 'insert',
tools: {
label: 'Image template',
type: 'button',
group: 'insert',
tools: {
label: 'Link',
type: 'button',
group: 'insert',
tools: {
label: 'Wikipedia',
type: 'button',
|
<pre>
//Add new references dropdown to the "advanced" section
$( '#wpTextbox1' ).wikiEditor( 'addToToolbar', {
} );
</pre>
|}
|
<pre>
//Add new build-a-box dropdown to the "advanced" section
$( '#wpTextbox1' ).wikiEditor( 'addToToolbar', {
} );
</pre>
|}
|
<pre>
//Add new infobox endings dropdown to the "advanced" section
$( '#wpTextbox1' ).wikiEditor( 'addToToolbar', {
}▼
post: '\n' + '|universe=[[Cytoverse]]' + '\n' + '|books=[[Skyward (series)]]' + '\n' + '}}'▼
action:
type: 'encapsulate',
▲ }
pre: '\n' + '|world=',
}▼
} );▼
}▼
}
}
}
}
}
▲ }
}
▲ } );
</pre>
|}
|
<pre>
//Add new page ends dropdown to the "advanced" section
$( '#wpTextbox1' ).wikiEditor( 'addToToolbar', {
label: '{' + '{Firstborn}}',
action:
type: 'encapsulate',
▲ }
options: {
}▼
pre: '\n' + '{' + '{Firstborn}}'
} );▼
}
} },
'whitesand': {
label: '{' + '{White Sand}}',
action: {
type: 'encapsulate',
options: {
pre: '\n' + '{' + '{White Sand}}'
}
}
}
}
}
}
▲ }
}
▲ } );
</pre>
|}
//These next two reference templates are very long so they are done differently
{
options: {
pre: '{' + '{url ref|url=',
}
},
},
{
options: {
pre: '{' + '{17s ref|topic/news/post',
* If you are having trouble, look at the example elements presented above and use them as a guide. Or simply copy one of the sample elements and modify it following the steps presented in this guide.
* To add a one line comment put <code>//</code> at the beginning of a line followed by the text of the comment. Whatever you write after a <code>//</code> on that line will not affect your code.
* For multi line comments put your comments between <code>/*</code> and <code>*/</code>.
* Code for your toolbar must have the exact correct number of curly brackets (<code>{</code>), square brackets (<code>[</code>), apostrophes (<code>'</code>), parentheses (<code>(</code>), and commas (<code>,</code>) to work. If your toolbar breaks after you changed something check to see if you missed or added an extra one of these.
* While not strictly necessary, it is a good idea to split code in your toolbar over multiple lines and with whitespace differentiating each "level" of the toolbar in a manner similar to how it is done in the examples on this page. This will help you keep track of the different parts of your code and will help you keep track of the number of open and closed curly brackets in your code.
==== Strings ====
A string is a piece of text within the toolbar that is encased between two apostrophes {<code>'</code>). Strings are used in labels and actions. They should follow the following guidelines
* Inserting <code>' + '</code> between two parts of a string can have effects on your [[Special:MyPage/common.js|common.js]] page (as will be discussed below), but will not appear on a page when the action is called, or be included in the label(s) on the actual toolbar. For example, both <code><nowiki>
* When writing out templates, whether for a label or an action, you must insert <code>' + '</code> between the first two curly brackets. For example, instead of writing <code><nowiki>{{Stormlight}}</nowiki></code> you should write <code><nowiki>{' + '{Stormlight}}</nowiki></code>. This prevents the template from applying categories to your [[Special:MyPage/common.js|common.js]] page and also prevents it from being listed on the relevant template's list of pages that use it.
* For the same reason you must also do this when writing category tags. For example, instead of writing <code><nowiki>[[Category: Stormlight]]</nowiki></code> you should write <code><nowiki>[' + '[Category: Stormlight]]</nowiki></code>.
* When writing code for substitutions this is even more important, since if you do not do it then the substitution will be performed when you save your [[Special:MyPage/common.js|common.js]] page. For example, instead of writing <code><nowiki>{{SUBST:PAGENAME}}</nowiki></code> you should write <code><nowiki>{' + '{SUBST:PAGENAME}}</nowiki></code>.
====
Many things in the toolbar must be given internal names. Internal names help the program differentiate between different parts of the toolbar. What you use as an internal name will not affect the toolbar so you can use any string of characters.
Internal names must not contain any spaces. If you want an internal name to be more than one word you can use a dash (<code>-</code>) instead of a space. You should not reuse internal names within your entire toolbar. If you use the same internal name
A label is the name of an element that will be displayed on the toolbar. For dropdowns these are displayed in the dropdown itself, while with buttons the label is shown when you hover your cursor over the icon for the button. Unlike internal names
{{anchor|action}}{{anchor|actions}}
==== Actions ====
While there are other types of actions that you can do, in this guide we focus on the <code>encapsulate</code> action as it is the easiest to understand and use. This action pastes one
The code for this action is as follows, and this format is the same for dropdowns, booklets and buttons.
<code>XXXX</code> is replaced by the string that goes before the highlighted text/cursor, and <code>YYYY</code> is replaced by the string that goes after the highlighted text/cursor.
* To have an action include a line break insert <code>\n</code> into the
* To have an action include an apostrophe (<code>'</code>) within the string that it inserts, place <code>\'</code> into your code at the place you want the apostrophe to go. If you do not include the backslash (<code>\</code>) and type additional apostrophes in your code it will cause the toolbar to break. You must put an additional backslash with each additional apostrophe you add to a string.
=== Creating Your Own Buttons ===
group: 'BBBB',
tools: {
label: 'DDDD',
type: 'button',
type: 'select',
list: {
label: 'XXXX',
action: {
<pre>
},
label: 'XXXX',
action: {
<pre>
$( '#wpTextbox1' ).wikiEditor( 'addToToolbar', {
'AAAA': {
}
}
<pre>
$( '#wpTextbox1' ).wikiEditor( 'addToToolbar', {
'groups': {
'DDDD': {
}
}
Here we will tell you how to create booklets that contain pages of characters. For other things you can do with booklets see [https://www.mediawiki.org/wiki/Extension:WikiEditor/Toolbar_customization Mediawiki's guide].
A key difference between dropdowns and booklets is that while with dropdowns every option must be an action, with booklets that is not the case. Booklets contain <code>pages</code> of <code>characters</code> that when clicked paste text into the page. Characters can be either simple
To create a new booklet section add the following code to your [[Special:MyPage/common.js|common.js]] page between the two [[#Basic]] sections and change the following things:
//Optional description
$( '#wpTextbox1' ).wikiEditor( 'addToToolbar', {
'AAAA': {
</pre>
<pre>
//Optional description
</pre>
<pre>
{
}
},
},
</pre>
//Remove the default <ref> button
$( '#wpTextbox1' ).wikiEditor( 'removeFromToolbar', {
});</pre>
|}
//remove the bulleted list button
$( '#wpTextbox1' ).wikiEditor( 'removeFromToolbar', {
});</pre>
|}
//remove the numbered list button
$( '#wpTextbox1' ).wikiEditor( 'removeFromToolbar', {
});</pre>
|}
//remove the default <br> button (to replace it with a <br/> button which is preferred on the Coppermind)
$( '#wpTextbox1' ).wikiEditor( 'removeFromToolbar', {
});</pre>
|}
//remove table button
$( '#wpTextbox1' ).wikiEditor( 'removeFromToolbar', {
});</pre>
|}
//remove File button
$( '#wpTextbox1' ).wikiEditor( 'removeFromToolbar', {
});</pre>
|}
//remove original link button
$( '#wpTextbox1' ).wikiEditor( 'removeFromToolbar', {
});</pre>
|}
<pre>
$( '#wpTextbox1' ).wikiEditor( 'removeFromToolbar', {
});</pre>
|}
|