@bhsd/codemirror-mediawiki 2.9.5 → 2.11.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.
package/README.md CHANGED
@@ -16,6 +16,7 @@
16
16
  - [extraKeys](#extrakeys)
17
17
  - [getLinter](#getlinter)
18
18
  - [getNodeAt](#getnodeat)
19
+ - [initialize](#initialize)
19
20
  - [lint](#lint)
20
21
  - [localize](#localize)
21
22
  - [prefer](#prefer)
@@ -30,6 +31,7 @@
30
31
  - [replaceSelections](#replaceselections)
31
32
  - [Extensions](#extensions)
32
33
  - [allowMultipleSelections](#allowmultipleselections)
34
+ - [autocompletion](#autocompletion)
33
35
  - [bracketMatching](#bracketmatching)
34
36
  - [closeBrackets](#closebrackets)
35
37
  - [highlightActiveLine](#highlightactiveline)
@@ -39,6 +41,7 @@
39
41
  - [escape](#escape)
40
42
  - [codeFolding](#codefolding)
41
43
  - [tagMatching](#tagmatching)
44
+ - [useMonaco](#usemonaco)
42
45
 
43
46
  </details>
44
47
 
@@ -86,6 +89,7 @@ const {CodeMirror6} = await import('https://unpkg.com/@bhsd/codemirror-mediawiki
86
89
  **param**: `HTMLTextAreaElement` the textarea element to be replaced by CodeMirror
87
90
  **param**: `string` the language mode to be used, default as plain text
88
91
  **param**: `unknown` the optional language configuration
92
+ **param**: `boolean` whether to initialize immediately, default as true
89
93
 
90
94
  ```js
91
95
  const cm = new CodeMirror6(textarea); // plain text
@@ -128,7 +132,7 @@ The current language mode, read-only.
128
132
  <details>
129
133
  <summary>Expand</summary>
130
134
 
131
- **type**: [`EditorView`](https://codemirror.net/6/docs/ref/#view.EditorView)
135
+ **type**: [`EditorView | undefined`](https://codemirror.net/6/docs/ref/#view.EditorView)
132
136
  The CodeMirror EditorView instance, read-only.
133
137
 
134
138
  </details>
@@ -202,6 +206,22 @@ const tree = cm.getNodeAt(0);
202
206
 
203
207
  </details>
204
208
 
209
+ ## initialize
210
+
211
+ <details>
212
+ <summary>Expand</summary>
213
+
214
+ *version added: 2.11.0*
215
+
216
+ **param**: `unknown` the optional language configuration
217
+ Initialize the editor.
218
+
219
+ ```js
220
+ cm.initialize();
221
+ ```
222
+
223
+ </details>
224
+
205
225
  ## lint
206
226
 
207
227
  <details>
@@ -430,9 +450,9 @@ Allow multiple selections.
430
450
 
431
451
  ## autocompletion
432
452
 
433
- *version added: 2.5.1*
453
+ *version added: 2.10.0*
434
454
 
435
- Provide autocompletion for the MediaWiki mode.
455
+ Provide autocompletion for MediaWiki, CSS and JavaScript modes.
436
456
 
437
457
  ## bracketMatching
438
458
 
@@ -477,7 +497,7 @@ Key bindings:
477
497
 
478
498
  ## codeFolding
479
499
 
480
- *version added: 2.3.0*
500
+ *version added: 2.10.0*
481
501
 
482
502
  Fold template parameters.
483
503
 
@@ -493,3 +513,9 @@ Key bindings:
493
513
  *version added: 2.4.1*
494
514
 
495
515
  Matched or unmatched tags are highlighted in cyan or dark red when the cursor is inside.
516
+
517
+ ## useMonaco
518
+
519
+ *version added: 2.11.0*
520
+
521
+ Use the Monaco editor instead of the CodeMirror editor.
@@ -14,7 +14,7 @@ export type LintSource = (doc: Text) => Diagnostic[] | Promise<Diagnostic[]>;
14
14
  export declare class CodeMirror6 {
15
15
  #private;
16
16
  get textarea(): HTMLTextAreaElement;
17
- get view(): EditorView;
17
+ get view(): EditorView | undefined;
18
18
  get lang(): string;
19
19
  get visible(): boolean;
20
20
  /**
@@ -22,7 +22,12 @@ export declare class CodeMirror6 {
22
22
  * @param lang 语言
23
23
  * @param config 语言设置
24
24
  */
25
- constructor(textarea: HTMLTextAreaElement, lang?: string, config?: unknown);
25
+ constructor(textarea: HTMLTextAreaElement, lang?: string, config?: unknown, init?: boolean);
26
+ /**
27
+ * 初始化编辑器
28
+ * @param config 语言设置
29
+ */
30
+ initialize(config?: unknown): void;
26
31
  /**
27
32
  * 设置语言
28
33
  * @param lang 语言
@@ -70,7 +75,7 @@ export declare class CodeMirror6 {
70
75
  * 设置翻译信息
71
76
  * @param messages 翻译信息
72
77
  */
73
- localize(messages: Record<string, string>): void;
78
+ localize(messages?: Record<string, string>): void;
74
79
  /**
75
80
  * 获取语法树节点
76
81
  * @param position 位置
@@ -78,9 +83,9 @@ export declare class CodeMirror6 {
78
83
  getNodeAt(position: number): SyntaxNode | undefined;
79
84
  /**
80
85
  * 滚动至指定位置
81
- * @param r 位置
86
+ * @param position 位置
82
87
  */
83
- scrollTo(r?: number | {
88
+ scrollTo(position?: number | {
84
89
  anchor: number;
85
90
  head: number;
86
91
  }): void;