@bhsd/codemirror-mediawiki 2.30.3 → 3.0.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.
@@ -3,5 +3,5 @@ import type { Config, MatchResult } from '@codemirror/language';
3
3
  import type { SyntaxNode } from '@lezer/common';
4
4
  export declare const findEnclosingBrackets: (node: SyntaxNode, pos: number, brackets: string) => MatchResult | undefined;
5
5
  export declare const findEnclosingPlainBrackets: (state: EditorState, pos: number, config: Required<Config>) => MatchResult | null;
6
- declare const _default: (configs: Config) => Extension;
6
+ declare const _default: (configs?: Config) => Extension;
7
7
  export default _default;
package/dist/matchTag.js CHANGED
@@ -109,8 +109,8 @@ export const matchTag = (state, pos) => {
109
109
  const end = searchTag(state, start);
110
110
  return end ? { matched: true, start, end } : { matched: false, start };
111
111
  };
112
- const matchingMark = Decoration.mark({ class: 'cm-matchingTag' }), nonmatchingMark = Decoration.mark({ class: 'cm-nonmatchingTag' });
113
- export default StateField.define({
112
+ const matchingMark = /* @__PURE__ */ Decoration.mark({ class: 'cm-matchingTag' }), nonmatchingMark = /* @__PURE__ */ Decoration.mark({ class: 'cm-nonmatchingTag' });
113
+ export default /* @__PURE__ */ StateField.define({
114
114
  create() {
115
115
  return Decoration.none;
116
116
  },
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: [] };