wikiplus-highlight 3.0.7 → 3.0.8

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (3) hide show
  1. package/README.md +3 -3
  2. package/dist/main.js +12 -15
  3. package/package.json +1 -1
package/README.md CHANGED
@@ -1,7 +1,7 @@
1
1
  # Wikiplus-highlight
2
2
 
3
3
  [![npm version](https://badge.fury.io/js/wikiplus-highlight.svg)](https://www.npmjs.com/package/wikiplus-highlight)
4
- [![CodeQL](https://github.com/bhsd-harry/Wikiplus-highlight/actions/workflows/github-code-scanning/codeql/badge.svg)](https://github.com/bhsd-harry/Wikiplus-highlight/actions/workflows/github-code-scanning/codeql)
4
+ [![CodeQL](https://github.com/bhsd-harry/Wikiplus-highlight/actions/workflows/codeql.yml/badge.svg)](https://github.com/bhsd-harry/Wikiplus-highlight/actions/workflows/codeql.yml)
5
5
 
6
6
  **Wikiplus-highlight** 是由 Bhsd 编写的一款 [Wikiplus](https://github.com/Wikiplus/Wikiplus) 语法高亮插件,它主要基于 MediaWiki 内置的 [JavaScript 模块](https://www.mediawiki.org/wiki/ResourceLoader/Core_modules)和 [CodeMirror](https://codemirror.net/) 编写。
7
7
 
@@ -9,13 +9,13 @@
9
9
 
10
10
  在*个人 JS 页*添加以下代码:
11
11
 
12
- ```javascript
12
+ ```js
13
13
  mw.loader.load('//cdn.jsdelivr.net/npm/wikiplus-highlight');
14
14
  ```
15
15
 
16
16
 
17
17
 
18
- ```javascript
18
+ ```js
19
19
  mw.loader.load('//unpkg.com/wikiplus-highlight');
20
20
  ```
21
21
 
package/dist/main.js CHANGED
@@ -9,21 +9,19 @@
9
9
  if (wphl === null || wphl === void 0 ? void 0 : wphl.version) {
10
10
  return;
11
11
  }
12
- const version = '3.0.7';
12
+ const version = '3.0.8';
13
13
  libs.wphl = { version, cmVersion: '2.9', ...wphl }; // 开始加载
14
14
  // 路径
15
15
  const CDN = '//testingcf.jsdelivr.net', MW_CDN = `npm/@bhsd/codemirror-mediawiki@${libs.wphl.cmVersion || 'latest'}/dist/mw.min.js`, REPO_CDN = 'npm/wikiplus-highlight';
16
- const /** 加载CodeMirror 6 */ init = 'CodeMirror6' in window
17
- ? Promise.resolve()
18
- : new Promise(resolve => {
19
- const script = document.createElement('script');
20
- script.addEventListener('load', () => {
21
- resolve();
22
- });
23
- script.type = 'module';
24
- script.src = `${CDN}/${MW_CDN}`;
25
- document.head.appendChild(script);
16
+ window.CodeMirror6 || (window.CodeMirror6 = new Promise(resolve => {
17
+ const script = document.createElement('script');
18
+ script.addEventListener('load', () => {
19
+ resolve(CodeMirror6);
26
20
  });
21
+ script.type = 'module';
22
+ script.src = `${CDN}/${MW_CDN}`;
23
+ document.head.appendChild(script);
24
+ }));
27
25
  const { wgPageName: page, wgNamespaceNumber: ns, wgPageContentModel: contentmodel, } = mw.config.get();
28
26
  const CONTENTMODELS = {
29
27
  'sanitized-css': 'css',
@@ -36,8 +34,8 @@
36
34
  828: 'lua',
37
35
  274: 'html',
38
36
  };
39
- // eslint-disable-next-line @typescript-eslint/no-unnecessary-condition, @typescript-eslint/unbound-method
40
- const getObject = mw.storage.getObject || ((key) => JSON.parse(String(localStorage.getItem(key))));
37
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
38
+ const getObject = (key) => JSON.parse(String(localStorage.getItem(key)));
41
39
  /**
42
40
  * 检查页面语言类型
43
41
  * @param value 页面内容
@@ -97,8 +95,7 @@
97
95
  * @param setting 是否是Wikiplus设置(使用json语法)
98
96
  */
99
97
  const renderEditor = async ($target, setting) => {
100
- await init;
101
- const cm = await CodeMirror6.fromTextArea($target[0], ...setting ? ['json'] : await getPageMode($target.val()));
98
+ const cm = await (await CodeMirror6).fromTextArea($target[0], ...setting ? ['json'] : await getPageMode($target.val()));
102
99
  cm.view.dom.id = 'Wikiplus-CodeMirror';
103
100
  document.querySelector('#Wikiplus-Quickedit-Jump > a').href = '#Wikiplus-CodeMirror';
104
101
  if (!setting) { // 普通Wikiplus编辑区
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "wikiplus-highlight",
3
- "version": "3.0.7",
3
+ "version": "3.0.8",
4
4
  "description": "A plugin for the MediaWiki front-end add-on \"Wikiplus\"",
5
5
  "keywords": [
6
6
  "mediawiki",