tiptap/examples/Components/Routes/History/index.vue
Gil B. Chan c6f281e487 change deprecated slot-scope to v-slot
Directive `slot-scope` is deprecated as of Vue v2.6.0. See [here](https://vuejs.org/v2/guide/components-slots.html) for details. Currently tiptap depends on Vue ^2.6.10. So this commit introduces new directive `v-slot` on README.md and examples.
2019-05-08 06:25:36 +09:00

72 lines
1.5 KiB
Vue

<template>
<div class="editor">
<editor-menu-bar :editor="editor" v-slot="{ commands, isActive }">
<div class="menubar">
<button
class="menubar__button"
@click="commands.undo"
>
<icon name="undo" />
</button>
<button
class="menubar__button"
@click="commands.redo"
>
<icon name="redo" />
</button>
</div>
</editor-menu-bar>
<editor-content class="editor__content" :editor="editor" />
</div>
</template>
<script>
import Icon from 'Components/Icon'
import { Editor, EditorContent, EditorMenuBar } from 'tiptap'
import {
HardBreak,
Heading,
Bold,
Code,
Italic,
History,
} from 'tiptap-extensions'
export default {
components: {
EditorContent,
EditorMenuBar,
Icon,
},
data() {
return {
editor: new Editor({
extensions: [
new HardBreak(),
new Heading({ levels: [1, 2, 3] }),
new Bold(),
new Code(),
new Italic(),
new History(),
],
content: `
<h2>
History
</h2>
<p>
Try to change some content here. With the <code>History</code> extension you are able to undo and redo your changes. You can also use keyboard shortcuts for this (<code>cmd+z</code> and <code>cmd+shift+z</code>).
</p>
`,
}),
}
},
beforeDestroy() {
this.editor.destroy()
},
}
</script>