UNPKG

@frontify/fondue

Version:
40 lines (39 loc) 1.17 kB
import { jsx as l } from "react/jsx-runtime"; import { KEY_ALIGN as n, setAlign as c } from "@udecode/plate-alignment"; import { useEditorState as d, useEventPlateId as p, useEditorSelector as a } from "@udecode/plate-core"; import { findNode as g } from "@udecode/slate"; import { isDefined as A } from "@udecode/utils"; import { forwardRef as h } from "react"; import { ToolbarButton as y } from "../../components/Toolbar/ToolbarButton.es.js"; const E = h(({ value: e, editorId: i, ...f }, m) => { const s = d(p(i)), u = a((r) => { const o = g(r, { match: (t) => A(t[n]) }); if (o && o.length > 0) { const t = o[0][n]; if (t === "right") return "right"; if (t === "center") return "center"; if (t === "justify") return "justify"; } return "left"; }, []); return /* @__PURE__ */ l( y, { pressed: u === e, onMouseDown: (r) => r.preventDefault(), onClick: () => c(s, { value: e }), ref: m, ...f } ); }); E.displayName = "AlignmentToolbarButton"; export { E as AlignmentToolbarButton }; //# sourceMappingURL=AlignmentToolbarbutton.es.js.map