-
Notifications
You must be signed in to change notification settings - Fork 15
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(wikieditor-highlight-cm6): fix wikilint
1. assuming templates to be transcluded 2. loading full parser config
- Loading branch information
1 parent
6569946
commit 2c08684
Showing
1 changed file
with
12 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -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) { | ||
|