2020-09-23 18:33:45 +08:00
|
|
|
<template>
|
|
|
|
<div v-if="editor">
|
2020-11-04 03:57:09 +08:00
|
|
|
<button @click="editor.chain().focus().orderedList().run()" :class="{ 'is-active': editor.isActive('orderedList') }">
|
2020-09-23 18:33:45 +08:00
|
|
|
ordered 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 OrderedList from '@tiptap/extension-ordered-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(),
|
|
|
|
OrderedList(),
|
|
|
|
ListItem(),
|
|
|
|
],
|
|
|
|
content: `
|
2020-10-27 21:53:23 +08:00
|
|
|
<ol>
|
2020-09-23 18:33:45 +08:00
|
|
|
<li>A list item</li>
|
|
|
|
<li>And another one</li>
|
2020-10-27 21:53:23 +08:00
|
|
|
</ol>
|
|
|
|
|
|
|
|
<ol start="5">
|
|
|
|
<li>This item starts at 5</li>
|
|
|
|
<li>And another one</li>
|
|
|
|
</ol>
|
2020-09-23 18:33:45 +08:00
|
|
|
`,
|
|
|
|
})
|
|
|
|
},
|
|
|
|
|
|
|
|
beforeDestroy() {
|
|
|
|
this.editor.destroy()
|
2020-09-24 06:29:05 +08:00
|
|
|
},
|
2020-09-23 18:33:45 +08:00
|
|
|
}
|
2020-09-24 06:29:05 +08:00
|
|
|
</script>
|