Files
tiptap/docs/src/demos/Guide/NodeViews/TableOfContents/index.vue
Philipp Kühn 5f54a86da7 fix bug
2021-03-12 23:52:54 +01:00

50 lines
899 B
Vue

<template>
<div v-if="editor">
<editor-content :editor="editor" />
</div>
</template>
<script>
import { Editor, EditorContent } from '@tiptap/vue-2'
import { defaultExtensions } from '@tiptap/starter-kit'
import TableOfContents from './TableOfContents.js'
export default {
components: {
EditorContent,
},
data() {
return {
editor: null,
}
},
mounted() {
this.editor = new Editor({
extensions: [
...defaultExtensions(),
TableOfContents,
],
content: `
<toc></toc>
<h2>1 heading</h2>
<p>paragraph</p>
<h3>1.1 heading</h3>
<p>paragraph</p>
<h3>1.2 heading</h3>
<p>paragraph</p>
<h2>2 heading</h2>
<p>paragraph</p>
<h3>2.1 heading</h3>
<p>paragraph</p>
`,
})
},
beforeDestroy() {
this.editor.destroy()
},
}
</script>