@bhsd/codemirror-mediawiki 2.4.1 → 2.4.3
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 +97 -1
- package/dist/codemirror.d.ts +7 -1
- package/dist/main.min.js +11 -11
- package/dist/mw.min.js +1 -1
- package/dist/mw.min.js.map +4 -4
- package/i18n/en.json +4 -2
- package/i18n/zh-hans.json +4 -2
- package/i18n/zh-hant.json +4 -2
- package/mw/base.ts +7 -2
- package/mw/config.ts +2 -2
- package/mw/msg.ts +3 -3
- package/mw/openLinks.ts +43 -30
- package/mw/preference.ts +6 -2
- package/mw/wikiEditor.ts +26 -0
- package/package.json +3 -2
package/README.md
CHANGED
|
@@ -15,6 +15,7 @@
|
|
|
15
15
|
- [Methods](#methods)
|
|
16
16
|
- [extraKeys](#extrakeys)
|
|
17
17
|
- [getLinter](#getlinter)
|
|
18
|
+
- [getNodeAt](#getnodeat)
|
|
18
19
|
- [lint](#lint)
|
|
19
20
|
- [localize](#localize)
|
|
20
21
|
- [prefer](#prefer)
|
|
@@ -25,6 +26,17 @@
|
|
|
25
26
|
- [update](#update)
|
|
26
27
|
- [Static methods](#static-methods)
|
|
27
28
|
- [replaceSelections](#replaceselections)
|
|
29
|
+
- [Extensions](#extensions)
|
|
30
|
+
- [allowMultipleSelections](#allowmultipleselections)
|
|
31
|
+
- [bracketMatching](#bracketmatching)
|
|
32
|
+
- [closeBrackets](#closebrackets)
|
|
33
|
+
- [highlightActiveLine](#highlightactiveline)
|
|
34
|
+
- [highlightSpecialChars](#highlightspecialchars)
|
|
35
|
+
- [highlightWhitespace](#highlightwhitespace)
|
|
36
|
+
- [highlightTrailingWhitespace](#highlighttrailingwhitespace)
|
|
37
|
+
- [escape](#escape)
|
|
38
|
+
- [codeFolding](#codefolding)
|
|
39
|
+
- [tagMatching](#tagmatching)
|
|
28
40
|
|
|
29
41
|
</details>
|
|
30
42
|
|
|
@@ -157,6 +169,23 @@ const linterCSS = await cm.getLinter({rules}); // Stylelint configuration
|
|
|
157
169
|
|
|
158
170
|
</details>
|
|
159
171
|
|
|
172
|
+
## getNodeAt
|
|
173
|
+
|
|
174
|
+
<details>
|
|
175
|
+
<summary>Expand</summary>
|
|
176
|
+
|
|
177
|
+
*version added: 2.4.2*
|
|
178
|
+
|
|
179
|
+
**param**: `number` position
|
|
180
|
+
**returns**: [`SyntaxNode | undefined`](https://lezer.codemirror.net/docs/ref/#common.SyntaxNode)
|
|
181
|
+
Get the syntax node at the given position.
|
|
182
|
+
|
|
183
|
+
```js
|
|
184
|
+
const tree = cm.getNodeAt(0);
|
|
185
|
+
```
|
|
186
|
+
|
|
187
|
+
</details>
|
|
188
|
+
|
|
160
189
|
## lint
|
|
161
190
|
|
|
162
191
|
<details>
|
|
@@ -208,7 +237,7 @@ cm.localize({
|
|
|
208
237
|
*version added: 2.0.9*
|
|
209
238
|
|
|
210
239
|
**param**: `string[] | Record<string, boolean>` the preferred [CodeMirror extensions](https://codemirror.net/docs/extensions/)
|
|
211
|
-
Set the preferred CodeMirror extensions.
|
|
240
|
+
Set the preferred CodeMirror extensions. Available extensions are introduced [later](#extensions).
|
|
212
241
|
|
|
213
242
|
```js
|
|
214
243
|
cm.prefer([
|
|
@@ -341,3 +370,70 @@ CodeMirror6.replaceSelections(cm.view, str => str.toUpperCase());
|
|
|
341
370
|
```
|
|
342
371
|
|
|
343
372
|
</details>
|
|
373
|
+
|
|
374
|
+
# Extensions
|
|
375
|
+
|
|
376
|
+
## allowMultipleSelections
|
|
377
|
+
|
|
378
|
+
*version added: 2.1.11*
|
|
379
|
+
|
|
380
|
+
Allow multiple selections.
|
|
381
|
+
|
|
382
|
+
## bracketMatching
|
|
383
|
+
|
|
384
|
+
*version added: 2.0.9*
|
|
385
|
+
|
|
386
|
+
Matched or unmatched brackets are highlighted in cyan or dark red when the cursor is next to them.
|
|
387
|
+
|
|
388
|
+
## closeBrackets
|
|
389
|
+
|
|
390
|
+
*version added: 2.0.9*
|
|
391
|
+
|
|
392
|
+
Automatically close brackets (`{`, `[` and `(`) and quotes (`"`, and `'` except for the MediaWiki mode).
|
|
393
|
+
|
|
394
|
+
## highlightActiveLine
|
|
395
|
+
|
|
396
|
+
Highlight the line the cursor is on in light cyan.
|
|
397
|
+
|
|
398
|
+
## highlightSpecialChars
|
|
399
|
+
|
|
400
|
+
Show invisible characters as red dots.
|
|
401
|
+
|
|
402
|
+
## highlightWhitespace
|
|
403
|
+
|
|
404
|
+
*version added: 2.0.12*
|
|
405
|
+
|
|
406
|
+
Show spaces and tabs as dots and arrows.
|
|
407
|
+
|
|
408
|
+
## highlightTrailingWhitespace
|
|
409
|
+
|
|
410
|
+
*version added: 2.0.9*
|
|
411
|
+
|
|
412
|
+
Highlight trailing whitespace in a red-orange color.
|
|
413
|
+
|
|
414
|
+
## escape
|
|
415
|
+
|
|
416
|
+
*version added: 2.2.2*
|
|
417
|
+
|
|
418
|
+
Key bindings:
|
|
419
|
+
|
|
420
|
+
- `Ctrl`/`Cmd` + `[`: Escape the selected text with HTML entities
|
|
421
|
+
- `Ctrl`/`Cmd` + `]`: Escape the selected text with URL encoding
|
|
422
|
+
|
|
423
|
+
## codeFolding
|
|
424
|
+
|
|
425
|
+
*version added: 2.3.0*
|
|
426
|
+
|
|
427
|
+
Fold template parameters.
|
|
428
|
+
|
|
429
|
+
Key bindings:
|
|
430
|
+
|
|
431
|
+
- `Ctrl` + `Shift` + `[`/`Cmd` + `Alt` + `[`: Fold the selected templates
|
|
432
|
+
- `Ctrl` + `Shift` + `]`/`Cmd` + `Alt` + `]`: Unfold the selected templates
|
|
433
|
+
- `Ctrl` + `Alt` + `]`: Unfold all templates
|
|
434
|
+
|
|
435
|
+
## tagMatching
|
|
436
|
+
|
|
437
|
+
*version added: 2.4.1*
|
|
438
|
+
|
|
439
|
+
Matched or unmatched tags are highlighted in cyan or dark red when the cursor is inside.
|
package/dist/codemirror.d.ts
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { EditorView } from '@codemirror/view';
|
|
2
2
|
import type { KeyBinding } from '@codemirror/view';
|
|
3
3
|
import type { Text } from '@codemirror/state';
|
|
4
|
+
import type { SyntaxNode } from '@lezer/common';
|
|
4
5
|
import type { Diagnostic } from '@codemirror/lint';
|
|
5
6
|
export type { MwConfig } from './mediawiki';
|
|
6
7
|
export type LintSource = (doc: Text) => Diagnostic[] | Promise<Diagnostic[]>;
|
|
@@ -65,9 +66,14 @@ export declare class CodeMirror6 {
|
|
|
65
66
|
* @param messages 翻译信息
|
|
66
67
|
*/
|
|
67
68
|
localize(messages: Record<string, string>): void;
|
|
69
|
+
/**
|
|
70
|
+
* 获取语法树节点
|
|
71
|
+
* @param position 位置
|
|
72
|
+
*/
|
|
73
|
+
getNodeAt(position: number): SyntaxNode | undefined;
|
|
68
74
|
/**
|
|
69
75
|
* 替换选中内容
|
|
70
|
-
* @param view
|
|
76
|
+
* @param view
|
|
71
77
|
* @param func 替换函数
|
|
72
78
|
*/
|
|
73
79
|
static replaceSelections(view: EditorView, func: (str: string) => string): void;
|