Using the basic version fo Tiptap editor:
<template>
<div v-if="editor">
<editor-content :editor="editor" />
</div>
</template>
<script>
import { Editor, EditorContent } from '@tiptap/vue-3'
import Document from '@tiptap/extension-document'
import Paragraph from '@tiptap/extension-paragraph'
import Text from '@tiptap/extension-text'
export default {
components: {
EditorContent,
},
data() {
return {
editor: null,
}
},
mounted() {
this.editor = new Editor({
extensions: [
Document,
Paragraph,
Text,
],
content: `
<p>The Paragraph extension is not required, but it’s very likely you want to use it. It’s needed to write paragraphs of text. </p>
`,
})
},
beforeUnmount() {
this.editor.destroy()
},
}
</script>
(which is available to test at https://tiptap.dev/api/nodes/paragraph)
I noticed that when pasting a text with multiple lines, such as :
Hello
This is a test with two break lines at the above and three after this:
Thanks!
The resulting is :
<p>Hello</p>
<p>This is a test with two break lines at the above and three after this:</p>
<p>Thanks!</p>
In this case, all the "multiple" break lines has been removed!
Is there a way to keep them, which means that once the paste is executed, the content should be:
<p>Hello</p>
<p></p>
<p></p>
<p>This is a test with two break lines at the above and three after this:</p>
<p></p>
<p></p>
<p></p>
<p>Thanks!</p>
(I'm ok with having <p><br /></p> instead of <p></p> by enabling the Hardbreak extension too, but in either case, it doesn't work).
