@bhsd/codemirror-mediawiki 3.12.0 → 3.12.1
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/LICENSE +19 -0
- package/dist/bidi.js +9 -8
- package/dist/constants.d.ts +2 -1
- package/dist/constants.js +2 -1
- package/dist/fold.js +4 -1
- package/dist/html.js +2 -2
- package/dist/javascript.d.ts +3 -3
- package/dist/javascript.js +25 -8
- package/dist/lua.d.ts +16 -0
- package/dist/lua.js +57 -1
- package/dist/main.min.js +29 -28
- package/dist/matchBrackets.d.ts +5 -0
- package/dist/matchBrackets.js +38 -15
- package/dist/matchTag.js +5 -5
- package/dist/mw.min.js +30 -29
- package/dist/theme.js +12 -0
- package/dist/token.js +1 -1
- package/dist/util.d.ts +20 -3
- package/dist/util.js +42 -2
- package/dist/vue.js +2 -2
- package/dist/wiki.min.js +30 -29
- package/i18n/en.json +1 -1
- package/i18n/zh-hans.json +1 -1
- package/i18n/zh-hant.json +1 -1
- package/package.json +14 -11
package/dist/theme.js
CHANGED
|
@@ -30,6 +30,12 @@ export const light = /* @__PURE__ */ EditorView.theme({
|
|
|
30
30
|
'.cm-globals, .cm-globals>*': {
|
|
31
31
|
color: '#164',
|
|
32
32
|
},
|
|
33
|
+
'.cm-doctag>*': {
|
|
34
|
+
color: '#219',
|
|
35
|
+
},
|
|
36
|
+
'.cm-doctag-type>*': {
|
|
37
|
+
color: '#085',
|
|
38
|
+
},
|
|
33
39
|
[matching]: {
|
|
34
40
|
backgroundColor: 'rgb(50,140,130,.32)',
|
|
35
41
|
},
|
|
@@ -69,6 +75,12 @@ nord = /* @__PURE__ */ (() => [
|
|
|
69
75
|
'.cm-globals, .cm-globals>*': {
|
|
70
76
|
color: '#d08770',
|
|
71
77
|
},
|
|
78
|
+
'.cm-doctag>*': {
|
|
79
|
+
color: '#81a1c1',
|
|
80
|
+
},
|
|
81
|
+
'.cm-doctag-type>*': {
|
|
82
|
+
color: '#ebcb8b',
|
|
83
|
+
},
|
|
72
84
|
'div.cm-activeLine': {
|
|
73
85
|
backgroundColor: 'rgb(76,86,106,.27)',
|
|
74
86
|
},
|
package/dist/token.js
CHANGED
|
@@ -121,7 +121,7 @@ const copyState = (state) => {
|
|
|
121
121
|
else if (key === 'extState') {
|
|
122
122
|
result[key] = (state.extName && state.extMode && state.extMode.copyState || copyState)(val);
|
|
123
123
|
}
|
|
124
|
-
else if (key !== 'data' && val && typeof val === 'object') {
|
|
124
|
+
else if (key !== 'data' && key !== 'extMode' && val && typeof val === 'object') {
|
|
125
125
|
// @ts-expect-error initial value
|
|
126
126
|
result[key] = { ...val }; // eslint-disable-line @typescript-eslint/no-misused-spread
|
|
127
127
|
}
|
package/dist/util.d.ts
CHANGED
|
@@ -1,8 +1,9 @@
|
|
|
1
|
-
import type { EditorView, TooltipView } from '@codemirror/view';
|
|
2
|
-
import type { Text, EditorState, SelectionRange } from '@codemirror/state';
|
|
1
|
+
import type { EditorView, TooltipView, Decoration } from '@codemirror/view';
|
|
2
|
+
import type { Text, EditorState, SelectionRange, Range } from '@codemirror/state';
|
|
3
3
|
import type { SyntaxNode } from '@lezer/common';
|
|
4
4
|
import type { Position } from 'vscode-languageserver-types';
|
|
5
5
|
import type { ConfigGetter } from '@bhsd/browser';
|
|
6
|
+
import type { DocRange } from './fold';
|
|
6
7
|
/**
|
|
7
8
|
* 转义HTML字符串
|
|
8
9
|
* @param text 原字符串
|
|
@@ -37,12 +38,28 @@ export declare const createTooltipView: (view: EditorView, innerHTML: string) =>
|
|
|
37
38
|
*/
|
|
38
39
|
export declare const sliceDoc: (state: EditorState, node: SyntaxNode | SelectionRange) => string;
|
|
39
40
|
/**
|
|
40
|
-
* Update the stack of opening (+) or closing (-)
|
|
41
|
+
* Update the stack of opening (+) or closing (-) braces
|
|
41
42
|
* @param state
|
|
42
43
|
* @param node 语法树节点
|
|
43
44
|
* @test
|
|
44
45
|
*/
|
|
45
46
|
export declare const braceStackUpdate: (state: EditorState, node: SyntaxNode) => [number, number];
|
|
47
|
+
/**
|
|
48
|
+
* Push a decoration to the array if the range is not empty
|
|
49
|
+
* @param decorations Decoration 数组
|
|
50
|
+
* @param decoration Decoration 实例
|
|
51
|
+
* @param from 起始位置或节点
|
|
52
|
+
* @param to 结束位置
|
|
53
|
+
*/
|
|
54
|
+
export declare const pushDecoration: (decorations: Range<Decoration>[], decoration: Decoration, from: number | DocRange, to?: number) => void;
|
|
55
|
+
/**
|
|
56
|
+
* Mark the type in a JSDoc/LDoc comment
|
|
57
|
+
* @param decorations
|
|
58
|
+
* @param from 起始位置
|
|
59
|
+
* @param mt 正则表达式匹配结果,第1个捕获组为标签,第2个捕获组为类型的起始括号`{`
|
|
60
|
+
* @test
|
|
61
|
+
*/
|
|
62
|
+
export declare const markDocTagType: (decorations: Range<Decoration>[], from: number, mt: RegExpExecArray) => Range<Decoration>[];
|
|
46
63
|
/**
|
|
47
64
|
* Check if the node is a template parameter value
|
|
48
65
|
* @param node 语法树节点
|
package/dist/util.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import elt from 'crelt';
|
|
2
2
|
import { tokens } from './config.js';
|
|
3
|
-
import { hoverSelector, } from './constants.js';
|
|
3
|
+
import { hoverSelector, doctagMark, typeMark, } from './constants.js';
|
|
4
4
|
const dict = { '\n': '<br>', '&': '&', '<': '<' };
|
|
5
5
|
/**
|
|
6
6
|
* 转义HTML字符串
|
|
@@ -47,7 +47,7 @@ export const createTooltipView = (view, innerHTML) => {
|
|
|
47
47
|
*/
|
|
48
48
|
export const sliceDoc = (state, node) => state.sliceDoc(node.from, node.to);
|
|
49
49
|
/**
|
|
50
|
-
* Update the stack of opening (+) or closing (-)
|
|
50
|
+
* Update the stack of opening (+) or closing (-) braces
|
|
51
51
|
* @param state
|
|
52
52
|
* @param node 语法树节点
|
|
53
53
|
* @test
|
|
@@ -56,6 +56,46 @@ export const braceStackUpdate = (state, node) => {
|
|
|
56
56
|
const brackets = sliceDoc(state, node);
|
|
57
57
|
return [brackets.split('{{').length - 1, 1 - brackets.split('}}').length];
|
|
58
58
|
};
|
|
59
|
+
/**
|
|
60
|
+
* Push a decoration to the array if the range is not empty
|
|
61
|
+
* @param decorations Decoration 数组
|
|
62
|
+
* @param decoration Decoration 实例
|
|
63
|
+
* @param from 起始位置或节点
|
|
64
|
+
* @param to 结束位置
|
|
65
|
+
*/
|
|
66
|
+
export const pushDecoration = (decorations, decoration, from, to) => {
|
|
67
|
+
if (typeof from !== 'number') {
|
|
68
|
+
({ from, to } = from);
|
|
69
|
+
}
|
|
70
|
+
if (from < to) {
|
|
71
|
+
decorations.push(decoration.range(from, to));
|
|
72
|
+
}
|
|
73
|
+
};
|
|
74
|
+
/**
|
|
75
|
+
* Mark the type in a JSDoc/LDoc comment
|
|
76
|
+
* @param decorations
|
|
77
|
+
* @param from 起始位置
|
|
78
|
+
* @param mt 正则表达式匹配结果,第1个捕获组为标签,第2个捕获组为类型的起始括号`{`
|
|
79
|
+
* @test
|
|
80
|
+
*/
|
|
81
|
+
export const markDocTagType = (decorations, from, mt) => {
|
|
82
|
+
const { input, indices } = mt, [start, end] = indices[1];
|
|
83
|
+
pushDecoration(decorations, doctagMark, from + start, from + end);
|
|
84
|
+
if (mt[2]) {
|
|
85
|
+
const re = /[{}]/gu, [, left] = indices[2];
|
|
86
|
+
re.lastIndex = left;
|
|
87
|
+
let m = re.exec(input), balance = 1;
|
|
88
|
+
while (m) {
|
|
89
|
+
balance += m[0] === '{' ? 1 : -1;
|
|
90
|
+
if (balance === 0) {
|
|
91
|
+
pushDecoration(decorations, typeMark, from + left, from + m.index);
|
|
92
|
+
break;
|
|
93
|
+
}
|
|
94
|
+
m = re.exec(input);
|
|
95
|
+
}
|
|
96
|
+
}
|
|
97
|
+
return decorations;
|
|
98
|
+
};
|
|
59
99
|
/**
|
|
60
100
|
* Check if the node is a template parameter value
|
|
61
101
|
* @param node 语法树节点
|
package/dist/vue.js
CHANGED
|
@@ -3,13 +3,13 @@ import { htmlLanguage, htmlCompletionSource } from '@codemirror/lang-html';
|
|
|
3
3
|
import { javascript } from '@codemirror/lang-javascript';
|
|
4
4
|
import { LanguageSupport } from '@codemirror/language';
|
|
5
5
|
import { cssCompletion } from './css.js';
|
|
6
|
-
import { jsCompletion,
|
|
6
|
+
import { jsCompletion, markGlobalsAndDocTagPlugin } from './javascript.js';
|
|
7
7
|
export default (_, cm) => vue({
|
|
8
8
|
base: new LanguageSupport(htmlLanguage, [
|
|
9
9
|
htmlLanguage.data.of({ autocomplete: htmlCompletionSource }),
|
|
10
10
|
javascript().support,
|
|
11
11
|
jsCompletion,
|
|
12
12
|
cssCompletion(),
|
|
13
|
-
|
|
13
|
+
markGlobalsAndDocTagPlugin(cm),
|
|
14
14
|
]),
|
|
15
15
|
});
|