improve basic example

This commit is contained in:
Philipp Kühn
2020-03-06 11:46:46 +01:00
parent e94415aa67
commit c6e003de85
2 changed files with 37 additions and 9 deletions

View File

@@ -3,16 +3,16 @@ title: Test
slug: test slug: test
--- ---
# Super epic editor demo <!-- # Super epic editor demo
- magic - magic
- epic - epic -->
<!-- <demo name="Basic" key="basic" /> --> <demo name="Basic" key="basic" />
# Super epic time demo <!-- # Super epic time demo
- nice numbers - nice numbers
- nice time - nice time
<demo name="Time" key="time" /> <demo name="Time" key="time" /> -->

View File

@@ -1,18 +1,46 @@
<template> <template>
<Layout> <div>
<div v-if="editor">
<button @click="editor.undo().focus()">
undo
</button>
<button @click="editor.redo().focus()">
redo
</button>
</div>
<div ref="editor"></div> <div ref="editor"></div>
</Layout> </div>
</template> </template>
<script> <script>
import Editor from '@tiptap/core' import Editor from '@tiptap/core'
import Document from '@tiptap/document-extension'
import Paragraph from '@tiptap/paragraph-extension'
import Text from '@tiptap/text-extension'
import History from '@tiptap/history-extension'
export default { export default {
data() {
return {
editor: null,
}
},
mounted() { mounted() {
new Editor({ this.editor = new Editor({
element: this.$refs.editor, element: this.$refs.editor,
content: '<p>foo</p>', content: '<p>foo</p>',
extensions: [
new Document(),
new Paragraph(),
new Text(),
new History(),
],
}) })
} },
beforeDestroy() {
this.editor.destroy()
},
} }
</script> </script>