@bhsd/codemirror-mediawiki 2.31.0 → 3.0.1
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 +181 -32
- package/dist/codemirror.d.ts +72 -47
- package/dist/codemirror.js +169 -208
- package/dist/color.d.ts +1 -6
- package/dist/color.js +1 -8
- package/dist/config.js +4 -4
- package/dist/escape.js +2 -2
- package/dist/fold.d.ts +53 -6
- package/dist/fold.js +130 -133
- package/dist/indent.d.ts +5 -1
- package/dist/indent.js +2 -1
- package/dist/javascript.d.ts +1 -0
- package/dist/javascript.js +2 -4
- package/dist/keybindings.js +1 -0
- package/dist/linter.js +43 -8
- package/dist/lintsource.d.ts +14 -0
- package/dist/lintsource.js +159 -0
- package/dist/main.min.js +25 -24
- package/dist/matchBrackets.d.ts +1 -1
- package/dist/matchTag.js +2 -2
- package/dist/mw.min.js +26 -25
- package/dist/mwConfig.js +0 -3
- package/dist/statusBar.d.ts +1 -1
- package/dist/token.d.ts +1 -1
- package/dist/token.js +11 -16
- package/dist/vue.d.ts +3 -0
- package/dist/vue.js +14 -0
- package/dist/wiki.min.js +25 -24
- package/i18n/en.json +2 -3
- package/i18n/zh-hans.json +2 -3
- package/i18n/zh-hant.json +2 -3
- package/package.json +10 -7
package/README.md
CHANGED
|
@@ -10,8 +10,17 @@
|
|
|
10
10
|
- [Browser Usage](#browser-usage)
|
|
11
11
|
- [JavaScript](#javascript)
|
|
12
12
|
- [CSS](#css)
|
|
13
|
+
- [Language modes](#language-modes)
|
|
14
|
+
- [css](#css)
|
|
15
|
+
- [html](#html)
|
|
16
|
+
- [javascript](#javascript)
|
|
17
|
+
- [json](#json)
|
|
18
|
+
- [lua](#lua)
|
|
19
|
+
- [mediawiki](#mediawiki)
|
|
20
|
+
- [vue](#vue)
|
|
13
21
|
- [Constructor](#constructor)
|
|
14
22
|
- [Accessors](#accessors)
|
|
23
|
+
- [dialect](#dialect)
|
|
15
24
|
- [lang](#lang)
|
|
16
25
|
- [textarea](#textarea)
|
|
17
26
|
- [view](#view)
|
|
@@ -54,7 +63,6 @@
|
|
|
54
63
|
- [refHover](#refhover)
|
|
55
64
|
- [scrollPastEnd](#scrollpastend)
|
|
56
65
|
- [signatureHelp](#signaturehelp)
|
|
57
|
-
- [tagMatching](#tagmatching)
|
|
58
66
|
- [Known issues](#known-issues)
|
|
59
67
|
- [Syntax Highlighting](#syntax-highlighting)
|
|
60
68
|
|
|
@@ -77,7 +85,16 @@ npm install @bhsd/codemirror-mediawiki
|
|
|
77
85
|
```
|
|
78
86
|
|
|
79
87
|
```js
|
|
80
|
-
import {
|
|
88
|
+
import {
|
|
89
|
+
CodeMirror6,
|
|
90
|
+
registerMediaWiki,
|
|
91
|
+
registerHTML,
|
|
92
|
+
registerCSS,
|
|
93
|
+
registerJavaScript,
|
|
94
|
+
registerJSON,
|
|
95
|
+
registerLua,
|
|
96
|
+
registerVue,
|
|
97
|
+
} from '@bhsd/codemirror-mediawiki';
|
|
81
98
|
```
|
|
82
99
|
|
|
83
100
|
# Browser Usage
|
|
@@ -88,26 +105,62 @@ You can download the code via CDN, for example:
|
|
|
88
105
|
|
|
89
106
|
```js
|
|
90
107
|
// static import
|
|
91
|
-
import {
|
|
108
|
+
import {
|
|
109
|
+
CodeMirror6,
|
|
110
|
+
registerMediaWiki,
|
|
111
|
+
registerHTML,
|
|
112
|
+
registerCSS,
|
|
113
|
+
registerJavaScript,
|
|
114
|
+
registerJSON,
|
|
115
|
+
registerLua,
|
|
116
|
+
registerVue,
|
|
117
|
+
} from 'https://cdn.jsdelivr.net/npm/@bhsd/codemirror-mediawiki';
|
|
92
118
|
```
|
|
93
119
|
|
|
94
120
|
or
|
|
95
121
|
|
|
96
122
|
```js
|
|
97
|
-
import {
|
|
123
|
+
import {
|
|
124
|
+
CodeMirror6,
|
|
125
|
+
registerMediaWiki,
|
|
126
|
+
registerHTML,
|
|
127
|
+
registerCSS,
|
|
128
|
+
registerJavaScript,
|
|
129
|
+
registerJSON,
|
|
130
|
+
registerLua,
|
|
131
|
+
registerVue,
|
|
132
|
+
} from 'https://unpkg.com/@bhsd/codemirror-mediawiki';
|
|
98
133
|
```
|
|
99
134
|
|
|
100
135
|
or
|
|
101
136
|
|
|
102
137
|
```js
|
|
103
138
|
// dynamic import
|
|
104
|
-
const {
|
|
139
|
+
const {
|
|
140
|
+
CodeMirror6,
|
|
141
|
+
registerMediaWiki,
|
|
142
|
+
registerHTML,
|
|
143
|
+
registerCSS,
|
|
144
|
+
registerJavaScript,
|
|
145
|
+
registerJSON,
|
|
146
|
+
registerLua,
|
|
147
|
+
registerVue,
|
|
148
|
+
} = await import('https://cdn.jsdelivr.net/npm/@bhsd/codemirror-mediawiki');
|
|
105
149
|
```
|
|
106
150
|
|
|
107
151
|
or
|
|
108
152
|
|
|
109
153
|
```js
|
|
110
|
-
const {
|
|
154
|
+
const {
|
|
155
|
+
CodeMirror6,
|
|
156
|
+
registerMediaWiki,
|
|
157
|
+
registerHTML,
|
|
158
|
+
registerCSS,
|
|
159
|
+
registerJavaScript,
|
|
160
|
+
registerJSON,
|
|
161
|
+
registerLua,
|
|
162
|
+
registerVue,
|
|
163
|
+
} = await import('https://unpkg.com/@bhsd/codemirror-mediawiki');
|
|
111
164
|
```
|
|
112
165
|
|
|
113
166
|
## CSS
|
|
@@ -122,6 +175,81 @@ or
|
|
|
122
175
|
<link rel="stylesheet" href="https://unpkg.com/@bhsd/codemirror-mediawiki/mediawiki.css">
|
|
123
176
|
```
|
|
124
177
|
|
|
178
|
+
# Language modes
|
|
179
|
+
|
|
180
|
+
## css
|
|
181
|
+
|
|
182
|
+
The CSS mode contains a [dialect](#dialect) for [Extension:TemplateStyles](https://www.mediawiki.org/wiki/Extension:TemplateStyles). You can bundle the CSS mode by importing the `registerCSS` function:
|
|
183
|
+
|
|
184
|
+
```js
|
|
185
|
+
import {registerCSS} from '@bhsd/codemirror-mediawiki';
|
|
186
|
+
registerCSS();
|
|
187
|
+
```
|
|
188
|
+
|
|
189
|
+
## html
|
|
190
|
+
|
|
191
|
+
This is a mixed MediaWiki-HTML mode, which is used for [Extension:Widgets](https://www.mediawiki.org/wiki/Extension:Widgets). You can bundle the HTML mode by importing the `registerHTML` function:
|
|
192
|
+
|
|
193
|
+
```js
|
|
194
|
+
import {registerHTML} from '@bhsd/codemirror-mediawiki';
|
|
195
|
+
registerHTML();
|
|
196
|
+
```
|
|
197
|
+
|
|
198
|
+
## javascript
|
|
199
|
+
|
|
200
|
+
You can bundle the JavaScript mode by importing the `registerJavaScript` function:
|
|
201
|
+
|
|
202
|
+
```js
|
|
203
|
+
import {registerJavaScript} from '@bhsd/codemirror-mediawiki';
|
|
204
|
+
registerJavaScript();
|
|
205
|
+
```
|
|
206
|
+
|
|
207
|
+
## json
|
|
208
|
+
|
|
209
|
+
You can bundle the JSON mode by importing the `registerJSON` function:
|
|
210
|
+
|
|
211
|
+
```js
|
|
212
|
+
import {registerJSON} from '@bhsd/codemirror-mediawiki';
|
|
213
|
+
registerJSON();
|
|
214
|
+
```
|
|
215
|
+
|
|
216
|
+
## lua
|
|
217
|
+
|
|
218
|
+
You can bundle the Lua mode by importing the `registerLua` function:
|
|
219
|
+
|
|
220
|
+
```js
|
|
221
|
+
import {registerLua} from '@bhsd/codemirror-mediawiki';
|
|
222
|
+
registerLua();
|
|
223
|
+
```
|
|
224
|
+
|
|
225
|
+
## mediawiki
|
|
226
|
+
|
|
227
|
+
You can bundle the MediaWiki mode by importing the `registerMediaWiki` function:
|
|
228
|
+
|
|
229
|
+
```js
|
|
230
|
+
import {registerMediaWiki} from '@bhsd/codemirror-mediawiki';
|
|
231
|
+
registerMediaWiki();
|
|
232
|
+
```
|
|
233
|
+
|
|
234
|
+
## vue
|
|
235
|
+
|
|
236
|
+
You can bundle the Vue mode by importing the `registerVue` function:
|
|
237
|
+
|
|
238
|
+
```js
|
|
239
|
+
import {registerVue} from '@bhsd/codemirror-mediawiki';
|
|
240
|
+
registerVue();
|
|
241
|
+
```
|
|
242
|
+
|
|
243
|
+
## Other languages
|
|
244
|
+
|
|
245
|
+
You can also register other languages by importing the `registerLanguage` function:
|
|
246
|
+
|
|
247
|
+
```js
|
|
248
|
+
import {registerLanguage} from '@bhsd/codemirror-mediawiki';
|
|
249
|
+
import {python} from '@codemirror/lang-python';
|
|
250
|
+
registerLanguage('python', python);
|
|
251
|
+
```
|
|
252
|
+
|
|
125
253
|
# Constructor
|
|
126
254
|
|
|
127
255
|
<details>
|
|
@@ -133,19 +261,33 @@ or
|
|
|
133
261
|
**param**: `boolean` whether to initialize immediately, default as true
|
|
134
262
|
|
|
135
263
|
```js
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
264
|
+
let cm;
|
|
265
|
+
cm = new CodeMirror6(textarea); // plain text
|
|
266
|
+
cm = new CodeMirror6(textarea, 'mediawiki', mwConfig);
|
|
267
|
+
cm = new CodeMirror6(textarea, 'html', mwConfig);
|
|
268
|
+
cm = new CodeMirror6(textarea, 'css');
|
|
269
|
+
cm = new CodeMirror6(textarea, 'javascript');
|
|
270
|
+
cm = new CodeMirror6(textarea, 'json');
|
|
271
|
+
cm = new CodeMirror6(textarea, 'lua');
|
|
272
|
+
cm = new CodeMirror6(textarea, 'vue');
|
|
143
273
|
```
|
|
144
274
|
|
|
145
275
|
</details>
|
|
146
276
|
|
|
147
277
|
# Accessors
|
|
148
278
|
|
|
279
|
+
## dialect
|
|
280
|
+
|
|
281
|
+
<details>
|
|
282
|
+
<summary>Expand</summary>
|
|
283
|
+
|
|
284
|
+
*version added: 2.28.0*
|
|
285
|
+
|
|
286
|
+
**type**: `'sanitized-css' | undefined`
|
|
287
|
+
Only used for [Extension:TemplateStyles](https://www.mediawiki.org/wiki/Extension:TemplateStyles) as a dialect of the CSS mode.
|
|
288
|
+
|
|
289
|
+
</details>
|
|
290
|
+
|
|
149
291
|
## lang
|
|
150
292
|
|
|
151
293
|
<details>
|
|
@@ -233,7 +375,7 @@ cm.extraKeys([
|
|
|
233
375
|
*version added: 2.1.3*
|
|
234
376
|
|
|
235
377
|
**param**: `Record<string, any>` the optional linter configuration
|
|
236
|
-
**returns**: `Promise<(
|
|
378
|
+
**returns**: `Promise<(state: EditorState) => Diagnostic[] | Promise<Diagnostic[]>>`
|
|
237
379
|
Get the default linting function, which can be used as the argument of [`lint`](#lint).
|
|
238
380
|
|
|
239
381
|
```js
|
|
@@ -283,11 +425,11 @@ cm.initialize();
|
|
|
283
425
|
<details>
|
|
284
426
|
<summary>Expand</summary>
|
|
285
427
|
|
|
286
|
-
**param**: `(
|
|
428
|
+
**param**: `(state: EditorState) => Diagnostic[] | Promise<Diagnostic[]>` the linting function
|
|
287
429
|
Set the linting function.
|
|
288
430
|
|
|
289
431
|
```js
|
|
290
|
-
cm.lint(doc => [
|
|
432
|
+
cm.lint(({doc}) => [
|
|
291
433
|
/**
|
|
292
434
|
* @type {Diagnostic}
|
|
293
435
|
* @see https://codemirror.net/docs/ref/#lint.Diagnostic
|
|
@@ -337,36 +479,48 @@ cm.prefer([
|
|
|
337
479
|
'autocompletion',
|
|
338
480
|
'bracketMatching',
|
|
339
481
|
'closeBrackets',
|
|
482
|
+
'codeFolding',
|
|
340
483
|
'highlightActiveLine',
|
|
484
|
+
'highlightSelectionMatches',
|
|
341
485
|
'highlightSpecialChars',
|
|
342
|
-
'highlightWhitespace',
|
|
343
486
|
'highlightTrailingWhitespace',
|
|
344
|
-
'
|
|
345
|
-
'codeFolding',
|
|
487
|
+
'highlightWhitespace',
|
|
346
488
|
'scrollPastEnd',
|
|
347
489
|
|
|
490
|
+
// only available in CSS and MediaWiki modes
|
|
491
|
+
'colorPicker',
|
|
492
|
+
|
|
348
493
|
// only available in MediaWiki mode
|
|
349
494
|
'escape',
|
|
350
|
-
'
|
|
495
|
+
'hover',
|
|
496
|
+
'inlayHints',
|
|
497
|
+
'openLinks',
|
|
351
498
|
'refHover',
|
|
499
|
+
'signatureHelp',
|
|
352
500
|
]);
|
|
353
501
|
cm.prefer({
|
|
354
502
|
allowMultipleSelections: false,
|
|
355
503
|
autocompletion: false,
|
|
356
504
|
bracketMatching: false,
|
|
357
505
|
closeBrackets: false,
|
|
506
|
+
codeFolding: false,
|
|
358
507
|
highlightActiveLine: false,
|
|
508
|
+
highlightSelectionMatches: false,
|
|
359
509
|
highlightSpecialChars: false,
|
|
360
|
-
highlightWhitespace: false,
|
|
361
510
|
highlightTrailingWhitespace: false,
|
|
362
|
-
|
|
363
|
-
codeFolding: false,
|
|
511
|
+
highlightWhitespace: false,
|
|
364
512
|
scrollPastEnd: false,
|
|
365
513
|
|
|
514
|
+
// only available in CSS and MediaWiki modes
|
|
515
|
+
colorPicker: false,
|
|
516
|
+
|
|
366
517
|
// only available in MediaWiki mode
|
|
367
518
|
escape: false,
|
|
368
|
-
|
|
519
|
+
hover: false,
|
|
520
|
+
inlayHints: false,
|
|
521
|
+
openLinks: false,
|
|
369
522
|
refHover: false,
|
|
523
|
+
signatureHelp: false,
|
|
370
524
|
});
|
|
371
525
|
```
|
|
372
526
|
|
|
@@ -433,11 +587,12 @@ Set the language mode.
|
|
|
433
587
|
|
|
434
588
|
```js
|
|
435
589
|
cm.setLanguage('mediawiki', mwConfig);
|
|
436
|
-
cm.setLanguage('html', mwConfig);
|
|
590
|
+
cm.setLanguage('html', mwConfig);
|
|
437
591
|
cm.setLanguage('css');
|
|
438
592
|
cm.setLanguage('javascript');
|
|
439
593
|
cm.setLanguage('json');
|
|
440
594
|
cm.setLanguage('lua');
|
|
595
|
+
cm.setLanguage('vue');
|
|
441
596
|
```
|
|
442
597
|
|
|
443
598
|
</details>
|
|
@@ -540,7 +695,7 @@ Provide autocompletion for MediaWiki, CSS and JavaScript modes.
|
|
|
540
695
|
|
|
541
696
|
*version added: 2.0.9*
|
|
542
697
|
|
|
543
|
-
Matched or unmatched brackets are highlighted in cyan or dark red when the cursor is next to them.
|
|
698
|
+
Matched or unmatched brackets or tags are highlighted in cyan or dark red when the cursor is next to them.
|
|
544
699
|
|
|
545
700
|
## closeBrackets
|
|
546
701
|
|
|
@@ -638,12 +793,6 @@ Allow the editor to be scrolled down past the end of the document.
|
|
|
638
793
|
|
|
639
794
|
Show the parser function signature when typing.
|
|
640
795
|
|
|
641
|
-
## tagMatching
|
|
642
|
-
|
|
643
|
-
*version added: 2.4.1*
|
|
644
|
-
|
|
645
|
-
Matched or unmatched tags are highlighted in cyan or dark red when the cursor is inside.
|
|
646
|
-
|
|
647
796
|
# Known issues
|
|
648
797
|
|
|
649
798
|
## Syntax Highlighting
|
package/dist/codemirror.d.ts
CHANGED
|
@@ -1,118 +1,143 @@
|
|
|
1
1
|
import { EditorView } from '@codemirror/view';
|
|
2
2
|
import type { KeyBinding } from '@codemirror/view';
|
|
3
|
-
import type { Extension
|
|
3
|
+
import type { Extension } from '@codemirror/state';
|
|
4
|
+
import type { LanguageSupport } from '@codemirror/language';
|
|
4
5
|
import type { SyntaxNode } from '@lezer/common';
|
|
5
|
-
import type { Diagnostic } from '@codemirror/lint';
|
|
6
6
|
import type { ConfigData } from 'wikiparser-node';
|
|
7
7
|
import type { MwConfig } from './token';
|
|
8
8
|
import type { DocRange } from './fold';
|
|
9
9
|
import type { Option, LiveOption } from './linter';
|
|
10
|
+
import type { LintSource, LintSourceGetter } from './lintsource';
|
|
10
11
|
export type { MwConfig };
|
|
11
|
-
export type
|
|
12
|
-
fixer?: (doc: Text, rule?: string) => string | Promise<string>;
|
|
13
|
-
};
|
|
14
|
-
export type Addon<T> = [(config?: T, cm?: CodeMirror6) => Extension, Record<string, T>];
|
|
12
|
+
export type Addon<T> = [(config?: T, cm?: CodeMirror6) => Extension, Record<string, T>?];
|
|
15
13
|
export type Dialect = 'sanitized-css' | undefined;
|
|
16
|
-
/**
|
|
14
|
+
/** Register MediaWiki language support */
|
|
15
|
+
export declare const registerMediaWiki: () => void;
|
|
16
|
+
/** Register mixed MediaWiki-HTML language support */
|
|
17
|
+
export declare const registerHTML: () => void;
|
|
18
|
+
/** Register JavaScript language support */
|
|
19
|
+
export declare const registerJavaScript: () => void;
|
|
20
|
+
/** Register CSS language support */
|
|
21
|
+
export declare const registerCSS: () => void;
|
|
22
|
+
/** Register JSON language support */
|
|
23
|
+
export declare const registerJSON: () => void;
|
|
24
|
+
/** Register Lua language support */
|
|
25
|
+
export declare const registerLua: () => void;
|
|
26
|
+
/** Register Vue language support */
|
|
27
|
+
export declare const registerVue: () => void;
|
|
28
|
+
/**
|
|
29
|
+
* Register a custom language support
|
|
30
|
+
* @param name language name
|
|
31
|
+
* @param lang language support
|
|
32
|
+
* @param lintSource optional linter
|
|
33
|
+
*/
|
|
34
|
+
export declare const registerLanguage: (name: string, lang: (config?: unknown) => LanguageSupport, lintSource?: LintSourceGetter) => void;
|
|
35
|
+
/** CodeMirror 6 editor */
|
|
17
36
|
export declare class CodeMirror6 {
|
|
18
37
|
#private;
|
|
38
|
+
/** only for sanitized-css */
|
|
39
|
+
dialect: Dialect;
|
|
19
40
|
getWikiConfig?: () => Promise<ConfigData>;
|
|
20
41
|
langConfig: MwConfig | undefined;
|
|
21
|
-
|
|
42
|
+
/** textarea element */
|
|
22
43
|
get textarea(): HTMLTextAreaElement;
|
|
44
|
+
/** EditorView instance */
|
|
23
45
|
get view(): EditorView | undefined;
|
|
46
|
+
/** language */
|
|
24
47
|
get lang(): string;
|
|
48
|
+
/** whether the editor view is visible */
|
|
25
49
|
get visible(): boolean;
|
|
26
50
|
/**
|
|
27
|
-
* @param textarea
|
|
28
|
-
* @param lang
|
|
29
|
-
* @param config
|
|
30
|
-
* @param init
|
|
51
|
+
* @param textarea textarea element
|
|
52
|
+
* @param lang language
|
|
53
|
+
* @param config language configuration
|
|
54
|
+
* @param init whether to initialize the editor immediately
|
|
31
55
|
*/
|
|
32
56
|
constructor(textarea: HTMLTextAreaElement, lang?: string, config?: unknown, init?: boolean);
|
|
33
57
|
/**
|
|
34
|
-
*
|
|
35
|
-
* @param config
|
|
58
|
+
* Initialize the editor
|
|
59
|
+
* @param config language configuration
|
|
36
60
|
*/
|
|
37
61
|
initialize(config?: unknown): void;
|
|
38
62
|
/**
|
|
39
|
-
*
|
|
40
|
-
* @param lang
|
|
41
|
-
* @param config
|
|
63
|
+
* Set language
|
|
64
|
+
* @param lang language
|
|
65
|
+
* @param config language configuration
|
|
42
66
|
*/
|
|
43
67
|
setLanguage(lang?: string, config?: unknown): Promise<void>;
|
|
44
68
|
/**
|
|
45
|
-
*
|
|
46
|
-
* @param lintSource
|
|
69
|
+
* Start syntax checking
|
|
70
|
+
* @param lintSource function for syntax checking
|
|
47
71
|
*/
|
|
48
72
|
lint(lintSource?: LintSource): void;
|
|
49
|
-
/**
|
|
73
|
+
/** Update syntax checking immediately */
|
|
50
74
|
update(): void;
|
|
51
75
|
/**
|
|
52
|
-
*
|
|
53
|
-
* @param names
|
|
76
|
+
* Add extensions
|
|
77
|
+
* @param names extension names
|
|
54
78
|
*/
|
|
55
79
|
prefer(names: string[] | Record<string, boolean>): void;
|
|
56
80
|
/**
|
|
57
|
-
*
|
|
58
|
-
* @param indent
|
|
81
|
+
* Set text indentation
|
|
82
|
+
* @param indent indentation string
|
|
59
83
|
*/
|
|
60
84
|
setIndent(indent: string): void;
|
|
61
85
|
/**
|
|
62
|
-
*
|
|
63
|
-
* @param wrapping
|
|
86
|
+
* Set line wrapping
|
|
87
|
+
* @param wrapping whether to enable line wrapping
|
|
64
88
|
*/
|
|
65
89
|
setLineWrapping(wrapping: boolean): void;
|
|
66
90
|
/**
|
|
67
|
-
*
|
|
68
|
-
* @param opt
|
|
91
|
+
* Get default linter
|
|
92
|
+
* @param opt linter options
|
|
69
93
|
*/
|
|
70
94
|
getLinter(opt?: Option | LiveOption): Promise<LintSource | undefined>;
|
|
71
95
|
/**
|
|
72
|
-
*
|
|
73
|
-
* @param insert
|
|
74
|
-
* @param force
|
|
96
|
+
* Set content
|
|
97
|
+
* @param insert new content
|
|
98
|
+
* @param force whether to forcefully replace the content
|
|
75
99
|
*/
|
|
76
100
|
setContent(insert: string, force?: boolean): void;
|
|
77
101
|
/**
|
|
78
|
-
*
|
|
79
|
-
* @param show
|
|
102
|
+
* Switch between textarea and editor view
|
|
103
|
+
* @param show whether to show the editor view
|
|
80
104
|
*/
|
|
81
105
|
toggle(show?: boolean): void;
|
|
82
|
-
/**
|
|
106
|
+
/** Destroy the editor */
|
|
83
107
|
destroy(): void;
|
|
84
108
|
/**
|
|
85
|
-
*
|
|
86
|
-
* @param keys
|
|
109
|
+
* Define extra key bindings
|
|
110
|
+
* @param keys key bindings
|
|
87
111
|
*/
|
|
88
112
|
extraKeys(keys: KeyBinding[]): void;
|
|
89
113
|
/**
|
|
90
|
-
*
|
|
91
|
-
* @param messages
|
|
114
|
+
* Set translation messages
|
|
115
|
+
* @param messages translation messages
|
|
92
116
|
*/
|
|
93
117
|
localize(messages?: Record<string, string>): void;
|
|
94
118
|
/**
|
|
95
|
-
*
|
|
96
|
-
* @param position
|
|
119
|
+
* Get the syntax node at the specified position
|
|
120
|
+
* @param position position
|
|
97
121
|
*/
|
|
98
122
|
getNodeAt(position: number): SyntaxNode | undefined;
|
|
99
123
|
/**
|
|
100
|
-
*
|
|
101
|
-
* @param position
|
|
124
|
+
* Scroll to the specified position
|
|
125
|
+
* @param position position or selection range
|
|
102
126
|
*/
|
|
103
127
|
scrollTo(position?: number | {
|
|
104
128
|
anchor: number;
|
|
105
129
|
head: number;
|
|
106
130
|
}): void;
|
|
107
131
|
/**
|
|
108
|
-
*
|
|
109
|
-
* @param view
|
|
110
|
-
* @param func
|
|
132
|
+
* Replace the current selection with the result of a function
|
|
133
|
+
* @param view EditorView instance
|
|
134
|
+
* @param func function to produce the replacement text
|
|
111
135
|
*/
|
|
112
136
|
static replaceSelections(view: EditorView, func: (str: string, range: DocRange) => string | [string, number, number?]): void;
|
|
113
137
|
/**
|
|
114
|
-
*
|
|
115
|
-
*
|
|
138
|
+
* Convert a [WikiParser-Node](https://npmjs.com/package/wikiparser-node) configuration
|
|
139
|
+
* to a CodeMirror-MediaWiki configuration
|
|
140
|
+
* @param config WikiParser-Node configuration
|
|
116
141
|
*/
|
|
117
142
|
static getMwConfig(config: ConfigData): MwConfig;
|
|
118
143
|
}
|