Default prevented on <a> click?

I’m in the process of adding hyperlinks, and have found that clicking on the rendered <a> in the editor doesn’t trigger a navigation, it seems like there is a Event#preventDefault() call occurring somewhere.

Not only does this prevent the navigation, but it also prevents shift+click to set the head of a text selection from its current anchor.

Has anyone come across this and have any insight?

This is how most (maybe all) browsers treat editable links—i.e. the behavior comes from the browser, not ProseMirror. You’ll see the same in TinyMCE etc. This makes sense, because trying to put the cursor in a link and then accidentally following it would be bad. A common solution is to show a tooltip below the link with a non-editable version, when the cursor is inside it.

2 Likes

Thanks for the clarification!

I found tiptap allows link opening. I can’t figure out how it works https://tiptap.scrumpy.io/links