MediaWiki:Common.js: Difference between revisions
No edit summary |
No edit summary |
||
| (4 intermediate revisions by the same user not shown) | |||
| Line 2: | Line 2: | ||
if (mw.config.get("wgAction") == "edit") { | if (mw.config.get("wgAction") == "edit") { | ||
mw.loader.load( 'https://codemirror.net/3/addon/comment/comment.js' ); | mw.loader.load( 'https://codemirror.net/3/addon/comment/comment.js' ); | ||
const customKeyMap = { | const customKeyMap = { | ||
"Ctrl-/": "toggleComment" | "Ctrl-/": "toggleComment" | ||
}; | }; | ||
const | const codeMirrorCoreModules = [ | ||
'ext.CodeMirror.lib', | |||
}); | 'ext.CodeMirror.mode.mediawiki' | ||
]; | |||
mw.loader.using( codeMirrorCoreModules, function () { | |||
CodeMirror.keyMap.pcDefault[ 'Ctrl-/' ] = "toggleComment"; | |||
CodeMirror.extendMode("mediawiki", { | |||
blockCommentStart: '<!--', | |||
blockCommentEnd: '-->', | |||
start: [ | |||
{ | |||
regex: /<!--.*-->/, | |||
token: 'comment', | |||
}, | |||
] | |||
}); | |||
window.cmEditor = document.getElementsByClassName("CodeMirror")[0].CodeMirror; | |||
}); | |||
} | } | ||