@bhsd/codemirror-mediawiki 3.10.0 → 3.10.2
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 +78 -78
- package/dist/bidi.d.ts +5 -0
- package/dist/bidi.js +5 -0
- package/dist/codemirror.d.ts +7 -0
- package/dist/codemirror.js +10 -3
- package/dist/color.d.ts +7 -4
- package/dist/color.js +4 -0
- package/dist/css.d.ts +5 -0
- package/dist/css.js +5 -0
- package/dist/escape.d.ts +21 -1
- package/dist/escape.js +42 -24
- package/dist/fold.d.ts +55 -3
- package/dist/fold.js +54 -30
- package/dist/hover.d.ts +14 -1
- package/dist/hover.js +49 -31
- package/dist/html.js +17 -12
- package/dist/indent.d.ts +7 -0
- package/dist/indent.js +7 -1
- package/dist/inlay.js +1 -1
- package/dist/javascript.d.ts +10 -1
- package/dist/javascript.js +6 -1
- package/dist/keybindings.d.ts +1 -0
- package/dist/keybindings.js +1 -0
- package/dist/keymap.d.ts +11 -0
- package/dist/keymap.js +3 -4
- package/dist/linter.d.ts +16 -0
- package/dist/linter.js +8 -1
- package/dist/lintsource.d.ts +36 -4
- package/dist/lintsource.js +37 -4
- package/dist/lua.js +31 -20
- package/dist/main.min.js +29 -29
- package/dist/matchBrackets.d.ts +16 -0
- package/dist/matchBrackets.js +16 -0
- package/dist/matchTag.d.ts +5 -2
- package/dist/matchTag.js +7 -4
- package/dist/mediawiki.d.ts +11 -0
- package/dist/mediawiki.js +8 -4
- package/dist/mw.min.js +31 -31
- package/dist/mwConfig.js +1 -1
- package/dist/openLinks.d.ts +8 -0
- package/dist/openLinks.js +8 -0
- package/dist/ref.d.ts +15 -1
- package/dist/ref.js +81 -65
- package/dist/signature.d.ts +6 -0
- package/dist/signature.js +22 -19
- package/dist/static.d.ts +4 -0
- package/dist/static.js +4 -0
- package/dist/theme.d.ts +1 -0
- package/dist/theme.js +3 -1
- package/dist/token.d.ts +9 -1
- package/dist/token.js +12 -6
- package/dist/util.d.ts +8 -0
- package/dist/util.js +8 -0
- package/dist/wiki.min.js +30 -30
- package/i18n/en.json +1 -1
- package/i18n/zh-hans.json +1 -1
- package/i18n/zh-hant.json +1 -1
- package/package.json +22 -22
package/dist/matchBrackets.d.ts
CHANGED
|
@@ -5,9 +5,25 @@ export interface Selection {
|
|
|
5
5
|
anchor: number;
|
|
6
6
|
head: number;
|
|
7
7
|
}
|
|
8
|
+
/**
|
|
9
|
+
* @ignore
|
|
10
|
+
* @test
|
|
11
|
+
*/
|
|
8
12
|
export declare const findEnclosingBrackets: (node: SyntaxNode, pos: number, brackets: string) => MatchResult | undefined;
|
|
13
|
+
/**
|
|
14
|
+
* @ignore
|
|
15
|
+
* @test
|
|
16
|
+
*/
|
|
9
17
|
export declare const findEnclosingPlainBrackets: (state: EditorState, pos: number, config: Required<Config>) => MatchResult | null;
|
|
18
|
+
/**
|
|
19
|
+
* @ignore
|
|
20
|
+
* @test
|
|
21
|
+
*/
|
|
10
22
|
export declare const trySelectMatchingBrackets: (state: EditorState, pos: number, dir: 1 | -1, config?: Config, inside?: boolean) => Selection | false;
|
|
23
|
+
/**
|
|
24
|
+
* @ignore
|
|
25
|
+
* @test
|
|
26
|
+
*/
|
|
11
27
|
export declare const selectMatchingBrackets: (state: EditorState, pos: number, config?: Config) => Selection | false;
|
|
12
28
|
declare const _default: (configs?: Config) => Extension;
|
|
13
29
|
export default _default;
|
package/dist/matchBrackets.js
CHANGED
|
@@ -1,5 +1,9 @@
|
|
|
1
1
|
import { Decoration, EditorView } from '@codemirror/view';
|
|
2
2
|
import { bracketMatching, matchBrackets, syntaxTree } from '@codemirror/language';
|
|
3
|
+
/**
|
|
4
|
+
* @ignore
|
|
5
|
+
* @test
|
|
6
|
+
*/
|
|
3
7
|
export const findEnclosingBrackets = (node, pos, brackets) => {
|
|
4
8
|
let parent = node;
|
|
5
9
|
while (parent) {
|
|
@@ -14,6 +18,10 @@ export const findEnclosingBrackets = (node, pos, brackets) => {
|
|
|
14
18
|
}
|
|
15
19
|
return undefined;
|
|
16
20
|
};
|
|
21
|
+
/**
|
|
22
|
+
* @ignore
|
|
23
|
+
* @test
|
|
24
|
+
*/
|
|
17
25
|
export const findEnclosingPlainBrackets = (state, pos, config) => {
|
|
18
26
|
const { brackets, maxScanDistance } = config, re = new RegExp(`[${[...brackets].filter((_, i) => i % 2).map(c => c === ']' ? String.raw `\]` : c).join('')}]`, 'gu'), str = state.sliceDoc(pos, pos + maxScanDistance);
|
|
19
27
|
let mt = re.exec(str);
|
|
@@ -26,6 +34,10 @@ export const findEnclosingPlainBrackets = (state, pos, config) => {
|
|
|
26
34
|
}
|
|
27
35
|
return null;
|
|
28
36
|
};
|
|
37
|
+
/**
|
|
38
|
+
* @ignore
|
|
39
|
+
* @test
|
|
40
|
+
*/
|
|
29
41
|
export const trySelectMatchingBrackets = (state, pos, dir, config, inside = false) => {
|
|
30
42
|
if (pos < 0) {
|
|
31
43
|
return false;
|
|
@@ -36,6 +48,10 @@ export const trySelectMatchingBrackets = (state, pos, dir, config, inside = fals
|
|
|
36
48
|
head: match.end[rightInside ? 'from' : 'to'],
|
|
37
49
|
};
|
|
38
50
|
};
|
|
51
|
+
/**
|
|
52
|
+
* @ignore
|
|
53
|
+
* @test
|
|
54
|
+
*/
|
|
39
55
|
export const selectMatchingBrackets = (state, pos, config) => trySelectMatchingBrackets(state, pos, -1, config)
|
|
40
56
|
|| trySelectMatchingBrackets(state, pos, 1, config)
|
|
41
57
|
|| trySelectMatchingBrackets(state, pos + 1, -1, config, true)
|
package/dist/matchTag.d.ts
CHANGED
|
@@ -4,11 +4,12 @@ import type { EditorState } from '@codemirror/state';
|
|
|
4
4
|
import type { MatchResult } from '@codemirror/language';
|
|
5
5
|
import type { SyntaxNode } from '@lezer/common';
|
|
6
6
|
declare type TagType = 'ext' | 'html';
|
|
7
|
-
|
|
7
|
+
export interface TagMatchResult extends MatchResult {
|
|
8
8
|
start: Tag;
|
|
9
9
|
end?: Tag;
|
|
10
10
|
}
|
|
11
|
-
|
|
11
|
+
/** @test */
|
|
12
|
+
export declare class Tag {
|
|
12
13
|
readonly type: TagType;
|
|
13
14
|
readonly name: string;
|
|
14
15
|
readonly first: SyntaxNode;
|
|
@@ -24,12 +25,14 @@ declare class Tag {
|
|
|
24
25
|
* 获取标签信息,破损的HTML标签会返回`null`
|
|
25
26
|
* @param state
|
|
26
27
|
* @param node 语法树节点
|
|
28
|
+
* @test
|
|
27
29
|
*/
|
|
28
30
|
export declare const getTag: (state: EditorState, node: SyntaxNode) => Tag | null;
|
|
29
31
|
/**
|
|
30
32
|
* 匹配标签
|
|
31
33
|
* @param state
|
|
32
34
|
* @param pos 位置
|
|
35
|
+
* @test
|
|
33
36
|
*/
|
|
34
37
|
export declare const matchTag: (state: EditorState, pos: number) => TagMatchResult | null;
|
|
35
38
|
declare const _default: StateField<DecorationSet>;
|
package/dist/matchTag.js
CHANGED
|
@@ -4,7 +4,8 @@ import { ensureSyntaxTree } from '@codemirror/language';
|
|
|
4
4
|
import { voidHtmlTags, selfClosingTags } from './config.js';
|
|
5
5
|
import { matchingCls, nonmatchingCls } from './constants.js';
|
|
6
6
|
import { sliceDoc } from './util.js';
|
|
7
|
-
|
|
7
|
+
/** @test */
|
|
8
|
+
export class Tag {
|
|
8
9
|
get closing() {
|
|
9
10
|
return isClosing(this.first, this.type, this.state, true);
|
|
10
11
|
}
|
|
@@ -38,8 +39,12 @@ const isTag = ({ name }) => /-(?:ext|html)tag-(?!bracket)/u.test(name), isTagCom
|
|
|
38
39
|
* 获取标签信息,破损的HTML标签会返回`null`
|
|
39
40
|
* @param state
|
|
40
41
|
* @param node 语法树节点
|
|
42
|
+
* @test
|
|
41
43
|
*/
|
|
42
44
|
export const getTag = (state, node) => {
|
|
45
|
+
if (!isTag(node)) {
|
|
46
|
+
return null;
|
|
47
|
+
}
|
|
43
48
|
const type = node.name.includes('exttag') ? 'ext' : 'html';
|
|
44
49
|
let { nextSibling, prevSibling } = node, nameNode = isName(node, type) ? node : null;
|
|
45
50
|
while (nextSibling && !isBracket(nextSibling, type)) {
|
|
@@ -88,6 +93,7 @@ const searchTag = (state, origin) => {
|
|
|
88
93
|
* 匹配标签
|
|
89
94
|
* @param state
|
|
90
95
|
* @param pos 位置
|
|
96
|
+
* @test
|
|
91
97
|
*/
|
|
92
98
|
export const matchTag = (state, pos) => {
|
|
93
99
|
const tree = ensureSyntaxTree(state, pos);
|
|
@@ -97,9 +103,6 @@ export const matchTag = (state, pos) => {
|
|
|
97
103
|
let node = tree.resolveInner(pos, -1);
|
|
98
104
|
if (!isTag(node)) {
|
|
99
105
|
node = tree.resolveInner(pos, 1);
|
|
100
|
-
if (!isTag(node)) {
|
|
101
|
-
return null;
|
|
102
|
-
}
|
|
103
106
|
}
|
|
104
107
|
const start = getTag(state, node);
|
|
105
108
|
if (!start) {
|
package/dist/mediawiki.d.ts
CHANGED
|
@@ -4,6 +4,7 @@
|
|
|
4
4
|
* @see https://gerrit.wikimedia.org/g/mediawiki/extensions/CodeMirror
|
|
5
5
|
*/
|
|
6
6
|
import { LanguageSupport } from '@codemirror/language';
|
|
7
|
+
import { EditorView } from '@codemirror/view';
|
|
7
8
|
import { MediaWiki } from './token.js';
|
|
8
9
|
import type { StreamParser, TagStyle } from '@codemirror/language';
|
|
9
10
|
import type { CompletionSource, Completion } from '@codemirror/autocomplete';
|
|
@@ -13,6 +14,16 @@ import type { MwConfig } from './token';
|
|
|
13
14
|
* @param name 节点名称
|
|
14
15
|
*/
|
|
15
16
|
export declare const isWikiLink: (name: string) => boolean;
|
|
17
|
+
/**
|
|
18
|
+
* 检查首字母大小写并插入正确的自动填充内容
|
|
19
|
+
* @param view
|
|
20
|
+
* @param completion 自动填充内容
|
|
21
|
+
* @param from 起始位置
|
|
22
|
+
* @param to 结束位置
|
|
23
|
+
* @test
|
|
24
|
+
*/
|
|
25
|
+
export declare const apply: (view: EditorView, completion: Completion, from: number, to: number) => void;
|
|
26
|
+
/** @test */
|
|
16
27
|
export declare class FullMediaWiki extends MediaWiki {
|
|
17
28
|
#private;
|
|
18
29
|
readonly templatedata: boolean;
|
package/dist/mediawiki.js
CHANGED
|
@@ -24,8 +24,9 @@ export const isWikiLink = (name) => /mw-[\w-]*link-ground/u.test(name);
|
|
|
24
24
|
* @param completion 自动填充内容
|
|
25
25
|
* @param from 起始位置
|
|
26
26
|
* @param to 结束位置
|
|
27
|
+
* @test
|
|
27
28
|
*/
|
|
28
|
-
const apply = (view, completion, from, to) => {
|
|
29
|
+
export const apply = (view, completion, from, to) => {
|
|
29
30
|
let { label } = completion, selection;
|
|
30
31
|
const initial = label.charAt(0).toLowerCase(), { state } = view, after = state.sliceDoc(to);
|
|
31
32
|
if (state.sliceDoc(from, from + 1) === initial) {
|
|
@@ -41,6 +42,7 @@ const apply = (view, completion, from, to) => {
|
|
|
41
42
|
selection,
|
|
42
43
|
});
|
|
43
44
|
};
|
|
45
|
+
/** @test */
|
|
44
46
|
export class FullMediaWiki extends MediaWiki {
|
|
45
47
|
constructor(config, templatedata = false) {
|
|
46
48
|
super(config);
|
|
@@ -152,7 +154,7 @@ export class FullMediaWiki extends MediaWiki {
|
|
|
152
154
|
* @param equal 是否有等号
|
|
153
155
|
*/
|
|
154
156
|
async #paramSuggest(search, page, equal) {
|
|
155
|
-
const {
|
|
157
|
+
const { paramSuggest } = this.config, result = await paramSuggest?.(page);
|
|
156
158
|
return result?.length
|
|
157
159
|
? {
|
|
158
160
|
offset: leadingSpaces(search).length,
|
|
@@ -506,12 +508,14 @@ const theme = /* @__PURE__ */ EditorView.theme({
|
|
|
506
508
|
backgroundColor: 'var(--cm-ref)',
|
|
507
509
|
},
|
|
508
510
|
// hover tooltip and signature tooltip
|
|
511
|
+
'.cm-tooltip-hover': {
|
|
512
|
+
maxHeight: '60vh',
|
|
513
|
+
overflow: 'hidden auto',
|
|
514
|
+
},
|
|
509
515
|
[hoverSelector]: {
|
|
510
516
|
padding: '2px 5px',
|
|
511
517
|
width: 'max-content',
|
|
512
518
|
maxWidth: '60vw',
|
|
513
|
-
maxHeight: '60vh',
|
|
514
|
-
overflowY: 'auto',
|
|
515
519
|
},
|
|
516
520
|
[`${hoverSelector} *`]: {
|
|
517
521
|
marginTop: '0!important',
|