1
0
mirror of https://github.com/BookStackApp/BookStack.git synced 2025-07-15 12:41:52 +03:00

Got callouts about working, simplified markdown setup

This commit is contained in:
Dan Brown
2022-01-07 21:22:07 +00:00
parent 0fb8ba00a5
commit 81dfe9c345
4 changed files with 60 additions and 156 deletions

View File

@ -0,0 +1,16 @@
import schema from "./schema";
import {DOMParser, DOMSerializer} from "prosemirror-model";
export function htmlToDoc(html) {
const renderDoc = document.implementation.createHTMLDocument();
renderDoc.body.innerHTML = html;
return DOMParser.fromSchema(schema).parse(renderDoc.body);
}
export function docToHtml(doc) {
const fragment = DOMSerializer.fromSchema(schema).serializeFragment(doc.content);
const renderDoc = document.implementation.createHTMLDocument();
renderDoc.body.appendChild(fragment);
return renderDoc.body.innerHTML;
}