MediaWiki:Gadget-Edittools-vector.js
外观
注意:保存之后,你必须清除浏览器缓存才能看到做出的更改。Google Chrome、Firefox、Microsoft Edge及Safari:按住⇧ Shift键并单击工具栏的“刷新”按钮。参阅Help:绕过浏览器缓存以获取更多帮助。
// <nowiki>
/* Generic code */
window.customizeToolbar = function( customizer ) {
/* Check if we are in edit mode and the required modules are available and then customize the toolbar */
if ( $.inArray( mw.config.get( 'wgAction' ), ['edit', 'submit'] ) !== -1 ) {
if ( mw.user.options.get('usebetatoolbar') ) {
mw.loader.using( 'ext.wikiEditor', function () {
$(document).ready( function() {
customizer.call( $( '#wpTextbox1' ) );
} );
} );
}
}
};
/* If the user manually chose this gadget */
if ( mw.user.options.get('gadget-Edittools-vector') ) {
customizeToolbar( function() {
this.wikiEditor('addToToolbar', {
'section': 'main',
'group': 'insert',
'tools': {
'category': {
label: '分类',
type: 'button',
oouiIcon: 'tag',
action: {
type: 'encapsulate',
options: {
pre: "[\[Category:",
post: "]]"
}
}
}
}
} );
this.wikiEditor('addToToolbar', {
'section': 'advanced',
'group': 'format',
'tools': {
'bolditalic': {
label: '粗斜体',
type: 'button',
icon: '//upload.wikimedia.org/wikipedia/commons/b/be/Toolbaricon_bolditalic_A.png',
action: {
type: 'encapsulate',
options: {
pre: "'''''",
periMsg: '粗斜体文字',
post: "'''''"
}
}
},
'strikethrough': {
label: '删除线',
type: 'button',
oouiIcon: 'strikethrough',
action: {
type: 'encapsulate',
options: {
pre: "<s>",
post: "</s>"
}
}
},
'underline': {
label: '下划线',
type: 'button',
oouiIcon: 'underline',
action: {
type: 'encapsulate',
options: {
pre: "<u>",
post: "</u>"
}
}
},
'quote': {
label: '块引用',
type: 'button',
oouiIcon: 'quotes',
action: {
type: 'encapsulate',
options: {
pre: "<blockquote>",
post: "</blockquote>"
}
}
},
'justify-left': {
label: '左对齐',
type: 'button',
oouiIcon: 'alignLeft',
action: {
type: 'encapsulate',
options: {
pre: "<div style=\"text-align: left;\">",
post: "</div>"
}
}
},
'justify-center': {
label: '居中',
type: 'button',
oouiIcon: 'alignCenter',
action: {
type: 'encapsulate',
options: {
pre: "<div style=\"text-align: center;\">",
post: "</div>"
}
}
},
'justify-right': {
label: '右对齐',
type: 'button',
oouiIcon: 'alignRight',
action: {
type: 'encapsulate',
options: {
pre: "<div style=\"text-align: right;\">",
post: "</div>"
}
}
},
'source': {
label: '源代码',
type: 'button',
oouiIcon: 'markup',
action: {
type: 'encapsulate',
options: {
pre: "<syntaxhighlight lang=\"text\">",
post: '</syntaxhighlight>'
}
}
}
}
} );
this.wikiEditor('addToToolbar', {
'section': 'advanced',
'group': 'insert',
'tools': {
'math': {
label: '数学公式',
type: 'button',
oouiIcon: 'mathematics',
action: {
type: 'encapsulate',
options: {
pre: "<math>",
periMsg: '插入数学公式',
post: "</math>"
}
}
},
'hidden': {
label: '注释或隐藏文字',
type: 'button',
oouiIcon: 'notice',
action: {
type: 'encapsulate',
options: {
pre: "<!-- ",
post: " -->"
}
}
},
'hline': {
label: '水平线',
type: 'button',
oouiIcon: 'subtract',
action: {
type: 'encapsulate',
options: {
pre: "----",
ownline: true
}
}
},
'hans-hant': {
label: '繁简转换',
type: 'button',
icon: '//upload.wikimedia.org/wikipedia/commons/thumb/a/aa/OOjs_UI_icon_LC-zh.svg/22px-OOjs_UI_icon_LC-zh.svg.png',
action: {
type: 'encapsulate',
options: {
pre: "-{",
periMsg: '转换文字',
post: "}-"
}
}
},
'references': {
label: '参考文献区',
type: 'button',
oouiIcon: 'references',
action: {
type: 'encapsulate',
options: {
pre: "\n==参考文献==\n{\{reflist}}\n",
}
}
}
}
} );
// dark mode fix
$('#wikiEditor-section-advanced .group-insert a[rel=hans-hant]').addClass('skin-invert');
$('#wikiEditor-section-advanced .group-format a[rel=bolditalic]').addClass('skin-invert');
} );
}
// </nowiki>