|
|
@ -19,7 +19,16 @@ const props = defineProps<{ |
|
|
|
|
|
|
|
|
|
|
|
const emits = defineEmits(['update:value']) |
|
|
|
const emits = defineEmits(['update:value']) |
|
|
|
|
|
|
|
|
|
|
|
const turndownService = new TurndownService() |
|
|
|
const turndownService = new TurndownService({}) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
turndownService.addRule('lineBreak', { |
|
|
|
|
|
|
|
filter: (node) => { |
|
|
|
|
|
|
|
return node.nodeName === 'BR' |
|
|
|
|
|
|
|
}, |
|
|
|
|
|
|
|
replacement: () => { |
|
|
|
|
|
|
|
return '<br />' |
|
|
|
|
|
|
|
}, |
|
|
|
|
|
|
|
}) |
|
|
|
|
|
|
|
|
|
|
|
turndownService.addRule('taskList', { |
|
|
|
turndownService.addRule('taskList', { |
|
|
|
filter: (node) => { |
|
|
|
filter: (node) => { |
|
|
@ -90,7 +99,9 @@ const tiptapExtensions = [ |
|
|
|
const editor = useEditor({ |
|
|
|
const editor = useEditor({ |
|
|
|
extensions: tiptapExtensions, |
|
|
|
extensions: tiptapExtensions, |
|
|
|
onUpdate: ({ editor }) => { |
|
|
|
onUpdate: ({ editor }) => { |
|
|
|
const markdown = turndownService.turndown(editor.getHTML()) |
|
|
|
const markdown = turndownService |
|
|
|
|
|
|
|
.turndown(editor.getHTML().replaceAll(/<p><\/p>/g, '<br />')) |
|
|
|
|
|
|
|
.replaceAll(/\n\n<br \/>\n\n/g, '<br>\n\n') |
|
|
|
|
|
|
|
|
|
|
|
vModel.value = markdown |
|
|
|
vModel.value = markdown |
|
|
|
}, |
|
|
|
}, |
|
|
|