kritya
kritya

Reputation: 3362

JS codemirror modify text using the object returned by onchange

I have a codemirror text box with onchange event which stores the object returned by the change function.

Now , in some other text box I have the original text ( the one before the change occurred ) and I want to implement the same change on the second text box as well , so both of them have same content.

There is a function replaceRange(). But I cant implement in on all kind of changes like multi-line or when user removes some text.

Is there any better way of doing it , for all kind of changes ? or is there a function in which I just pass the object and it automatically modifies the text accordingly.

Upvotes: 0

Views: 511

Answers (1)

Eliran Malka
Eliran Malka

Reputation: 16263

Instead of getting the text from the first editor, get the document from it, and than use it to swap the older document on the other.

See it in the docs:

Upvotes: 1

Related Questions