UNPKG

@frontify/fondue

Version:
45 lines (44 loc) 1.94 kB
import { jsx as r } from "react/jsx-runtime"; import { useEditorState as a, useEventPlateId as i, toggleNodeType as u } from "@udecode/plate-core"; import { unwrapList as E } from "@udecode/plate-list"; import { ELEMENT_PARAGRAPH as g } from "@udecode/plate-paragraph"; import { getNode as h, someNode as N, withoutNormalizing as x, getParentNode as y, setElements as l } from "@udecode/slate"; import { focusEditor as T } from "@udecode/slate-react"; import { IconStylingWrapper as L } from "../../helper.es.js"; import { ToolbarButton as P } from "../../../components/Toolbar/ToolbarButton.es.js"; import C from "../../../../../foundation/Icon/Generated/IconListCheck16.es.js"; import { ELEMENT_CHECK_ITEM as S } from "../id.es.js"; const R = ({ id: o, type: m = S }) => { var p, e, n; const t = a(i(o)), s = ((p = t == null ? void 0 : t.selection) == null ? void 0 : p.focus.path) && h(t, (n = (e = t == null ? void 0 : t.selection) == null ? void 0 : e.focus) == null ? void 0 : n.path), c = !!(t != null && t.selection) && N(t, { match: { type: m } }); return /* @__PURE__ */ r( P, { pressed: c, onPointerDown: (f) => { f.preventDefault(), f.stopPropagation(), b(t, { type: m, isActive: c, node: s }), T(t); }, children: /* @__PURE__ */ r(L, { icon: /* @__PURE__ */ r(C, {}) }) } ); }, b = (o, { type: m, isActive: t, node: s }) => x(o, () => { var c, p; if (o != null && o.selection) { if (t || E(o, {}), u(o, { activeType: m }), !(s != null && s.textStyle)) { const e = y(o, (p = (c = o == null ? void 0 : o.selection) == null ? void 0 : c.focus) == null ? void 0 : p.path), n = e && e[0].type; l(o, { textStyle: n }); } t && l(o, { type: (s == null ? void 0 : s.textStyle) ?? g }); } }); export { R as CheckboxListToolbarButton, b as toggleCheckboxList }; //# sourceMappingURL=CheckboxListToolbarButton.es.js.map