User:NACGNOH/common.js: Difference between revisions

From Deadlock Wiki
Jump to navigation Jump to search
NACGNOH (talk | contribs)
m WikiEditor/Toolbar customization TEST
NACGNOH (talk | contribs)
mNo edit summary
Line 9: Line 9:
             tools: {
             tools: {
                 AlignCenter: {
                 AlignCenter: {
                     label: '居中',
                     label: 'Center',
                     type: 'button',
                     type: 'button',
                     oouiIcon: 'alignCenter',
                     oouiIcon: 'alignCenter',

Revision as of 16:31, 14 October 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', {
            section: 'advanced',
            group: 'format',
            tools: {
                AlignCenter: {
                    label: 'Center',
                    type: 'button',
                    oouiIcon: 'alignCenter',
                    action: {
                        type: 'encapsulate',
                        options: {
                            pre: "<center>",
                            post: "</center>"
                        }
                    }
                }
            }
        } );
    } );
}