Handle clicking on text inside CodeMirror 6

Is there a way to handle clicking on the text and triggering a custom action?

I was thinking of adding two features to my note-taking app.

  1. CTRL + click to open the link
  2. Click inside markdown checkbox toggle the checkbox. I have this feature in GNU Emacs

I can handle the parsing part, detecting offset start and end of markdown checkbox or URL. But not sure how to handle it on the CodeMirror side.

Any idea if something like this is possible, and how would you approach this?

You can use EditorView.domEventHandlers to register a handler, then use posAtCoords to figure out what is being clicked, and take it from there.