@uva-glass/component-library
Version:
React components UvA
67 lines (66 loc) • 2.02 kB
JavaScript
import { H as d, T as h, B as m, j as S, z as w, P as v, v as C, K as p, W as E } from "../../../../LexicalTable.prod-CYafu_j9.js";
import { w as u } from "../../../../Lexical.prod-CniF7zEE.js";
const b = 100, P = (e, n) => {
const t = E(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();
}
}, I = (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 = v(e), r = t.getChildren().length, l = d(e);
let s = m(e);
const c = l.getChildren(), T = c.length;
for (let i = 0; i < T; 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((R) => {
R.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 ? I(e) : S(n, o);
};
export {
P as createTable,
F as deleteColumn,
A as deleteRow,
I as deleteTable,
O as insertColumn,
B as insertRow
};
//# sourceMappingURL=helpers.js.map