@adminforth/markdown 1.2.8 → 1.2.10
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/build.log +2 -2
- package/custom/MarkdownEditor.vue +16 -3
- package/custom/package-lock.json +702 -1932
- package/custom/package.json +3 -3
- package/dist/custom/MarkdownEditor.vue +16 -3
- package/dist/custom/package-lock.json +702 -1932
- package/dist/custom/package.json +3 -3
- package/package.json +1 -1
package/build.log
CHANGED
|
@@ -10,5 +10,5 @@ custom/package-lock.json
|
|
|
10
10
|
custom/package.json
|
|
11
11
|
custom/tsconfig.json
|
|
12
12
|
|
|
13
|
-
sent
|
|
14
|
-
total size is
|
|
13
|
+
sent 124,301 bytes received 115 bytes 248,832.00 bytes/sec
|
|
14
|
+
total size is 123,849 speedup is 1.00
|
|
@@ -15,7 +15,7 @@ import { Editor } from '@milkdown/core';
|
|
|
15
15
|
import { Crepe } from '@milkdown/crepe';
|
|
16
16
|
import type { AdminForthColumn } from '@/types/Common';
|
|
17
17
|
import '@milkdown/crepe/theme/common/style.css';
|
|
18
|
-
import '@milkdown/crepe/theme/frame
|
|
18
|
+
import '@milkdown/crepe/theme/frame.css';
|
|
19
19
|
|
|
20
20
|
const props = defineProps<{
|
|
21
21
|
column: AdminForthColumn,
|
|
@@ -32,6 +32,14 @@ const isFocused = ref(false);
|
|
|
32
32
|
let milkdownInstance: Editor | null = null;
|
|
33
33
|
let crepeInstance: Crepe | null = null;
|
|
34
34
|
|
|
35
|
+
function normalizeMarkdownForMilkdown(markdown: string): string {
|
|
36
|
+
if (!markdown) return '';
|
|
37
|
+
// Milkdown/Crepe’s remark parser can choke on raw HTML nodes inside list items
|
|
38
|
+
// (e.g. `<br />` gets parsed as an `html` AST node). Convert those line breaks
|
|
39
|
+
// back into plain markdown newlines before parsing.
|
|
40
|
+
return markdown.replace(/<br\s*\/?\s*>/gi, '\n');
|
|
41
|
+
}
|
|
42
|
+
|
|
35
43
|
onMounted(async () => {
|
|
36
44
|
if (!editorContainer.value) return;
|
|
37
45
|
try {
|
|
@@ -64,14 +72,19 @@ onMounted(async () => {
|
|
|
64
72
|
|
|
65
73
|
// Crepe
|
|
66
74
|
if (props.column.components.edit.meta.pluginType === 'crepe' || props.column.components.create.meta.pluginType === 'crepe') {
|
|
75
|
+
const normalizedInitialValue = normalizeMarkdownForMilkdown(content.value);
|
|
76
|
+
if (normalizedInitialValue !== content.value) {
|
|
77
|
+
content.value = normalizedInitialValue;
|
|
78
|
+
}
|
|
79
|
+
|
|
67
80
|
crepeInstance = await new Crepe({
|
|
68
81
|
root: editorContainer.value,
|
|
69
|
-
defaultValue:
|
|
82
|
+
defaultValue: normalizedInitialValue,
|
|
70
83
|
});
|
|
71
84
|
|
|
72
85
|
crepeInstance.on((listener) => {
|
|
73
86
|
listener.markdownUpdated(async () => {
|
|
74
|
-
let markdownContent = crepeInstance.getMarkdown();
|
|
87
|
+
let markdownContent = normalizeMarkdownForMilkdown(crepeInstance.getMarkdown());
|
|
75
88
|
markdownContent = await replaceBlobsWithS3Urls(markdownContent);
|
|
76
89
|
emit('update:value', markdownContent);
|
|
77
90
|
});
|