@bhsd/codemirror-mediawiki 2.4.5 → 2.5.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 +41 -3
- package/dist/codemirror.d.ts +8 -1
- package/dist/main.min.js +12 -12
- package/dist/mw.min.js +1 -1
- package/dist/mw.min.js.map +3 -3
- package/i18n/en.json +5 -3
- package/i18n/zh-hans.json +5 -3
- package/i18n/zh-hant.json +5 -3
- package/mw/README.md +134 -0
- package/mw/base.ts +20 -5
- package/mw/config.ts +5 -2
- package/mw/msg.ts +1 -1
- package/mw/openLinks.ts +14 -3
- package/mw/textSelection.ts +7 -12
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -25,6 +25,7 @@
|
|
|
25
25
|
- [toggle](#toggle)
|
|
26
26
|
- [update](#update)
|
|
27
27
|
- [Static methods](#static-methods)
|
|
28
|
+
- [getMwConfig](#getmwconfig)
|
|
28
29
|
- [replaceSelections](#replaceselections)
|
|
29
30
|
- [Extensions](#extensions)
|
|
30
31
|
- [allowMultipleSelections](#allowmultipleselections)
|
|
@@ -46,20 +47,34 @@ This repository contains a modified version of the frontend scripts and styles f
|
|
|
46
47
|
|
|
47
48
|
Here is a [demo](https://bhsd-harry.github.io/codemirror-mediawiki).
|
|
48
49
|
|
|
50
|
+
Nonetheless, this repository also provides a customized version with additional functionality for use in a MediaWiki site. Browser editing tools such as [Wikiplus-highlight](https://github.com/bhsd-harry/Wikiplus-highlight) and an [InPageEdit plugin](https://github.com/inpageedit/Plugins) are built upon it. Please refer to a separate [README](./mw/README.md) file for the information.
|
|
51
|
+
|
|
49
52
|
# Usage
|
|
50
53
|
|
|
51
54
|
You can download the code via CDN, for example:
|
|
52
55
|
|
|
53
56
|
```js
|
|
54
57
|
// static import
|
|
55
|
-
import {CodeMirror6} from 'https://cdn.jsdelivr.net/npm/@bhsd/codemirror-mediawiki
|
|
58
|
+
import {CodeMirror6} from 'https://cdn.jsdelivr.net/npm/@bhsd/codemirror-mediawiki';
|
|
59
|
+
```
|
|
60
|
+
|
|
61
|
+
or
|
|
62
|
+
|
|
63
|
+
```js
|
|
64
|
+
import {CodeMirror6} from 'https://unpkg.com/@bhsd/codemirror-mediawiki';
|
|
56
65
|
```
|
|
57
66
|
|
|
58
67
|
or
|
|
59
68
|
|
|
60
69
|
```js
|
|
61
70
|
// dynamic import
|
|
62
|
-
const {CodeMirror6} = await import('https://cdn.jsdelivr.net/npm/@bhsd/codemirror-mediawiki
|
|
71
|
+
const {CodeMirror6} = await import('https://cdn.jsdelivr.net/npm/@bhsd/codemirror-mediawiki');
|
|
72
|
+
```
|
|
73
|
+
|
|
74
|
+
or
|
|
75
|
+
|
|
76
|
+
```js
|
|
77
|
+
const {CodeMirror6} = await import('https://unpkg.com/@bhsd/codemirror-mediawiki');
|
|
63
78
|
```
|
|
64
79
|
|
|
65
80
|
# Constructor
|
|
@@ -354,6 +369,23 @@ Refresh linting immediately.
|
|
|
354
369
|
|
|
355
370
|
# Static methods
|
|
356
371
|
|
|
372
|
+
## getMwConfig
|
|
373
|
+
|
|
374
|
+
<details>
|
|
375
|
+
<summary>Expand</summary>
|
|
376
|
+
|
|
377
|
+
*version added: 2.4.7*
|
|
378
|
+
|
|
379
|
+
**param**: [`Config`](https://github.com/bhsd-harry/wikiparser-node/wiki/types#config) the [WikiLint](https://npmjs.com/package/wikilint) configuration
|
|
380
|
+
**returns**: `MwConfig`
|
|
381
|
+
Derive the configuration for the MediaWiki mode from WikiLint configuration.
|
|
382
|
+
|
|
383
|
+
```js
|
|
384
|
+
const mwConfig = CodeMirror6.getMwConfig(config);
|
|
385
|
+
```
|
|
386
|
+
|
|
387
|
+
</details>
|
|
388
|
+
|
|
357
389
|
## replaceSelections
|
|
358
390
|
|
|
359
391
|
<details>
|
|
@@ -361,7 +393,7 @@ Refresh linting immediately.
|
|
|
361
393
|
|
|
362
394
|
*version added: 2.2.2*
|
|
363
395
|
|
|
364
|
-
**param**: [`EditorView`](https://codemirror.net/6/docs/ref/#view.EditorView) the CodeMirror EditorView instance
|
|
396
|
+
**param**: [`EditorView`](https://codemirror.net/6/docs/ref/#view.EditorView) the CodeMirror EditorView instance
|
|
365
397
|
**param**: `(str: string) => string` the replacement function
|
|
366
398
|
Replace the selected text with the return value of the replacement function.
|
|
367
399
|
|
|
@@ -379,6 +411,12 @@ CodeMirror6.replaceSelections(cm.view, str => str.toUpperCase());
|
|
|
379
411
|
|
|
380
412
|
Allow multiple selections.
|
|
381
413
|
|
|
414
|
+
## autocompletion
|
|
415
|
+
|
|
416
|
+
*version added: 2.5.0*
|
|
417
|
+
|
|
418
|
+
Provide autocompletion for the MediaWiki mode.
|
|
419
|
+
|
|
382
420
|
## bracketMatching
|
|
383
421
|
|
|
384
422
|
*version added: 2.0.9*
|
package/dist/codemirror.d.ts
CHANGED
|
@@ -3,7 +3,9 @@ import type { KeyBinding } from '@codemirror/view';
|
|
|
3
3
|
import type { Text } from '@codemirror/state';
|
|
4
4
|
import type { SyntaxNode } from '@lezer/common';
|
|
5
5
|
import type { Diagnostic } from '@codemirror/lint';
|
|
6
|
-
|
|
6
|
+
import type { Config } from 'wikilint';
|
|
7
|
+
import type { MwConfig } from './mediawiki';
|
|
8
|
+
export type { MwConfig };
|
|
7
9
|
export type LintSource = (doc: Text) => Diagnostic[] | Promise<Diagnostic[]>;
|
|
8
10
|
export declare const CDN = "https://testingcf.jsdelivr.net";
|
|
9
11
|
export declare class CodeMirror6 {
|
|
@@ -77,4 +79,9 @@ export declare class CodeMirror6 {
|
|
|
77
79
|
* @param func 替换函数
|
|
78
80
|
*/
|
|
79
81
|
static replaceSelections(view: EditorView, func: (str: string) => string): void;
|
|
82
|
+
/**
|
|
83
|
+
* 将wikiparser-node设置转换为codemirror-mediawiki设置
|
|
84
|
+
* @param config
|
|
85
|
+
*/
|
|
86
|
+
static getMwConfig(config: Config): MwConfig;
|
|
80
87
|
}
|