@bhsd/codemirror-mediawiki 3.4.2 → 3.5.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 +0 -1
- package/dist/codemirror.d.ts +2 -2
- package/dist/codemirror.js +6 -5
- package/dist/html.js +3 -3
- package/dist/lintsource.d.ts +2 -0
- package/dist/main.min.js +23 -23
- package/dist/mediawiki.d.ts +1 -0
- package/dist/mediawiki.js +7 -7
- package/dist/mw.min.js +27 -27
- package/dist/static.d.ts +2 -0
- package/dist/static.js +2 -0
- package/dist/token.js +12 -3
- package/dist/wiki.min.js +26 -26
- package/i18n/en.json +1 -1
- package/i18n/zh-hans.json +1 -1
- package/i18n/zh-hant.json +1 -1
- package/package.json +3 -3
package/dist/mediawiki.d.ts
CHANGED
|
@@ -8,6 +8,7 @@ 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 re: RegExp;
|
|
11
12
|
/**
|
|
12
13
|
* 判断节点是否包含指定类型
|
|
13
14
|
* @param types 节点类型
|
package/dist/mediawiki.js
CHANGED
|
@@ -11,7 +11,7 @@ import { MediaWiki } from './token';
|
|
|
11
11
|
import { htmlTags, tokens } from './config';
|
|
12
12
|
import { braceStackUpdate } from './fold';
|
|
13
13
|
import { EditorView } from '@codemirror/view';
|
|
14
|
-
const re = new RegExp(String.raw `\.(?:${wmf})\.org$`, 'u');
|
|
14
|
+
export const re = /* @__PURE__ */ (() => new RegExp(String.raw `\.(?:${wmf})\.org$`, 'u'))();
|
|
15
15
|
/**
|
|
16
16
|
* 检查首字母大小写并插入正确的自动填充内容
|
|
17
17
|
* @param view
|
|
@@ -162,10 +162,10 @@ export class FullMediaWiki extends MediaWiki {
|
|
|
162
162
|
get completionSource() {
|
|
163
163
|
return async (context) => {
|
|
164
164
|
const { state, pos, explicit } = context, node = syntaxTree(state).resolve(pos, -1), types = new Set(node.name.split('_')), isParserFunction = hasTag(types, 'parserFunctionName'),
|
|
165
|
-
/** 开头不包含` `,但可能包含`_` */ search = state.sliceDoc(node.from, pos).trimStart(), start = pos - search.length;
|
|
165
|
+
/** 开头不包含` `,但可能包含`_` */ search = state.sliceDoc(node.from, pos).trimStart(), start = pos - search.length, isWMF = re.test(location.hostname);
|
|
166
166
|
let { prevSibling } = node;
|
|
167
|
-
if (explicit || isParserFunction && search.includes('#') ||
|
|
168
|
-
const validFor = /^[^|{}<>[\]#]*$/u;
|
|
167
|
+
if (explicit || isParserFunction && search.includes('#') || isWMF) {
|
|
168
|
+
const validFor = isWMF ? null : { validFor: /^[^|{}<>[\]#]*$/u };
|
|
169
169
|
if (isParserFunction || hasTag(types, 'templateName')) {
|
|
170
170
|
const options = search.includes(':') ? [] : [...this.functionSynonyms], suggestions = await this.#linkSuggest(search, 10) ?? { offset: 0, options: [] };
|
|
171
171
|
options.push(...suggestions.options);
|
|
@@ -174,14 +174,14 @@ export class FullMediaWiki extends MediaWiki {
|
|
|
174
174
|
: {
|
|
175
175
|
from: start + suggestions.offset,
|
|
176
176
|
options,
|
|
177
|
-
validFor,
|
|
177
|
+
...validFor,
|
|
178
178
|
};
|
|
179
179
|
}
|
|
180
180
|
else if (explicit && hasTag(types, 'templateBracket') && context.matchBefore(/\{\{$/u)) {
|
|
181
181
|
return {
|
|
182
182
|
from: pos,
|
|
183
183
|
options: this.functionSynonyms,
|
|
184
|
-
validFor,
|
|
184
|
+
...validFor,
|
|
185
185
|
};
|
|
186
186
|
}
|
|
187
187
|
const isPage = hasTag(types, 'pageName') && hasTag(types, 'parserFunction') || 0;
|
|
@@ -206,7 +206,7 @@ export class FullMediaWiki extends MediaWiki {
|
|
|
206
206
|
// eslint-disable-next-line unicorn/explicit-length-check
|
|
207
207
|
from: start + suggestions.offset - (isPage && prefix.length),
|
|
208
208
|
options: suggestions.options,
|
|
209
|
-
validFor,
|
|
209
|
+
...validFor,
|
|
210
210
|
};
|
|
211
211
|
}
|
|
212
212
|
const isArgument = hasTag(types, 'templateArgumentName'), prevIsDelimiter = prevSibling?.name.includes(tokens.templateDelimiter), isDelimiter = hasTag(types, 'templateDelimiter')
|