text-editor-studio-ts
Version:
A powerful mobile-responsive rich text editor built with Lexical and React
53 lines (52 loc) • 2.48 kB
JavaScript
import { l as l$1 } from "./LexicalCollaborationContext.prod-_XIRbBSl.js";
import { r, t } from "./index-BwW17RmP.js";
import { useRef, useContext, useMemo, useEffect } from "react";
import { jsx } from "react/jsx-runtime";
function l(e) {
const t2 = e.transform();
return new Set(t2 ? [t2] : []);
}
function f({ initialEditor: f2, children: d, initialNodes: m, initialTheme: u, skipCollabChecks: h, skipEditableListener: g }) {
const _ = useRef(false), x = useContext(r);
null == x && function(e, ...t2) {
const n = new URL("https://lexical.dev/docs/error"), o = new URLSearchParams();
o.append("code", e);
for (const e2 of t2) o.append("v", e2);
throw n.search = o.toString(), Error(`Minified Lexical error #${e}; visit ${n.toString()} for the full message or use the non-minified dev environment for full errors and additional helpful warnings.`);
}(9);
const [v, { getTheme: E }] = x, w = useMemo(() => {
const e = u || E() || void 0, t$1 = t(x, e);
void 0 !== e && (f2._config.theme = e), f2._parentEditor = f2._parentEditor || v;
const o = f2._createEditorArgs, r2 = o && o.namespace;
if (m) {
r2 || (f2._config.namespace = v._config.namespace);
for (let e2 of m) {
let t2 = null, n = null;
if ("function" != typeof e2) {
const o3 = e2;
e2 = o3.replace, t2 = o3.with, n = o3.withKlass || null;
}
const o2 = f2._nodes.get(e2.getType());
f2._nodes.set(e2.getType(), { exportDOM: o2 ? o2.exportDOM : void 0, klass: e2, replace: t2, replaceWithKlass: n, transforms: l(e2) });
}
} else if (o && o.nodes) r2 || (f2._config.namespace = v._config.namespace);
else {
const e2 = f2._nodes = new Map(v._nodes);
r2 || (f2._config.namespace = v._config.namespace);
for (const [t2, n] of e2) f2._nodes.set(t2, { exportDOM: n.exportDOM, klass: n.klass, replace: n.replace, replaceWithKlass: n.replaceWithKlass, transforms: l(n.klass) });
}
return [f2, t$1];
}, []), { isCollabActive: b, yjsDocMap: k } = l$1(), C = h || _.current || k.has(f2.getKey());
return useEffect(() => {
C && (_.current = true);
}, [C]), useEffect(() => {
if (!g) {
const e = (e2) => f2.setEditable(e2);
return e(v.isEditable()), v.registerEditableListener(e);
}
}, [f2, v, g]), jsx(r.Provider, { value: w, children: !b || C ? d : null });
}
export {
f
};
//# sourceMappingURL=LexicalNestedComposer.prod-DcHyIDfI.js.map