I want a part of code in codemirror to be turned into hyperlink on alt-mouseover. Can someone suggest a good way to do it ?
You can’t turn the content DOM itself into a hyperlink, but you can do something like this:
Register a mouseover handler on the editor
When the mouse goes over a token that you are interested in (say, a span with
cm-linkclass, or you could use
markTextto add a specific class to the elements you’re interested in)…
charCoordsto find the position of that token and overlay your own link, styled to look like the content, over the editor.
You can also try to use
markText to replace the text with an atomic element that you watch for mouseovers on. You won’t really be able to edit it as easily, though.
Would it be possible to use an anchor tag, for better accessibility?
Not in CodeMirror 5.x, but version 6 allows you to wrap decorated text in arbitrary inline tags.
Wait seriously, how?
tagName option to