Get CodeMirror instance from wrapper element?

#1

Is there any way to get a CodeMirror instance from its wrapper element?

And is there an internal instance index you can access?

0 Likes

#2

Yes, the .CodeMirror property on the DOM node.

No. There is one, but it’s private.

0 Likes

#3

I don’t see what you mean. There’s a CodeMirror CSS class but how do I get myCodeMirror (as you named it in CodeMirror.fromTextArea(myTextArea) from the DOM element?

0 Likes

#4
document.querySelector(".CodeMirror").CodeMirror
0 Likes

#5

Got it. Thanks.

0 Likes

#6

Another question: I’m getting a CodeMirror instance from the original element (textarea, pre, whatever) using element.nextSibling then getting the instance as you explained above. Is there a cleaner more reliable way to do this?

0 Likes

#7

Nope, nothing apart from saving the original value you got when you called fromTextarea somewhere.

0 Likes

#8

Okay. The reason I’m doing this is the case where you’re adding my toolbars to a third party page where that value is buried in some gob of compressed code.

Thanks.

0 Likes