User:Robinr78/common.js: Difference between revisions

From Robin's SM-201 Website
Jump to navigation Jump to search
No edit summary
No edit summary
Line 8: Line 8:


$textarea.wikiEditor( 'addToToolbar', {
$textarea.wikiEditor( 'addToToolbar', {
section: 'secondary',
section: 'main',
group: 'default',
groups: {
tools: {
list: {
dothing: {
tools: {
type: 'element',
templates: {
element: function ( context ) {
label: 'Templates',
// Note that the `context` object contains various useful references.
type: 'select',
console.log( context );
list: {
var button = new OO.ui.ButtonInputWidget( {
'Ping-button': {
label: 'Do a thing',
label: '{{Ping}}',
icon: 'hieroglyph'
action: {
} );
type: 'encapsulate',
button.connect( null, {
options: {
click: function ( e ) {
pre: '{{Ping|',
// Do whatever is required when the button is clicked.
post: '}}'
console.log( e );
}
OO.ui.alert( 'A thing is done.' );
}
},
'Clear-button': {
label: 'Clear',
action: {
type: 'encapsulate',
options: {
pre: '{{Clear}}'
}
}
},
'Done-button': {
label: 'Done',
action: {
type: 'encapsulate',
options: {
pre: '{{Done}}'
}
}
}
}
} ); 
}
return button.$element;
}
}
}
}
}
}
} );
}
} );


/* Your code goes here */
/* Your code goes here */

Revision as of 00:00, 31 December 2022

// 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', {
/* Your code goes here */

	$textarea.wikiEditor( 'addToToolbar', {
	section: 'main',
	groups: {
		list: {
			tools: {
				templates: {
					label: 'Templates',
					type: 'select',
					list: {
						'Ping-button': {
							label: '{{Ping}}',
							action: {
								type: 'encapsulate',
								options: {
									pre: '{{Ping|',
									post: '}}'
								}
							}
						},
						'Clear-button': {
							label: 'Clear',
							action: {
								type: 'encapsulate',
								options: {
									pre: '{{Clear}}'
								}
							}
						},
						'Done-button': {
							label: 'Done',
							action: {
								type: 'encapsulate',
								options: {
									pre: '{{Done}}'
								}
							}
						}
					}
				}
			}
		}
	}
} );

/* Your code goes here */
		} );
	} );
}