Tiptap: Any way to clear the contents of tiptap programatically?

Created on 10 Sep 2018  ·  2Comments  ·  Source: ueberdosis/tiptap

I'm using tiptap within a messaging service and would like to clear the contents of the editor when a message is uploaded. However, I can't quite work out how I would go about doing this.

Once again, looking for a little bit of assistance with this, please. 👍

Most helpful comment

I released 0.11.0 – you can call clearContent() now.

Example

<template>
  <div>
    <editor ref="editor">
      <div slot="content" slot-scope="props">
        <p>Some content</p>
      </div>
    </editor>
    <button @click="clear">Clear Content</button>
  </div>
</template>

<script>
import { Editor } from 'tiptap'

export default {
  components: {
    Editor,
  },
  methods: {
    clear() {
      this.$refs.editor.clearContent()
    } 
  },
}
</script>

All 2 comments

I released 0.11.0 – you can call clearContent() now.

Example

<template>
  <div>
    <editor ref="editor">
      <div slot="content" slot-scope="props">
        <p>Some content</p>
      </div>
    </editor>
    <button @click="clear">Clear Content</button>
  </div>
</template>

<script>
import { Editor } from 'tiptap'

export default {
  components: {
    Editor,
  },
  methods: {
    clear() {
      this.$refs.editor.clearContent()
    } 
  },
}
</script>

You're a star @philippkuehn. Many thanks!

Was this page helpful?
0 / 5 - 0 ratings

Related issues

unikitty37 picture unikitty37  ·  3Comments

afwn90cj93201nixr2e1re picture afwn90cj93201nixr2e1re  ·  3Comments

santicros picture santicros  ·  3Comments

Auxxxxlx picture Auxxxxlx  ·  3Comments

chrisjbrown picture chrisjbrown  ·  3Comments