User:Speravir/config-WikiEditor.js
Note: After publishing, you may have to bypass your browser's cache to see the changes.
- Firefox / Safari: Hold Shift while clicking Reload, or press either Ctrl-F5 or Ctrl-R (⌘-R on a Mac)
- Google Chrome: Press Ctrl-Shift-R (⌘-Shift-R on a Mac)
- Edge: Hold Ctrl while clicking Refresh, or press Ctrl-F5.
// <nowiki>
/* [[:mw:Extension:WikiEditor]] / [[:mw:Extension:WikiEditor/Toolbar customization]] and
* https://github.com/wikimedia/mediawiki-extensions-WikiEditor/blob/master/modules/jquery.wikiEditor.toolbar.config.js
*/
var userSig = '— ~~~ <span style="font-size:80%;color:#555;">– ~~~~~</span>', // signature
customizeToolbar = function () {
$( '#wpTextbox1' ).wikiEditor( 'removeFromToolbar', {
section: 'main',
group: 'insert',
tool: 'signature' // Remove default signature button
});
$( '#wpTextbox1' ).wikiEditor( 'removeFromToolbar', {
section: 'advanced',
group: 'size',
tool: 'big' // inserts obsolete HTML element "<big>"
});
$( '#wpTextbox1' ).wikiEditor( 'removeFromToolbar', {
section: 'advanced',
group: 'size',
tool: 'small' // just for consistency
});
// End of removeFromToolbar
$( '#wpTextbox1' ).wikiEditor( 'addToToolbar', {
section: 'main',
group: 'insert',
tools: {
'customsig': { // Custom signature
label: 'Signatur & Datum',
type: 'button',
icon: 'https://upload.wikimedia.org/wikipedia/commons/2/2d/Insert-signature2.svg',
// https://commons.wikimedia.org/wiki/File:Insert-signature2.svg
action: {
type: 'encapsulate',
options: {
pre: userSig
}
}
}
}
}); // addToToolbar: customsig
$( '#wpTextbox1' ).wikiEditor( 'addToToolbar', {
section: 'advanced',
group: 'format',
tools: {
'strikethrough': {
label: 'Durchgestrichen',
type: 'button',
icon: 'https://upload.wikimedia.org/wikipedia/commons/f/f9/Toolbaricon_regular_S_stroke.png',
// https://commons.wikimedia.org/wiki/File:Toolbaricon_regular_S_stroke.png
action: {
type: 'encapsulate',
options: {
pre: '<s>',
post: '</s>'
}
}
},
'comment': {
label: 'Kommentar',
type: 'button',
icon: 'https://upload.wikimedia.org/wikipedia/commons/9/93/Toolbaricon_decomment.png',
// https://commons.wikimedia.org/wiki/File:Toolbaricon_decomment.png
action: {
type: 'encapsulate',
options: {
pre: '<!-- ',
post: ' -->'
}
}
} // 'comment'
}
}); // addToToolbar: strikethrough/comment
$( '#wpTextbox1' ).wikiEditor( 'addToToolbar', {
section: 'advanced',
group: 'size',
tools: {
'bigger': {
label: 'Größer',
type: 'button',
icon: 'https://upload.wikimedia.org/wikipedia/commons/0/0d/OOjs_UI_icon_bigger-ltr.svg',
// https://commons.wikimedia.org/wiki/File:OOjs_UI_icon_bigger-ltr.svg
action: {
type: 'encapsulate',
options: {
pre: '<span style="font-size:larger;">', // clean with CSS
post: '</span>'
}
}
},
'smaller': {
label: 'Kleiner',
type: 'button',
icon: 'https://upload.wikimedia.org/wikipedia/commons/d/dc/OOjs_UI_icon_smaller-ltr.svg',
// https://commons.wikimedia.org/wiki/File:OOjs_UI_icon_smaller-ltr.svg
action: {
type: 'encapsulate',
options: {
pre: '<small>',
post: '</small>'
}
}
}
}
}); // addToToolbar: bigger/smaller
}; // var customizeToolbar
/* Check if view is in edit mode and that the required modules are available. Then, customize the toolbar … */
if ( $.inArray( mw.config.get( 'wgAction' ), [ 'edit', 'submit' ] ) !== -1 ) {
mw.loader.using( 'user.options' ).then( function () {
// This can be the string "0" if the user disabled the preference ([[phab:T54542#555387]])
if ( mw.user.options.get( 'usebetatoolbar' ) == 1 ) {
$.when(
mw.loader.using( 'ext.wikiEditor' ), $.ready
).then( customizeToolbar );
}
} );
} // end of edit check
// </nowiki>