打开/关闭菜单
Toggle preferences menu
打开/关闭个人菜单
未登录
未登录用户的IP地址会在进行任意编辑后公开展示。

MediaWiki:Gadget-custom-toolbar.js

MediaWiki界面页面
Cirno.9讨论 | 贡献2023年6月3日 (六) 20:18的版本

注意:在发布之后,您可能需要清除浏览器缓存才能看到所作出的变更的影响。

  • Firefox或Safari:按住Shift的同时单击刷新,或按Ctrl-F5Ctrl-R(Mac为⌘-R
  • Google Chrome:Ctrl-Shift-R(Mac为⌘-Shift-R
  • Internet Explorer或Edge:按住Ctrl的同时单击刷新,或按Ctrl-F5
  • Opera:Ctrl-F5
// 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: 'main',
            groups: {
                list: {
                    tools: {
                        templates: {
                            label: '题库模板',
                            type: 'select',
                            list: {
                                'A1-button': {
                                    label: 'A1型题',
                                    action: {
                                        type: 'encapsulate',
                                        options: {
                                            pre: '{{A型题\n|source=\n|title=\n|choices="A":"","B":"","C":"","D":"","E":""\n|answer=\n|explain=',
                                            post: '\n}}'
                                        }
                                    }
                                },
                                'Clear-button': {
                                    label: 'Clear',
                                    action: {
                                        type: 'encapsulate',
                                        options: {
                                            pre: '{{Clear}}'
                                        }
                                    }
                                },
                                'Done-button': {
                                    label: 'Done',
                                    action: {
                                        type: 'encapsulate',
                                        options: {
                                            pre: '{{Done}}'
                                        }
                                    }
                                }
                            }
                        }
                    }
                }
            }
        } );
	} );
}