@bhsd/codemirror-mediawiki 3.11.1 → 3.11.2

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.
@@ -9,6 +9,7 @@ import { MediaWiki } from './token.js';
9
9
  import type { StreamParser, TagStyle } from '@codemirror/language';
10
10
  import type { CompletionSource, Completion } from '@codemirror/autocomplete';
11
11
  import type { MwConfig } from './token';
12
+ import type { TagName } from './config';
12
13
  /**
13
14
  * 是否是普通维基链接
14
15
  * @param name 节点名称
@@ -23,6 +24,13 @@ export declare const isWikiLink: (name: string) => boolean;
23
24
  * @test
24
25
  */
25
26
  export declare const apply: (view: EditorView, completion: Completion, from: number, to: number) => void;
27
+ /**
28
+ * 判断节点是否包含指定类型
29
+ * @param types 节点类型
30
+ * @param names 指定类型
31
+ * @test
32
+ */
33
+ export declare const hasTag: (types: Set<string>, names: TagName | TagName[]) => boolean;
26
34
  /** @test */
27
35
  export declare class FullMediaWiki extends MediaWiki {
28
36
  #private;
package/dist/mediawiki.js CHANGED
@@ -11,7 +11,7 @@ import { commonHtmlAttrs, htmlAttrs, extAttrs } from 'wikiparser-node/dist/util/
11
11
  import { htmlTags, tokens } from './config.js';
12
12
  import { hoverSelector, isWMF, } from './constants.js';
13
13
  import { MediaWiki } from './token.js';
14
- import { hasTag, leadingSpaces, findTemplateName, } from './util.js';
14
+ import { leadingSpaces, findTemplateName } from './util.js';
15
15
  const ranks = { Required: 1, Suggested: 2, Optional: 3, Deprecated: 4 };
16
16
  /**
17
17
  * 是否是普通维基链接
@@ -42,6 +42,13 @@ export const apply = (view, completion, from, to) => {
42
42
  selection,
43
43
  });
44
44
  };
45
+ /**
46
+ * 判断节点是否包含指定类型
47
+ * @param types 节点类型
48
+ * @param names 指定类型
49
+ * @test
50
+ */
51
+ export const hasTag = (types, names) => (Array.isArray(names) ? names : [names]).some(name => types.has(name in tokens ? tokens[name] : name));
45
52
  /** @test */
46
53
  export class FullMediaWiki extends MediaWiki {
47
54
  constructor(config, templatedata = false) {