Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
function build(treeFn, version) {
let post = PostAbstractHelpers.build(treeFn);
switch (version) {
case MOBILEDOC_VERSION_0_2:
return MobiledocRenderer_0_2.render(post);
case MOBILEDOC_VERSION_0_3:
return MobiledocRenderer_0_3.render(post);
case MOBILEDOC_VERSION_0_3_1:
return MobiledocRenderer_0_3_1.render(post);
case MOBILEDOC_VERSION_0_3_2:
return MobiledocRenderer_0_3_2.render(post);
case undefined:
case null:
return mobiledocRenderers.render(post);
default:
throw new Error(`Unknown version of mobiledoc renderer requested: ${version}`);
}
}
function buildFromText(texts, editorOptions={}) {
let renderElement = editorOptions.element;
delete editorOptions.element;
let {post, range} = PostAbstractHelpers.buildFromText(texts);
let mobiledoc = MobiledocRenderer.render(post);
editorOptions.mobiledoc = mobiledoc;
let editor = new Editor(editorOptions);
if (renderElement) {
editor.render(renderElement);
range = retargetRange(range, editor.post);
editor.selectRange(range);
}
return editor;
}