@uva-glass/component-library
Version:
React components UvA
72 lines (71 loc) • 2.68 kB
JavaScript
import { jsxs as L, jsx as n } from "react/jsx-runtime";
import { o as P } from "../../../../LexicalComposerContext.prod-DLlRM5wP.js";
import { a as h, c as g, u as y } from "../../../../Lexical.prod-CniF7zEE.js";
import { useState as C, useRef as E, useCallback as T, useEffect as m } from "react";
import { L as w } from "../../../../LexicalTable.prod-CYafu_j9.js";
import { BlockFormatPlugin as N } from "../BlockFormatPlugin/BlockFormatPlugin.js";
import { ListPlugin as k } from "../ListPlugin/ListPlugin.js";
import { LinkPlugin as x } from "../LinkPlugin/LinkPlugin.js";
import { HistoryPlugin as B } from "../HistoryPlugin/HistoryPlugin.js";
import { T as S } from "../../../../TablePlugin-MjKuocl4.js";
import { TableCellContextMenu as z } from "../TablePlugin/TableCellContextMenu/TableCellContextMenu.js";
import { s as A } from "../../../../RteEditor.module-oFMKEW6f.js";
import { setScrollableContainers as b, removeScrollableContainers as K } from "../../helpers.js";
const Q = ({ editorScrollPosition: d }) => {
const [t] = P(), [i, s] = C(null), u = E(null), f = T(() => {
const e = h();
if (g(e)) {
const l = e.anchor.getNode(), a = w(l);
if (a) {
const p = t.getElementByKey(a.getKey()), c = p ? p.getBoundingClientRect() : { right: 0, bottom: 0, height: 0 };
s({ xPos: c.right, yPos: c.bottom, height: c.height });
} else
s(null);
}
}, [t]), v = (e) => {
var r;
(r = u.current) == null || r.mutateTable(e);
}, o = () => {
t.update(() => {
const e = h();
if (g(e)) {
const l = e.anchor.getNode();
w(l) && (y(null), s(null));
}
});
};
return m(() => {
t.registerUpdateListener(({ editorState: e }) => {
e.read(() => {
f();
});
});
}, [t, f]), m(() => (b(o), window.addEventListener("scroll", o), window.addEventListener("resize", o), () => {
window.removeEventListener("scroll", o), window.removeEventListener("resize", o), K(o);
}), [t]), m(() => {
const e = () => {
b(o);
};
return window.addEventListener("keydown", e, { capture: !0 }), () => {
window.removeEventListener("keydown", e);
};
}, []), /* @__PURE__ */ L("div", { className: A.editor__toolbar, children: [
/* @__PURE__ */ n(N, {}),
/* @__PURE__ */ n(k, {}),
/* @__PURE__ */ n(S, { isActive: !!i, ref: u }),
i && /* @__PURE__ */ n(
z,
{
position: i,
parentScrollPosition: d,
onAction: v
}
),
/* @__PURE__ */ n(x, { parentScrollPosition: d }),
/* @__PURE__ */ n(B, {})
] });
};
export {
Q as ToolBarPlugin
};
//# sourceMappingURL=ToolbarPlugin.js.map