mirror of
https://github.com/ueberdosis/tiptap.git
synced 2025-01-08 20:38:12 +08:00
52 lines
1.0 KiB
Vue
52 lines
1.0 KiB
Vue
|
<template>
|
||
|
<div v-if="editor">
|
||
|
<button @click="editor.focus().horizontalRule()">
|
||
|
horizontalRule
|
||
|
</button>
|
||
|
|
||
|
<editor-content :editor="editor" />
|
||
|
</div>
|
||
|
</template>
|
||
|
|
||
|
<script>
|
||
|
import { Editor } from '@tiptap/core'
|
||
|
import { EditorContent } from '@tiptap/vue'
|
||
|
import Document from '@tiptap/extension-document'
|
||
|
import Paragraph from '@tiptap/extension-paragraph'
|
||
|
import Text from '@tiptap/extension-text'
|
||
|
import HorizontalRule from '@tiptap/extension-horizontal-rule'
|
||
|
|
||
|
export default {
|
||
|
components: {
|
||
|
EditorContent,
|
||
|
},
|
||
|
|
||
|
data() {
|
||
|
return {
|
||
|
editor: null,
|
||
|
}
|
||
|
},
|
||
|
|
||
|
mounted() {
|
||
|
this.editor = new Editor({
|
||
|
extensions: [
|
||
|
Document(),
|
||
|
Paragraph(),
|
||
|
Text(),
|
||
|
HorizontalRule(),
|
||
|
],
|
||
|
content: `
|
||
|
<p>This is a paragraph.</p>
|
||
|
<hr>
|
||
|
<p>And this is another paragraph.</p>
|
||
|
<hr>
|
||
|
<p>But between those paragraphs are horizontal rules.</p>
|
||
|
`,
|
||
|
})
|
||
|
},
|
||
|
|
||
|
beforeDestroy() {
|
||
|
this.editor.destroy()
|
||
|
}
|
||
|
}
|
||
|
</script>
|