User:NACGNOH/common.js: Difference between revisions

From Deadlock Wiki
Jump to navigation Jump to search
NACGNOH (talk | contribs)
WikiEditor/Toolbar customization Test
 
NACGNOH (talk | contribs)
m WikiEditor/Toolbar customization TEST
Line 1: Line 1:
// Check if we're editing a page.
// Check if we're editing a page.
if ( [ 'edit', 'submit' ].indexOf( mw.config.get( 'wgAction' ) ) !== -1 ) {
if ( [ 'edit', 'submit' ].indexOf( mw.config.get( 'wgAction' ) ) !== -1 ) {
// Add a hook handler.
    // Add a hook handler.
mw.hook( 'wikiEditor.toolbarReady' ).add( function ( $textarea ) {
    mw.hook( 'wikiEditor.toolbarReady' ).add( function ( $textarea ) {
// 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: 'advanced',
            section: 'advanced',
group: 'format',
            group: 'format',
tools: {
            tools: {
comment: {
                AlignCenter: {
label: 'Comment',
                    label: '居中',
type: 'button',
                    type: 'button',
icon: 'https://upload.wikimedia.org/wikipedia/commons/3/37/Btn_toolbar_commentaire.png',
                    oouiIcon: 'alignCenter',
action: {
                    action: {
type: 'encapsulate',
                        type: 'encapsulate',
options: {
                        options: {
pre: '<!-- ',
                            pre: "<center>",
post: ' -->'
                            post: "</center>"
}
                        }
}
                    }
}
                }
}
            }
} );
        } );
} );
    } );
}
}

Revision as of 17:20, 13 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: '居中',
                    type: 'button',
                    oouiIcon: 'alignCenter',
                    action: {
                        type: 'encapsulate',
                        options: {
                            pre: "<center>",
                            post: "</center>"
                        }
                    }
                }
            }
        } );
    } );
}