editor.js icon indicating copy to clipboard operation
editor.js copied to clipboard

Custom callback for tools

Open shalama opened this issue 5 years ago • 0 comments

How to send a callback from an custom tool.

We want to implement some custom tool e.g. to create an header navigation. For this purpose it would be very helpful to trigger our header logic only if the header tool was called. At the moment every tool that was activated calls on the onChange method of the editor. So is there a way to create custom events that could be listend on or can we distinguish to tool with the onChange event?

this.editor = new EditorJS({
      holder: this.id,
      tools: {
        header: {
          class: ToolbarHeadings,
          inlineToolbar: true`},
list: {
          class: List,
          inlineToolbar: true
        }
,onChange: () => {
//Do something if header was activated
//Do something else if  List was activated
})

Any advise would be appreciated.

shalama avatar Mar 06 '21 11:03 shalama