@frontify/fondue
Version:
Design system of Frontify
42 lines (41 loc) • 1.25 kB
JavaScript
import { getPointBefore as a, getParentNode as u, getStartPoint as p, select as c } from "@udecode/slate";
import { KEY_ELEMENT_BREAK_AFTER_COLUMN as l } from "./createColumnBreakPlugin.es.js";
import { setColumnBreaks as f } from "./utils/setColumnBreaks.es.js";
import { updateColumnBreaks as m } from "./utils/updateColumnBreaks.es.js";
const C = (t, s) => {
const e = p(t, s);
setTimeout(() => {
c(t, {
anchor: e,
focus: e
});
});
}, k = (t) => {
var e;
const s = t.plugins.find((o) => o.key === l);
return ((e = s == null ? void 0 : s.options) == null ? void 0 : e.columns) ?? 1;
}, g = (t) => {
const { apply: s } = t, e = k(t);
t.apply = (o) => {
switch (o.type) {
case "split_node": {
o.properties = { ...o.properties, breakAfterColumn: void 0 };
break;
}
case "merge_node": {
const n = a(t, o.path);
if (!n)
break;
const r = u(t, n.path);
if (f(t, { at: n, value: void 0 }), m(t, e), r != null && r[0].breakAfterColumn)
return C(t, o.path), t;
break;
}
}
s(o);
}, setTimeout(() => m(t, e));
};
export {
g as useColumnBreakHandler
};
//# sourceMappingURL=useColumnBreakHandler.es.js.map