UNPKG

@dndbuilder.com/react

Version:

Drag and drop builder for React

81 lines (80 loc) 3.28 kB
"use client"; import { jsxs as e, jsx as t, Fragment as s } from "react/jsx-runtime"; import { getBlock as A } from "../../../../../store/selectors.js"; import { selectBlock as m, duplicateBlock as D, copyToClipboard as j, removeBlock as k } from "../../store/builder-slice.js"; import { useAppSelector as E } from "../../hooks/use-app-selector.js"; import { useState as F } from "react"; import { useAppDispatch as R } from "../../hooks/use-app-dispatch.js"; import "../../store/theme-slice.js"; import "../../config/builder.config.js"; import "../../../../../_virtual/cjs.js"; import { useAction as T } from "../../hooks/use-action.js"; import { useFrame as w } from "../../hooks/use-frame.js"; import { BuilderRightPanelType as z } from "../../types/index.js"; import { ContextMenu as L, ContextMenuTrigger as N, ContextMenuPortal as O, ContextMenuContent as Y, ContextMenuItem as r, ContextMenuSeparator as h, ContextMenuShortcut as c } from "./context-menu.js"; const b = ({ blockId: o, children: u }) => { var p; const n = R(), { save: d, pasteFromClipboard: C, getPlatformSpecificCopyShortcut: f, getPlatformSpecificPasteShortcut: g, getPlatformSpecificSaveShortcut: S, toggleRightPanel: x, getClipboardData: P } = T(), { document: a } = w(), [M, y] = F(!0), l = E(A(o)), i = l == null ? void 0 : l.type; return /* @__PURE__ */ e( L, { onOpenChange: async (B) => { if (B) { const v = await P(); y(!!v); } }, children: [ /* @__PURE__ */ t(N, { asChild: !0, children: u }), /* @__PURE__ */ t(O, { container: a == null ? void 0 : a.body, children: /* @__PURE__ */ e(Y, { children: [ i !== "root" && /* @__PURE__ */ e(s, { children: [ /* @__PURE__ */ e(r, { onClick: () => n(m(o)), children: [ "Edit ", /* @__PURE__ */ t("span", { className: "ml-1.5 capitalize", children: (p = i == null ? void 0 : i.split("-")) == null ? void 0 : p.join(" ") }) ] }), /* @__PURE__ */ t(r, { onClick: () => n(D({ blockId: o })), children: "Duplicate" }), /* @__PURE__ */ t(h, {}), /* @__PURE__ */ e(r, { onClick: () => n(j({ blockId: o })), children: [ "Copy ", /* @__PURE__ */ t(c, { children: f() }) ] }) ] }), /* @__PURE__ */ e(r, { disabled: !M, onClick: () => C({ blockId: o }), children: [ "Paste ", /* @__PURE__ */ t(c, { children: g() }) ] }), /* @__PURE__ */ t(h, {}), /* @__PURE__ */ t( r, { onClick: () => { i !== "root" && n(m(o)), x(z.LAYER); }, children: "Structure" } ), /* @__PURE__ */ e(r, { onClick: d, children: [ "Save", /* @__PURE__ */ t(c, { children: S() }) ] }), i !== "root" && /* @__PURE__ */ t(s, { children: /* @__PURE__ */ e(r, { onClick: () => n(k(o)), children: [ "Delete", /* @__PURE__ */ t(c, { children: "⌦" }) ] }) }) ] }) }) ] } ); }; export { b as EditorContextMenu }; //# sourceMappingURL=editor-context-menu.js.map