@bhsd/codemirror-mediawiki 2.1.13 → 2.2.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 +48 -2
- package/dist/codemirror.d.ts +13 -0
- package/dist/main.min.js +12 -12
- package/dist/main.min.js.map +3 -3
- package/dist/mw.min.js +1 -1
- package/dist/mw.min.js.map +4 -4
- package/mw/base.ts +78 -40
- package/mw/config.ts +1 -1
- package/mw/escape.ts +36 -0
- package/mw/msg.ts +34 -0
- package/mw/preference.ts +81 -0
- package/package.json +3 -3
- package/src/codemirror.ts +52 -25
package/README.md
CHANGED
|
@@ -6,11 +6,14 @@
|
|
|
6
6
|
|
|
7
7
|
- [Description](#description)
|
|
8
8
|
- [Usage](#usage)
|
|
9
|
-
|
|
9
|
+
- [Constructor](#constructor)
|
|
10
|
+
- [Accessors](#accessors)
|
|
10
11
|
- [textarea](#textarea)
|
|
11
12
|
- [lang](#lang)
|
|
12
13
|
- [view](#view)
|
|
13
14
|
- [visible](#visible)
|
|
15
|
+
- [Methods](#methods)
|
|
16
|
+
- [extraKeys](#extrakeys)
|
|
14
17
|
- [getLinter](#getlinter)
|
|
15
18
|
- [lint](#lint)
|
|
16
19
|
- [prefer](#prefer)
|
|
@@ -19,6 +22,8 @@
|
|
|
19
22
|
- [setLanguage](#setlanguage)
|
|
20
23
|
- [toggle](#toggle)
|
|
21
24
|
- [update](#update)
|
|
25
|
+
- [Static methods](#static-methods)
|
|
26
|
+
- [replaceSelections](#replaceselections)
|
|
22
27
|
|
|
23
28
|
</details>
|
|
24
29
|
|
|
@@ -44,7 +49,7 @@ or
|
|
|
44
49
|
const {CodeMirror6} = await import('https://cdn.jsdelivr.net/npm/@bhsd/codemirror-mediawiki/dist/main.min.js');
|
|
45
50
|
```
|
|
46
51
|
|
|
47
|
-
|
|
52
|
+
# Constructor
|
|
48
53
|
|
|
49
54
|
<details>
|
|
50
55
|
<summary>Expand</summary>
|
|
@@ -65,6 +70,8 @@ const cm = new CodeMirror6(textarea, 'lua');
|
|
|
65
70
|
|
|
66
71
|
</details>
|
|
67
72
|
|
|
73
|
+
# Accessors
|
|
74
|
+
|
|
68
75
|
## textarea
|
|
69
76
|
|
|
70
77
|
<details>
|
|
@@ -109,6 +116,26 @@ Whether the editor is visible, read-only.
|
|
|
109
116
|
|
|
110
117
|
</details>
|
|
111
118
|
|
|
119
|
+
# Methods
|
|
120
|
+
|
|
121
|
+
## extraKeys
|
|
122
|
+
|
|
123
|
+
<details>
|
|
124
|
+
<summary>Expand</summary>
|
|
125
|
+
|
|
126
|
+
*version added: 2.2.0*
|
|
127
|
+
|
|
128
|
+
**param**: [`KeyBinding[]`](https://codemirror.net/docs/ref/#view.KeyBinding) the extra key bindings
|
|
129
|
+
Add extra key bindings.
|
|
130
|
+
|
|
131
|
+
```js
|
|
132
|
+
cm.extraKeys([
|
|
133
|
+
{key: 'Tab', run: () => console.log('Tab'), preventDefault: true},
|
|
134
|
+
]);
|
|
135
|
+
```
|
|
136
|
+
|
|
137
|
+
</details>
|
|
138
|
+
|
|
112
139
|
## getLinter
|
|
113
140
|
|
|
114
141
|
<details>
|
|
@@ -266,3 +293,22 @@ cm.toggle(false); // hide CodeMirror
|
|
|
266
293
|
Refresh linting immediately.
|
|
267
294
|
|
|
268
295
|
</details>
|
|
296
|
+
|
|
297
|
+
# Static methods
|
|
298
|
+
|
|
299
|
+
## replaceSelections
|
|
300
|
+
|
|
301
|
+
<details>
|
|
302
|
+
<summary>Expand</summary>
|
|
303
|
+
|
|
304
|
+
*version added: 2.2.0*
|
|
305
|
+
|
|
306
|
+
**param**: [`EditorView`](https://codemirror.net/6/docs/ref/#view.EditorView) the CodeMirror EditorView instance
|
|
307
|
+
**param**: `(str: string) => string` the replacement function
|
|
308
|
+
Replace the selected text with the return value of the replacement function.
|
|
309
|
+
|
|
310
|
+
```js
|
|
311
|
+
CodeMirror6.replaceSelections(cm.view, str => str.toUpperCase());
|
|
312
|
+
```
|
|
313
|
+
|
|
314
|
+
</details>
|
package/dist/codemirror.d.ts
CHANGED
|
@@ -1,8 +1,10 @@
|
|
|
1
1
|
import { EditorView } from '@codemirror/view';
|
|
2
|
+
import type { KeyBinding } from '@codemirror/view';
|
|
2
3
|
import type { Text } from '@codemirror/state';
|
|
3
4
|
import type { Diagnostic } from '@codemirror/lint';
|
|
4
5
|
export type { MwConfig } from './mediawiki';
|
|
5
6
|
export type LintSource = (doc: Text) => Diagnostic[] | Promise<Diagnostic[]>;
|
|
7
|
+
export declare const CDN = "https://testingcf.jsdelivr.net";
|
|
6
8
|
export declare class CodeMirror6 {
|
|
7
9
|
#private;
|
|
8
10
|
get textarea(): HTMLTextAreaElement;
|
|
@@ -50,4 +52,15 @@ export declare class CodeMirror6 {
|
|
|
50
52
|
* @param show 是否显示编辑器
|
|
51
53
|
*/
|
|
52
54
|
toggle(show?: boolean): void;
|
|
55
|
+
/**
|
|
56
|
+
* 添加额外快捷键
|
|
57
|
+
* @param keys 快捷键
|
|
58
|
+
*/
|
|
59
|
+
extraKeys(keys: KeyBinding[]): void;
|
|
60
|
+
/**
|
|
61
|
+
* 替换选中内容
|
|
62
|
+
* @param view EditorView
|
|
63
|
+
* @param func 替换函数
|
|
64
|
+
*/
|
|
65
|
+
static replaceSelections(view: EditorView, func: (str: string) => string): void;
|
|
53
66
|
}
|