Skip to content

Commit

Permalink
feat(MediaWiki:Gadget-wikieditor-highlight.js): 添加高亮设置开关
Browse files Browse the repository at this point in the history
  • Loading branch information
bhsd-harry authored Dec 4, 2024
1 parent 0c5222b commit 02efa0b
Showing 1 changed file with 10 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -12,13 +12,7 @@
const isAdvanced = ["loading", "loaded", "executing", "ready"].includes(mw.loader.getState("ext.wikiEditor"));
const init = async () => {
if (!window.CodeMirror6) {
await new Promise((resolve) => {
const script = document.createElement("script");
script.addEventListener("load", resolve);
script.type = "module";
script.src = "https://testingcf.jsdelivr.net/npm/@bhsd/codemirror-mediawiki@latest/dist/mw.min.js";
document.head.append(script);
});
await libCachedCode.injectCachedCode("https://testingcf.jsdelivr.net/npm/@bhsd/codemirror-mediawiki@latest/dist/wiki.min.js", "js");
}
cm = await window.CodeMirror6.fromTextArea($textarea[0]);
$(".group-codeeditor-main").hide();
Expand All @@ -33,13 +27,20 @@
if (cm) {
cm.toggle();
$(".group-codeeditor-main").toggle();
btn2.$element.toggle();

Check failure on line 30 in src/gadgets/wikieditor-highlight/MediaWiki:Gadget-wikieditor-highlight.js

View workflow job for this annotation

GitHub Actions / linter_test

ESLint Annotation

'btn2' was used before it was defined. (no-use-before-define) - https://eslint.org/docs/latest/rules/no-use-before-define @ https://github.com/MoegirlPediaInterfaceAdmins/MoegirlPediaInterfaceCodes/blob/dec8841/src/gadgets/wikieditor-highlight/MediaWiki:Gadget-wikieditor-highlight.js#L30
} else {
await init();
btn.$element.after(btn2.$element);

Check failure on line 33 in src/gadgets/wikieditor-highlight/MediaWiki:Gadget-wikieditor-highlight.js

View workflow job for this annotation

GitHub Actions / linter_test

ESLint Annotation

'btn2' was used before it was defined. (no-use-before-define) - https://eslint.org/docs/latest/rules/no-use-before-define @ https://github.com/MoegirlPediaInterfaceAdmins/MoegirlPediaInterfaceCodes/blob/dec8841/src/gadgets/wikieditor-highlight/MediaWiki:Gadget-wikieditor-highlight.js#L33
}
btn.$element.toggleClass("tool-active");
state = !state;
localObjectStorage.setItem("wikieditor-codemirror", state);
});
const btn2 = new OO.ui.ButtonWidget({
classes: ["tool"], icon: "settings", framed: false, title: "代码高亮设置",
}).on("click", async () => {

Check failure on line 41 in src/gadgets/wikieditor-highlight/MediaWiki:Gadget-wikieditor-highlight.js

View workflow job for this annotation

GitHub Actions / linter_test

ESLint Annotation

Async arrow function has no 'await' expression. (require-await) - https://eslint.org/docs/latest/rules/require-await @ https://github.com/MoegirlPediaInterfaceAdmins/MoegirlPediaInterfaceCodes/blob/dec8841/src/gadgets/wikieditor-highlight/MediaWiki:Gadget-wikieditor-highlight.js#L41
$("#cm-settings").trigger("click");
});
$textarea.on("wikiEditor-toolbar-doneInitialSections", () => {
btn.$element.appendTo("#wikiEditor-section-main > .group-insert");
});
Expand All @@ -51,8 +52,9 @@
state = false;
}
if (state) {
await mw.loader.using("ext.wikiEditor");
await mw.loader.using(["ext.wikiEditor", "oojs-ui.styles.icons-interactions"]);
await init();
btn.$element.addClass("tool-active");
btn.$element.after(btn2.$element);
}
})();

0 comments on commit 02efa0b

Please sign in to comment.