更多操作
无编辑摘要 |
无编辑摘要 |
||
(未显示同一用户的21个中间版本) | |||
第3行: | 第3行: | ||
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. | ||
setTimeout(function (){ | |||
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. | ||
//向advanced节中添加下划线等功能 | |||
$textarea.wikiEditor( 'addToToolbar', { | |||
section: 'advanced', | |||
group: 'format', | |||
tools: { | |||
"strikethrough": { | |||
label: '下划线', | |||
type: 'button', | |||
oouiIcon: 'underline', | |||
action: { | |||
type: 'encapsulate', | |||
options: { | |||
pre: "<u>", | |||
post: "</u>" | |||
} | |||
} | |||
} | |||
} | |||
} ); | |||
$textarea.wikiEditor( 'addToToolbar', { | |||
section: 'advanced', | |||
group: 'format', | |||
tools: { | |||
"strikethrough": { | |||
label: '删除线', | |||
type: 'button', | |||
oouiIcon: 'strikethrough', | |||
action: { | |||
type: 'encapsulate', | |||
options: { | |||
pre: "<s>", | |||
post: "</s>" | |||
} | |||
} | |||
} | |||
} | |||
} ); | |||
$textarea.wikiEditor( 'addToToolbar', { | |||
section: 'advanced', | |||
group: 'format', | |||
tools: { | |||
hline: { | |||
label: '水平线', | |||
type: 'button', | |||
oouiIcon: 'subtract', | |||
action: { | |||
type: 'encapsulate', | |||
options: { | |||
pre: '----', | |||
ownline: true | |||
} | |||
} | |||
} | |||
} | |||
} ); | |||
$textarea.wikiEditor( 'addToToolbar', { | |||
section: 'advanced', | |||
group: 'format', | |||
tools: { | |||
comment: { | |||
label: '注释', | |||
type: 'button', | |||
oouiIcon: 'quotes', | |||
action: { | |||
type: 'encapsulate', | |||
options: { | |||
pre: '<!-- ', | |||
post: ' -->' | |||
} | |||
} | |||
} | |||
} | |||
} ); | |||
$textarea.wikiEditor( 'addToToolbar', { | |||
section: 'advanced', | |||
group: 'insert', | |||
tools: { | |||
comment: { | |||
label: '分类', | |||
type: 'button', | |||
oouiIcon: 'tag', | |||
action: { | |||
type: 'encapsulate', | |||
options: { | |||
pre: '[[分类:', | |||
post: ']]' | |||
} | |||
} | |||
} | |||
} | |||
} ); | |||
//新建quickTemplates 小节 | |||
$textarea.wikiEditor( 'addToToolbar', { | $textarea.wikiEditor( 'addToToolbar', { | ||
sections: { | sections: { | ||
第29行: | 第122行: | ||
type: 'encapsulate', | type: 'encapsulate', | ||
options: { | options: { | ||
pre: '__TOC__\n{{刷题入口}}\n=={{ | pre: '<!--<noinclude> 用于防止总和页面内出现本内容-->\n<noinclude>__TOC__\n{{刷题入口}}</noinclude>\n<!--本页标题,第一级子页面用二级标题(两个等号),第二级子页面用三级标题,同理-->\n== {{subst:SUBPAGENAME}} ', | ||
post: '==\n\n<noinclude>{{目录-{{ROOTPAGENAME}}|display=none}}</noinclude>' | post: ' ==\n\n<noinclude>{{目录-{{ROOTPAGENAME}}|display=none}}</noinclude>' | ||
} | |||
} | |||
} | |||
,'standard-tikupage-ky':{ | |||
label: '标准考研题库页面', | |||
action: { | |||
type: 'encapsulate', | |||
options: { | |||
pre: '<!--<noinclude> 用于防止总和页面内出现本内容-->\n<noinclude>__TOC__\n{{刷题入口}}</noinclude>\n<!--本页标题,第一级子页面用二级标题(两个等号),第二级子页面用三级标题,同理-->\n== {{subst:SUBPAGENAME}} ', | |||
post: ' ==\n\n===A型题===\n\n===B型题===\n\n===C型题===\n\n===X型题===\n\n<noinclude>{{目录-{{ROOTPAGENAME}}|display=none}}</noinclude>' | |||
} | |||
} | |||
} | |||
,'standard-tikupage-AX-L1':{ | |||
label: '标准题库页面(人卫习题集,第一级子页)', | |||
action: { | |||
type: 'encapsulate', | |||
options: { | |||
pre: '<!--<noinclude> 用于防止总和页面内出现本内容-->\n<noinclude>__TOC__\n{{刷题入口}}</noinclude>\n<!--本页标题,第一级子页面用二级标题(两个等号),第二级子页面用三级标题,同理-->\n== ', | |||
post: '==\n<!--题型分类,标题需比本页标题更低一级-->\n\n===名词解释===\n\n===A1型题===\n\n===A2型题===\n\n===B型题===\n\n===C型题===\n\n===A3型题===\n\n===简答题===\n\n<noinclude>{{目录-{{ROOTPAGENAME}}|display=none}}</noinclude>' | |||
} | } | ||
} | } | ||
} | } | ||
,'standard-tikupage-AX-L2':{ | |||
label: '标准题库页面( | label: '标准题库页面(人卫习题集,第二级子页)', | ||
action: { | action: { | ||
type: 'encapsulate', | type: 'encapsulate', | ||
options: { | options: { | ||
pre: '__TOC__\n{{刷题入口}}\n== | pre: '<!--<noinclude> 用于防止总和页面内出现本内容-->\n<noinclude>__TOC__\n{{刷题入口}}</noinclude>\n<!--本页标题,第一级子页面用二级标题(两个等号),第二级子页面用三级标题,同理-->\n=== ', | ||
post: '==\n\n===名词解释===\n\n===A1型题===\n\n===A2型题===\n\n===B型题===\n\n===C型题===\n\n===A3型题===\n\n===简答题===\n\n<noinclude>{{目录-{{ROOTPAGENAME}}|display=none}}</noinclude>' | post: '===\n<!--题型分类,标题需比本页标题更低一级-->\n\n====名词解释====\n\n====A1型题====\n\n====A2型题====\n\n====B型题====\n\n====C型题====\n\n====A3型题====\n\n====简答题====\n\n<noinclude>{{目录-{{ROOTPAGENAME}}|display=none}}</noinclude>' | ||
} | } | ||
} | } | ||
第192行: | 第305行: | ||
} | } | ||
} ); | } ); | ||
} ); | } );},0) | ||
} | } | ||
//</nowiki> | //</nowiki> |
2023年7月14日 (五) 10:42的最新版本
// Check if we're editing a page.
//<nowiki>
if ( [ 'edit', 'submit' ].indexOf( mw.config.get( 'wgAction' ) ) !== -1 ) {
// Add a hook handler.
setTimeout(function (){
mw.hook( 'wikiEditor.toolbarReady' ).add( function ( $textarea ) {
// Configure a new toolbar entry on the given $textarea jQuery object.
//向advanced节中添加下划线等功能
$textarea.wikiEditor( 'addToToolbar', {
section: 'advanced',
group: 'format',
tools: {
"strikethrough": {
label: '下划线',
type: 'button',
oouiIcon: 'underline',
action: {
type: 'encapsulate',
options: {
pre: "<u>",
post: "</u>"
}
}
}
}
} );
$textarea.wikiEditor( 'addToToolbar', {
section: 'advanced',
group: 'format',
tools: {
"strikethrough": {
label: '删除线',
type: 'button',
oouiIcon: 'strikethrough',
action: {
type: 'encapsulate',
options: {
pre: "<s>",
post: "</s>"
}
}
}
}
} );
$textarea.wikiEditor( 'addToToolbar', {
section: 'advanced',
group: 'format',
tools: {
hline: {
label: '水平线',
type: 'button',
oouiIcon: 'subtract',
action: {
type: 'encapsulate',
options: {
pre: '----',
ownline: true
}
}
}
}
} );
$textarea.wikiEditor( 'addToToolbar', {
section: 'advanced',
group: 'format',
tools: {
comment: {
label: '注释',
type: 'button',
oouiIcon: 'quotes',
action: {
type: 'encapsulate',
options: {
pre: '<!-- ',
post: ' -->'
}
}
}
}
} );
$textarea.wikiEditor( 'addToToolbar', {
section: 'advanced',
group: 'insert',
tools: {
comment: {
label: '分类',
type: 'button',
oouiIcon: 'tag',
action: {
type: 'encapsulate',
options: {
pre: '[[分类:',
post: ']]'
}
}
}
}
} );
//新建quickTemplates 小节
$textarea.wikiEditor( 'addToToolbar', {
sections: {
quickTemplates: {
type: 'toolbar', // Can also be 'booklet',
label: '快捷模板'
// or labelMsg: 'section-emoticons-label' for a localized label
}
}
} );
//标准题库页面
$textarea.wikiEditor( 'addToToolbar', {
section: 'quickTemplates',
groups: {
list: {
tools: {
templates: {
label: '标准题库模板',
type: 'select',
list: {
'standard-tikupage':{
label: '标准题库页面',
action: {
type: 'encapsulate',
options: {
pre: '<!--<noinclude> 用于防止总和页面内出现本内容-->\n<noinclude>__TOC__\n{{刷题入口}}</noinclude>\n<!--本页标题,第一级子页面用二级标题(两个等号),第二级子页面用三级标题,同理-->\n== {{subst:SUBPAGENAME}} ',
post: ' ==\n\n<noinclude>{{目录-{{ROOTPAGENAME}}|display=none}}</noinclude>'
}
}
}
,'standard-tikupage-ky':{
label: '标准考研题库页面',
action: {
type: 'encapsulate',
options: {
pre: '<!--<noinclude> 用于防止总和页面内出现本内容-->\n<noinclude>__TOC__\n{{刷题入口}}</noinclude>\n<!--本页标题,第一级子页面用二级标题(两个等号),第二级子页面用三级标题,同理-->\n== {{subst:SUBPAGENAME}} ',
post: ' ==\n\n===A型题===\n\n===B型题===\n\n===C型题===\n\n===X型题===\n\n<noinclude>{{目录-{{ROOTPAGENAME}}|display=none}}</noinclude>'
}
}
}
,'standard-tikupage-AX-L1':{
label: '标准题库页面(人卫习题集,第一级子页)',
action: {
type: 'encapsulate',
options: {
pre: '<!--<noinclude> 用于防止总和页面内出现本内容-->\n<noinclude>__TOC__\n{{刷题入口}}</noinclude>\n<!--本页标题,第一级子页面用二级标题(两个等号),第二级子页面用三级标题,同理-->\n== ',
post: '==\n<!--题型分类,标题需比本页标题更低一级-->\n\n===名词解释===\n\n===A1型题===\n\n===A2型题===\n\n===B型题===\n\n===C型题===\n\n===A3型题===\n\n===简答题===\n\n<noinclude>{{目录-{{ROOTPAGENAME}}|display=none}}</noinclude>'
}
}
}
,'standard-tikupage-AX-L2':{
label: '标准题库页面(人卫习题集,第二级子页)',
action: {
type: 'encapsulate',
options: {
pre: '<!--<noinclude> 用于防止总和页面内出现本内容-->\n<noinclude>__TOC__\n{{刷题入口}}</noinclude>\n<!--本页标题,第一级子页面用二级标题(两个等号),第二级子页面用三级标题,同理-->\n=== ',
post: '===\n<!--题型分类,标题需比本页标题更低一级-->\n\n====名词解释====\n\n====A1型题====\n\n====A2型题====\n\n====B型题====\n\n====C型题====\n\n====A3型题====\n\n====简答题====\n\n<noinclude>{{目录-{{ROOTPAGENAME}}|display=none}}</noinclude>'
}
}
}
,
}
}
}
}
}
} );
//题库模板的下拉菜单
$textarea.wikiEditor( 'addToToolbar', {
section: 'quickTemplates',
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=\n}}\n\n',
post: ''
}
}
}
,'A2-button': {
label: 'A2型题',
action: {
type: 'encapsulate',
options: {
pre: '{{A2型题\n|source=\n|title=\n|choices="A":"","B":"","C":"","D":"","E":""\n|answer=\n|explain=\n}}\n\n',
post: ''
}
}
}
,'A3-button': {
label: 'A3型题',
action: {
type: 'encapsulate',
options: {
pre: '{{A3型题\n|source=\n|sourceRange=\n|title="",""\n|choices={"A":"","B":"","C":"","D":"","E":""},{"A":"","B":"","C":"","D":"","E":""}\n|answer="",""\n|explain="",""\n|info=\n}}\n\n',
post: ''
}
}
}
,'B-button': {
label: 'B型题',
action: {
type: 'encapsulate',
options: {
pre: '{{B型题\n|source=\n|sourceRange=\n|title="",""\n|choices="A":"","B":"","C":"","D":"","E":""\n|answer="",""\n|explain="",""\n}}\n\n',
post: ''
}
}
}
,'C-button': {
label: 'C型题',
action: {
type: 'encapsulate',
options: {
pre: '{{C型题\n|source=\n|sourceRange=\n|title="",""\n|choices="A":"","B":"","C":"","D":"","E":""\n|answer="",""\n|explain="",""\n}}\n\n',
post: ''
}
}
}
,'X-button': {
label: 'X型题',
action: {
type: 'encapsulate',
options: {
pre: '{{X型题\n|source=\n|title=\n|choices="A":"","B":"","C":"","D":"","E":""\n|answer=\n|explain=\n}}\n\n',
post: ''
}
}
}
,'TK-button': {
label: 'TK型题',
action: {
type: 'encapsulate',
options: {
pre: '{{TK型题\n|source=\n|pos=\n|title=\n|answer="",""\n|explain=\n}}\n\n',
post: ''
}
}
}
,'MJ-button': {
label: 'MJ型题',
action: {
type: 'encapsulate',
options: {
pre: '{{MJ型题\n|source=\n|inputbox=0\n|title=\n|answer=\n}}\n\n',
post: ''
}
}
}
,'PD-button': {
label: 'PD型题',
action: {
type: 'encapsulate',
options: {
pre: '{{PD型题\n|source=\n|title=\n|answer=\n|explain=\n}}\n\n',
post: ''
}
}
}
}
}
}
}
}
} );
$textarea.wikiEditor( 'addToToolbar', {
section: 'quickTemplates',
groups: {
list: {
tools: {
templates: {
label: '词库模板',
type: 'select',
list: {
'word-button': {
label: '单词模板',
action: {
type: 'encapsulate',
options: {
pre: '{{单词\n|wordName=\n|wordPro=\n|wordZh=\n|source=\n|define=\n|relatewords={{relatewords|}}\n}}\n\n',
post: ''
}
}
}
,'glossary-button': {
label: '名解模板',
action: {
type: 'encapsulate',
options: {
pre: '{{名解\n|wordZh=\n|wordEng=\n|source=\n|define=\n|explain=\n|relatewords={{relatewords|}}\n}}\n\n',
post: ''
}
}
}
}
}
}
}
}
} );
} );},0)
}
//</nowiki>