Jump to content

User:Zackmann08/scripts/EditToolbar.js

From Wikipedia, the free encyclopedia
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.
// Add syntaxhighlight button
mw.hook( 'wikiEditor.toolbarReady' ).add( function ( $textarea ) {
    $textarea.wikiEditor( 'addToToolbar', {
        section: 'main', // Options: 'main', 'advanced'
        group: 'insert', // Options: 'format', 'insert', etc.
        tools: {
            'syntaxhighlight-button': {
                type: 'button',
                label: 'Syntaxhighlight', // Button text
                icon: '//upload.wikimedia.org/wikipedia/commons/c/cd/OOjs_UI_icon_code.svg',
                action: {
					type: 'encapsulate',
					options: {
						pre: '<syntaxhighlight inline lang="wikitext">',
						peri: 'FOO',
						post: '</syntaxhighlight>'
					}
				}
            },
			'longitem-button': {
                type: 'button',
                label: 'Longitem', // Button text
                icon: '//upload.wikimedia.org/wikipedia/commons/3/3c/OOjs_UI_icon_newline-ltr.svg',         
                action: {
					type: 'encapsulate',
					options: {
						pre: '{{longitem|',
						peri: 'FOO',
						post: '}}'
					}
				}
            }
        }
    });
});
if (document.querySelector('#wpTextbox1' )){
	$( '#wpTextbox1' ).wikiEditor( 'removeFromToolbar', {
		'section': 'main',
		'group': 'insert',
		'tool': 'link'
	});
	
	$( '#wpTextbox1' ).wikiEditor( 'removeFromToolbar', {
		'section': 'main',
		'group': 'insert',
		'tool': 'file'
	});
	
	$( '#wpTextbox1' ).wikiEditor( 'removeFromToolbar', {
		'section': 'main',
		'group': 'insert',
		'tool': 'template-wizard'
	});
	
	$( '#wpTextbox1' ).wikiEditor( 'removeFromToolbar', {
		'section': 'main',
		'group': 'insert',
		'tool': 'reference'
	});
	
	$( '#wpTextbox1' ).wikiEditor( 'removeFromToolbar', {
		'section': 'main',
		'group': 'insert',
		'tool': 'reference'
	});
}