@bhsd/codemirror-mediawiki 2.19.6 → 2.19.7
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.
- package/README.md +1 -0
- package/dist/color.d.ts +6 -2
- package/dist/fold.d.ts +6 -3
- package/dist/keymap.d.ts +2 -0
- package/dist/main.min.js +18 -16
- package/dist/mediawiki.d.ts +6 -0
- package/dist/mw.min.js +21 -20
- package/dist/mwConfig.mjs +29 -27
- package/dist/static.d.ts +1 -1
- package/dist/wiki.min.js +21 -19
- package/i18n/en.json +1 -1
- package/i18n/zh-hans.json +1 -1
- package/i18n/zh-hant.json +1 -1
- package/package.json +5 -3
- package/src/static.ts +29 -35
package/i18n/en.json
CHANGED
package/i18n/zh-hans.json
CHANGED
package/i18n/zh-hant.json
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@bhsd/codemirror-mediawiki",
|
|
3
|
-
"version": "2.19.
|
|
3
|
+
"version": "2.19.7",
|
|
4
4
|
"description": "Modified CodeMirror mode based on wikimedia/mediawiki-extensions-CodeMirror",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"mediawiki",
|
|
@@ -34,10 +34,10 @@
|
|
|
34
34
|
"scripts": {
|
|
35
35
|
"prepublishOnly": "npm run build",
|
|
36
36
|
"build:core": "esbuild ./src/codemirror.ts --charset=utf8 --bundle --minify --target=es2019 --format=esm --sourcemap --outfile=dist/main.min.js && esbuild ./src/linter.ts --charset=utf8 --target=es2019 --format=esm --outfile=dist/linter.mjs && tsc --emitDeclarationOnly",
|
|
37
|
-
"build:mw": "esbuild ./mw/base.ts --charset=utf8 --bundle --minify --target=es2019 --format=esm --
|
|
37
|
+
"build:mw": "esbuild ./mw/base.ts --charset=utf8 --bundle --minify --target=es2019 --format=esm --outfile=dist/mw.min.js && esbuild ./mw/config.ts --charset=utf8 --bundle --target=es2019 --format=esm --outfile=dist/mwConfig.mjs",
|
|
38
38
|
"build:wiki": "esbuild ./mw/base.ts --charset=utf8 --bundle --minify --target=es2019 --format=iife --sourcemap --outfile=dist/wiki.min.js",
|
|
39
39
|
"build:gh-page": "bash build.sh",
|
|
40
|
-
"build:test": "tsc --project test/tsconfig.json &&
|
|
40
|
+
"build:test": "tsc --project test/tsconfig.json && mocha",
|
|
41
41
|
"build": "npm run build:core && npm run build:mw && npm run build:wiki && eslint --no-eslintrc -c .eslintrc.dist.cjs dist/*.js",
|
|
42
42
|
"lint:ts": "tsc --noEmit && tsc --project mw/tsconfig.json --noEmit && tsc --project test/tsconfig.json --noEmit && eslint --cache .",
|
|
43
43
|
"lint:css": "stylelint *.css",
|
|
@@ -72,6 +72,7 @@
|
|
|
72
72
|
"@stylistic/stylelint-plugin": "^3.1.1",
|
|
73
73
|
"@types/eslint": "^8.56.10",
|
|
74
74
|
"@types/jquery": "^3.5.32",
|
|
75
|
+
"@types/mocha": "^10.0.10",
|
|
75
76
|
"@types/node": "^22.10.1",
|
|
76
77
|
"@types/oojs-ui": "^0.49.0",
|
|
77
78
|
"@typescript-eslint/eslint-plugin": "^8.16.0",
|
|
@@ -89,6 +90,7 @@
|
|
|
89
90
|
"eslint-plugin-unicorn": "^56.0.1",
|
|
90
91
|
"http-server": "^14.1.0",
|
|
91
92
|
"luacheck-browserify": "^0.2.0",
|
|
93
|
+
"mocha": "^10.8.2",
|
|
92
94
|
"monaco-editor": "^0.52.0",
|
|
93
95
|
"monaco-wiki": "^1.5.0",
|
|
94
96
|
"stylelint": "^16.11.0",
|
package/src/static.ts
CHANGED
|
@@ -26,41 +26,35 @@ export const tagModes = {
|
|
|
26
26
|
graph: 'json',
|
|
27
27
|
};
|
|
28
28
|
|
|
29
|
-
/**
|
|
30
|
-
* Object.fromEntries polyfill
|
|
31
|
-
* @param entries
|
|
32
|
-
* @param obj
|
|
33
|
-
* @param string 是否为字符串
|
|
34
|
-
*/
|
|
35
|
-
const fromEntries = (entries: readonly string[], obj: Record<string, unknown>, string?: boolean): void => {
|
|
36
|
-
for (const entry of entries) {
|
|
37
|
-
obj[entry] = string ? entry : true;
|
|
38
|
-
}
|
|
39
|
-
};
|
|
40
|
-
|
|
41
29
|
export const getStaticMwConfig = (
|
|
42
|
-
{
|
|
30
|
+
{
|
|
31
|
+
parserFunction: [p0, p1, ...p2],
|
|
32
|
+
protocol,
|
|
33
|
+
nsid,
|
|
34
|
+
variants,
|
|
35
|
+
redirection,
|
|
36
|
+
ext,
|
|
37
|
+
doubleUnderscore: [d0, d1, d2],
|
|
38
|
+
img,
|
|
39
|
+
}: Config,
|
|
43
40
|
modes: Record<string, string>,
|
|
44
|
-
): MwConfig => {
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
41
|
+
): MwConfig => ({
|
|
42
|
+
tags: Object.fromEntries(ext.map(s => [s, true])),
|
|
43
|
+
tagModes: modes,
|
|
44
|
+
doubleUnderscore: [
|
|
45
|
+
Object.fromEntries((d2 && d0.length === 0 ? Object.keys(d2) : d0).map(s => [`__${s}__`, true])),
|
|
46
|
+
Object.fromEntries(d1.map(s => [`__${s}__`, true])),
|
|
47
|
+
],
|
|
48
|
+
functionSynonyms: [
|
|
49
|
+
{
|
|
50
|
+
...p0,
|
|
51
|
+
...Object.fromEntries(p2.flat().map(s => [s, s])),
|
|
55
52
|
},
|
|
56
|
-
[
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
fromEntries(parserFunction[1], mwConfig.functionSynonyms[1]);
|
|
65
|
-
return mwConfig;
|
|
66
|
-
};
|
|
53
|
+
Object.fromEntries(p1.map(s => [s, true])),
|
|
54
|
+
],
|
|
55
|
+
urlProtocols: `${protocol}|//`,
|
|
56
|
+
nsid,
|
|
57
|
+
img: Object.fromEntries(Object.entries(img).map(([k, v]) => [k, `img_${v}`])),
|
|
58
|
+
variants,
|
|
59
|
+
redirection,
|
|
60
|
+
});
|