LLWiki正在建设中,欢迎加入我们

“MediaWiki:Gadget-inspect.js”的版本间差异

跳转到导航 跳转到搜索
删除107字节 、​ 2023年3月27日 (一) 13:11
无编辑摘要
(正确预览Tabs扩展)
 
(未显示2个用户的5个中间版本)
}
// 先提交Ajax请求,这里手动设置cache: true
const getJSON = $mw.getloader.using({ dataType: 'jsonext.CodeMirror.data', cache: true),
url: '//cdn.jsdelivr.net/gh/bhsd-harry/LLWiki@1.6/json/gadget-CodeMirror.json' }),
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: "来西亚简体", data: "zh-my"},
{label: "新加坡简体", data: "zh-sg"}, {label: "臺灣體", data: "zh-tw"}],
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.config.set('extCodeMirrorConfig', data[0]);
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: data[0],
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 );
6,698

个编辑

导航菜单