Event handlers for static HTML

Hi, I’m building my editor (using Tiptap) and I have some questions regarding handling events like onHover or onClick. There are extensions that I want to build:

  1. Mention - the toDOM() will return an a tag with appropriate href. However, I’d like to add to it extra feature which will show user details card on hover (from database).
  2. Spoiler - a block with initially hidden content (hidden class) which became visible on click (hidden class removed)

I have a button in my editor which shows modal with a preview, i.e. the HTML which will be the very final results. I’d like to add to this preview HTML code these event handlers too (i.e the one which display hover card and the one which removes hidden class). The same HTML will be saved to database and used on appropriate site so I’d like to simply use this HTML and have all event listeners already linked. How can I do that?

Any ideas? Another example is an annotation extension which would produce a button which after click, open a popover with for example link to the source of a quote.