User:Speravir/config-WikiEditor.js: Difference between revisions
Content deleted Content added
Undo own revision 24338331 Tag: Undo |
mNo edit summary |
||
(3 intermediate revisions by the same user not shown) | |||
Line 3: | Line 3: | ||
* https://github.com/wikimedia/mediawiki-extensions-WikiEditor/blob/master/modules/jquery.wikiEditor.toolbar.config.js |
* https://github.com/wikimedia/mediawiki-extensions-WikiEditor/blob/master/modules/jquery.wikiEditor.toolbar.config.js |
||
*/ |
*/ |
||
var userSig = '— |
var userSig = '—<span style="white-space:nowrap"> ~~~ – ~~~~~</span>', // signature, note usersignature in "global.js" |
||
customizeToolbar = function () { |
customizeToolbar = function () { |
||
$( '#wpTextbox1' ).wikiEditor( 'removeFromToolbar', { |
$( '#wpTextbox1' ).wikiEditor( 'removeFromToolbar', { |
||
Line 28: | Line 28: | ||
label: 'Signatur & Datum', |
label: 'Signatur & Datum', |
||
type: 'button', |
type: 'button', |
||
icon: 'https://upload.wikimedia.org/wikipedia/commons |
icon: 'https://upload.wikimedia.org/wikipedia/commons/2/2d/Insert-signature2.svg', |
||
// |
// https://commons.wikimedia.org/wiki/File:Insert-signature2.svg |
||
action: { |
action: { |
||
type: 'encapsulate', |
type: 'encapsulate', |
||
Line 47: | Line 47: | ||
type: 'button', |
type: 'button', |
||
icon: 'https://upload.wikimedia.org/wikipedia/commons/f/f9/Toolbaricon_regular_S_stroke.png', |
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: { |
action: { |
||
type: 'encapsulate', |
type: 'encapsulate', |
||
Line 60: | Line 60: | ||
type: 'button', |
type: 'button', |
||
icon: 'https://upload.wikimedia.org/wikipedia/commons/9/93/Toolbaricon_decomment.png', |
icon: 'https://upload.wikimedia.org/wikipedia/commons/9/93/Toolbaricon_decomment.png', |
||
// |
// https://commons.wikimedia.org/wiki/File:Toolbaricon_decomment.png |
||
action: { |
action: { |
||
type: 'encapsulate', |
type: 'encapsulate', |
||
Line 79: | Line 79: | ||
type: 'button', |
type: 'button', |
||
icon: 'https://upload.wikimedia.org/wikipedia/commons/0/0d/OOjs_UI_icon_bigger-ltr.svg', |
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: { |
action: { |
||
type: 'encapsulate', |
type: 'encapsulate', |
||
Line 92: | Line 92: | ||
type: 'button', |
type: 'button', |
||
icon: 'https://upload.wikimedia.org/wikipedia/commons/d/dc/OOjs_UI_icon_smaller-ltr.svg', |
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: { |
action: { |
||
type: 'encapsulate', |
type: 'encapsulate', |
Latest revision as of 23:05, 6 February 2024
// <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="white-space:nowrap"> ~~~ – ~~~~~</span>', // signature, note usersignature in "global.js"
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>