@bhsd/codemirror-mediawiki 2.10.0 → 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 +26 -1
- package/dist/codemirror.d.ts +10 -5
- package/dist/main.min.js +13 -13
- package/dist/mw.min.js +9 -5
- package/dist/mw.min.js.map +3 -3
- package/dist/plugins.d.ts +2 -1
- package/dist/util.d.ts +5 -1
- package/i18n/en.json +2 -1
- package/i18n/zh-hans.json +2 -1
- package/i18n/zh-hant.json +2 -1
- package/package.json +4 -3
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)
|
|
@@ -40,6 +41,7 @@
|
|
|
40
41
|
- [escape](#escape)
|
|
41
42
|
- [codeFolding](#codefolding)
|
|
42
43
|
- [tagMatching](#tagmatching)
|
|
44
|
+
- [useMonaco](#usemonaco)
|
|
43
45
|
|
|
44
46
|
</details>
|
|
45
47
|
|
|
@@ -87,6 +89,7 @@ const {CodeMirror6} = await import('https://unpkg.com/@bhsd/codemirror-mediawiki
|
|
|
87
89
|
**param**: `HTMLTextAreaElement` the textarea element to be replaced by CodeMirror
|
|
88
90
|
**param**: `string` the language mode to be used, default as plain text
|
|
89
91
|
**param**: `unknown` the optional language configuration
|
|
92
|
+
**param**: `boolean` whether to initialize immediately, default as true
|
|
90
93
|
|
|
91
94
|
```js
|
|
92
95
|
const cm = new CodeMirror6(textarea); // plain text
|
|
@@ -129,7 +132,7 @@ The current language mode, read-only.
|
|
|
129
132
|
<details>
|
|
130
133
|
<summary>Expand</summary>
|
|
131
134
|
|
|
132
|
-
**type**: [`EditorView`](https://codemirror.net/6/docs/ref/#view.EditorView)
|
|
135
|
+
**type**: [`EditorView | undefined`](https://codemirror.net/6/docs/ref/#view.EditorView)
|
|
133
136
|
The CodeMirror EditorView instance, read-only.
|
|
134
137
|
|
|
135
138
|
</details>
|
|
@@ -203,6 +206,22 @@ const tree = cm.getNodeAt(0);
|
|
|
203
206
|
|
|
204
207
|
</details>
|
|
205
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
|
+
|
|
206
225
|
## lint
|
|
207
226
|
|
|
208
227
|
<details>
|
|
@@ -494,3 +513,9 @@ Key bindings:
|
|
|
494
513
|
*version added: 2.4.1*
|
|
495
514
|
|
|
496
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.
|
package/dist/codemirror.d.ts
CHANGED
|
@@ -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
|
|
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
|
|
86
|
+
* @param position 位置
|
|
82
87
|
*/
|
|
83
|
-
scrollTo(
|
|
88
|
+
scrollTo(position?: number | {
|
|
84
89
|
anchor: number;
|
|
85
90
|
head: number;
|
|
86
91
|
}): void;
|