UNPKG

@uva-glass/component-library

Version:

React components UvA

67 lines (66 loc) 2.02 kB
import { z as d, R as h, B as m, Z as S, H as w, P as E, x as C, K as p, W as I } from "../../../../LexicalTable.prod-C6duSS2P.js"; import { T as u } from "../../../../Lexical.prod-CWyHQUEM.js"; const b = 100, P = (e, n) => { const t = I(0, 0, !1); for (let o = 0; o < e; o++) { const r = p(); for (let l = 0; l < n; l++) { const s = C(0, void 0, b / n); s.append(u()), r.append(s); } t.append(r); } return t; }, A = (e) => { const n = w(e), t = n.getNextSibling() || n.getPreviousSibling(), o = n.getParentOrThrow(); if (o.getChildrenSize() > 1 ? n.remove() : o.remove(), t !== null) { const r = t.getFirstDescendant(); r && r.select(); } }, v = (e) => { d(e).remove(); }, B = (e, n) => { const t = p(), o = w(e), r = o.getChildrenSize(); for (let s = 0; s < r; s++) { const c = C(0); c.append(u()), t.append(c); } n === "insertRowAbove" ? o.insertBefore(t) : o.insertAfter(t); const l = t.getFirstDescendant(); l && l.select(); }, O = (e, n) => { const t = w(e); if (!h(e)) throw new Error("Selected node is not a TableCellNode"); const o = E(e), r = t.getChildren().length, l = d(e); let s = m(e); const c = l.getChildren(), R = c.length; for (let i = 0; i < R; i++) { const a = C(0); a.append(u()); const f = c[i].getChildren()[s]; f && (n === "insertColumnLeft" ? f.insertBefore(a) : f.insertAfter(a)), c.forEach((T) => { T.getChildren().forEach((x) => { x.setWidth(b / r); }); }); } s = n === "insertColumnLeft" ? s : s + 1; const g = c[o].getChildren()[s]; g && g.select(); }, F = (e) => { var r; if (!h(e)) throw new Error("Selected node is not a TableCellNode"); const n = d(e), t = ((r = n.getFirstChild()) == null ? void 0 : r.getChildrenSize()) || 0, o = m(e); t === 1 ? v(e) : S(n, o); }; export { P as createTable, F as deleteColumn, A as deleteRow, v as deleteTable, O as insertColumn, B as insertRow }; //# sourceMappingURL=helpers.js.map