1 import schema from "./schema";
2 import {DOMParser, DOMSerializer} from "prosemirror-model";
8 export function htmlToDoc(html) {
9 const renderDoc = document.implementation.createHTMLDocument();
10 renderDoc.body.innerHTML = html;
11 return DOMParser.fromSchema(schema).parse(renderDoc.body);
18 export function docToHtml(doc) {
19 const fragment = DOMSerializer.fromSchema(schema).serializeFragment(doc.content);
20 const renderDoc = document.implementation.createHTMLDocument();
21 renderDoc.body.appendChild(fragment);
22 return renderDoc.body.innerHTML;
26 * @class KeyedMultiStack
27 * Holds many stacks, seperated via a key, with a simple
28 * interface to pop and push values to the stacks.
30 export class KeyedMultiStack {
38 * @return {undefined|*}
41 if (Array.isArray(this.stack[key])) {
42 return this.stack[key].pop();
52 if (this.stack[key] === undefined) {
56 this.stack[key].push(value);