When URLs are wrapped in anchor tags, we reparent the text nodes from the DOM to the new anchor node in order to prevent CodeMirror from getting confused and hiding the cursor when it's inside the URL. Additionally, we apply the cm-string class to the anchor tag to keep the style the same. We also only apply the cm-string-link class to the surrounding span tag when links are not wrapped in anchor tags in order to avoid triggering the custom link behavior by accident. Finally, we put an event listener on the anchor tags that prevents the contextmenu event from bubbling to CodeMirror's handler in order to restore the expected behavior of context menus for links.
When URLs are wrapped in anchor tags, we reparent the text nodes from the DOM to the new anchor node in order to prevent CodeMirror from getting confused and hiding the cursor when it's inside the URL. Additionally, we apply the
cm-string class
to the anchor tag to keep the style the same. We also only apply thecm-string-link
class to the surrounding span tag when links are not wrapped in anchor tags in order to avoid triggering the custom link behavior by accident. Finally, we put an event listener on the anchor tags that prevents thecontextmenu
event from bubbling to CodeMirror's handler in order to restore the expected behavior of context menus for links.