Skip to content

Commit

Permalink
fix(wikieditor-highlight-cm6): fix wikilint
Browse files Browse the repository at this point in the history
1. assuming templates to be transcluded
2. loading full parser config
  • Loading branch information
bhsd-harry committed Jan 14, 2024
1 parent 6569946 commit 2c08684
Showing 1 changed file with 12 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -10,23 +10,32 @@
let cm, state = localObjectStorage.getItem("wikieditor-codemirror", false);
const $textarea = $("#wpTextbox1");
const isAdvanced = ["loading", "loaded", "executing", "ready"].includes(mw.loader.getState("ext.wikiEditor"));
const lang = mw.config.get("wgNamespaceNumber") === 274 ? "html" : "mediawiki";
const ns = mw.config.get("wgNamespaceNumber");
const lang = ns === 274 ? "html" : "mediawiki";
const init = () => new Promise((resolve) => {
const script = document.createElement("script");
script.addEventListener("load", async () => {
cm = await CodeMirror.fromTextArea($textarea[0], lang);
cm.defaultLint(true);
cm.prefer([
"highlightSpecialChars",
"highlightActiveLine",
"highlightWhitespace",
"bracketMatching",
"closeBrackets",
]);
const [config] = await Promise.all([
libCachedCode.getCachedCode("https://testingcf.jsdelivr.net/npm/wikiparser-node/config/moegirl.json"),
cm.defaultLint(true, {include: ns === 10}),
]);
try {
window.wikiparse.setConfig(JSON.parse(config));
} catch (e) {
console.error(e);
}
resolve();
});
script.type = "module";
script.src = "https://testingcf.jsdelivr.net/npm/@bhsd/[email protected].2/mw/dist/base.min.js";
script.src = "https://testingcf.jsdelivr.net/npm/@bhsd/[email protected].4/mw/dist/base.min.js";
document.head.appendChild(script);
});
if (!isAdvanced) {
Expand Down

0 comments on commit 2c08684

Please sign in to comment.