@bhsd/codemirror-mediawiki 3.5.0 → 3.5.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.
@@ -8,7 +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
+ export declare const isWMF: boolean;
12
12
  /**
13
13
  * 判断节点是否包含指定类型
14
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
- export const re = /* @__PURE__ */ (() => new RegExp(String.raw `\.(?:${wmf})\.org$`, 'u'))();
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
@@ -162,7 +162,7 @@ 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, isWMF = re.test(location.hostname);
165
+ /** 开头不包含` `,但可能包含`_` */ search = state.sliceDoc(node.from, pos).trimStart(), start = pos - search.length;
166
166
  let { prevSibling } = node;
167
167
  if (explicit || isParserFunction && search.includes('#') || isWMF) {
168
168
  const validFor = isWMF ? null : { validFor: /^[^|{}<>[\]#]*$/u };