@bhsd/codemirror-mediawiki 2.30.2 → 2.31.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/dist/mediawiki.js CHANGED
@@ -5,11 +5,12 @@
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';
8
9
  import { commonHtmlAttrs, htmlAttrs, extAttrs } from 'wikiparser-node/dist/util/sharable.mjs';
9
10
  import { MediaWiki } from './token';
10
11
  import { htmlTags, tokens } from './config';
11
12
  import { braceStackUpdate } from './fold';
12
- const wmf = /\.(?:wiktionary|wiki(?:pedia|books|news|quote|source|versity|voyage))\.org$/u;
13
+ const re = new RegExp(String.raw `\.(?:${wmf})\.org$`, 'u');
13
14
  /**
14
15
  * 检查首字母大小写并插入正确的自动填充内容
15
16
  * @param view
@@ -162,7 +163,7 @@ export class FullMediaWiki extends MediaWiki {
162
163
  const { state, pos, explicit } = context, node = syntaxTree(state).resolve(pos, -1), types = new Set(node.name.split('_')), isParserFunction = hasTag(types, 'parserFunctionName'),
163
164
  /** 开头不包含` `,但可能包含`_` */ search = state.sliceDoc(node.from, pos).trimStart(), start = pos - search.length;
164
165
  let { prevSibling } = node;
165
- if (explicit || isParserFunction && search.includes('#') || wmf.test(location.hostname)) {
166
+ if (explicit || isParserFunction && search.includes('#') || re.test(location.hostname)) {
166
167
  const validFor = /^[^|{}<>[\]#]*$/u;
167
168
  if (isParserFunction || hasTag(types, 'templateName')) {
168
169
  const options = search.includes(':') ? [] : [...this.functionSynonyms], suggestions = await this.#linkSuggest(search, 10) ?? { offset: 0, options: [] };