Thanks for this, I'd really like to have this functionality. I'm seeing an issue with this where sometimes this does not get cleared after clicking on the link, so subsequently, if you click within the editor NOT on the link (after you've already clicked on the link) it will still try to open the link. This happens even on the linked example, intermittently (you must click the button "Run with JS" first). I've tried multiple browsers to the same affect. Any idea why this is happening? I'm at a loss.
Thanks,
Nic