@bhsd/codemirror-mediawiki 3.6.1 → 3.6.3
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/escape.js +0 -1
- package/dist/fold.d.ts +1 -1
- package/dist/fold.js +16 -5
- package/dist/linter.d.ts +1 -1
- package/dist/linter.js +2 -3
- package/dist/lua.js +1 -7
- package/dist/main.min.js +26 -26
- package/dist/matchBrackets.js +2 -4
- package/dist/mediawiki.d.ts +5 -0
- package/dist/mediawiki.js +23 -13
- package/dist/mw.min.js +27 -27
- package/dist/statusBar.js +0 -1
- package/dist/theme.js +2 -0
- package/dist/token.js +17 -30
- package/dist/wiki.min.js +27 -27
- package/i18n/en.json +1 -1
- package/i18n/zh-hans.json +1 -1
- package/i18n/zh-hant.json +1 -1
- package/package.json +25 -25
package/dist/statusBar.js
CHANGED
|
@@ -83,7 +83,6 @@ const updateMenu = (cm, allDiagnostics, main, classList, optionAll, menu, fixer)
|
|
|
83
83
|
menu.replaceChildren(...actions, ...quickfix);
|
|
84
84
|
}
|
|
85
85
|
};
|
|
86
|
-
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
87
86
|
export default (cm, fixer) => [
|
|
88
87
|
showPanel.of(view => {
|
|
89
88
|
let diagnostics = [], menu;
|
package/dist/theme.js
CHANGED
|
@@ -23,6 +23,7 @@ export const light = /* @__PURE__ */ EditorView.theme({
|
|
|
23
23
|
'--cm-tpl': '#80c',
|
|
24
24
|
'--cm-var': '#ad9300',
|
|
25
25
|
'--cm-var-name': '#ac6600',
|
|
26
|
+
'--cm-ref': 'rgb(223,242,235,.5)',
|
|
26
27
|
},
|
|
27
28
|
[matching]: {
|
|
28
29
|
backgroundColor: 'rgb(50,140,130,.32)',
|
|
@@ -71,6 +72,7 @@ nord = /* @__PURE__ */ (() => [
|
|
|
71
72
|
'--cm-tpl': '#9f78a5',
|
|
72
73
|
'--cm-var': '#d08770',
|
|
73
74
|
'--cm-var-name': '#d08770',
|
|
75
|
+
'--cm-ref': 'rgb(60,90,80,0.5)',
|
|
74
76
|
},
|
|
75
77
|
'div.cm-activeLine': {
|
|
76
78
|
backgroundColor: 'rgb(76,86,106,.27)',
|
package/dist/token.js
CHANGED
|
@@ -1,8 +1,3 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* @author pastakhov, MusikAnimal, Bhsd and others
|
|
3
|
-
* @license GPL-2.0-or-later
|
|
4
|
-
* @see https://gerrit.wikimedia.org/g/mediawiki/extensions/CodeMirror
|
|
5
|
-
*/
|
|
6
1
|
var __runInitializers = (this && this.__runInitializers) || function (thisArg, initializers, value) {
|
|
7
2
|
var useValue = arguments.length > 2;
|
|
8
3
|
for (var i = 0; i < initializers.length; i++) {
|
|
@@ -37,6 +32,12 @@ var __esDecorate = (this && this.__esDecorate) || function (ctor, descriptorIn,
|
|
|
37
32
|
if (target) Object.defineProperty(target, contextIn.name, descriptor);
|
|
38
33
|
done = true;
|
|
39
34
|
};
|
|
35
|
+
/**
|
|
36
|
+
* @author pastakhov, MusikAnimal, Bhsd and others
|
|
37
|
+
* @license GPL-2.0-or-later
|
|
38
|
+
* @see https://gerrit.wikimedia.org/g/mediawiki/extensions/CodeMirror
|
|
39
|
+
*/
|
|
40
|
+
/* eslint-disable @typescript-eslint/class-methods-use-this */
|
|
40
41
|
import { Tag } from '@lezer/highlight';
|
|
41
42
|
import { getRegex } from '@bhsd/common';
|
|
42
43
|
import { decodeHTML } from '@bhsd/browser';
|
|
@@ -120,7 +121,7 @@ const copyState = (state) => {
|
|
|
120
121
|
}
|
|
121
122
|
else if (key !== 'data' && val && typeof val === 'object') {
|
|
122
123
|
// @ts-expect-error initial value
|
|
123
|
-
result[key] = { ...val };
|
|
124
|
+
result[key] = { ...val };
|
|
124
125
|
}
|
|
125
126
|
}
|
|
126
127
|
return result;
|
|
@@ -129,9 +130,7 @@ const copyState = (state) => {
|
|
|
129
130
|
* 判断字符串是否为 HTML 实体
|
|
130
131
|
* @param str 字符串
|
|
131
132
|
*/
|
|
132
|
-
const isHtmlEntity = (str) =>
|
|
133
|
-
// eslint-disable-next-line @typescript-eslint/no-misused-spread
|
|
134
|
-
typeof document !== 'object' || str.startsWith('#') || [...decodeHTML(`&${str}`)].length === 1;
|
|
133
|
+
const isHtmlEntity = (str) => typeof document !== 'object' || str.startsWith('#') || [...decodeHTML(`&${str}`)].length === 1;
|
|
135
134
|
/**
|
|
136
135
|
* 更新内部 Tokenizer
|
|
137
136
|
* @param state
|
|
@@ -180,7 +179,6 @@ const lookahead = (chars, comment) => {
|
|
|
180
179
|
const { data: { tags } } = comment;
|
|
181
180
|
table['<'] = String.raw `<(?!!--${tags.includes('onlyinclude') ? '|onlyinclude>' : ''}|(?:${tags.filter(tag => tag !== 'onlyinclude').join('|')})(?:[\s/>]|$))`;
|
|
182
181
|
}
|
|
183
|
-
// eslint-disable-next-line @typescript-eslint/no-misused-spread
|
|
184
182
|
return [...chars].map(ch => table[ch]).join('|');
|
|
185
183
|
};
|
|
186
184
|
/**
|
|
@@ -383,12 +381,8 @@ let MediaWiki = (() => {
|
|
|
383
381
|
return class MediaWiki {
|
|
384
382
|
static {
|
|
385
383
|
const _metadata = typeof Symbol === "function" && Symbol.metadata ? Object.create(null) : void 0;
|
|
386
|
-
_inChars_decorators = [(getTokenizer)
|
|
387
|
-
|
|
388
|
-
];
|
|
389
|
-
_inStr_decorators = [(getTokenizer)
|
|
390
|
-
// eslint-disable-next-line @typescript-eslint/class-methods-use-this
|
|
391
|
-
];
|
|
384
|
+
_inChars_decorators = [(getTokenizer)];
|
|
385
|
+
_inStr_decorators = [(getTokenizer)];
|
|
392
386
|
_eatWikiText_decorators = [getTokenizer];
|
|
393
387
|
_eatApostrophes_decorators = [getTokenizer];
|
|
394
388
|
_eatExternalLinkProtocol_decorators = [(getTokenizer)];
|
|
@@ -405,9 +399,7 @@ let MediaWiki = (() => {
|
|
|
405
399
|
_inHtmlTagAttribute_decorators = [getTokenizer];
|
|
406
400
|
_inExtTagAttribute_decorators = [(getTokenizer)];
|
|
407
401
|
_eatExtTagArea_decorators = [(getTokenizer)];
|
|
408
|
-
_inExtTokens_decorators = [(getTokenizer)
|
|
409
|
-
// eslint-disable-next-line @typescript-eslint/class-methods-use-this
|
|
410
|
-
];
|
|
402
|
+
_inExtTokens_decorators = [(getTokenizer)];
|
|
411
403
|
_inVariable_decorators = [getTokenizer];
|
|
412
404
|
_inSubst_decorators = [(getTokenizer)];
|
|
413
405
|
_inParserFunctionName_decorators = [(getTokenizer)];
|
|
@@ -501,7 +493,6 @@ let MediaWiki = (() => {
|
|
|
501
493
|
* @param parent
|
|
502
494
|
*/
|
|
503
495
|
addToken(token, hidden = false, parent) {
|
|
504
|
-
// eslint-disable-next-line @typescript-eslint/no-unnecessary-condition
|
|
505
496
|
this[hidden ? 'hiddenTable' : 'tokenTable'][`mw-${token}`] ??= Tag.define(parent);
|
|
506
497
|
}
|
|
507
498
|
/**
|
|
@@ -550,13 +541,13 @@ let MediaWiki = (() => {
|
|
|
550
541
|
this.addToken(`section--${i}`);
|
|
551
542
|
}
|
|
552
543
|
for (const tag of this.tags) {
|
|
553
|
-
this.addToken(`tag-${tag}`, tag !== 'nowiki' && tag !== 'pre');
|
|
544
|
+
this.addToken(`tag-${tag}`, tag !== 'nowiki' && tag !== 'pre' && tag !== 'ref');
|
|
554
545
|
this.addToken(`ext-${tag}`, true);
|
|
555
546
|
}
|
|
556
547
|
for (const tag of this.permittedHtmlTags) {
|
|
557
548
|
this.addToken(`html-${tag}`, true);
|
|
558
549
|
}
|
|
559
|
-
for (const i
|
|
550
|
+
for (const i of Object.keys(this.autocompleteNamespaces)) {
|
|
560
551
|
if (Number.isInteger(Number(i))) {
|
|
561
552
|
this.addToken(`function-${i}`, true);
|
|
562
553
|
}
|
|
@@ -583,7 +574,7 @@ let MediaWiki = (() => {
|
|
|
583
574
|
}
|
|
584
575
|
eatWikiText(style) {
|
|
585
576
|
if (style in tokens) {
|
|
586
|
-
style = tokens[style];
|
|
577
|
+
style = tokens[style];
|
|
587
578
|
}
|
|
588
579
|
const regex = /^(?:(?:RFC|PMID)[\p{Zs}\t]+\d+|ISBN[\p{Zs}\t]+(?:97[89][\p{Zs}\t-]?)?(?:\d[\p{Zs}\t-]?){9}[\dxX])\b/u;
|
|
589
580
|
return (stream, state) => {
|
|
@@ -661,7 +652,6 @@ let MediaWiki = (() => {
|
|
|
661
652
|
}
|
|
662
653
|
else if (ch === ' '
|
|
663
654
|
&& !/^ \s*(?=<!--)(?:\s|<!--(?:(?!-->).)*-->)+$/u.test(stream.string)) {
|
|
664
|
-
/** @todo indent-pre is sometimes suppressed */
|
|
665
655
|
return tokens.skipFormatting;
|
|
666
656
|
}
|
|
667
657
|
}
|
|
@@ -852,7 +842,6 @@ let MediaWiki = (() => {
|
|
|
852
842
|
return '';
|
|
853
843
|
};
|
|
854
844
|
}
|
|
855
|
-
// eslint-disable-next-line @typescript-eslint/class-methods-use-this
|
|
856
845
|
eatFreeExternalLink(stream, state) {
|
|
857
846
|
const mt = stream.match(freeRegex[0]);
|
|
858
847
|
if (!stream.eol() && mt[0].includes('(') && getPunctuations().includes(stream.peek())) {
|
|
@@ -974,7 +963,6 @@ let MediaWiki = (() => {
|
|
|
974
963
|
chain(state, this.inChars(mt[0], 'imageParameter'));
|
|
975
964
|
}
|
|
976
965
|
}
|
|
977
|
-
// eslint-disable-next-line @typescript-eslint/class-methods-use-this
|
|
978
966
|
eatList(stream, state) {
|
|
979
967
|
const mt = stream.match(/^[*#;:]*/u), { dt } = state;
|
|
980
968
|
if (mt[0].includes(';')) {
|
|
@@ -1165,8 +1153,8 @@ let MediaWiki = (() => {
|
|
|
1165
1153
|
if (dt.n && dt.html) {
|
|
1166
1154
|
dt.html--;
|
|
1167
1155
|
}
|
|
1168
|
-
if (tagname === inHtmlTag[
|
|
1169
|
-
inHtmlTag.
|
|
1156
|
+
if (tagname === inHtmlTag[inHtmlTag.length - 1]) {
|
|
1157
|
+
inHtmlTag.pop();
|
|
1170
1158
|
}
|
|
1171
1159
|
else {
|
|
1172
1160
|
chain(state, this.inStr('>', 'error'));
|
|
@@ -1207,7 +1195,7 @@ let MediaWiki = (() => {
|
|
|
1207
1195
|
const mt = stream.match(/^\/?>/u);
|
|
1208
1196
|
if (mt) {
|
|
1209
1197
|
if (!this.voidHtmlTags.has(name) && (mt[0] === '>' || !selfClosingTags.includes(name))) {
|
|
1210
|
-
state.inHtmlTag.
|
|
1198
|
+
state.inHtmlTag.push(name);
|
|
1211
1199
|
state.dt.html++;
|
|
1212
1200
|
}
|
|
1213
1201
|
pop(state);
|
|
@@ -1696,7 +1684,6 @@ let MediaWiki = (() => {
|
|
|
1696
1684
|
: this.eatWikiText(style)(stream, state);
|
|
1697
1685
|
};
|
|
1698
1686
|
}
|
|
1699
|
-
// eslint-disable-next-line @typescript-eslint/class-methods-use-this
|
|
1700
1687
|
eatEntity(stream, style) {
|
|
1701
1688
|
const entity = stream.match(/^(?:#x[a-f\d]+|#\d+|[a-z\d]+);/iu);
|
|
1702
1689
|
return entity && isHtmlEntity(entity[0]) ? tokens.htmlEntity : style;
|