54 lines
1.0 KiB
Vue
54 lines
1.0 KiB
Vue
<template>
|
|
<div v-if="editor">
|
|
<button @click="editor.chain().focus().bulletList().run()" :class="{ 'is-active': editor.isActive('bulletList') }">
|
|
bullet list
|
|
</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 BulletList from '@tiptap/extension-bullet-list'
|
|
import ListItem from '@tiptap/extension-list-item'
|
|
|
|
export default {
|
|
components: {
|
|
EditorContent,
|
|
},
|
|
|
|
data() {
|
|
return {
|
|
editor: null,
|
|
}
|
|
},
|
|
|
|
mounted() {
|
|
this.editor = new Editor({
|
|
extensions: [
|
|
Document,
|
|
Paragraph,
|
|
Text,
|
|
BulletList,
|
|
ListItem,
|
|
],
|
|
content: `
|
|
<ul>
|
|
<li>A list item</li>
|
|
<li>And another one</li>
|
|
</ul>
|
|
`,
|
|
})
|
|
},
|
|
|
|
beforeDestroy() {
|
|
this.editor.destroy()
|
|
},
|
|
}
|
|
</script>
|