@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.
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 171,308 bytes received 115 bytes 342,846.00 bytes/sec
14
- total size is 170,848 speedup is 1.00
13
+ sent 124,301 bytes received 115 bytes 248,832.00 bytes/sec
14
+ total size is 123,849 speedup is 1.00
@@ -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
  });