6,698
个编辑
LLWiki正在建设中,欢迎加入我们!
小 |
小 |
||
(未显示1个用户的4个中间版本) | |||
}
// 先提交Ajax请求,这里手动设置cache: true
const getJSON =
getExt = mw.loader.using(['ext.CodeMirror.lib', 'ext.CodeMirror.mode.mediawiki']);
// 生成通用的API请求
if (isGadget( 'PreviewWithVariant' ) ) {
const options = [{label: "大陆简体", data: "zh-cn"}, {label: "香港繁體", data: "zh-hk"},
{label: "澳門繁體", data: "zh-mo"}, {label: "大马
{label: "新加坡简体", data: "zh-sg"}, {label: "
select = new OO.ui.DropdownInputWidget({classes: ['inspector-variant'], options: options, value: lang})
.on('change', () => { lang = select.getValue(); }),
// $.when很容易出错,这里保险起见用Promise.all
Promise.all([getJSON, mw.request, getExt]).then(data => {
mw.hook( 'codemirror.config' ).fire();
text = data[1].query.pages[0].revisions[0].content;
editor = new CodeMirror($outer[0], {value: text, mode: 'text/mediawiki'
mwConfig: mw.config.get('extCodeMirrorConfig'), lineWrapping: true, lineNumbers: true
});
$wrapper = $( editor.getWrapperElement() ).toggle().append( [$dropdown, $hints] );
$('<div>', {id: 'inspector-btns', html: btns.map(ele => ele.$element)}).appendTo( $outer );
|