I’ve got a working CM editor, whose document I’d like to link so that it is displayed inside another editor. The code I’m using is:
// create a wrapper element for the CM clone
var cloneDOM = document.createElement('div');
cloneDOM.id = "printedCM";
cloneDOM.style.height = "auto";
document.getElementById('middle').appendChild(cloneDOM);
// create the clone, using the wrapper element and a linked doc from the current editor
var clone = new CodeMirror(cloneDOM, {value: editor.getDoc().linkedDoc()});
// copy lineNumber settings
clone.setOption("lineNumbers", this.editor.getOption("lineNumbers"));
I can confirm that clone.getValue() always produces the text contained in editor.getValue(), so I know the doc is being updated. However, the cloneDOM instance always shows a blank editor, even after I call clone.refresh().
I’m also fairly certain this worked in CM4. Am I missing something obvious? Has something changed from v4->v5?
Thanks so much,
Emmanuel