@adminforth/markdown 1.2.9 → 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.
@@ -10,9 +10,9 @@
10
10
  "author": "",
11
11
  "license": "ISC",
12
12
  "dependencies": {
13
- "@milkdown/kit": "^7.8.0",
14
- "@milkdown/theme-nord": "^7.8.0",
15
- "@milkdown/vue": "^7.7.0",
13
+ "@milkdown/kit": "^7.18.0",
14
+ "@milkdown/theme-nord": "^7.18.0",
15
+ "@milkdown/vue": "^7.18.0",
16
16
  "dompurify": "^3.2.4",
17
17
  "marked": "^15.0.7"
18
18
  }
@@ -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: content.value,
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
  });