Difference between revisions of "MediaWiki:Common.js"

From Mechanics
Line 14: Line 14:
label: 'Math',
label: 'Math',
type: 'button',
type: 'button',
icon: '//upload.wikimedia.org/wikipedia/commons/2/2e/Button_math.png',
icon: 'https://latex.codecogs.com/png.image?\dpi{200}&space;\sqrt{x}&space;',
//icon: '//upload.wikimedia.org/wikipedia/commons/2/2e/Button_math.png',
action: {
action: {
type: 'encapsulate',
type: 'encapsulate',

Revision as of 13:33, 16 February 2022

/* Any JavaScript here will be loaded for all users on every page load. */

// Check if we're editing a page.
if ( [ 'edit', 'submit' ].indexOf( mw.config.get( 'wgAction' ) ) !== -1 ) {
	// Add a hook handler.
	mw.hook( 'wikiEditor.toolbarReady' ).add( function ( $textarea ) {
		
		// Add Math button
		$( '#wpTextbox1' ).wikiEditor( 'addToToolbar', {
			section: 'advanced',
			group: 'format',
			tools: {
				"math": {
					label: 'Math',
					type: 'button',
					icon: 'https://latex.codecogs.com/png.image?\dpi{200}&space;\sqrt{x}&space;',
					//icon: '//upload.wikimedia.org/wikipedia/commons/2/2e/Button_math.png',
					action: {
						type: 'encapsulate',
						options: {
							pre: "<math>",
							post: "</math>"
						}
					}
				}
			}
		} );
	} );
}