Skip to content

Conversation

@elyscape
Copy link
Contributor

@elyscape elyscape commented Apr 2, 2018

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 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.
@tulios
Copy link
Owner

tulios commented Apr 3, 2018

Awesome!

@tulios tulios merged commit f72ff5f into tulios:master Apr 3, 2018
@elyscape elyscape deleted the improve-link-wrapping branch April 3, 2018 08:38
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants