@bhsd/codemirror-mediawiki 3.0.3 → 3.1.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 CHANGED
@@ -8,8 +8,8 @@
8
8
  - [Description](#description)
9
9
  - [Installation](#installation)
10
10
  - [Browser Usage](#browser-usage)
11
- - [JavaScript](#javascript)
12
- - [CSS](#css)
11
+ - [Download JavaScript](#download-javascript)
12
+ - [Download CSS](#download-css)
13
13
  - [Language modes](#language-modes)
14
14
  - [css](#css)
15
15
  - [html](#html)
@@ -101,7 +101,10 @@ import {
101
101
 
102
102
  You can download the code via CDN, for example:
103
103
 
104
- ## JavaScript
104
+ ## Download JavaScript
105
+
106
+ <details>
107
+ <summary>Expand</summary>
105
108
 
106
109
  ```js
107
110
  // static import
@@ -163,7 +166,12 @@ const {
163
166
  } = await import('https://unpkg.com/@bhsd/codemirror-mediawiki');
164
167
  ```
165
168
 
166
- ## CSS
169
+ </details>
170
+
171
+ ## Download CSS
172
+
173
+ <details>
174
+ <summary>Expand</summary>
167
175
 
168
176
  ```html
169
177
  <link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/@bhsd/codemirror-mediawiki/mediawiki.css">
@@ -175,10 +183,15 @@ or
175
183
  <link rel="stylesheet" href="https://unpkg.com/@bhsd/codemirror-mediawiki/mediawiki.css">
176
184
  ```
177
185
 
186
+ </details>
187
+
178
188
  # Language modes
179
189
 
180
190
  ## css
181
191
 
192
+ <details>
193
+ <summary>Expand</summary>
194
+
182
195
  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
196
 
184
197
  ```js
@@ -186,8 +199,27 @@ import {registerCSS} from '@bhsd/codemirror-mediawiki';
186
199
  registerCSS();
187
200
  ```
188
201
 
202
+ If you want a more granular control over the extensions, you can import the `registerCSSCore` function and the desired extensions:
203
+
204
+ ```js
205
+ import {registerCSSCore} from '@bhsd/codemirror-mediawiki';
206
+ registerCSSCore();
207
+ ```
208
+
209
+ In addition to the common [extensions](#extensions), here are some CSS-specific extensions. Note that these extensions may not take effect if the corresponding common extensions are not registered:
210
+
211
+ ```js
212
+ import {registerColorPickerForCSS} from '@bhsd/codemirror-mediawiki';
213
+ registerColorPickerForCSS();
214
+ ```
215
+
216
+ </details>
217
+
189
218
  ## html
190
219
 
220
+ <details>
221
+ <summary>Expand</summary>
222
+
191
223
  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
224
 
193
225
  ```js
@@ -195,8 +227,20 @@ import {registerHTML} from '@bhsd/codemirror-mediawiki';
195
227
  registerHTML();
196
228
  ```
197
229
 
230
+ If you want a more granular control over the extensions, you can import the `registerHTMLCore` function and the desired extensions:
231
+
232
+ ```js
233
+ import {registerHTMLCore} from '@bhsd/codemirror-mediawiki';
234
+ registerHTMLCore();
235
+ ```
236
+
237
+ </details>
238
+
198
239
  ## javascript
199
240
 
241
+ <details>
242
+ <summary>Expand</summary>
243
+
200
244
  You can bundle the JavaScript mode by importing the `registerJavaScript` function:
201
245
 
202
246
  ```js
@@ -204,8 +248,20 @@ import {registerJavaScript} from '@bhsd/codemirror-mediawiki';
204
248
  registerJavaScript();
205
249
  ```
206
250
 
251
+ If you want a more granular control over the extensions, you can import the `registerJavaScriptCore` function and the desired extensions:
252
+
253
+ ```js
254
+ import {registerJavaScriptCore} from '@bhsd/codemirror-mediawiki';
255
+ registerJavaScriptCore();
256
+ ```
257
+
258
+ </details>
259
+
207
260
  ## json
208
261
 
262
+ <details>
263
+ <summary>Expand</summary>
264
+
209
265
  You can bundle the JSON mode by importing the `registerJSON` function:
210
266
 
211
267
  ```js
@@ -213,8 +269,20 @@ import {registerJSON} from '@bhsd/codemirror-mediawiki';
213
269
  registerJSON();
214
270
  ```
215
271
 
272
+ If you want a more granular control over the extensions, you can import the `registerJSONCore` function and the desired extensions:
273
+
274
+ ```js
275
+ import {registerJSONCore} from '@bhsd/codemirror-mediawiki';
276
+ registerJSONCore();
277
+ ```
278
+
279
+ </details>
280
+
216
281
  ## lua
217
282
 
283
+ <details>
284
+ <summary>Expand</summary>
285
+
218
286
  You can bundle the Lua mode by importing the `registerLua` function:
219
287
 
220
288
  ```js
@@ -222,8 +290,20 @@ import {registerLua} from '@bhsd/codemirror-mediawiki';
222
290
  registerLua();
223
291
  ```
224
292
 
293
+ If you want a more granular control over the extensions, you can import the `registerLuaCore` function and the desired extensions:
294
+
295
+ ```js
296
+ import {registerLuaCore} from '@bhsd/codemirror-mediawiki';
297
+ registerLuaCore();
298
+ ```
299
+
300
+ </details>
301
+
225
302
  ## mediawiki
226
303
 
304
+ <details>
305
+ <summary>Expand</summary>
306
+
227
307
  You can bundle the MediaWiki mode by importing the `registerMediaWiki` function:
228
308
 
229
309
  ```js
@@ -231,8 +311,33 @@ import {registerMediaWiki} from '@bhsd/codemirror-mediawiki';
231
311
  registerMediaWiki();
232
312
  ```
233
313
 
314
+ If you want a more granular control over the extensions, you can import the `registerMediaWikiCore` function and the desired extensions:
315
+
316
+ ```js
317
+ import {registerMediaWikiCore} from '@bhsd/codemirror-mediawiki';
318
+ registerMediaWikiCore();
319
+ ```
320
+
321
+ In addition to the common [extensions](#extensions), here are some MediaWiki-specific extensions. Note that these extensions may not take effect if the corresponding common extensions are not registered:
322
+
323
+ ```js
324
+ import {
325
+ registerColorPickerForMediaWiki,
326
+ registerBracketMatchingForMediaWiki,
327
+ registerCodeFoldingForMediaWiki
328
+ } from '@bhsd/codemirror-mediawiki';
329
+ registerColorPickerForMediaWiki();
330
+ registerBracketMatchingForMediaWiki();
331
+ registerCodeFoldingForMediaWiki();
332
+ ```
333
+
334
+ </details>
335
+
234
336
  ## vue
235
337
 
338
+ <details>
339
+ <summary>Expand</summary>
340
+
236
341
  You can bundle the Vue mode by importing the `registerVue` function:
237
342
 
238
343
  ```js
@@ -240,8 +345,31 @@ import {registerVue} from '@bhsd/codemirror-mediawiki';
240
345
  registerVue();
241
346
  ```
242
347
 
348
+ If you want a more granular control over the extensions, you can import the `registerVueCore` function and the desired extensions:
349
+
350
+ ```js
351
+ import {registerVueCore} from '@bhsd/codemirror-mediawiki';
352
+ registerVueCore();
353
+ ```
354
+
355
+ In addition to the common [extensions](#extensions), here are some Vue-specific extensions. Note that these extensions may not take effect if the corresponding common extensions are not registered:
356
+
357
+ ```js
358
+ import {
359
+ registerCloseBracketsForVue,
360
+ registerColorPickerForVue,
361
+ } from '@bhsd/codemirror-mediawiki';
362
+ registerCloseBracketsForVue();
363
+ registerColorPickerForVue();
364
+ ```
365
+
366
+ </details>
367
+
243
368
  ## Other languages
244
369
 
370
+ <details>
371
+ <summary>Expand</summary>
372
+
245
373
  You can also register other languages by importing the `registerLanguage` function:
246
374
 
247
375
  ```js
@@ -250,6 +378,16 @@ import {python} from '@codemirror/lang-python';
250
378
  registerLanguage('python', python);
251
379
  ```
252
380
 
381
+ If you want a more granular control over the extensions, you can import the `registerLanguageCore` function and the desired extensions:
382
+
383
+ ```js
384
+ import {registerLanguageCore} from '@bhsd/codemirror-mediawiki';
385
+ import {python} from '@codemirror/lang-python';
386
+ registerLanguageCore('python', python);
387
+ ```
388
+
389
+ </details>
390
+
253
391
  # Constructor
254
392
 
255
393
  <details>
@@ -681,30 +819,81 @@ CodeMirror6.replaceSelections(cm.view, str => str.toUpperCase());
681
819
 
682
820
  ## allowMultipleSelections
683
821
 
822
+ <details>
823
+ <summary>Expand</summary>
824
+
684
825
  *version added: 2.1.11*
685
826
 
686
827
  Allow multiple selections. This extension also enables rectangular selections by holding down the `Alt` key.
687
828
 
829
+ For granular control over the bundled extensions, you can import the `registerAllowMultipleSelections` function:
830
+
831
+ ```js
832
+ import {registerAllowMultipleSelections} from '@bhsd/codemirror-mediawiki';
833
+ registerAllowMultipleSelections();
834
+ ```
835
+
836
+ </details>
837
+
688
838
  ## autocompletion
689
839
 
840
+ <details>
841
+ <summary>Expand</summary>
842
+
690
843
  *version added: 2.5.1*
691
844
 
692
845
  Provide autocompletion for MediaWiki, CSS and JavaScript modes.
693
846
 
847
+ For granular control over the bundled extensions, you can import the `registerAutocompletion` function:
848
+
849
+ ```js
850
+ import {registerAutocompletion} from '@bhsd/codemirror-mediawiki';
851
+ registerAutocompletion();
852
+ ```
853
+
854
+ </details>
855
+
694
856
  ## bracketMatching
695
857
 
858
+ <details>
859
+ <summary>Expand</summary>
860
+
696
861
  *version added: 2.0.9*
697
862
 
698
863
  Matched or unmatched brackets or tags are highlighted in cyan or dark red when the cursor is next to them.
699
864
 
865
+ For granular control over the bundled extensions, you can import the `registerBracketMatching` function:
866
+
867
+ ```js
868
+ import {registerBracketMatching} from '@bhsd/codemirror-mediawiki';
869
+ registerBracketMatching();
870
+ ```
871
+
872
+ </details>
873
+
700
874
  ## closeBrackets
701
875
 
876
+ <details>
877
+ <summary>Expand</summary>
878
+
702
879
  *version added: 2.0.9*
703
880
 
704
881
  Automatically close brackets (`{`, `[` and `(`) and quotes (`"`, and `'` except for the MediaWiki mode).
705
882
 
883
+ For granular control over the bundled extensions, you can import the `registerCloseBrackets` function:
884
+
885
+ ```js
886
+ import {registerCloseBrackets} from '@bhsd/codemirror-mediawiki';
887
+ registerCloseBrackets();
888
+ ```
889
+
890
+ </details>
891
+
706
892
  ## codeFolding
707
893
 
894
+ <details>
895
+ <summary>Expand</summary>
896
+
708
897
  *version added: 2.3.0*
709
898
 
710
899
  Fold sections, templates, parser functions and extension tags in the MediaWiki mode, and code blocks in other modes.
@@ -716,14 +905,38 @@ Key bindings:
716
905
  - `Ctrl` + `Alt` + `[`: Fold all
717
906
  - `Ctrl` + `Alt` + `]`: Unfold all
718
907
 
908
+ For granular control over the bundled extensions, you can import the `registerCodeFolding` function:
909
+
910
+ ```js
911
+ import {registerCodeFolding} from '@bhsd/codemirror-mediawiki';
912
+ registerCodeFolding();
913
+ ```
914
+
915
+ </details>
916
+
719
917
  ## colorPicker
720
918
 
919
+ <details>
920
+ <summary>Expand</summary>
921
+
721
922
  *version added: 2.18.0*
722
923
 
723
924
  Provide color pickers for CSS and MediaWiki modes.
724
925
 
926
+ For granular control over the bundled extensions, you can import the `registerColorPicker` functions. Note that you also need to register this extension for specific languages([CSS](#css), [MediaWiki](#mediawiki) or [Vue](#vue)):
927
+
928
+ ```js
929
+ import {registerColorPicker} from '@bhsd/codemirror-mediawiki';
930
+ registerColorPicker();
931
+ ```
932
+
933
+ </details>
934
+
725
935
  ## escape
726
936
 
937
+ <details>
938
+ <summary>Expand</summary>
939
+
727
940
  *version added: 2.2.2*
728
941
 
729
942
  Key bindings:
@@ -731,68 +944,209 @@ Key bindings:
731
944
  - `Ctrl`/`Cmd` + `[`: Escape the selected text with HTML entities
732
945
  - `Ctrl`/`Cmd` + `]`: Escape the selected text with URL encoding
733
946
 
947
+ For granular control over the bundled extensions, you can import the `registerEscape` function:
948
+
949
+ ```js
950
+ import {registerEscape} from '@bhsd/codemirror-mediawiki';
951
+ registerEscape();
952
+ ```
953
+
954
+ </details>
955
+
734
956
  ## highlightActiveLine
735
957
 
958
+ <details>
959
+ <summary>Expand</summary>
960
+
736
961
  Highlight the line the cursor is on in light cyan.
737
962
 
963
+ For granular control over the bundled extensions, you can import the `registerHighlightActiveLine` function:
964
+
965
+ ```js
966
+ import {registerHighlightActiveLine} from '@bhsd/codemirror-mediawiki';
967
+ registerHighlightActiveLine();
968
+ ```
969
+
970
+ </details>
971
+
738
972
  ## highlightSelectionMatches
739
973
 
974
+ <details>
975
+ <summary>Expand</summary>
976
+
740
977
  *version added: 2.15.3*
741
978
 
742
979
  Highlight texts that match the selection in light green.
743
980
 
981
+ For granular control over the bundled extensions, you can import the `registerHighlightSelectionMatches` function:
982
+
983
+ ```js
984
+ import {registerHighlightSelectionMatches} from '@bhsd/codemirror-mediawiki';
985
+ registerHighlightSelectionMatches();
986
+ ```
987
+
988
+ </details>
989
+
744
990
  ## highlightSpecialChars
745
991
 
992
+ <details>
993
+ <summary>Expand</summary>
994
+
746
995
  Show invisible characters as red dots.
747
996
 
997
+ For granular control over the bundled extensions, you can import the `registerHighlightSpecialChars` function:
998
+
999
+ ```js
1000
+ import {registerHighlightSpecialChars} from '@bhsd/codemirror-mediawiki';
1001
+ registerHighlightSpecialChars();
1002
+ ```
1003
+
1004
+ </details>
1005
+
748
1006
  ## highlightTrailingWhitespace
749
1007
 
1008
+ <details>
1009
+ <summary>Expand</summary>
1010
+
750
1011
  *version added: 2.0.9*
751
1012
 
752
1013
  Highlight trailing whitespace in a red-orange color.
753
1014
 
1015
+ For granular control over the bundled extensions, you can import the `registerHighlightTrailingWhitespace` function:
1016
+
1017
+ ```js
1018
+ import {registerHighlightTrailingWhitespace} from '@bhsd/codemirror-mediawiki';
1019
+ registerHighlightTrailingWhitespace();
1020
+ ```
1021
+
1022
+ </details>
1023
+
754
1024
  ## highlightWhitespace
755
1025
 
1026
+ <details>
1027
+ <summary>Expand</summary>
1028
+
756
1029
  *version added: 2.0.12*
757
1030
 
758
1031
  Show spaces and tabs as dots and arrows.
759
1032
 
1033
+ For granular control over the bundled extensions, you can import the `registerHighlightWhitespace` function:
1034
+
1035
+ ```js
1036
+ import {registerHighlightWhitespace} from '@bhsd/codemirror-mediawiki';
1037
+ registerHighlightWhitespace();
1038
+ ```
1039
+
1040
+ </details>
1041
+
760
1042
  ## hover
761
1043
 
1044
+ <details>
1045
+ <summary>Expand</summary>
1046
+
762
1047
  *version added: 2.21.1*
763
1048
 
764
1049
  Show the help information of a magic word when hovering.
765
1050
 
1051
+ For granular control over the bundled extensions, you can import the `registerHover` function:
1052
+
1053
+ ```js
1054
+ import {registerHover} from '@bhsd/codemirror-mediawiki';
1055
+ registerHover();
1056
+ ```
1057
+
1058
+ </details>
1059
+
766
1060
  ## inlayHints
767
1061
 
1062
+ <details>
1063
+ <summary>Expand</summary>
1064
+
768
1065
  *version added: 2.22.0*
769
1066
 
770
1067
  Show inlay hints for anonymous parameters.
771
1068
 
1069
+ For granular control over the bundled extensions, you can import the `registerInlayHints` function:
1070
+
1071
+ ```js
1072
+ import {registerInlayHints} from '@bhsd/codemirror-mediawiki';
1073
+ registerInlayHints();
1074
+ ```
1075
+
1076
+ </details>
1077
+
772
1078
  ## openLinks
773
1079
 
1080
+ <details>
1081
+ <summary>Expand</summary>
1082
+
774
1083
  *version added: 2.19.6*
775
1084
 
776
1085
  CTRL/CMD-click opens a link in a new tab.
777
1086
 
1087
+ For granular control over the bundled extensions, you can import the `registerOpenLinks` function:
1088
+
1089
+ ```js
1090
+ import {registerOpenLinks} from '@bhsd/codemirror-mediawiki';
1091
+ registerOpenLinks();
1092
+ ```
1093
+
1094
+ </details>
1095
+
778
1096
  ## refHover
779
1097
 
1098
+ <details>
1099
+ <summary>Expand</summary>
1100
+
780
1101
  *version added: 2.17.1*
781
1102
 
782
1103
  Show the content of the `<ref>` tag defined elsewhere when hovering.
783
1104
 
1105
+ For granular control over the bundled extensions, you can import the `registerRefHover` function:
1106
+
1107
+ ```js
1108
+ import {registerRefHover} from '@bhsd/codemirror-mediawiki';
1109
+ registerRefHover();
1110
+ ```
1111
+
1112
+ </details>
1113
+
784
1114
  ## scrollPastEnd
785
1115
 
1116
+ <details>
1117
+ <summary>Expand</summary>
1118
+
786
1119
  *version added: 2.15.3*
787
1120
 
788
1121
  Allow the editor to be scrolled down past the end of the document.
789
1122
 
1123
+ For granular control over the bundled extensions, you can import the `registerScrollPastEnd` function:
1124
+
1125
+ ```js
1126
+ import {registerScrollPastEnd} from '@bhsd/codemirror-mediawiki';
1127
+ registerScrollPastEnd();
1128
+ ```
1129
+
1130
+ </details>
1131
+
790
1132
  ## signatureHelp
791
1133
 
1134
+ <details>
1135
+ <summary>Expand</summary>
1136
+
792
1137
  *version added: 2.21.1*
793
1138
 
794
1139
  Show the parser function signature when typing.
795
1140
 
1141
+ For granular control over the bundled extensions, you can import the `registerSignatureHelp` function:
1142
+
1143
+ ```js
1144
+ import {registerSignatureHelp} from '@bhsd/codemirror-mediawiki';
1145
+ registerSignatureHelp();
1146
+ ```
1147
+
1148
+ </details>
1149
+
796
1150
  # Known issues
797
1151
 
798
1152
  ## Syntax Highlighting
@@ -1,37 +1,20 @@
1
1
  import { EditorView } from '@codemirror/view';
2
2
  import type { KeyBinding } from '@codemirror/view';
3
3
  import type { Extension } from '@codemirror/state';
4
- import type { LanguageSupport } from '@codemirror/language';
5
4
  import type { SyntaxNode } from '@lezer/common';
6
5
  import type { ConfigData } from 'wikiparser-node';
7
6
  import type { MwConfig } from './token';
8
7
  import type { DocRange } from './fold';
9
8
  import type { Option, LiveOption } from './linter';
10
9
  import type { LintSource, LintSourceGetter } from './lintsource';
11
- export type { MwConfig };
12
- export type Addon<T> = [(config?: T, cm?: CodeMirror6) => Extension, Record<string, T>?];
10
+ export type AddonMain<T> = (config?: T, cm?: CodeMirror6) => Extension;
11
+ export type Addon<T> = [AddonMain<T>, Record<string, T>?];
13
12
  export type Dialect = 'sanitized-css' | undefined;
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;
13
+ export declare const plain: () => Extension;
14
+ export declare const languages: Record<string, (config?: any) => Extension>;
15
+ export declare const avail: Record<string, Addon<any>>;
16
+ export declare const linterRegistry: Record<string, LintSourceGetter>;
17
+ export declare const destroyListeners: ((view: EditorView) => void)[];
35
18
  /** CodeMirror 6 editor */
36
19
  export declare class CodeMirror6 {
37
20
  #private;
@@ -139,5 +122,5 @@ export declare class CodeMirror6 {
139
122
  * to a CodeMirror-MediaWiki configuration
140
123
  * @param config WikiParser-Node configuration
141
124
  */
142
- static getMwConfig(config: ConfigData): MwConfig;
125
+ abstract static getMwConfig(config: ConfigData): MwConfig;
143
126
  }