@bhsd/codemirror-mediawiki 2.27.2 → 2.28.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
@@ -10,8 +10,8 @@
10
10
  - [Usage](#usage)
11
11
  - [Constructor](#constructor)
12
12
  - [Accessors](#accessors)
13
- - [textarea](#textarea)
14
13
  - [lang](#lang)
14
+ - [textarea](#textarea)
15
15
  - [view](#view)
16
16
  - [visible](#visible)
17
17
  - [Methods](#methods)
@@ -26,6 +26,7 @@
26
26
  - [setContent](#setcontent)
27
27
  - [setIndent](#setindent)
28
28
  - [setLanguage](#setlanguage)
29
+ - [setLineWrapping](#setlinewrapping)
29
30
  - [toggle](#toggle)
30
31
  - [update](#update)
31
32
  - [Static methods](#static-methods)
@@ -36,19 +37,19 @@
36
37
  - [autocompletion](#autocompletion)
37
38
  - [bracketMatching](#bracketmatching)
38
39
  - [closeBrackets](#closebrackets)
39
- - [highlightActiveLine](#highlightactiveline)
40
- - [highlightSpecialChars](#highlightspecialchars)
41
- - [highlightWhitespace](#highlightwhitespace)
42
- - [highlightTrailingWhitespace](#highlighttrailingwhitespace)
43
- - [highlightSelectionMatches](#highlightselectionmatches)
44
40
  - [codeFolding](#codefolding)
45
- - [scrollPastEnd](#scrollpastend)
46
41
  - [colorPicker](#colorpicker)
47
42
  - [escape](#escape)
48
- - [tagMatching](#tagmatching)
49
- - [refHover](#refhover)
43
+ - [highlightActiveLine](#highlightactiveline)
44
+ - [highlightSelectionMatches](#highlightselectionmatches)
45
+ - [highlightSpecialChars](#highlightspecialchars)
46
+ - [highlightTrailingWhitespace](#highlighttrailingwhitespace)
47
+ - [highlightWhitespace](#highlightwhitespace)
50
48
  - [hover](#hover)
51
49
  - [openLinks](#openlinks)
50
+ - [refHover](#refhover)
51
+ - [scrollPastEnd](#scrollpastend)
52
+ - [tagMatching](#tagmatching)
52
53
  - [Known issues](#known-issues)
53
54
  - [Syntax Highlighting](#syntax-highlighting)
54
55
 
@@ -114,25 +115,25 @@ const cm = new CodeMirror6(textarea, 'lua');
114
115
 
115
116
  # Accessors
116
117
 
117
- ## textarea
118
+ ## lang
118
119
 
119
120
  <details>
120
121
  <summary>Expand</summary>
121
122
 
122
- **type**: `HTMLTextAreaElement`
123
- The textarea element replaced by CodeMirror, read-only.
123
+ *version added: 2.0.14*
124
+
125
+ **type**: `string`
126
+ The current language mode, read-only.
124
127
 
125
128
  </details>
126
129
 
127
- ## lang
130
+ ## textarea
128
131
 
129
132
  <details>
130
133
  <summary>Expand</summary>
131
134
 
132
- *version added: 2.0.14*
133
-
134
- **type**: `string`
135
- The current language mode, read-only.
135
+ **type**: `HTMLTextAreaElement`
136
+ The textarea element replaced by CodeMirror, read-only.
136
137
 
137
138
  </details>
138
139
 
@@ -394,6 +395,23 @@ cm.setLanguage('lua');
394
395
 
395
396
  </details>
396
397
 
398
+ ## setLineWrapping
399
+
400
+ <details>
401
+ <summary>Expand</summary>
402
+
403
+ *version added: 2.28.0*
404
+
405
+ **param**: `boolean` whether to enable line wrapping
406
+ Switch between line wrapping and no line wrapping.
407
+
408
+ ```js
409
+ cm.setLineWrapping(false);
410
+ cm.setLineWrapping(true);
411
+ ```
412
+
413
+ </details>
414
+
397
415
  ## toggle
398
416
 
399
417
  <details>
@@ -483,32 +501,6 @@ Matched or unmatched brackets are highlighted in cyan or dark red when the curso
483
501
 
484
502
  Automatically close brackets (`{`, `[` and `(`) and quotes (`"`, and `'` except for the MediaWiki mode).
485
503
 
486
- ## highlightActiveLine
487
-
488
- Highlight the line the cursor is on in light cyan.
489
-
490
- ## highlightSpecialChars
491
-
492
- Show invisible characters as red dots.
493
-
494
- ## highlightWhitespace
495
-
496
- *version added: 2.0.12*
497
-
498
- Show spaces and tabs as dots and arrows.
499
-
500
- ## highlightTrailingWhitespace
501
-
502
- *version added: 2.0.9*
503
-
504
- Highlight trailing whitespace in a red-orange color.
505
-
506
- ## highlightSelectionMatches
507
-
508
- *version added: 2.15.3*
509
-
510
- Highlight texts that match the selection in light green.
511
-
512
504
  ## codeFolding
513
505
 
514
506
  *version added: 2.3.0*
@@ -522,12 +514,6 @@ Key bindings:
522
514
  - `Ctrl` + `Alt` + `[`: Fold all
523
515
  - `Ctrl` + `Alt` + `]`: Unfold all
524
516
 
525
- ## scrollPastEnd
526
-
527
- *version added: 2.15.3*
528
-
529
- Allow the editor to be scrolled down past the end of the document.
530
-
531
517
  ## colorPicker
532
518
 
533
519
  *version added: 2.18.0*
@@ -543,17 +529,31 @@ Key bindings:
543
529
  - `Ctrl`/`Cmd` + `[`: Escape the selected text with HTML entities
544
530
  - `Ctrl`/`Cmd` + `]`: Escape the selected text with URL encoding
545
531
 
546
- ## tagMatching
532
+ ## highlightActiveLine
547
533
 
548
- *version added: 2.4.1*
534
+ Highlight the line the cursor is on in light cyan.
549
535
 
550
- Matched or unmatched tags are highlighted in cyan or dark red when the cursor is inside.
536
+ ## highlightSelectionMatches
551
537
 
552
- ## refHover
538
+ *version added: 2.15.3*
553
539
 
554
- *version added: 2.17.1*
540
+ Highlight texts that match the selection in light green.
555
541
 
556
- Show the content of the `<ref>` tag defined elsewhere when hovering.
542
+ ## highlightSpecialChars
543
+
544
+ Show invisible characters as red dots.
545
+
546
+ ## highlightTrailingWhitespace
547
+
548
+ *version added: 2.0.9*
549
+
550
+ Highlight trailing whitespace in a red-orange color.
551
+
552
+ ## highlightWhitespace
553
+
554
+ *version added: 2.0.12*
555
+
556
+ Show spaces and tabs as dots and arrows.
557
557
 
558
558
  ## hover
559
559
 
@@ -561,6 +561,30 @@ Show the content of the `<ref>` tag defined elsewhere when hovering.
561
561
 
562
562
  Show the help information of a magic word when hovering.
563
563
 
564
+ ## openLinks
565
+
566
+ *version added: 2.19.6*
567
+
568
+ CTRL/CMD-click opens a link in a new tab.
569
+
570
+ ## refHover
571
+
572
+ *version added: 2.17.1*
573
+
574
+ Show the content of the `<ref>` tag defined elsewhere when hovering.
575
+
576
+ ## scrollPastEnd
577
+
578
+ *version added: 2.15.3*
579
+
580
+ Allow the editor to be scrolled down past the end of the document.
581
+
582
+ ## tagMatching
583
+
584
+ *version added: 2.4.1*
585
+
586
+ Matched or unmatched tags are highlighted in cyan or dark red when the cursor is inside.
587
+
564
588
  ## signatureHelp
565
589
 
566
590
  *version added: 2.21.1*
@@ -573,12 +597,6 @@ Show the parser function signature when typing.
573
597
 
574
598
  Show inlay hints for anonymous parameters.
575
599
 
576
- ## openLinks
577
-
578
- *version added: 2.19.6*
579
-
580
- CTRL/CMD-click opens a link in a new tab.
581
-
582
600
  # Known issues
583
601
 
584
602
  ## Syntax Highlighting
@@ -12,11 +12,13 @@ export type LintSource = ((doc: Text) => Diagnostic[] | Promise<Diagnostic[]>) &
12
12
  fixer?: (doc: Text, rule?: string) => string | Promise<string>;
13
13
  };
14
14
  export type Addon<T> = [(config?: T, cm?: CodeMirror6) => Extension, Record<string, T>];
15
+ export type Dialect = 'sanitized-css' | undefined;
15
16
  /** CodeMirror 6 编辑器 */
16
17
  export declare class CodeMirror6 {
17
18
  #private;
18
19
  getWikiConfig?: () => Promise<ConfigData>;
19
20
  langConfig: MwConfig | undefined;
21
+ dialect: Dialect;
20
22
  get textarea(): HTMLTextAreaElement;
21
23
  get view(): EditorView | undefined;
22
24
  get lang(): string;
@@ -56,6 +58,11 @@ export declare class CodeMirror6 {
56
58
  * @param indent 缩进字符串
57
59
  */
58
60
  setIndent(indent: string): void;
61
+ /**
62
+ * 设置文本换行
63
+ * @param wrapping 是否换行
64
+ */
65
+ setLineWrapping(wrapping: boolean): void;
59
66
  /**
60
67
  * 获取默认linter
61
68
  * @param opt 选项
package/dist/css.d.ts CHANGED
@@ -1,3 +1,4 @@
1
1
  import { LanguageSupport } from '@codemirror/language';
2
- declare const _default: () => LanguageSupport;
2
+ import type { Dialect } from './codemirror';
3
+ declare const _default: (dialect: Dialect) => LanguageSupport;
3
4
  export default _default;
@@ -0,0 +1,8 @@
1
+ export declare const noDetectionLangs: Set<string>;
2
+ /**
3
+ * 检测文本的缩进方式
4
+ * @param text 文本内容
5
+ * @param defaultIndent 默认缩进方式
6
+ * @param lang 语言
7
+ */
8
+ export declare const detectIndent: (text: string, defaultIndent: string, lang: string) => string;
@@ -24,7 +24,7 @@ const encapsulateLines = (text, pre, post) => {
24
24
  const lines = text.split("\n");
25
25
  return lines.map((line) => {
26
26
  var _a, _b;
27
- const str = ((_b = (_a = /^(={1,6})(.+)\1$/u.exec(line)) == null ? void 0 : _a[2]) != null ? _b : line).trim();
27
+ const str = ((_b = (_a = /^(={1,6})(.+)\1\s*$/u.exec(line)) == null ? void 0 : _a[2]) != null ? _b : line).trim();
28
28
  return pre === " " || lines.length === 1 || line.trim() ? pre + str + post : str;
29
29
  }).join("\n");
30
30
  };