merge/merge.js fromTextArea()

How can I create a 3-way CodeMirror.MergeView() with content from 3 existing <textarea> elements? The reason that I need this is because I want to submit the 3 <textarea> with a POST form when the user has finished editing.

Thank you.

You can’t do that directly, but you can feed the .value properties of the textareas to the MergeView constructor and then hide the textareas. You’ll have to wire up the logic that moves the text back into the fields on submit yourself.

Is there any constructor such as CodeMirror.MergeViewFromTextArea() that replaces the middle column editor (of a 3-way merge) with the <textarea> content like CodeMirror.fromTextArea(), and also keeps the content of <textarea> updated? This would work for me too.

No, that isn’t included in the library.

OK, thank you!
FWIW I think it would be a useful addition to the library. A constructor CodeMirror.MergeViewFromTextArea() that works like CodeMirror.fromTextArea() but with added originLeft/originRight merge editors.

1 Like