Hi,
I am wishing to use CodeMirror in a side-by-side editor (editor/preview panel). Here’s part of my code.
var myEditor = CodeMirror.fromTextArea(page_content, {
lineNumbers: true,
mode: "markdown",
lineWrapping: true,
lineNumbers:false,
indentWithTabs: true
});
function updateTextArea() {
myEditor.save();
}
myEditor.on('change', updateTextArea);
In dev tools, I expected to see the textarea
element keep up to date with changes but it doesn’t seem to be saving.
An aside – elsewhere, I’m using cmark.js (CommonMark) to update the preview panel with this, which uses changes to the original textarea to update the preview…
function parseAndRender() {
$("#preview").html(qcode.markdown2html($("#post_content, #page_content").val()));
}
$("#post_content, #page_content").on('keyup paste cut mouseup', parseAndRender);
parseAndRender();
$("#post_content, #page_content, #preview, .CodeMirror-scroll").scrollTogether();