index.vue 984 B

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  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 {
  14. Heading,
  15. Bold,
  16. Code,
  17. Italic,
  18. Strike,
  19. Underline,
  20. History
  21. } from 'tiptap-extensions'
  22. export default {
  23. components: {
  24. EditorContent,
  25. BubbleMenu
  26. },
  27. data(){
  28. return {
  29. editor: null
  30. }
  31. },
  32. // This is called only on client (in browser)
  33. mounted(){
  34. this.editor = new Editor({
  35. extensions: [
  36. new Heading({ levels: [1, 2, 3]}),
  37. new Bold(),
  38. new Code(),
  39. new Italic(),
  40. new Strike(),
  41. new Underline(),
  42. new History()
  43. ]
  44. })
  45. },
  46. beforeDestroy(){
  47. // Always destroy your editor instance when it's no longer needed
  48. this.editor && this.editor.destroy()
  49. }
  50. }
  51. </script>