MediaWiki:Common.js:修订间差异

Baneq留言 | 贡献
无编辑摘要
Baneq留言 | 贡献
无编辑摘要
第1行: 第1行:
$( function () {
$( function () {
mw.hook( 'wikiEditor.toolbarReady' ).add( function ( $textarea ) {
mw.hook( 'wikiEditor.toolbarReady' ).add( function ( $textarea ) {
// 包裹型:选中文字后点击,把文字包进模板
// 包裹型工具:选中文字→包起来
var wrap = {
function wrapTool( pre, peri, post ) {
'红':  { pre: '{{红|',   peri: '文字', post: '}}' },
return { type: 'button', label: '', action: {
'绿':  { pre: '{{绿|',  peri: '文字', post: '}}' },
type: 'encapsulate', options: { pre: pre, peri: peri, post: post } } };
'蓝':  { pre: '{{蓝|',   peri: '文字', post: '}}' },
}
'橙':  { pre: '{{橙|',  peri: '文字', post: '}}' },
// 插入型工具:插入骨架
'高亮': { pre: '{{高亮|', peri: '文字', post: '}}' },
function insTool( text ) {
'指令': { pre: '{{指令|', peri: '/命令', post: '}}' },
return { type: 'button', label: '', action: {
'键':  { pre: '{{键|',   peri: 'F3',  post: '}}' },
type: 'encapsulate', options: { pre: text } } };
'剧透': { pre: '{{剧透|', peri: '剧透内容', post: '}}' },
}
'提示': { pre: '{{提示|', peri: '提示内容', post: '}}' },
'警告': { pre: '{{警告|', peri: '警告内容', post: '}}' },
'成功': { pre: '{{成功|', peri: '允许/成功内容', post: '}}' },
'公告': { pre: '{{公告|', peri: '公告内容', post: '}}' },
// 折叠:选中文字当内容,标题留占位符"标题"
'折叠': { pre: '{{折叠|标题=标题|', peri: '折叠内容', post: '}}' }
};
// 插入型:无参数的标记
var insert = {
'待补充': '{{待补充}}'
};
 
var tools = {};
Object.keys( wrap ).forEach( function ( name ) {
tools[ name ] = {
label: name, type: 'button',
action: { type: 'encapsulate', options: wrap[ name ] }
};
} );
Object.keys( insert ).forEach( function ( name ) {
tools[ name ] = {
label: name, type: 'button',
action: { type: 'encapsulate', options: { pre: insert[ name ] } }
};
} );


$textarea.wikiEditor( 'addToToolbar', {
$textarea.wikiEditor( 'addToToolbar', {
section: 'main', group: 'format', tools: tools
sections: {
noblecraft: {
type: 'booklet',
label: 'NobleCraft 格式',
pages: {
colors: {
layout: 'characters',
label: '颜色/强调',
characters: [
{ action:{type:'encapsulate',options:{pre:'{{红|',peri:'文字',post:'}}'}}, label:'红' },
{ action:{type:'encapsulate',options:{pre:'{{绿|',peri:'文字',post:'}}'}}, label:'绿' },
{ action:{type:'encapsulate',options:{pre:'{{蓝|',peri:'文字',post:'}}'}}, label:'蓝' },
{ action:{type:'encapsulate',options:{pre:'{{橙|',peri:'文字',post:'}}'}}, label:'' },
{ action:{type:'encapsulate',options:{pre:'{{高亮|',peri:'文字',post:'}}'}}, label:'高亮' },
{ action:{type:'encapsulate',options:{pre:'{{提示|',peri:'提示内容',post:'}}'}}, label:'提示' },
{ action:{type:'encapsulate',options:{pre:'{{警告|',peri:'警告内容',post:'}}'}}, label:'警告' },
{ action:{type:'encapsulate',options:{pre:'{{成功|',peri:'内容',post:'}}'}}, label:'成功' }
]
},
game: {
layout: 'characters',
label: '游戏元素',
characters: [
{ action:{type:'encapsulate',options:{pre:'{{指令|',peri:'/命令',post:'}}'}}, label:'指令' },
{ action:{type:'encapsulate',options:{pre:'{{键|',peri:'F3',post:'}}'}}, label:'键' },
{ action:{type:'encapsulate',options:{pre:'{{坐标|x=',peri:'0',post:'|y=0|z=0}}'}}, label:'坐标' },
{ action:{type:'encapsulate',options:{pre:'{{稀有度|',peri:'史诗',post:'}}'}}, label:'稀有度' },
{ action:{type:'encapsulate',options:{pre:'{{评分星|',peri:'4',post:'}}'}}, label:'评分星' },
{ action:{type:'encapsulate',options:{pre:'{{状态|',peri:'可用',post:'}}'}}, label:'状态' },
{ action:{type:'encapsulate',options:{pre:'{{版本|',peri:'1.0',post:'}}'}}, label:'版本' }
]
},
links: {
layout: 'characters',
label: '链接/剧情',
characters: [
{ action:{type:'encapsulate',options:{pre:'{{NPC|',peri:'角色名',post:'}}'}}, label:'NPC' },
{ action:{type:'encapsulate',options:{pre:'{{地点|',peri:'地点名',post:'}}'}}, label:'地点' },
{ action:{type:'encapsulate',options:{pre:'{{物品|',peri:'物品名',post:'}}'}}, label:'物品' },
{ action:{type:'encapsulate',options:{pre:'{{剧透|',peri:'剧透内容',post:'}}'}}, label:'剧透' },
{ action:{type:'encapsulate',options:{pre:'{{对话|角色=角色名|',peri:'台词',post:'}}'}}, label:'对话' }
]
},
blocks: {
layout: 'characters',
label: '区块/标记',
characters: [
{ action:{type:'encapsulate',options:{pre:'{{折叠|标题=标题|',peri:'内容',post:'}}'}}, label:'折叠' },
{ action:{type:'encapsulate',options:{pre:'{{公告|',peri:'公告内容',post:'}}'}}, label:'公告' },
{ action:{type:'encapsulate',options:{pre:'{{待补充}}'}}, label:'待补充' },
{ action:{type:'encapsulate',options:{pre:'{{待更新}}'}}, label:'待更新' },
{ action:{type:'encapsulate',options:{pre:'{{主条目|',peri:'页面名',post:'}}'}}, label:'主条目' },
{ action:{type:'encapsulate',options:{pre:'{{参见|',peri:'页面名',post:'}}'}}, label:'参见' }
]
}
}
}
}
} );
} );
} );
} );
} );
} );