MediaWiki:Gadget-Emoji.js:修订间差异
来自Limbo Wiki
小 (排版) |
小无编辑摘要 |
||
第18行: | 第18行: | ||
} | } | ||
}); | }); | ||
$textarea.wikiEditor( 'addToToolbar', { | |||
section: 'secondary', | |||
group: 'default', | |||
tools: { | |||
dothing: { | |||
type: 'element', | |||
element: function ( context ) { | |||
// Note that the `context` object contains various useful references. | |||
console.log( context ); | |||
var button = new OO.ui.ButtonInputWidget( { | |||
label: 'Do a thing', | |||
icon: 'hieroglyph' | |||
} ); | |||
button.connect( null, { | |||
click: function ( e ) { | |||
// Do whatever is required when the button is clicked. | |||
console.log( e ); | |||
OO.ui.alert( 'A thing is done.' ); | |||
} | |||
} ); | |||
return button.$element; | |||
} | |||
} | |||
} | |||
} ); | |||
});}); | });}); |
2022年4月2日 (六) 23:48的版本
$(function() {mw.hook( 'wikiEditor.toolbarReady' ).add( function ( $textarea ) { $textarea.wikiEditor( 'addToToolbar',{ section: 'advanced', group: 'format', tools: { buttonId: { label: 'Comment visible only for editors', type: 'button', action: { type: 'encapsulate', options: { pre: '<!-- ', peri: 'Insert comment here', post: ' -->' } } } } }); $textarea.wikiEditor( 'addToToolbar', { section: 'secondary', group: 'default', tools: { dothing: { type: 'element', element: function ( context ) { // Note that the `context` object contains various useful references. console.log( context ); var button = new OO.ui.ButtonInputWidget( { label: 'Do a thing', icon: 'hieroglyph' } ); button.connect( null, { click: function ( e ) { // Do whatever is required when the button is clicked. console.log( e ); OO.ui.alert( 'A thing is done.' ); } } ); return button.$element; } } } } ); });});