@bhsd/codemirror-mediawiki 3.8.1 → 3.9.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 +45 -2
- package/dist/bidi.js +3 -3
- package/dist/codemirror.d.ts +9 -1
- package/dist/codemirror.js +51 -31
- package/dist/color.d.ts +1 -2
- package/dist/color.js +5 -16
- package/dist/config.d.ts +3 -2
- package/dist/config.js +4 -13
- package/dist/constants.d.ts +2 -1
- package/dist/constants.js +2 -1
- package/dist/escape.d.ts +1 -1
- package/dist/escape.js +11 -10
- package/dist/fold.d.ts +2 -1
- package/dist/fold.js +9 -8
- package/dist/hover.d.ts +1 -1
- package/dist/hover.js +9 -8
- package/dist/html.js +6 -5
- package/dist/indent.js +1 -1
- package/dist/index.d.ts +2 -2
- package/dist/index.js +38 -41
- package/dist/inlay.d.ts +1 -1
- package/dist/inlay.js +11 -15
- package/dist/keymap.d.ts +2 -1
- package/dist/keymap.js +2 -3
- package/dist/linter.d.ts +2 -11
- package/dist/linter.js +17 -31
- package/dist/lintsource.d.ts +2 -2
- package/dist/lintsource.js +18 -33
- package/dist/lua.js +2 -1
- package/dist/main.min.js +27 -24
- package/dist/matchTag.js +2 -2
- package/dist/mediawiki.d.ts +2 -2
- package/dist/mediawiki.js +20 -17
- package/dist/mw.min.js +30 -27
- package/dist/mwConfig.js +3 -2
- package/dist/openLinks.js +9 -8
- package/dist/ref.d.ts +1 -1
- package/dist/ref.js +8 -6
- package/dist/signature.d.ts +1 -1
- package/dist/signature.js +3 -3
- package/dist/statusBar.js +8 -3
- package/dist/theme.js +1 -1
- package/dist/token.d.ts +2 -3
- package/dist/token.js +5 -3
- package/dist/util.d.ts +5 -0
- package/dist/util.js +7 -2
- package/dist/vue.js +2 -2
- package/dist/wiki.min.js +29 -26
- package/i18n/en.json +1 -1
- package/i18n/zh-hans.json +1 -1
- package/i18n/zh-hant.json +1 -1
- package/package.json +12 -10
package/dist/matchTag.js
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { Decoration, EditorView } from '@codemirror/view';
|
|
2
2
|
import { StateField } from '@codemirror/state';
|
|
3
3
|
import { ensureSyntaxTree } from '@codemirror/language';
|
|
4
|
-
import { voidHtmlTags, selfClosingTags } from './config';
|
|
5
|
-
import { matchingCls, nonmatchingCls } from './constants';
|
|
4
|
+
import { voidHtmlTags, selfClosingTags } from './config.js';
|
|
5
|
+
import { matchingCls, nonmatchingCls } from './constants.js';
|
|
6
6
|
class Tag {
|
|
7
7
|
get closing() {
|
|
8
8
|
return isClosing(this.first, this.type, this.state, true);
|
package/dist/mediawiki.d.ts
CHANGED
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
* @see https://gerrit.wikimedia.org/g/mediawiki/extensions/CodeMirror
|
|
5
5
|
*/
|
|
6
6
|
import { LanguageSupport } from '@codemirror/language';
|
|
7
|
-
import { MediaWiki } from './token';
|
|
7
|
+
import { MediaWiki } from './token.js';
|
|
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';
|
|
@@ -40,4 +40,4 @@ export declare class FullMediaWiki extends MediaWiki {
|
|
|
40
40
|
* Get a LanguageSupport instance for the MediaWiki mode.
|
|
41
41
|
* @param config Configuration for the MediaWiki mode
|
|
42
42
|
*/
|
|
43
|
-
export declare const
|
|
43
|
+
export declare const mediawikiBase: (config: MwConfig) => LanguageSupport;
|
package/dist/mediawiki.js
CHANGED
|
@@ -3,15 +3,15 @@
|
|
|
3
3
|
* @license GPL-2.0-or-later
|
|
4
4
|
* @see https://gerrit.wikimedia.org/g/mediawiki/extensions/CodeMirror
|
|
5
5
|
*/
|
|
6
|
-
import {
|
|
6
|
+
import { StreamLanguage, syntaxTree, HighlightStyle, LanguageSupport, syntaxHighlighting, } from '@codemirror/language';
|
|
7
|
+
import { EditorView } from '@codemirror/view';
|
|
7
8
|
import { insertCompletionText, pickedCompletion } from '@codemirror/autocomplete';
|
|
8
9
|
import { isUnderscore } from '@bhsd/cm-util';
|
|
9
10
|
import { commonHtmlAttrs, htmlAttrs, extAttrs } from 'wikiparser-node/dist/util/sharable.mjs';
|
|
10
|
-
import { htmlTags, tokens } from './config';
|
|
11
|
-
import { isolateSelector, ltrSelector
|
|
12
|
-
import { MediaWiki } from './token';
|
|
13
|
-
import { braceStackUpdate,
|
|
14
|
-
import { EditorView } from '@codemirror/view';
|
|
11
|
+
import { htmlTags, tokens } from './config.js';
|
|
12
|
+
import { isWMF, isolateSelector, ltrSelector } from './constants.js';
|
|
13
|
+
import { MediaWiki } from './token.js';
|
|
14
|
+
import { hasTag, braceStackUpdate, leadingSpaces, } from './util.js';
|
|
15
15
|
/**
|
|
16
16
|
* 是否是普通维基链接
|
|
17
17
|
* @param name 节点名称
|
|
@@ -116,8 +116,7 @@ export class FullMediaWiki extends MediaWiki {
|
|
|
116
116
|
}
|
|
117
117
|
else {
|
|
118
118
|
search = search.replace(/_/gu, ' ');
|
|
119
|
-
|
|
120
|
-
[{ length: offset }] = mt;
|
|
119
|
+
offset = leadingSpaces(search).length;
|
|
121
120
|
search = search.slice(offset);
|
|
122
121
|
if (search.startsWith(':')) {
|
|
123
122
|
const [{ length }] = /^:\s*/u.exec(search);
|
|
@@ -155,7 +154,7 @@ export class FullMediaWiki extends MediaWiki {
|
|
|
155
154
|
const { config: { paramSuggest } } = this, result = await paramSuggest?.(page);
|
|
156
155
|
return result?.length
|
|
157
156
|
? {
|
|
158
|
-
offset:
|
|
157
|
+
offset: leadingSpaces(search).length,
|
|
159
158
|
options: result.map(([key, detail]) => ({ type: 'variable', label: key + equal, detail })),
|
|
160
159
|
}
|
|
161
160
|
: undefined;
|
|
@@ -163,11 +162,15 @@ export class FullMediaWiki extends MediaWiki {
|
|
|
163
162
|
/** 自动补全魔术字和标签名 */
|
|
164
163
|
get completionSource() {
|
|
165
164
|
return async (context) => {
|
|
166
|
-
const { state, pos, explicit } = context, node = syntaxTree(state).resolve(pos, -1), { name: n, from: f, to: t } = node, types = new Set(n.split('_')), isParserFunction = hasTag(types, 'parserFunctionName'),
|
|
165
|
+
const { state, pos, explicit } = context, node = syntaxTree(state).resolve(pos, -1), { name: n, from: f, to: t, } = node, types = new Set(n.split('_')), isParserFunction = hasTag(types, 'parserFunctionName'),
|
|
167
166
|
/** 开头不包含` `,但可能包含`_` */ search = state.sliceDoc(f, pos).trimStart(), start = pos - search.length;
|
|
168
167
|
let { prevSibling } = node;
|
|
169
168
|
if (explicit || isParserFunction && search.includes('#') || isWMF) {
|
|
170
|
-
const
|
|
169
|
+
const obj = isWMF
|
|
170
|
+
? null
|
|
171
|
+
: {
|
|
172
|
+
validFor: /^[^|{}<>[\]#]*$/u,
|
|
173
|
+
};
|
|
171
174
|
if (isParserFunction || hasTag(types, 'templateName')) {
|
|
172
175
|
const options = search.includes(':') ? [] : [...this.functionSynonyms], suggestions = await this.#linkSuggest(search, 10) ?? { offset: 0, options: [] };
|
|
173
176
|
options.push(...suggestions.options);
|
|
@@ -176,14 +179,14 @@ export class FullMediaWiki extends MediaWiki {
|
|
|
176
179
|
: {
|
|
177
180
|
from: start + suggestions.offset,
|
|
178
181
|
options,
|
|
179
|
-
...
|
|
182
|
+
...obj,
|
|
180
183
|
};
|
|
181
184
|
}
|
|
182
185
|
else if (explicit && hasTag(types, 'templateBracket') && context.matchBefore(/\{\{$/u)) {
|
|
183
186
|
return {
|
|
184
187
|
from: pos,
|
|
185
188
|
options: this.functionSynonyms,
|
|
186
|
-
...
|
|
189
|
+
...obj,
|
|
187
190
|
};
|
|
188
191
|
}
|
|
189
192
|
const isPage = hasTag(types, 'pageName') && hasTag(types, 'parserFunction') || 0;
|
|
@@ -212,7 +215,7 @@ export class FullMediaWiki extends MediaWiki {
|
|
|
212
215
|
// eslint-disable-next-line unicorn/explicit-length-check
|
|
213
216
|
from: start + suggestions.offset - (isPage && prefix.length),
|
|
214
217
|
options: suggestions.options,
|
|
215
|
-
...
|
|
218
|
+
...obj,
|
|
216
219
|
};
|
|
217
220
|
}
|
|
218
221
|
const isArgument = hasTag(types, 'templateArgumentName'), prevIsDelimiter = prevSibling?.name.includes(tokens.templateDelimiter), isDelimiter = hasTag(types, 'templateDelimiter')
|
|
@@ -516,7 +519,7 @@ const theme = /* @__PURE__ */ EditorView.theme({
|
|
|
516
519
|
* Get a LanguageSupport instance for the MediaWiki mode.
|
|
517
520
|
* @param config Configuration for the MediaWiki mode
|
|
518
521
|
*/
|
|
519
|
-
export const
|
|
520
|
-
const mode = new FullMediaWiki(config), lang = StreamLanguage.define(mode.mediawiki())
|
|
521
|
-
return new LanguageSupport(lang, [
|
|
522
|
+
export const mediawikiBase = (config) => {
|
|
523
|
+
const mode = new FullMediaWiki(config), lang = StreamLanguage.define(mode.mediawiki());
|
|
524
|
+
return new LanguageSupport(lang, [syntaxHighlighting(HighlightStyle.define(mode.getTagStyles())), theme]);
|
|
522
525
|
};
|