Get element className

Hello.

Is it possible get the classname from element where is cursor| located in editor content?

For clarification: https://jsfiddle.net/3tj1wv44/1/ (Click with mouse on element… Is highlighted. Same highlighting i need when you move cursor in editor with keyboard.)

Any way to solve this is much appreciate.

Thanks in advance.

You could use getTokenTypeAt and prefix the first word in the resulting string with cm- to get a class name (if it’s not empty).

thank you, but when try:
console.log(editor.getTokenTypeAt(10,10));

give me error:
Unable to get property ‘chunkSize’ of undefined or null reference / codemirror.js (405,37)

same error with:
console.log(editor.getTokenAt(10));

Am I doing anything wrong?

Yes, you’re passing the wrong kind of arguments to getTokenAt. I linked the docs—take a look at them.

thank you!
It works https://jsfiddle.net/3tj1wv44/2/