- In other languages
Note: After saving, you have to bypass your browser's cache to see the changes.
Google Chrome, Firefox, Microsoft Edge, and Safari: Hold down the ⇧ Shift key and click the Reload toolbar button.
For details and instructions about other browsers, see Wikipedia:Bypass your cache.
// <nowiki>
;(function($, mw) {
'use strict';
if (!(
mw.user.options.get( 'showtoolbar' ) &&
//!mw.user.options.get( 'usebetatoolbar' ) &&
['edit', 'submit'].indexOf(mw.config.get('wgAction')) > -1
)) return;
const buttons = [
[
'//upload.wikimedia.org/wikipedia/commons/c/c9/Button_strike.png',
'Strike',
'<s>',
'</s>',
'Strike-through text'
],
[
'//upload.wikimedia.org/wikipedia/commons/3/34/Button_hide_comment.png',
'Insert hidden Comment',
'<!-- ',
' -->',
'Comment'
],
[
'//upload.wikimedia.org/wikipedia/commons/f/fd/Button_blockquote.png',
'Insert block of quoted text',
'<blockquote>\n',
'\n</blockquote>',
'Block quote'
]
];
function init() {
const $toolbar = $( '.section-advanced > .group-insert' );
const $currentFocused = $('#wpTextbox1');
buttons.forEach(function(button) {
const $button = $( '<img>' ).attr( {
src: button[0],
alt: button[1],
title: button[1],
'class': 'mw-toolbar-editbutton'
});
$button.on('click', function() {
$currentFocused.textSelection(
'encapsulateSelection', {
pre: button[2],
peri: button[4],
post: button[3]
}
);
});
$toolbar.append($button);
//mw.toolbar.addButton.apply( null, button );
});
}
mw.loader.using( 'ext.wikiEditor' ).then(init);
})(window.jQuery, window.mediaWiki);
// </nowiki>