Tiptap: How to bind click event to node?

Created on 14 Jan 2019  路  3Comments  路  Source: ueberdosis/tiptap

Most helpful comment

You can pass prosemirror plugins to your extensions. There are some editor props you can use 鈥撀爄n your case it's handleClick.

import { Node, Plugin } from 'tiptap'

export default class CustomNode extends Node {

  get name() {
    return 'custom_node'
  }

  get schema() {
    // schema
  }

  get plugins() {
    return [
      new Plugin({
        props: {
          handleClick(view, pos) {
            // do something
          },
        },
      }),
    ]
  }

}

All 3 comments

You can pass prosemirror plugins to your extensions. There are some editor props you can use 鈥撀爄n your case it's handleClick.

import { Node, Plugin } from 'tiptap'

export default class CustomNode extends Node {

  get name() {
    return 'custom_node'
  }

  get schema() {
    // schema
  }

  get plugins() {
    return [
      new Plugin({
        props: {
          handleClick(view, pos) {
            // do something
          },
        },
      }),
    ]
  }

}

Thanks. That is helpful. But it brings a new problem. I can not visit this. Is it possible to get the Vue instance in functon handleClick? For now, my solution is to store some variables through using LocalStorage, then I can visit these variables in CustomNode.js. But I really want to find a way to visit this directly in handleClick.

Or maybe we can register these editor props when the Editor is initialized?
Like this.

new Editor({ 
  handleClick: ( view, pos, event) => {} .   // now it is not supported
})

Was this page helpful?
0 / 5 - 0 ratings

Related issues

dolbex picture dolbex  路  3Comments

agentq15 picture agentq15  路  3Comments

klaasgeldof picture klaasgeldof  路  3Comments

panayotisk picture panayotisk  路  4Comments

jameswragg picture jameswragg  路  3Comments