Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
// 2. Do something vaguely like loadPost
// https://github.com/ErisDS/mobiledoc-kit/blob/master/src/js/editor/editor.js#L193
// 2.a. Parse our HTML and convert to a DOM with same API as browser
let dom = new JSDOM(`${sanitizedHTML}`);
// 2.b. Use Mobiledoc-kit's own DOM Parser to convert the DOM into mobiledoc's internal format
// We use our parser plugins by default, but this is extensible
if (!options.plugins) {
options.plugins = createParserPlugins({
createDocument(html) {
return (new JSDOM(html)).window.document;
}
});
}
let parser = new DOMParser(new Builder(), options);
let post = parser.parse(dom.window.document.body);
// 3. Do something vaguely like serializePost, to render the mobiledoc internal format as mobiledoc
// https://github.com/ErisDS/mobiledoc-kit/blob/master/src/js/editor/editor.js#L567
let mobiledoc = mobiledocRenderer.render(post, '0.3.1');
return mobiledoc;
};