16,874
个编辑
LLWiki正在建设中,欢迎加入我们!
小 |
小 |
||
"use strict";
/*global mw, $, OO, CodeMirror*/
mw.util.addCSS(
'.CodeMirror { float:right; position:sticky; top:7px; border:1px solid; height:calc(100vh - 55px); }' +▼
$.getJSON( '/zh?title=mediawiki:gadget-CodeMirror.json&action=raw&ctype=application/json', config => {
let text = '';
const
'#mw-content-text > .mw-parser-output, .CodeMirror { display:inline-block; width:49%; }' +
▲ '.CodeMirror { float:right; position:sticky; top:7px; border:1px solid; height:calc(100vh - 55px); }'
$content = $('#mw-content-text'),
id = mw.config.get( 'wgArticleId' ),
api = new mw.Api(),
editor = new CodeMirror($content[0], {mode: 'text/mediawiki', mwConfig: config, lineWrapping: true}),
wrapper = $( editor.getWrapperElement() ),
console.log('API request: 查询最新编辑时间戳');
const now = mw.now();
}, reason => { mw.notify(`编辑失败!错误信息:${reason}`, {type: 'error'}); });
}, reason => { mw.notify(`无法获得最新编辑时间戳!错误信息:${reason}`, {type: 'error'}); });
▲ btn2 = new OO.ui.ButtonWidget({label: '预览'}).on('click', () => {
console.log('API request: 请求预览');
const now = mw.now();
console.log(`End API request: 已生成预览,用时 ${mw.now() - now} ms`);
$content.children( '.mw-parser-output' ).replaceWith( html );
mw.hook( 'wikipage.content' ).fire($content);
}, reason => { mw.notify(`无法生成预览!错误信息:${reason}`, {type: 'error'}); });
▲ btn3 = new OO.ui.ButtonWidget({label: '还原', flags: ['destructive']}).on('click', () => {
editor.setValue( text );
}), new OO.ui.ButtonWidget({label: '隐藏'}).on('click', () => {
css.disabled = !css.disabled;
$('<div>', {html: [btn1.$element, btn2.$element, btn3.$element]}).appendTo( $content )▼
wrapper.toggle();
}), new OO.ui.ButtonWidget({label: '继续', flags: 'progressive', icon: 'next'}).on('click', () => {
window.href = `/?redirect=no&curid=${id + 1}`; })];
▲ $('<div>', {html:
.css({float: 'right', clear: 'right', position: 'sticky', bottom: 0});
mw.request = mw.request || api.get({action: 'query', revids: mw.config.get('wgRevisionId'), prop: 'revisions',
|