Tiptap: [question] Is there any way to reset `content` without destroying/recreating the editor object?

Created on 27 Nov 2018  路  1Comment  路  Source: ueberdosis/tiptap

I wonder if I am doing it right, but currently I am wrapping the tiptap editor-content into a self-defined component like this:

export default {
  props: {  value: String },
  data() { return { editor: null } },
  watch: {
    content: {
      handler() { 
        if (this.editor) this.editor.destroy()
        this.editor = new Editor({ content: this.value, ... })
      },
      immediate: true
    },
  },
  beforeDestroy() {
    this.editor.destroy()
  }

What I want to do is to re-set the content of the editor when the value prop changes. But each time when it changes, I have to destroy and re-new the editor again. I wonder if there is some better way to do this without recreating the editor object.

Most helpful comment

Yeah, you can use editor.setContent() and editor.clearContent() for that!

>All comments

Yeah, you can use editor.setContent() and editor.clearContent() for that!

Was this page helpful?
0 / 5 - 0 ratings

Related issues

asseti6 picture asseti6  路  3Comments

leandromatos picture leandromatos  路  4Comments

connecteev picture connecteev  路  3Comments

afwn90cj93201nixr2e1re picture afwn90cj93201nixr2e1re  路  3Comments

jameswragg picture jameswragg  路  3Comments