{line, ch} -> token span?

Given a Position, is it possible to access the actual DOM node used to represent the token at that position? I’ve done some searching here and in the old google group, to no avail.

Thanks!
Emmanuel

I don’t think that there is. What’s your use case? You probably shouldn’t want to be manipulating the spans themselves. Can you get away with setBookmark or markText?

I have a DOM tree based on the AST represented by CodeMirror’s contents (output from a compiler), and I’d like to construct that tree using the actual nodes used by CM. The benefit here is that I can use the highlighter function to decorate CM, and see those nodes highlighted in the tree.

FWIW - I’m already using markText to replace those nodes - but instead I want to shuffle them around, not replace them.

I don’t think that’s really going to work very well. You could hook into the "renderLine" event, and copy the nodes that you are interested in there. But in general, there is no single DOM element that corresponds to a token – the editor’s DOM is updated a lot, in response to various events, and that involves redrawing it.