Note: After saving, you have to bypass your browser's cache to see the changes. Google Chrome, Firefox, Microsoft Edge and Safari: Hold down the ⇧ Shift key and click the Reload toolbar button. For details and instructions about other browsers, see Wikipedia:Bypass your cache.
// Add Templates section to WikiEditor 2010 toolbar
// Place this code in your common.js file

// 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 ) {
        
        // Add the Templates toolbar section
        $textarea.wikiEditor( 'addToToolbar', {
            sections: {
                templates: {
                    type: 'toolbar',
                    label: 'Templates'
                }
            }
        } );
        
        // Add a group for warning templates
        $textarea.wikiEditor( 'addToToolbar', {
            section: 'templates',
            groups: {
                warnings: {
                    label: 'Warning templates'
                }
            }
        } );
        
        // Add the uw-3rr button
        $textarea.wikiEditor( 'addToToolbar', {
            section: 'templates',
            group: 'warnings',
            tools: {
                'uw-3rr': {
                    label: '{{uw-3rr}} - 3RR warning',
                    type: 'button',
                    oouiIcon: 'alert',
                    action: {
                        type: 'encapsulate',
                        options: {
                            pre: '{{uw-3rr}}'
                        }
                    }
                }
            }
        } );
        
    } );
}