I like to replace any Markdown-Mode link/url token that appears in the document at any time with a TextMarker.
And I know that there are a lot of ways, but you maybe know which is the best one?
(Performance is important, it is for displaying your files like a filemanager… up to 1000 links will happen sometimes)
Which Event to use?
Right know i use “changes”.
I increase the change.to.line by the change.text.length if necessary and call eachLine() to get the lineHandle
Works well, but the change.to.line stuff is bit ugly.
Is simpler and I would get the lineHandle directly.
But I think the documentation wan’t to say, I shouldn’t do that?^^ I’m not sure about what state means:
The handler may mess with the style of the resulting element, or add event handlers, but should not try to change the state of the editor.
Get Token Position
lineHandle.styles contains the token positions and names i need.
But is undefined if the line is not already rendered.
getLineTokens( ) the way I use right know.
But every token is only a single character and I have to loop
token.type.indexOf("link") for any of them to find the start and end Chars on my own. That works, but I have the feeling it do something what codemirror already knows?
getTokenAt() according to the documentation not with good performance
getTokenAt, which re-parses the part of the line before the token for every call.
That is everything I have in mind right know.
Thank you! CodeMirror is so awesome!
I think you should not look at the code right now, its ugly ^^