Get CodeMirror instance from wrapper element?

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

And is there an internal instance index you can access?

Yes, the .CodeMirror property on the DOM node.

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

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?

document.querySelector(".CodeMirror").CodeMirror

Got it. Thanks.

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?

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

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.