1 import schema from "./schema";
2 import {DOMParser, DOMSerializer} from "prosemirror-model";
5 export function htmlToDoc(html) {
6 const renderDoc = document.implementation.createHTMLDocument();
7 renderDoc.body.innerHTML = html;
8 return DOMParser.fromSchema(schema).parse(renderDoc.body);
11 export function docToHtml(doc) {
12 const fragment = DOMSerializer.fromSchema(schema).serializeFragment(doc.content);
13 const renderDoc = document.implementation.createHTMLDocument();
14 renderDoc.body.appendChild(fragment);
15 return renderDoc.body.innerHTML;
19 * @class KeyedMultiStack
20 * Holds many stacks, seperated via a key, with a simple
21 * interface to pop and push values to the stacks.
23 export class KeyedMultiStack {
31 * @return {undefined|*}
34 if (Array.isArray(this.stack[key])) {
35 return this.stack[key].pop();
45 if (this.stack[key] === undefined) {
49 this.stack[key].push(value);