Topic on Extension talk:CodeMirror

How to send a command to CodeMirror from JS?

Summary by
Putnik (talkcontribs)

There are many scripts that change the value of the textarea. But CodeMirror does not react to these changes in any way. What are the options to send new text to CodeMirror?

Trustable (talkcontribs)

Did you find out anything? I would like know for example: How can I call the function "switchCodeMirror()" in JavaScript?

NKohli (WMF) (talkcontribs)

Hi, can you elaborate on this a bit with an example? Thanks.

Trustable (talkcontribs)

A script changes the content of the textarea. What function needs to be called by the script to update the CodeMirror output?

NKohli (WMF) (talkcontribs)

Does sound like what you're looking for? Please add your comments to that ticket or create a new one if that's different from what you're seeking. We'll get around to this in a while after conquering some more troublesome bugs. Thank you.

Trustable (talkcontribs)

I found a solution:

  1. program calls "$( '#wpTextbox1' ).data( 'wikiEditor-context' ).modules.toolbar.$toolbar.find( 'a.tool[rel=CodeMirror]' ).click();" to disable CodeMirror
  2. program modifies the text in the textarea
  3. program call "$( '#wpTextbox1' ).data( 'wikiEditor-context' ).modules.toolbar.$toolbar.find( 'a.tool[rel=CodeMirror]' ).click();" to enable CodeMirror

Not elegant, but works for me.

Reply to "How to send a command to CodeMirror from JS?"