@bhsd/codemirror-mediawiki 2.30.0 → 2.30.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/dist/codemirror.js +4 -4
- package/dist/indent.d.ts +2 -2
- package/dist/indent.js +3 -3
- package/dist/main.min.js +20 -20
- package/dist/mw.min.js +22 -22
- package/dist/wiki.min.js +22 -22
- package/i18n/en.json +1 -1
- package/i18n/zh-hans.json +1 -1
- package/i18n/zh-hant.json +1 -1
- package/package.json +1 -1
package/dist/codemirror.js
CHANGED
|
@@ -22,7 +22,7 @@ import { tagModes, getStaticMwConfig } from './static';
|
|
|
22
22
|
import bidiIsolation from './bidi';
|
|
23
23
|
import toolKeymap from './keymap';
|
|
24
24
|
import statusBar from './statusBar';
|
|
25
|
-
import { detectIndent
|
|
25
|
+
import { detectIndent } from './indent';
|
|
26
26
|
import bracketMatching from './matchBrackets';
|
|
27
27
|
import javascript from './javascript';
|
|
28
28
|
import css from './css';
|
|
@@ -185,8 +185,8 @@ export class CodeMirror6 {
|
|
|
185
185
|
textarea.value = doc.toString();
|
|
186
186
|
textarea.dispatchEvent(new Event('input'));
|
|
187
187
|
}, 400);
|
|
188
|
-
if (!
|
|
189
|
-
this.setIndent(
|
|
188
|
+
if (!startDoc.toString().trim()) {
|
|
189
|
+
this.setIndent(this.#indentStr);
|
|
190
190
|
}
|
|
191
191
|
}
|
|
192
192
|
if (focusChanged) {
|
|
@@ -335,7 +335,7 @@ export class CodeMirror6 {
|
|
|
335
335
|
*/
|
|
336
336
|
setIndent(indent) {
|
|
337
337
|
if (this.#view) {
|
|
338
|
-
this.#effects(this.#indent.reconfigure(indentUnit.of(indent)));
|
|
338
|
+
this.#effects(this.#indent.reconfigure(indentUnit.of(detectIndent(this.#view.state.doc, indent, this.#lang))));
|
|
339
339
|
}
|
|
340
340
|
else {
|
|
341
341
|
this.#indentStr = indent;
|
package/dist/indent.d.ts
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
|
|
1
|
+
import type { Text } from '@codemirror/state';
|
|
2
2
|
/**
|
|
3
3
|
* 检测文本的缩进方式
|
|
4
4
|
* @param text 文本内容
|
|
5
5
|
* @param defaultIndent 默认缩进方式
|
|
6
6
|
* @param lang 语言
|
|
7
7
|
*/
|
|
8
|
-
export declare const detectIndent: (text: string, defaultIndent: string, lang: string) => string;
|
|
8
|
+
export declare const detectIndent: (text: string | Text, defaultIndent: string, lang: string) => string;
|
package/dist/indent.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
|
|
1
|
+
const noDetectionLangs = new Set(['plain', 'mediawiki', 'html']);
|
|
2
2
|
/**
|
|
3
3
|
* 检测文本的缩进方式
|
|
4
4
|
* @param text 文本内容
|
|
@@ -9,9 +9,9 @@ export const detectIndent = (text, defaultIndent, lang) => {
|
|
|
9
9
|
if (noDetectionLangs.has(lang)) {
|
|
10
10
|
return defaultIndent;
|
|
11
11
|
}
|
|
12
|
-
const lineSpaces = [];
|
|
12
|
+
const lineSpaces = [], lines = typeof text === 'string' ? text.split('\n') : text.text;
|
|
13
13
|
let tabLines = 0;
|
|
14
|
-
for (const line of
|
|
14
|
+
for (const line of lines) {
|
|
15
15
|
if (!line.trim()) {
|
|
16
16
|
continue;
|
|
17
17
|
}
|