index.vue 790 B

1234567891011121314151617181920212223242526272829303132333435363738
  1. <template>
  2. <div class="editor editor-squished">
  3. <bubble-menu :editor="editor" />
  4. <editor-content
  5. class="editor__content"
  6. :editor="editor"
  7. />
  8. </div>
  9. </template>
  10. <script>
  11. import { Editor, EditorContent } from "tiptap"
  12. import BubbleMenu from '~/components/editor/BubbleMenu'
  13. import { Heading } from 'tiptap-extensions'
  14. export default {
  15. components: {
  16. EditorContent,
  17. BubbleMenu
  18. },
  19. data(){
  20. return {
  21. editor: null
  22. }
  23. },
  24. // This is called only on client (in browser)
  25. mounted(){
  26. this.editor = new Editor({
  27. extensions: [
  28. new Heading({ levels: [1, 2, 3]})
  29. ]
  30. })
  31. },
  32. beforeDestroy(){
  33. // Always destroy your editor instance when it's no longer needed
  34. this.editor && this.editor.destroy()
  35. }
  36. }
  37. </script>