@bhsd/codemirror-mediawiki 3.5.1 → 3.6.0
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 -1
- package/dist/bidi.js +5 -4
- package/dist/codemirror.d.ts +3 -3
- package/dist/codemirror.js +22 -7
- package/dist/constants.d.ts +1 -0
- package/dist/constants.js +9 -0
- package/dist/escape.js +3 -5
- package/dist/fold.d.ts +0 -6
- package/dist/fold.js +17 -28
- package/dist/hover.d.ts +1 -22
- package/dist/hover.js +32 -39
- package/dist/html.js +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.js +11 -11
- package/dist/inlay.js +5 -6
- package/dist/lintsource.js +4 -2
- package/dist/lua.js +4 -0
- package/dist/main.min.js +28 -27
- package/dist/matchTag.js +2 -1
- package/dist/mediawiki.d.ts +0 -7
- package/dist/mediawiki.js +11 -18
- package/dist/mw.min.js +31 -30
- package/dist/mwConfig.js +22 -4
- package/dist/openLinks.d.ts +0 -1
- package/dist/openLinks.js +6 -10
- package/dist/ref.js +26 -9
- package/dist/signature.js +1 -1
- package/dist/static.js +3 -2
- package/dist/statusBar.js +26 -42
- package/dist/theme.js +51 -52
- package/dist/token.d.ts +6 -4
- package/dist/token.js +18 -13
- package/dist/util.d.ts +39 -0
- package/dist/util.js +53 -0
- package/dist/vue.js +1 -1
- package/dist/wiki.min.js +30 -29
- package/i18n/en.json +2 -2
- package/i18n/zh-hans.json +2 -2
- package/i18n/zh-hant.json +2 -2
- package/package.json +8 -11
package/dist/matchTag.js
CHANGED
|
@@ -2,6 +2,7 @@ import { Decoration, EditorView } from '@codemirror/view';
|
|
|
2
2
|
import { StateField } from '@codemirror/state';
|
|
3
3
|
import { ensureSyntaxTree } from '@codemirror/language';
|
|
4
4
|
import { voidHtmlTags, selfClosingTags } from './config';
|
|
5
|
+
import { matchingCls, nonmatchingCls } from './constants';
|
|
5
6
|
class Tag {
|
|
6
7
|
get closing() {
|
|
7
8
|
return isClosing(this.first, this.type, this.state, true);
|
|
@@ -109,7 +110,7 @@ export const matchTag = (state, pos) => {
|
|
|
109
110
|
const end = searchTag(state, start);
|
|
110
111
|
return end ? { matched: true, start, end } : { matched: false, start };
|
|
111
112
|
};
|
|
112
|
-
const matchingMark = /* @__PURE__ */ Decoration.mark({ class:
|
|
113
|
+
const matchingMark = /* @__PURE__ */ Decoration.mark({ class: matchingCls }), nonmatchingMark = /* @__PURE__ */ Decoration.mark({ class: nonmatchingCls });
|
|
113
114
|
export default /* @__PURE__ */ StateField.define({
|
|
114
115
|
create() {
|
|
115
116
|
return Decoration.none;
|
package/dist/mediawiki.d.ts
CHANGED
|
@@ -8,13 +8,6 @@ import { MediaWiki } from './token';
|
|
|
8
8
|
import type { StreamParser, TagStyle } from '@codemirror/language';
|
|
9
9
|
import type { CompletionSource, Completion } from '@codemirror/autocomplete';
|
|
10
10
|
import type { MwConfig } from './token';
|
|
11
|
-
export declare const isWMF: boolean;
|
|
12
|
-
/**
|
|
13
|
-
* 判断节点是否包含指定类型
|
|
14
|
-
* @param types 节点类型
|
|
15
|
-
* @param names 指定类型
|
|
16
|
-
*/
|
|
17
|
-
export declare const hasTag: (types: Set<string>, names: string | string[]) => boolean;
|
|
18
11
|
export declare class FullMediaWiki extends MediaWiki {
|
|
19
12
|
#private;
|
|
20
13
|
readonly nsRegex: RegExp;
|
package/dist/mediawiki.js
CHANGED
|
@@ -5,13 +5,13 @@
|
|
|
5
5
|
*/
|
|
6
6
|
import { HighlightStyle, LanguageSupport, StreamLanguage, syntaxHighlighting, syntaxTree, } from '@codemirror/language';
|
|
7
7
|
import { insertCompletionText, pickedCompletion } from '@codemirror/autocomplete';
|
|
8
|
-
import {
|
|
8
|
+
import { isUnderscore } from '@bhsd/cm-util';
|
|
9
9
|
import { commonHtmlAttrs, htmlAttrs, extAttrs } from 'wikiparser-node/dist/util/sharable.mjs';
|
|
10
|
-
import { MediaWiki } from './token';
|
|
11
10
|
import { htmlTags, tokens } from './config';
|
|
12
|
-
import {
|
|
11
|
+
import { isolateSelector, ltrSelector, isWMF } from './constants';
|
|
12
|
+
import { MediaWiki } from './token';
|
|
13
|
+
import { braceStackUpdate, hasTag } from './util';
|
|
13
14
|
import { EditorView } from '@codemirror/view';
|
|
14
|
-
export const isWMF = /* @__PURE__ */ (() => typeof location === 'object' && new RegExp(String.raw `\.(?:${wmf})\.org$`, 'u').test(location.hostname))();
|
|
15
15
|
/**
|
|
16
16
|
* 检查首字母大小写并插入正确的自动填充内容
|
|
17
17
|
* @param view
|
|
@@ -30,12 +30,6 @@ const apply = (view, completion, from, to) => {
|
|
|
30
30
|
annotations: pickedCompletion.of(completion),
|
|
31
31
|
});
|
|
32
32
|
};
|
|
33
|
-
/**
|
|
34
|
-
* 判断节点是否包含指定类型
|
|
35
|
-
* @param types 节点类型
|
|
36
|
-
* @param names 指定类型
|
|
37
|
-
*/
|
|
38
|
-
export const hasTag = (types, names) => (Array.isArray(names) ? names : [names]).some(name => types.has(name in tokens ? tokens[name] : name));
|
|
39
33
|
export class FullMediaWiki extends MediaWiki {
|
|
40
34
|
constructor(config) {
|
|
41
35
|
super(config);
|
|
@@ -45,7 +39,7 @@ export class FullMediaWiki extends MediaWiki {
|
|
|
45
39
|
type: i ? 'constant' : 'function',
|
|
46
40
|
label,
|
|
47
41
|
})));
|
|
48
|
-
this.doubleUnderscore = doubleUnderscore.flatMap(Object.keys).map((label) => ({
|
|
42
|
+
this.doubleUnderscore = doubleUnderscore.flatMap(Object.keys).filter(isUnderscore).map((label) => ({
|
|
49
43
|
type: 'constant',
|
|
50
44
|
label,
|
|
51
45
|
}));
|
|
@@ -136,7 +130,7 @@ export class FullMediaWiki extends MediaWiki {
|
|
|
136
130
|
const underscore = str.slice(offset).includes('_');
|
|
137
131
|
return {
|
|
138
132
|
offset,
|
|
139
|
-
options: (await linkSuggest(search,
|
|
133
|
+
options: (await linkSuggest(search, subpage, ns)).map(([label]) => ({
|
|
140
134
|
type: 'text',
|
|
141
135
|
label: underscore ? label.replace(/ /gu, '_') : label,
|
|
142
136
|
})),
|
|
@@ -149,12 +143,11 @@ export class FullMediaWiki extends MediaWiki {
|
|
|
149
143
|
* @param equal 是否有等号
|
|
150
144
|
*/
|
|
151
145
|
async #paramSuggest(search, page, equal) {
|
|
152
|
-
const { config: { paramSuggest } } = this;
|
|
153
|
-
return
|
|
146
|
+
const { config: { paramSuggest } } = this, result = await paramSuggest?.(page);
|
|
147
|
+
return result?.length
|
|
154
148
|
? {
|
|
155
149
|
offset: /^\s*/u.exec(search)[0].length,
|
|
156
|
-
options: (
|
|
157
|
-
.map(([key, detail]) => ({ type: 'variable', label: key + equal, detail })),
|
|
150
|
+
options: result.map(([key, detail]) => ({ type: 'variable', label: key + equal, detail })),
|
|
158
151
|
}
|
|
159
152
|
: undefined;
|
|
160
153
|
}
|
|
@@ -495,10 +488,10 @@ const theme = /* @__PURE__ */ EditorView.theme({
|
|
|
495
488
|
[getSelector(['pre', 'nowiki'], 'tag-')]: {
|
|
496
489
|
backgroundColor: 'rgb(0,0,0,.04)',
|
|
497
490
|
},
|
|
498
|
-
|
|
491
|
+
[`${isolateSelector}, &[dir="rtl"] .cm-mw-template-name`]: {
|
|
499
492
|
unicodeBidi: 'isolate',
|
|
500
493
|
},
|
|
501
|
-
|
|
494
|
+
[ltrSelector]: {
|
|
502
495
|
direction: 'ltr',
|
|
503
496
|
display: 'inline-block',
|
|
504
497
|
},
|