I borrowed applyDOMChange and ad hoc use the default schema, things seems to work, will watch for edge cases:
function markdown_html(){
// takes markdown and convert to internal doc model
let newdoc=fromMarkdown(schema, markitor.getContent("text"));
// find the transform from orig doc to new doc
// borrow from applyDOMChange
applydocChange(editor,newdoc);
html_markdown(); //since the html is the true reference, we take a hit with markdown normalization
};
function html_markdown(){
let markdown=toMarkdown(editor.doc);
let markdowndoc=fromText(schema,markdown);
applydocChange(markitor,markdowndoc);