tulios / json-viewer

It is a Chrome extension for printing JSON and JSONP.
https://chrome.google.com/webstore/detail/json-viewer/gbmdgpbipfallnflgajpaliibnhdgobh
MIT License
3.31k stars 678 forks source link

Improve link anchor wrapping #204

Closed elyscape closed 6 years ago

elyscape commented 6 years ago

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 commented 6 years ago

Awesome!