@frontify/fondue
Version:
Design system of Frontify
25 lines (24 loc) • 837 B
JavaScript
import { deserializeHtml as p } from "@udecode/plate-core";
import { ELEMENT_PARAGRAPH as l } from "@udecode/plate-paragraph";
import { normalizeEditor as m } from "@udecode/slate";
import { InitPlateEditor as s } from "./InitPlateEditor.es.js";
const c = (e) => "type" in e[0] ? e : [{ type: "p", children: e }], d = [{ type: l, children: [{ text: "" }] }], T = ({ editorId: e = "parseRawValue", raw: a, plugins: o }) => {
const t = s.init(`${e}_parseRawValue`, o).getInstance();
let r = d;
if (!a)
return r;
try {
r = JSON.parse(a);
} catch {
const i = a.trim().replaceAll(/>\s+</g, "><"), n = p(t, {
element: i
});
r = c(n);
}
return t.children = r, m(t, { force: !0 }), t.children;
};
export {
d as EMPTY_RICH_TEXT_VALUE,
T as parseRawValue
};
//# sourceMappingURL=parseRawValue.es.js.map