laif-ds
Version:
Design System di Laif con componenti React basati su principi di Atomic Design
22 lines (21 loc) • 821 B
JavaScript
"use client";
import { useLexicalComposerContext as l } from "./LexicalComposerContext.prod.js";
import { useMemo as d, useState as f, useRef as m, useLayoutEffect as b, useEffect as w } from "react";
const E = typeof window < "u" && window.document !== void 0 && window.document.createElement !== void 0 ? b : w;
function p(e) {
return { initialValueFn: () => e.isEditable(), subscribe: (t) => e.registerEditableListener(t) };
}
function F() {
return function(e) {
const [t] = l(), n = d(() => e(t), [t, e]), [r, o] = f(() => n.initialValueFn()), i = m(r);
return E(() => {
const { initialValueFn: c, subscribe: a } = n, u = c();
return i.current !== u && (i.current = u, o(u)), a((s) => {
i.current = s, o(s);
});
}, [n, e]), r;
}(p);
}
export {
F as useLexicalEditable
};