@bhsd/codemirror-mediawiki 3.4.2 → 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.
package/README.md CHANGED
@@ -1221,7 +1221,6 @@ registerSignatureHelp();
1221
1221
 
1222
1222
  ### Extension
1223
1223
 
1224
- 1. [Extension:Translate](https://www.mediawiki.org/wiki/Extension:Translate) is not supported.
1225
1224
  1. [Extension:Poem](https://www.mediawiki.org/wiki/Extension:Poem) should prevent preformatted text ([Example](http://bhsd-harry.github.io/monaco-wiki/tests.html#%3Cpoem%3E%20with%20leading%20whitespace)).
1226
1225
 
1227
1226
  ### Transclusion
@@ -6,7 +6,7 @@ import type { ConfigData } from 'wikiparser-node';
6
6
  import type { MwConfig } from './token';
7
7
  import type { DocRange, foldHandler } from './fold';
8
8
  import type { Option, LiveOption } from './linter';
9
- import type { LintSource, LintSourceGetter } from './lintsource';
9
+ import type { LintSource, LintSources, LintSourceGetter } from './lintsource';
10
10
  import type { detectIndent } from './indent';
11
11
  import type statusBar from './statusBar';
12
12
  export type AddonMain<T> = (config?: T, cm?: CodeMirror6) => Extension;
@@ -67,7 +67,7 @@ export declare class CodeMirror6 {
67
67
  * Start syntax checking
68
68
  * @param lintSource function for syntax checking
69
69
  */
70
- lint(lintSource?: LintSource): void;
70
+ lint(lintSource?: LintSources): void;
71
71
  /** Update syntax checking immediately */
72
72
  update(): void;
73
73
  /**
@@ -225,20 +225,21 @@ export class CodeMirror6 {
225
225
  * @param lintSource function for syntax checking
226
226
  */
227
227
  lint(lintSource) {
228
- const linterExtension = lintSource
228
+ const lintSources = typeof lintSource === 'function' ? [lintSource] : lintSource;
229
+ const linterExtension = lintSources
229
230
  ? [
230
- linter(async ({ state }) => {
231
- const diagnostics = await lintSource(state);
231
+ ...lintSources.map(source => linter(async ({ state }) => {
232
+ const diagnostics = await source(state);
232
233
  if (state.readOnly) {
233
234
  for (const diagnostic of diagnostics) {
234
235
  delete diagnostic.actions;
235
236
  }
236
237
  }
237
238
  return diagnostics;
238
- }),
239
+ })),
239
240
  lintGutter(),
240
241
  keymap.of(lintKeymap),
241
- optionalFunctions.statusBar(this, lintSource.fixer),
242
+ optionalFunctions.statusBar(this, lintSources[0].fixer),
242
243
  ]
243
244
  : [];
244
245
  if (lintSource) {
package/dist/html.js CHANGED
@@ -1,5 +1,5 @@
1
1
  import { configureNesting } from '@lezer/html';
2
- import { htmlPlain, htmlCompletionSourceWith } from '@codemirror/lang-html';
2
+ import { htmlLanguage, htmlCompletionSourceWith } from '@codemirror/lang-html';
3
3
  import { javascript, javascriptLanguage } from '@codemirror/lang-javascript';
4
4
  import { cssLanguage } from '@codemirror/lang-css';
5
5
  import { LanguageSupport } from '@codemirror/language';
@@ -7,14 +7,14 @@ import { jsCompletion } from './javascript';
7
7
  import { mediawiki } from './mediawiki';
8
8
  import { cssCompletion } from './css';
9
9
  export default (config) => {
10
- const { language, support } = mediawiki(config), lang = new LanguageSupport(htmlPlain.configure({
10
+ const { language, support } = mediawiki(config), lang = new LanguageSupport(htmlLanguage.configure({
11
11
  wrap: configureNesting([
12
12
  { tag: 'script', parser: javascriptLanguage.parser },
13
13
  { tag: 'style', parser: cssLanguage.parser },
14
14
  { tag: 'noinclude', parser: language.parser },
15
15
  ], [{ name: 'style', parser: cssLanguage.parser.configure({ top: 'Styles' }) }]),
16
16
  }), [
17
- htmlPlain.data.of({
17
+ htmlLanguage.data.of({
18
18
  autocomplete: htmlCompletionSourceWith({
19
19
  extraTags: {
20
20
  noinclude: { globalAttrs: false },
@@ -6,7 +6,14 @@ import type { Option, LiveOption } from './linter';
6
6
  export type LintSource = ((state: EditorState) => Diagnostic[] | Promise<Diagnostic[]>) & {
7
7
  fixer?: (doc: Text, rule?: string) => string | Promise<string>;
8
8
  };
9
+ export type LintSources = LintSource | [LintSource] | [LintSource, LintSource];
9
10
  export type LintSourceGetter = (opt?: Option | LiveOption, view?: EditorView, nestedMWLanguage?: Language) => LintSource | Promise<LintSource>;
11
+ /**
12
+ * 获取Linter选项
13
+ * @param opt Linter选项
14
+ * @param runtime 是否为运行时选项
15
+ */
16
+ export declare const getOpt: (opt: Option | LiveOption, runtime?: boolean) => Option | Promise<Option>;
10
17
  export declare const getWikiLintSource: LintSourceGetter;
11
18
  export declare const getJsLintSource: LintSourceGetter;
12
19
  export declare const getCssLintSource: LintSourceGetter;
@@ -9,7 +9,7 @@ import { posToIndex } from './hover';
9
9
  * @param opt Linter选项
10
10
  * @param runtime 是否为运行时选项
11
11
  */
12
- const getOpt = (opt, runtime) => typeof opt === 'function' ? opt(runtime) : opt;
12
+ export const getOpt = (opt, runtime) => typeof opt === 'function' ? opt(runtime) : opt;
13
13
  /**
14
14
  * 获取指定行列的位置
15
15
  * @param doc 文档