How to handle events inside decorations?

hi @marijn

I see here that you passed the dispatch function to the commentUI plugin.

I tried doing the same, but ended up getting an applying a mismatch transaction error, since some decorations were created in the init hook and others in the apply hook and I’m guessing the state transaction can’t differ.

I believe you got around this by separating the commentPlugin and commentUI functionality.

I was wondering if another possibility was, rather than a dispatch function only to the UI plugin, passing the editor instance itself with its view and state.

Passing it like this:

export default (editorVm) => new Plugin({ ...})

And using it somewhere else like this:

 editorVm.view.dispatch(
    editorVm.state.tr.setMeta('meta key', {})
 )

Not sure if you foresee any problems not using the arguments not directly using the plugins respective hooks.