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

MediaWiki:Gadget-CodeMirror.js

来自LLWiki
跳转到导航 跳转到搜索

注意:在保存之后,您可能需要清除浏览器缓存才能看到所作出的变更的影响。

  • Firefox或Safari:按住Shift的同时单击刷新,或按Ctrl-F5Ctrl-R(Mac为⌘-R
  • Google Chrome:Ctrl-Shift-R(Mac为⌘-Shift-R
  • Internet Explorer:按住Ctrl的同时单击刷新,或按Ctrl-F5
  • Opera:前往菜单 → 设置(Mac为Opera → Preferences),然后隐私和安全 → 清除浏览数据 → 缓存的图片和文件
//<nowiki>
// 由ResourceLoader直接调用,不可使用ES6语法
/**
 * @Function: 高亮显示模板和其他页内Wikitext代码
 * @Author: [[User:Bhsd]]
 */
"use strict";
/*global CodeMirror*/
if (['view', 'edit', 'submit'].includes( mw.config.get( 'wgAction' ) )) {
	mw.hook( 'wikipage.content' ).add(function($content) {
		const $pre = $content.find( '.wiki-highlight' ).text(function() {
			return this.textContent.replace(/^(-->|<\/noinclude>)/, '').replace(/(<!--|<noinclude>)$/, '');
		}).add( $content.find( '.wiki' ) );
		if ($pre.length === 0) { return; }
		console.debug('Hook: wikipage.content, 开始高亮模板代码');
		mw.loader.using( 'ext.gadget.site-lib.codemirror' ).then(function() { CodeMirror.runmode( $pre ); });
	});
}
//</nowiki>
// [[category:作为模块的小工具]] [[category:桌面版小工具]] [[category:手机版小工具]] [[category:阅读工具]]
// {{DEFAULTSORT:CodeMirror.js}}