@bhsd/codemirror-mediawiki 3.5.2 → 3.6.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/README.md +1 -1
- package/dist/bidi.js +5 -4
- package/dist/codemirror.d.ts +2 -2
- package/dist/codemirror.js +9 -4
- package/dist/constants.d.ts +1 -0
- package/dist/constants.js +9 -0
- package/dist/fold.d.ts +0 -6
- package/dist/fold.js +10 -15
- package/dist/hover.d.ts +1 -22
- package/dist/hover.js +32 -38
- package/dist/html.js +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.js +11 -11
- package/dist/inlay.js +4 -3
- package/dist/lintsource.js +1 -1
- package/dist/main.min.js +28 -27
- package/dist/matchTag.js +2 -1
- package/dist/mediawiki.d.ts +0 -7
- package/dist/mediawiki.js +18 -21
- package/dist/mw.min.js +31 -30
- package/dist/openLinks.d.ts +0 -1
- package/dist/openLinks.js +7 -11
- package/dist/ref.js +25 -8
- package/dist/signature.js +5 -4
- package/dist/statusBar.js +20 -20
- package/dist/theme.js +51 -52
- package/dist/token.d.ts +5 -3
- 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 +3 -3
- package/i18n/zh-hans.json +3 -3
- package/i18n/zh-hant.json +3 -3
- package/package.json +8 -8
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,14 +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 { wmf } from '@bhsd/common';
|
|
9
8
|
import { isUnderscore } from '@bhsd/cm-util';
|
|
10
9
|
import { commonHtmlAttrs, htmlAttrs, extAttrs } from 'wikiparser-node/dist/util/sharable.mjs';
|
|
11
|
-
import { MediaWiki } from './token';
|
|
12
10
|
import { htmlTags, tokens } from './config';
|
|
13
|
-
import {
|
|
11
|
+
import { isolateSelector, ltrSelector, isWMF } from './constants';
|
|
12
|
+
import { MediaWiki } from './token';
|
|
13
|
+
import { braceStackUpdate, hasTag } from './util';
|
|
14
14
|
import { EditorView } from '@codemirror/view';
|
|
15
|
-
export const isWMF = /* @__PURE__ */ (() => typeof location === 'object' && new RegExp(String.raw `\.(?:${wmf})\.org$`, 'u').test(location.hostname))();
|
|
16
15
|
/**
|
|
17
16
|
* 检查首字母大小写并插入正确的自动填充内容
|
|
18
17
|
* @param view
|
|
@@ -21,22 +20,21 @@ export const isWMF = /* @__PURE__ */ (() => typeof location === 'object' && new
|
|
|
21
20
|
* @param to 结束位置
|
|
22
21
|
*/
|
|
23
22
|
const apply = (view, completion, from, to) => {
|
|
24
|
-
let { label } = completion;
|
|
25
|
-
const initial = label.charAt(0).toLowerCase();
|
|
26
|
-
if (
|
|
23
|
+
let { label } = completion, selection;
|
|
24
|
+
const initial = label.charAt(0).toLowerCase(), { state } = view, after = state.sliceDoc(to);
|
|
25
|
+
if (state.sliceDoc(from, from + 1) === initial) {
|
|
27
26
|
label = initial + label.slice(1);
|
|
28
27
|
}
|
|
28
|
+
if (!/^\s*\|/u.test(after)) {
|
|
29
|
+
selection = { anchor: from + label.length + 1, head: from + label.length * 2 + 1 };
|
|
30
|
+
label += `|${label}${/^\s*\]\]/u.test(after) ? '' : ']]'}`;
|
|
31
|
+
}
|
|
29
32
|
view.dispatch({
|
|
30
|
-
...insertCompletionText(
|
|
33
|
+
...insertCompletionText(state, label, from, to),
|
|
31
34
|
annotations: pickedCompletion.of(completion),
|
|
35
|
+
selection,
|
|
32
36
|
});
|
|
33
37
|
};
|
|
34
|
-
/**
|
|
35
|
-
* 判断节点是否包含指定类型
|
|
36
|
-
* @param types 节点类型
|
|
37
|
-
* @param names 指定类型
|
|
38
|
-
*/
|
|
39
|
-
export const hasTag = (types, names) => (Array.isArray(names) ? names : [names]).some(name => types.has(name in tokens ? tokens[name] : name));
|
|
40
38
|
export class FullMediaWiki extends MediaWiki {
|
|
41
39
|
constructor(config) {
|
|
42
40
|
super(config);
|
|
@@ -137,7 +135,7 @@ export class FullMediaWiki extends MediaWiki {
|
|
|
137
135
|
const underscore = str.slice(offset).includes('_');
|
|
138
136
|
return {
|
|
139
137
|
offset,
|
|
140
|
-
options: (await linkSuggest(search,
|
|
138
|
+
options: (await linkSuggest(search, subpage, ns)).map(([label]) => ({
|
|
141
139
|
type: 'text',
|
|
142
140
|
label: underscore ? label.replace(/ /gu, '_') : label,
|
|
143
141
|
})),
|
|
@@ -150,12 +148,11 @@ export class FullMediaWiki extends MediaWiki {
|
|
|
150
148
|
* @param equal 是否有等号
|
|
151
149
|
*/
|
|
152
150
|
async #paramSuggest(search, page, equal) {
|
|
153
|
-
const { config: { paramSuggest } } = this;
|
|
154
|
-
return
|
|
151
|
+
const { config: { paramSuggest } } = this, result = await paramSuggest?.(page);
|
|
152
|
+
return result?.length
|
|
155
153
|
? {
|
|
156
154
|
offset: /^\s*/u.exec(search)[0].length,
|
|
157
|
-
options: (
|
|
158
|
-
.map(([key, detail]) => ({ type: 'variable', label: key + equal, detail })),
|
|
155
|
+
options: result.map(([key, detail]) => ({ type: 'variable', label: key + equal, detail })),
|
|
159
156
|
}
|
|
160
157
|
: undefined;
|
|
161
158
|
}
|
|
@@ -496,10 +493,10 @@ const theme = /* @__PURE__ */ EditorView.theme({
|
|
|
496
493
|
[getSelector(['pre', 'nowiki'], 'tag-')]: {
|
|
497
494
|
backgroundColor: 'rgb(0,0,0,.04)',
|
|
498
495
|
},
|
|
499
|
-
|
|
496
|
+
[`${isolateSelector}, &[dir="rtl"] .cm-mw-template-name`]: {
|
|
500
497
|
unicodeBidi: 'isolate',
|
|
501
498
|
},
|
|
502
|
-
|
|
499
|
+
[ltrSelector]: {
|
|
503
500
|
direction: 'ltr',
|
|
504
501
|
display: 'inline-block',
|
|
505
502
|
},
|