@bhsd/codemirror-mediawiki 2.0.12 → 2.0.13

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
@@ -8,7 +8,9 @@
8
8
  - [Usage](#usage)
9
9
  - [constructor](#constructor)
10
10
  - [textarea](#textarea)
11
+ - [lang](#lang)
11
12
  - [view](#view)
13
+ - [getLinter](#getlinter)
12
14
  - [lint](#lint)
13
15
  - [prefer](#prefer)
14
16
  - [setIndent](#setindent)
@@ -64,6 +66,16 @@ The textarea element replaced by CodeMirror.
64
66
 
65
67
  </details>
66
68
 
69
+ ## lang
70
+
71
+ <details>
72
+ <summary>Expand</summary>
73
+
74
+ **type**: `string`
75
+ The current language mode.
76
+
77
+ </details>
78
+
67
79
  ## view
68
80
 
69
81
  <details>
@@ -74,23 +86,33 @@ The CodeMirror EditorView instance.
74
86
 
75
87
  </details>
76
88
 
89
+ ## getLinter
90
+
91
+ <details>
92
+ <summary>Expand</summary>
93
+
94
+ **returns**: `Promise<(doc: Text) => Diagnostic[] | Promise<Diagnostic[]>>`
95
+ Get the default linting function, which can be used as the argument of [`lint`](#lint).
96
+
97
+ </details>
98
+
77
99
  ## lint
78
100
 
79
101
  <details>
80
102
  <summary>Expand</summary>
81
103
 
82
- **param**: `(str: string) => Diagnostic[] | Promise<Diagnostic[]>` the linting function
104
+ **param**: `(doc: Text) => Diagnostic[] | Promise<Diagnostic[]>` the linting function
83
105
  Set the linting function.
84
106
 
85
107
  ```js
86
- cm.lint( ( str ) => [
108
+ cm.lint( ( doc ) => [
87
109
  /**
88
110
  * @type {Diagnostic}
89
111
  * @see https://codemirror.net/docs/ref/#lint.Diagnostic
90
112
  */
91
113
  {
92
114
  from: 0,
93
- to: str.length,
115
+ to: doc.toString().length,
94
116
  message: 'error message',
95
117
  severity: 'error',
96
118
  },
@@ -1,8 +1,11 @@
1
1
  import { EditorView } from '@codemirror/view';
2
+ import type { Text } from '@codemirror/state';
2
3
  import type { Diagnostic } from '@codemirror/lint';
3
4
  export type { MwConfig } from './mediawiki';
5
+ export type LintSource = (doc: Text) => Diagnostic[] | Promise<Diagnostic[]>;
4
6
  export declare class CodeMirror6 {
5
7
  #private;
8
+ lang: string;
6
9
  get textarea(): HTMLTextAreaElement;
7
10
  get view(): EditorView;
8
11
  /**
@@ -21,11 +24,13 @@ export declare class CodeMirror6 {
21
24
  * 开始语法检查
22
25
  * @param lintSource 语法检查函数
23
26
  */
24
- lint(lintSource?: (str: string) => Diagnostic[] | Promise<Diagnostic[]>): void;
27
+ lint(lintSource?: LintSource): void;
25
28
  /** 立即更新语法检查 */
26
29
  update(): void;
27
30
  /** 添加扩展 */
28
31
  prefer(names: string[]): void;
29
32
  /** 设置缩进 */
30
33
  setIndent(indent: string): void;
34
+ /** 获取默认linter */
35
+ getLinter(): Promise<LintSource>;
31
36
  }