User:PPenloglou-WMF/common.js: Difference between revisions

From mediawiki.org
Content deleted Content added
No edit summary
No edit summary
Line 5: Line 5:
// Configure a new toolbar entry on the given $textarea jQuery object.
// Configure a new toolbar entry on the given $textarea jQuery object.
$textarea.wikiEditor( 'addToToolbar', {
$textarea.wikiEditor( 'addToToolbar', {
section: 'emoticons',
group: 'faces',
tools: {
tools: {
smile: {
smile: {
label: 'Smile!', // or use mw.msg() for a localized label, see above
label: 'Smile!', // or use mw.message( key ).escaped() for a localized label, see above
filters: [ 'body.ns-talk' ],
type: 'button',
type: 'button',
icon: '//upload.wikimedia.org/wikipedia/commons/thumb/a/a4/Gnome-face-smile.svg/22px-Gnome-face-smile.svg.png',
icon: '//upload.wikimedia.org/wikipedia/commons/thumb/a/a4/Gnome-face-smile.svg/22px-Gnome-face-smile.svg.png',

Revision as of 19:45, 10 May 2024

// 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 ) {
		// Configure a new toolbar entry on the given $textarea jQuery object.
		$textarea.wikiEditor( 'addToToolbar', {
	tools: {
		smile: {
			label: 'Smile!', // or use mw.message( key ).escaped() for a localized label, see above
			type: 'button',
			icon: '//upload.wikimedia.org/wikipedia/commons/thumb/a/a4/Gnome-face-smile.svg/22px-Gnome-face-smile.svg.png',
			action: {
				type: 'encapsulate',
				options: {
					pre: ":)" // text to be inserted
				}
			}
		}
	}
} );
	} );
}