Skip to content
Discussion options

You must be logged in to vote

Hi @tt4g,

I'm pretty sure the way to go is to use the destroy method on the NodeView object you return. Tiptap just uses the standard ProseMirror NodeView interface under the hood, and that has a destroy hook for exactly this kind of cleanup.

I haven't spun this up myself to test it, but it should totally work. Maybe you can give this a shot?

addNodeView() {
  return ({ editor, node, getPos }) => {
    const { view } = editor;

    const button = document.createElement('button');
    button.innerHTML = `This button has been clicked ${node.attrs.count} times.`;

    // define the handler so you can remove it later
    const handleClick = () => {
      if (typeof getPos === 'function') {

Replies: 1 comment 1 reply

Comment options

You must be logged in to vote
1 reply
@tt4g
Comment options

Answer selected by tt4g
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
2 participants