2020-08-21 03:25:15 +08:00
|
|
|
|
<template>
|
|
|
|
|
<div v-if="editor">
|
2020-09-22 15:08:08 +08:00
|
|
|
|
<button @click="editor.chain().focus().italic().run()" :class="{ 'is-active': editor.isActive('italic') }">
|
2020-08-21 03:25:15 +08:00
|
|
|
|
italic
|
|
|
|
|
</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 Italic from '@tiptap/extension-italic'
|
|
|
|
|
|
|
|
|
|
export default {
|
|
|
|
|
components: {
|
|
|
|
|
EditorContent,
|
|
|
|
|
},
|
|
|
|
|
|
|
|
|
|
data() {
|
|
|
|
|
return {
|
|
|
|
|
editor: null,
|
|
|
|
|
}
|
|
|
|
|
},
|
|
|
|
|
|
|
|
|
|
mounted() {
|
|
|
|
|
this.editor = new Editor({
|
|
|
|
|
extensions: [
|
2020-09-09 16:58:10 +08:00
|
|
|
|
Document(),
|
|
|
|
|
Paragraph(),
|
|
|
|
|
Text(),
|
|
|
|
|
Italic(),
|
2020-08-21 03:25:15 +08:00
|
|
|
|
],
|
|
|
|
|
content: `
|
|
|
|
|
<p>This isn’t italic.</p>
|
|
|
|
|
<p><em>This is italic.</em></p>
|
|
|
|
|
<p><i>And this.</i></p>
|
|
|
|
|
<p style="font-style: italic">This as well.</p>
|
|
|
|
|
`,
|
|
|
|
|
})
|
|
|
|
|
},
|
|
|
|
|
|
|
|
|
|
beforeDestroy() {
|
|
|
|
|
this.editor.destroy()
|
2020-09-24 06:29:05 +08:00
|
|
|
|
},
|
2020-08-21 03:25:15 +08:00
|
|
|
|
}
|
2020-09-24 06:29:05 +08:00
|
|
|
|
</script>
|