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:
16
resources/js/editor/util.js
Normal file
16
resources/js/editor/util.js
Normal 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;
|
||||
}
|
Reference in New Issue
Block a user