@measured/puck 0.21.0-canary.6dae6cb7 → 0.21.0-canary.cf074bc6

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -768,7 +768,9 @@ var keyCodeMap = {
768
768
  KeyW: "w",
769
769
  KeyX: "x",
770
770
  KeyY: "y",
771
- KeyZ: "z"
771
+ KeyZ: "z",
772
+ Delete: "delete",
773
+ Backspace: "backspace"
772
774
  };
773
775
  var useHotkeyStore = create()(
774
776
  subscribeWithSelector((set) => ({
@@ -792,8 +794,10 @@ var monitorHotkeys = (doc) => {
792
794
  ([key2, value]) => value === !!combo[key2]
793
795
  );
794
796
  if (conditionMet) {
795
- e.preventDefault();
796
- cb();
797
+ const handled = cb(e);
798
+ if (handled !== false) {
799
+ e.preventDefault();
800
+ }
797
801
  }
798
802
  });
799
803
  if (key !== "meta" && key !== "ctrl" && key !== "shift") {
@@ -1017,7 +1021,7 @@ var flattenData = (state, config) => {
1017
1021
  (content) => content,
1018
1022
  (item) => {
1019
1023
  data.push(item);
1020
- return null;
1024
+ return item;
1021
1025
  }
1022
1026
  );
1023
1027
  return data;
@@ -6421,7 +6425,7 @@ function useGetPuck() {
6421
6425
  init_react_import();
6422
6426
  import {
6423
6427
  createContext as createContext8,
6424
- useCallback as useCallback20,
6428
+ useCallback as useCallback21,
6425
6429
  useContext as useContext13,
6426
6430
  useEffect as useEffect29,
6427
6431
  useMemo as useMemo20,
@@ -7981,12 +7985,73 @@ var usePreviewModeHotkeys = () => {
7981
7985
  useHotkey({ ctrl: true, i: true }, toggleInteractive);
7982
7986
  };
7983
7987
 
7988
+ // lib/use-delete-hotkeys.ts
7989
+ init_react_import();
7990
+ import { useCallback as useCallback17 } from "react";
7991
+ var isElementVisible = (element) => {
7992
+ let current = element;
7993
+ while (current && current !== document.body) {
7994
+ const style = window.getComputedStyle(current);
7995
+ if (style.display === "none" || style.visibility === "hidden" || style.opacity === "0" || current.getAttribute("aria-hidden") === "true" || current.hasAttribute("hidden")) {
7996
+ return false;
7997
+ }
7998
+ current = current.parentElement;
7999
+ }
8000
+ return true;
8001
+ };
8002
+ var shouldBlockDeleteHotkey = (e) => {
8003
+ var _a;
8004
+ if (e == null ? void 0 : e.defaultPrevented) return true;
8005
+ const origin = ((_a = e == null ? void 0 : e.composedPath) == null ? void 0 : _a.call(e)[0]) || (e == null ? void 0 : e.target) || document.activeElement;
8006
+ if (origin instanceof HTMLElement) {
8007
+ const tag = origin.tagName.toLowerCase();
8008
+ if (tag === "input" || tag === "textarea" || tag === "select") return true;
8009
+ if (origin.isContentEditable) return true;
8010
+ const role = origin.getAttribute("role");
8011
+ if (role === "textbox" || role === "combobox" || role === "searchbox" || role === "listbox" || role === "grid") {
8012
+ return true;
8013
+ }
8014
+ }
8015
+ const modal = document.querySelector(
8016
+ 'dialog[open], [aria-modal="true"], [role="dialog"], [role="alertdialog"]'
8017
+ );
8018
+ if (modal && isElementVisible(modal)) {
8019
+ return true;
8020
+ }
8021
+ return false;
8022
+ };
8023
+ var useDeleteHotkeys = () => {
8024
+ const appStore = useAppStoreApi();
8025
+ const deleteSelectedComponent = useCallback17(
8026
+ (e) => {
8027
+ var _a;
8028
+ if (shouldBlockDeleteHotkey(e)) {
8029
+ return false;
8030
+ }
8031
+ const { state, dispatch, permissions, selectedItem } = appStore.getState();
8032
+ const sel = (_a = state.ui) == null ? void 0 : _a.itemSelector;
8033
+ if (!(sel == null ? void 0 : sel.zone) || !selectedItem) return true;
8034
+ if (!permissions.getPermissions({ item: selectedItem }).delete)
8035
+ return true;
8036
+ dispatch({
8037
+ type: "remove",
8038
+ index: sel.index,
8039
+ zone: sel.zone
8040
+ });
8041
+ return true;
8042
+ },
8043
+ [appStore]
8044
+ );
8045
+ useHotkey({ delete: true }, deleteSelectedComponent);
8046
+ useHotkey({ backspace: true }, deleteSelectedComponent);
8047
+ };
8048
+
7984
8049
  // components/Puck/index.tsx
7985
8050
  import fdeq from "fast-deep-equal";
7986
8051
 
7987
8052
  // components/Puck/components/Header/index.tsx
7988
8053
  init_react_import();
7989
- import { memo as memo4, useCallback as useCallback17, useMemo as useMemo19, useState as useState23 } from "react";
8054
+ import { memo as memo4, useCallback as useCallback18, useMemo as useMemo19, useState as useState23 } from "react";
7990
8055
 
7991
8056
  // components/MenuBar/index.tsx
7992
8057
  init_react_import();
@@ -8113,7 +8178,7 @@ var HeaderInner = () => {
8113
8178
  const rightSideBarVisible = useAppStore(
8114
8179
  (s) => s.state.ui.rightSideBarVisible
8115
8180
  );
8116
- const toggleSidebars = useCallback17(
8181
+ const toggleSidebars = useCallback18(
8117
8182
  (sidebar) => {
8118
8183
  const widerViewport = window.matchMedia("(min-width: 638px)").matches;
8119
8184
  const sideBarVisible = sidebar === "left" ? leftSideBarVisible : rightSideBarVisible;
@@ -8223,7 +8288,7 @@ init_react_import();
8223
8288
 
8224
8289
  // components/Puck/components/ResizeHandle/index.tsx
8225
8290
  init_react_import();
8226
- import { useCallback as useCallback18, useRef as useRef10 } from "react";
8291
+ import { useCallback as useCallback19, useRef as useRef10 } from "react";
8227
8292
 
8228
8293
  // css-module:/home/runner/work/puck/puck/packages/core/components/Puck/components/ResizeHandle/styles.module.css#css-module
8229
8294
  init_react_import();
@@ -8244,7 +8309,7 @@ var ResizeHandle = ({
8244
8309
  const isDragging = useRef10(false);
8245
8310
  const startX = useRef10(0);
8246
8311
  const startWidth = useRef10(0);
8247
- const handleMouseMove = useCallback18(
8312
+ const handleMouseMove = useCallback19(
8248
8313
  (e) => {
8249
8314
  if (!isDragging.current) return;
8250
8315
  const delta = e.clientX - startX.current;
@@ -8255,7 +8320,7 @@ var ResizeHandle = ({
8255
8320
  },
8256
8321
  [onResize, position]
8257
8322
  );
8258
- const handleMouseUp = useCallback18(() => {
8323
+ const handleMouseUp = useCallback19(() => {
8259
8324
  var _a;
8260
8325
  if (!isDragging.current) return;
8261
8326
  isDragging.current = false;
@@ -8271,7 +8336,7 @@ var ResizeHandle = ({
8271
8336
  onResizeEnd(finalWidth);
8272
8337
  resetAutoZoom();
8273
8338
  }, [onResizeEnd]);
8274
- const handleMouseDown = useCallback18(
8339
+ const handleMouseDown = useCallback19(
8275
8340
  (e) => {
8276
8341
  var _a;
8277
8342
  isDragging.current = true;
@@ -8331,7 +8396,7 @@ var Sidebar = ({
8331
8396
 
8332
8397
  // lib/use-sidebar-resize.ts
8333
8398
  init_react_import();
8334
- import { useCallback as useCallback19, useEffect as useEffect28, useRef as useRef11, useState as useState24 } from "react";
8399
+ import { useCallback as useCallback20, useEffect as useEffect28, useRef as useRef11, useState as useState24 } from "react";
8335
8400
  function useSidebarResize(position, dispatch) {
8336
8401
  const [width, setWidth] = useState24(null);
8337
8402
  const sidebarRef = useRef11(null);
@@ -8368,7 +8433,7 @@ function useSidebarResize(position, dispatch) {
8368
8433
  setWidth(storeWidth);
8369
8434
  }
8370
8435
  }, [storeWidth]);
8371
- const handleResizeEnd = useCallback19(
8436
+ const handleResizeEnd = useCallback20(
8372
8437
  (width2) => {
8373
8438
  dispatch({
8374
8439
  type: "setUi",
@@ -8539,7 +8604,7 @@ function PuckProvider({ children }) {
8539
8604
  );
8540
8605
  return __spreadValues(__spreadValues({}, pluginFieldTransforms), fieldTransforms);
8541
8606
  }, [fieldTransforms, plugins]);
8542
- const generateAppStore = useCallback20(
8607
+ const generateAppStore = useCallback21(
8543
8608
  (state) => {
8544
8609
  return {
8545
8610
  state,
@@ -8668,6 +8733,7 @@ function PuckLayout({ children }) {
8668
8733
  }, []);
8669
8734
  const ready = useAppStore((s) => s.status === "READY");
8670
8735
  useMonitorHotkeys();
8736
+ useDeleteHotkeys();
8671
8737
  useEffect29(() => {
8672
8738
  if (ready && iframe.enabled) {
8673
8739
  const frameDoc = getFrame();
package/dist/index.js CHANGED
@@ -1661,7 +1661,9 @@ var keyCodeMap = {
1661
1661
  KeyW: "w",
1662
1662
  KeyX: "x",
1663
1663
  KeyY: "y",
1664
- KeyZ: "z"
1664
+ KeyZ: "z",
1665
+ Delete: "delete",
1666
+ Backspace: "backspace"
1665
1667
  };
1666
1668
  var useHotkeyStore = (0, import_zustand.create)()(
1667
1669
  (0, import_middleware.subscribeWithSelector)((set) => ({
@@ -1685,8 +1687,10 @@ var monitorHotkeys = (doc) => {
1685
1687
  ([key2, value]) => value === !!combo[key2]
1686
1688
  );
1687
1689
  if (conditionMet) {
1688
- e.preventDefault();
1689
- cb();
1690
+ const handled = cb(e);
1691
+ if (handled !== false) {
1692
+ e.preventDefault();
1693
+ }
1690
1694
  }
1691
1695
  });
1692
1696
  if (key !== "meta" && key !== "ctrl" && key !== "shift") {
@@ -1910,7 +1914,7 @@ var flattenData = (state, config) => {
1910
1914
  (content) => content,
1911
1915
  (item) => {
1912
1916
  data.push(item);
1913
- return null;
1917
+ return item;
1914
1918
  }
1915
1919
  );
1916
1920
  return data;
@@ -7048,7 +7052,7 @@ Drawer.Item = DrawerItem;
7048
7052
 
7049
7053
  // components/Puck/index.tsx
7050
7054
  init_react_import();
7051
- var import_react59 = require("react");
7055
+ var import_react60 = require("react");
7052
7056
 
7053
7057
  // components/SidebarSection/index.tsx
7054
7058
  init_react_import();
@@ -8586,9 +8590,70 @@ var usePreviewModeHotkeys = () => {
8586
8590
  useHotkey({ ctrl: true, i: true }, toggleInteractive);
8587
8591
  };
8588
8592
 
8589
- // lib/use-puck.ts
8593
+ // lib/use-delete-hotkeys.ts
8590
8594
  init_react_import();
8591
8595
  var import_react55 = require("react");
8596
+ var isElementVisible = (element) => {
8597
+ let current = element;
8598
+ while (current && current !== document.body) {
8599
+ const style = window.getComputedStyle(current);
8600
+ if (style.display === "none" || style.visibility === "hidden" || style.opacity === "0" || current.getAttribute("aria-hidden") === "true" || current.hasAttribute("hidden")) {
8601
+ return false;
8602
+ }
8603
+ current = current.parentElement;
8604
+ }
8605
+ return true;
8606
+ };
8607
+ var shouldBlockDeleteHotkey = (e) => {
8608
+ var _a;
8609
+ if (e == null ? void 0 : e.defaultPrevented) return true;
8610
+ const origin = ((_a = e == null ? void 0 : e.composedPath) == null ? void 0 : _a.call(e)[0]) || (e == null ? void 0 : e.target) || document.activeElement;
8611
+ if (origin instanceof HTMLElement) {
8612
+ const tag = origin.tagName.toLowerCase();
8613
+ if (tag === "input" || tag === "textarea" || tag === "select") return true;
8614
+ if (origin.isContentEditable) return true;
8615
+ const role = origin.getAttribute("role");
8616
+ if (role === "textbox" || role === "combobox" || role === "searchbox" || role === "listbox" || role === "grid") {
8617
+ return true;
8618
+ }
8619
+ }
8620
+ const modal = document.querySelector(
8621
+ 'dialog[open], [aria-modal="true"], [role="dialog"], [role="alertdialog"]'
8622
+ );
8623
+ if (modal && isElementVisible(modal)) {
8624
+ return true;
8625
+ }
8626
+ return false;
8627
+ };
8628
+ var useDeleteHotkeys = () => {
8629
+ const appStore = useAppStoreApi();
8630
+ const deleteSelectedComponent = (0, import_react55.useCallback)(
8631
+ (e) => {
8632
+ var _a;
8633
+ if (shouldBlockDeleteHotkey(e)) {
8634
+ return false;
8635
+ }
8636
+ const { state, dispatch, permissions, selectedItem } = appStore.getState();
8637
+ const sel = (_a = state.ui) == null ? void 0 : _a.itemSelector;
8638
+ if (!(sel == null ? void 0 : sel.zone) || !selectedItem) return true;
8639
+ if (!permissions.getPermissions({ item: selectedItem }).delete)
8640
+ return true;
8641
+ dispatch({
8642
+ type: "remove",
8643
+ index: sel.index,
8644
+ zone: sel.zone
8645
+ });
8646
+ return true;
8647
+ },
8648
+ [appStore]
8649
+ );
8650
+ useHotkey({ delete: true }, deleteSelectedComponent);
8651
+ useHotkey({ backspace: true }, deleteSelectedComponent);
8652
+ };
8653
+
8654
+ // lib/use-puck.ts
8655
+ init_react_import();
8656
+ var import_react56 = require("react");
8592
8657
  var import_zustand6 = require("zustand");
8593
8658
  var generateUsePuck = (store) => {
8594
8659
  const history = {
@@ -8615,7 +8680,7 @@ var generateUsePuck = (store) => {
8615
8680
  };
8616
8681
  return storeData;
8617
8682
  };
8618
- var UsePuckStoreContext = (0, import_react55.createContext)(
8683
+ var UsePuckStoreContext = (0, import_react56.createContext)(
8619
8684
  null
8620
8685
  );
8621
8686
  var convertToPickedStore = (store) => {
@@ -8629,12 +8694,12 @@ var convertToPickedStore = (store) => {
8629
8694
  };
8630
8695
  };
8631
8696
  var useRegisterUsePuckStore = (appStore) => {
8632
- const [usePuckStore] = (0, import_react55.useState)(
8697
+ const [usePuckStore] = (0, import_react56.useState)(
8633
8698
  () => (0, import_zustand6.createStore)(
8634
8699
  () => generateUsePuck(convertToPickedStore(appStore.getState()))
8635
8700
  )
8636
8701
  );
8637
- (0, import_react55.useEffect)(() => {
8702
+ (0, import_react56.useEffect)(() => {
8638
8703
  return appStore.subscribe(
8639
8704
  (store) => convertToPickedStore(store),
8640
8705
  (pickedStore) => {
@@ -8646,7 +8711,7 @@ var useRegisterUsePuckStore = (appStore) => {
8646
8711
  };
8647
8712
  function createUsePuck() {
8648
8713
  return function usePuck2(selector) {
8649
- const usePuckApi = (0, import_react55.useContext)(UsePuckStoreContext);
8714
+ const usePuckApi = (0, import_react56.useContext)(UsePuckStoreContext);
8650
8715
  if (!usePuckApi) {
8651
8716
  throw new Error("usePuck must be used inside <Puck>.");
8652
8717
  }
@@ -8658,7 +8723,7 @@ function createUsePuck() {
8658
8723
  };
8659
8724
  }
8660
8725
  function usePuck() {
8661
- (0, import_react55.useEffect)(() => {
8726
+ (0, import_react56.useEffect)(() => {
8662
8727
  console.warn(
8663
8728
  "You're using the `usePuck` method without a selector, which may cause unnecessary re-renders. Replace with `createUsePuck` and provide a selector for improved performance."
8664
8729
  );
@@ -8666,7 +8731,7 @@ function usePuck() {
8666
8731
  return createUsePuck()((s) => s);
8667
8732
  }
8668
8733
  function useGetPuck() {
8669
- const usePuckApi = (0, import_react55.useContext)(UsePuckStoreContext);
8734
+ const usePuckApi = (0, import_react56.useContext)(UsePuckStoreContext);
8670
8735
  if (!usePuckApi) {
8671
8736
  throw new Error("usePuckGet must be used inside <Puck>.");
8672
8737
  }
@@ -8678,7 +8743,7 @@ var import_fast_deep_equal3 = __toESM(require("fast-deep-equal"));
8678
8743
 
8679
8744
  // components/Puck/components/Header/index.tsx
8680
8745
  init_react_import();
8681
- var import_react56 = require("react");
8746
+ var import_react57 = require("react");
8682
8747
 
8683
8748
  // components/MenuBar/index.tsx
8684
8749
  init_react_import();
@@ -8760,7 +8825,7 @@ var HeaderInner = () => {
8760
8825
  } = usePropsContext();
8761
8826
  const dispatch = useAppStore((s) => s.dispatch);
8762
8827
  const appStore = useAppStoreApi();
8763
- const defaultHeaderRender = (0, import_react56.useMemo)(() => {
8828
+ const defaultHeaderRender = (0, import_react57.useMemo)(() => {
8764
8829
  if (renderHeader) {
8765
8830
  console.warn(
8766
8831
  "`renderHeader` is deprecated. Please use `overrides.header` and the `usePuck` hook instead"
@@ -8775,7 +8840,7 @@ var HeaderInner = () => {
8775
8840
  }
8776
8841
  return DefaultOverride;
8777
8842
  }, [renderHeader]);
8778
- const defaultHeaderActionsRender = (0, import_react56.useMemo)(() => {
8843
+ const defaultHeaderActionsRender = (0, import_react57.useMemo)(() => {
8779
8844
  if (renderHeaderActions) {
8780
8845
  console.warn(
8781
8846
  "`renderHeaderActions` is deprecated. Please use `overrides.headerActions` and the `usePuck` hook instead."
@@ -8795,7 +8860,7 @@ var HeaderInner = () => {
8795
8860
  const CustomHeaderActions = useAppStore(
8796
8861
  (s) => s.overrides.headerActions || defaultHeaderActionsRender
8797
8862
  );
8798
- const [menuOpen, setMenuOpen] = (0, import_react56.useState)(false);
8863
+ const [menuOpen, setMenuOpen] = (0, import_react57.useState)(false);
8799
8864
  const rootTitle = useAppStore((s) => {
8800
8865
  var _a, _b;
8801
8866
  const rootData = (_a = s.state.indexes.nodes["root"]) == null ? void 0 : _a.data;
@@ -8805,7 +8870,7 @@ var HeaderInner = () => {
8805
8870
  const rightSideBarVisible = useAppStore(
8806
8871
  (s) => s.state.ui.rightSideBarVisible
8807
8872
  );
8808
- const toggleSidebars = (0, import_react56.useCallback)(
8873
+ const toggleSidebars = (0, import_react57.useCallback)(
8809
8874
  (sidebar) => {
8810
8875
  const widerViewport = window.matchMedia("(min-width: 638px)").matches;
8811
8876
  const sideBarVisible = sidebar === "left" ? leftSideBarVisible : rightSideBarVisible;
@@ -8908,14 +8973,14 @@ var HeaderInner = () => {
8908
8973
  }
8909
8974
  );
8910
8975
  };
8911
- var Header = (0, import_react56.memo)(HeaderInner);
8976
+ var Header = (0, import_react57.memo)(HeaderInner);
8912
8977
 
8913
8978
  // components/Puck/components/Sidebar/index.tsx
8914
8979
  init_react_import();
8915
8980
 
8916
8981
  // components/Puck/components/ResizeHandle/index.tsx
8917
8982
  init_react_import();
8918
- var import_react57 = require("react");
8983
+ var import_react58 = require("react");
8919
8984
 
8920
8985
  // css-module:/home/runner/work/puck/puck/packages/core/components/Puck/components/ResizeHandle/styles.module.css#css-module
8921
8986
  init_react_import();
@@ -8932,11 +8997,11 @@ var ResizeHandle = ({
8932
8997
  }) => {
8933
8998
  const { frameRef } = useCanvasFrame();
8934
8999
  const resetAutoZoom = useResetAutoZoom(frameRef);
8935
- const handleRef = (0, import_react57.useRef)(null);
8936
- const isDragging = (0, import_react57.useRef)(false);
8937
- const startX = (0, import_react57.useRef)(0);
8938
- const startWidth = (0, import_react57.useRef)(0);
8939
- const handleMouseMove = (0, import_react57.useCallback)(
9000
+ const handleRef = (0, import_react58.useRef)(null);
9001
+ const isDragging = (0, import_react58.useRef)(false);
9002
+ const startX = (0, import_react58.useRef)(0);
9003
+ const startWidth = (0, import_react58.useRef)(0);
9004
+ const handleMouseMove = (0, import_react58.useCallback)(
8940
9005
  (e) => {
8941
9006
  if (!isDragging.current) return;
8942
9007
  const delta = e.clientX - startX.current;
@@ -8947,7 +9012,7 @@ var ResizeHandle = ({
8947
9012
  },
8948
9013
  [onResize, position]
8949
9014
  );
8950
- const handleMouseUp = (0, import_react57.useCallback)(() => {
9015
+ const handleMouseUp = (0, import_react58.useCallback)(() => {
8951
9016
  var _a;
8952
9017
  if (!isDragging.current) return;
8953
9018
  isDragging.current = false;
@@ -8963,7 +9028,7 @@ var ResizeHandle = ({
8963
9028
  onResizeEnd(finalWidth);
8964
9029
  resetAutoZoom();
8965
9030
  }, [onResizeEnd]);
8966
- const handleMouseDown = (0, import_react57.useCallback)(
9031
+ const handleMouseDown = (0, import_react58.useCallback)(
8967
9032
  (e) => {
8968
9033
  var _a;
8969
9034
  isDragging.current = true;
@@ -9023,14 +9088,14 @@ var Sidebar = ({
9023
9088
 
9024
9089
  // lib/use-sidebar-resize.ts
9025
9090
  init_react_import();
9026
- var import_react58 = require("react");
9091
+ var import_react59 = require("react");
9027
9092
  function useSidebarResize(position, dispatch) {
9028
- const [width, setWidth] = (0, import_react58.useState)(null);
9029
- const sidebarRef = (0, import_react58.useRef)(null);
9093
+ const [width, setWidth] = (0, import_react59.useState)(null);
9094
+ const sidebarRef = (0, import_react59.useRef)(null);
9030
9095
  const storeWidth = useAppStore(
9031
9096
  (s) => position === "left" ? s.state.ui.leftSideBarWidth : s.state.ui.rightSideBarWidth
9032
9097
  );
9033
- (0, import_react58.useEffect)(() => {
9098
+ (0, import_react59.useEffect)(() => {
9034
9099
  if (typeof window !== "undefined" && !storeWidth) {
9035
9100
  try {
9036
9101
  const savedWidths = localStorage.getItem("puck-sidebar-widths");
@@ -9055,12 +9120,12 @@ function useSidebarResize(position, dispatch) {
9055
9120
  }
9056
9121
  }
9057
9122
  }, [dispatch, position, storeWidth]);
9058
- (0, import_react58.useEffect)(() => {
9123
+ (0, import_react59.useEffect)(() => {
9059
9124
  if (storeWidth !== void 0) {
9060
9125
  setWidth(storeWidth);
9061
9126
  }
9062
9127
  }, [storeWidth]);
9063
- const handleResizeEnd = (0, import_react58.useCallback)(
9128
+ const handleResizeEnd = (0, import_react59.useCallback)(
9064
9129
  (width2) => {
9065
9130
  dispatch({
9066
9131
  type: "setUi",
@@ -9115,11 +9180,11 @@ var FieldSideBar = () => {
9115
9180
  );
9116
9181
  return /* @__PURE__ */ (0, import_jsx_runtime46.jsx)(SidebarSection, { noPadding: true, noBorderTop: true, showBreadcrumbs: true, title, children: /* @__PURE__ */ (0, import_jsx_runtime46.jsx)(Fields, {}) });
9117
9182
  };
9118
- var propsContext = (0, import_react59.createContext)({});
9183
+ var propsContext = (0, import_react60.createContext)({});
9119
9184
  function PropsProvider(props) {
9120
9185
  return /* @__PURE__ */ (0, import_jsx_runtime46.jsx)(propsContext.Provider, { value: props, children: props.children });
9121
9186
  }
9122
- var usePropsContext = () => (0, import_react59.useContext)(propsContext);
9187
+ var usePropsContext = () => (0, import_react60.useContext)(propsContext);
9123
9188
  function PuckProvider({ children }) {
9124
9189
  const {
9125
9190
  config,
@@ -9136,14 +9201,14 @@ function PuckProvider({ children }) {
9136
9201
  onAction,
9137
9202
  fieldTransforms
9138
9203
  } = usePropsContext();
9139
- const iframe = (0, import_react59.useMemo)(
9204
+ const iframe = (0, import_react60.useMemo)(
9140
9205
  () => __spreadValues({
9141
9206
  enabled: true,
9142
9207
  waitForStyles: true
9143
9208
  }, _iframe),
9144
9209
  [_iframe]
9145
9210
  );
9146
- const [generatedAppState] = (0, import_react59.useState)(() => {
9211
+ const [generatedAppState] = (0, import_react60.useState)(() => {
9147
9212
  var _a, _b, _c, _d, _e, _f, _g, _h, _i;
9148
9213
  const initial = __spreadValues(__spreadValues({}, defaultAppState.ui), initialUi);
9149
9214
  let clientUiState = {};
@@ -9203,7 +9268,7 @@ function PuckProvider({ children }) {
9203
9268
  return walkAppState(newAppState, config);
9204
9269
  });
9205
9270
  const { appendData = true } = _initialHistory || {};
9206
- const [blendedHistories] = (0, import_react59.useState)(
9271
+ const [blendedHistories] = (0, import_react60.useState)(
9207
9272
  [
9208
9273
  ...(_initialHistory == null ? void 0 : _initialHistory.histories) || [],
9209
9274
  ...appendData ? [{ state: generatedAppState }] : []
@@ -9223,7 +9288,7 @@ function PuckProvider({ children }) {
9223
9288
  overrides,
9224
9289
  plugins
9225
9290
  });
9226
- const loadedFieldTransforms = (0, import_react59.useMemo)(() => {
9291
+ const loadedFieldTransforms = (0, import_react60.useMemo)(() => {
9227
9292
  const _plugins = plugins || [];
9228
9293
  const pluginFieldTransforms = _plugins.reduce(
9229
9294
  (acc, plugin) => __spreadValues(__spreadValues({}, acc), plugin.fieldTransforms),
@@ -9231,7 +9296,7 @@ function PuckProvider({ children }) {
9231
9296
  );
9232
9297
  return __spreadValues(__spreadValues({}, pluginFieldTransforms), fieldTransforms);
9233
9298
  }, [fieldTransforms, plugins]);
9234
- const generateAppStore = (0, import_react59.useCallback)(
9299
+ const generateAppStore = (0, import_react60.useCallback)(
9235
9300
  (state) => {
9236
9301
  return {
9237
9302
  state,
@@ -9257,15 +9322,15 @@ function PuckProvider({ children }) {
9257
9322
  loadedFieldTransforms
9258
9323
  ]
9259
9324
  );
9260
- const [appStore] = (0, import_react59.useState)(
9325
+ const [appStore] = (0, import_react60.useState)(
9261
9326
  () => createAppStore(generateAppStore(initialAppState))
9262
9327
  );
9263
- (0, import_react59.useEffect)(() => {
9328
+ (0, import_react60.useEffect)(() => {
9264
9329
  if (process.env.NODE_ENV !== "production") {
9265
9330
  window.__PUCK_INTERNAL_DO_NOT_USE = { appStore };
9266
9331
  }
9267
9332
  }, [appStore]);
9268
- (0, import_react59.useEffect)(() => {
9333
+ (0, import_react60.useEffect)(() => {
9269
9334
  const state = appStore.getState().state;
9270
9335
  appStore.setState(__spreadValues({}, generateAppStore(state)));
9271
9336
  }, [config, plugins, loadedOverrides, viewports, iframe, onAction, metadata]);
@@ -9274,8 +9339,8 @@ function PuckProvider({ children }) {
9274
9339
  index: initialHistoryIndex,
9275
9340
  initialAppState
9276
9341
  });
9277
- const previousData = (0, import_react59.useRef)(null);
9278
- (0, import_react59.useEffect)(() => {
9342
+ const previousData = (0, import_react60.useRef)(null);
9343
+ (0, import_react60.useEffect)(() => {
9279
9344
  appStore.subscribe(
9280
9345
  (s) => s.state.data,
9281
9346
  (data) => {
@@ -9289,7 +9354,7 @@ function PuckProvider({ children }) {
9289
9354
  }, []);
9290
9355
  useRegisterPermissionsSlice(appStore, permissions);
9291
9356
  const uPuckStore = useRegisterUsePuckStore(appStore);
9292
- (0, import_react59.useEffect)(() => {
9357
+ (0, import_react60.useEffect)(() => {
9293
9358
  const { resolveAndCommitData } = appStore.getState();
9294
9359
  resolveAndCommitData();
9295
9360
  }, []);
@@ -9301,7 +9366,7 @@ function PuckLayout({ children }) {
9301
9366
  dnd,
9302
9367
  initialHistory: _initialHistory
9303
9368
  } = usePropsContext();
9304
- const iframe = (0, import_react59.useMemo)(
9369
+ const iframe = (0, import_react60.useMemo)(
9305
9370
  () => __spreadValues({
9306
9371
  enabled: true,
9307
9372
  waitForStyles: true
@@ -9326,7 +9391,7 @@ function PuckLayout({ children }) {
9326
9391
  sidebarRef: rightSidebarRef,
9327
9392
  handleResizeEnd: handleRightSidebarResizeEnd
9328
9393
  } = useSidebarResize("right", dispatch);
9329
- (0, import_react59.useEffect)(() => {
9394
+ (0, import_react60.useEffect)(() => {
9330
9395
  if (!window.matchMedia("(min-width: 638px)").matches) {
9331
9396
  dispatch({
9332
9397
  type: "setUi",
@@ -9350,17 +9415,18 @@ function PuckLayout({ children }) {
9350
9415
  };
9351
9416
  }, []);
9352
9417
  const overrides = useAppStore((s) => s.overrides);
9353
- const CustomPuck = (0, import_react59.useMemo)(
9418
+ const CustomPuck = (0, import_react60.useMemo)(
9354
9419
  () => overrides.puck || DefaultOverride,
9355
9420
  [overrides]
9356
9421
  );
9357
- const [mounted, setMounted] = (0, import_react59.useState)(false);
9358
- (0, import_react59.useEffect)(() => {
9422
+ const [mounted, setMounted] = (0, import_react60.useState)(false);
9423
+ (0, import_react60.useEffect)(() => {
9359
9424
  setMounted(true);
9360
9425
  }, []);
9361
9426
  const ready = useAppStore((s) => s.status === "READY");
9362
9427
  useMonitorHotkeys();
9363
- (0, import_react59.useEffect)(() => {
9428
+ useDeleteHotkeys();
9429
+ (0, import_react60.useEffect)(() => {
9364
9430
  if (ready && iframe.enabled) {
9365
9431
  const frameDoc = getFrame();
9366
9432
  if (frameDoc) {
package/dist/index.mjs CHANGED
@@ -18,7 +18,7 @@ import {
18
18
  setDeep,
19
19
  useGetPuck,
20
20
  usePuck
21
- } from "./chunk-NBNCSA43.mjs";
21
+ } from "./chunk-MYJB3LKU.mjs";
22
22
  import {
23
23
  init_react_import,
24
24
  migrate,
@@ -1661,7 +1661,9 @@ var keyCodeMap = {
1661
1661
  KeyW: "w",
1662
1662
  KeyX: "x",
1663
1663
  KeyY: "y",
1664
- KeyZ: "z"
1664
+ KeyZ: "z",
1665
+ Delete: "delete",
1666
+ Backspace: "backspace"
1665
1667
  };
1666
1668
  var useHotkeyStore = (0, import_zustand.create)()(
1667
1669
  (0, import_middleware.subscribeWithSelector)((set) => ({
@@ -1685,8 +1687,10 @@ var monitorHotkeys = (doc) => {
1685
1687
  ([key2, value]) => value === !!combo[key2]
1686
1688
  );
1687
1689
  if (conditionMet) {
1688
- e.preventDefault();
1689
- cb();
1690
+ const handled = cb(e);
1691
+ if (handled !== false) {
1692
+ e.preventDefault();
1693
+ }
1690
1694
  }
1691
1695
  });
1692
1696
  if (key !== "meta" && key !== "ctrl" && key !== "shift") {
@@ -1910,7 +1914,7 @@ var flattenData = (state, config) => {
1910
1914
  (content) => content,
1911
1915
  (item) => {
1912
1916
  data.push(item);
1913
- return null;
1917
+ return item;
1914
1918
  }
1915
1919
  );
1916
1920
  return data;
@@ -7048,7 +7052,7 @@ Drawer.Item = DrawerItem;
7048
7052
 
7049
7053
  // components/Puck/index.tsx
7050
7054
  init_react_import();
7051
- var import_react59 = require("react");
7055
+ var import_react60 = require("react");
7052
7056
 
7053
7057
  // components/SidebarSection/index.tsx
7054
7058
  init_react_import();
@@ -8586,9 +8590,70 @@ var usePreviewModeHotkeys = () => {
8586
8590
  useHotkey({ ctrl: true, i: true }, toggleInteractive);
8587
8591
  };
8588
8592
 
8589
- // lib/use-puck.ts
8593
+ // lib/use-delete-hotkeys.ts
8590
8594
  init_react_import();
8591
8595
  var import_react55 = require("react");
8596
+ var isElementVisible = (element) => {
8597
+ let current = element;
8598
+ while (current && current !== document.body) {
8599
+ const style = window.getComputedStyle(current);
8600
+ if (style.display === "none" || style.visibility === "hidden" || style.opacity === "0" || current.getAttribute("aria-hidden") === "true" || current.hasAttribute("hidden")) {
8601
+ return false;
8602
+ }
8603
+ current = current.parentElement;
8604
+ }
8605
+ return true;
8606
+ };
8607
+ var shouldBlockDeleteHotkey = (e) => {
8608
+ var _a;
8609
+ if (e == null ? void 0 : e.defaultPrevented) return true;
8610
+ const origin = ((_a = e == null ? void 0 : e.composedPath) == null ? void 0 : _a.call(e)[0]) || (e == null ? void 0 : e.target) || document.activeElement;
8611
+ if (origin instanceof HTMLElement) {
8612
+ const tag = origin.tagName.toLowerCase();
8613
+ if (tag === "input" || tag === "textarea" || tag === "select") return true;
8614
+ if (origin.isContentEditable) return true;
8615
+ const role = origin.getAttribute("role");
8616
+ if (role === "textbox" || role === "combobox" || role === "searchbox" || role === "listbox" || role === "grid") {
8617
+ return true;
8618
+ }
8619
+ }
8620
+ const modal = document.querySelector(
8621
+ 'dialog[open], [aria-modal="true"], [role="dialog"], [role="alertdialog"]'
8622
+ );
8623
+ if (modal && isElementVisible(modal)) {
8624
+ return true;
8625
+ }
8626
+ return false;
8627
+ };
8628
+ var useDeleteHotkeys = () => {
8629
+ const appStore = useAppStoreApi();
8630
+ const deleteSelectedComponent = (0, import_react55.useCallback)(
8631
+ (e) => {
8632
+ var _a;
8633
+ if (shouldBlockDeleteHotkey(e)) {
8634
+ return false;
8635
+ }
8636
+ const { state, dispatch, permissions, selectedItem } = appStore.getState();
8637
+ const sel = (_a = state.ui) == null ? void 0 : _a.itemSelector;
8638
+ if (!(sel == null ? void 0 : sel.zone) || !selectedItem) return true;
8639
+ if (!permissions.getPermissions({ item: selectedItem }).delete)
8640
+ return true;
8641
+ dispatch({
8642
+ type: "remove",
8643
+ index: sel.index,
8644
+ zone: sel.zone
8645
+ });
8646
+ return true;
8647
+ },
8648
+ [appStore]
8649
+ );
8650
+ useHotkey({ delete: true }, deleteSelectedComponent);
8651
+ useHotkey({ backspace: true }, deleteSelectedComponent);
8652
+ };
8653
+
8654
+ // lib/use-puck.ts
8655
+ init_react_import();
8656
+ var import_react56 = require("react");
8592
8657
  var import_zustand6 = require("zustand");
8593
8658
  var generateUsePuck = (store) => {
8594
8659
  const history = {
@@ -8615,7 +8680,7 @@ var generateUsePuck = (store) => {
8615
8680
  };
8616
8681
  return storeData;
8617
8682
  };
8618
- var UsePuckStoreContext = (0, import_react55.createContext)(
8683
+ var UsePuckStoreContext = (0, import_react56.createContext)(
8619
8684
  null
8620
8685
  );
8621
8686
  var convertToPickedStore = (store) => {
@@ -8629,12 +8694,12 @@ var convertToPickedStore = (store) => {
8629
8694
  };
8630
8695
  };
8631
8696
  var useRegisterUsePuckStore = (appStore) => {
8632
- const [usePuckStore] = (0, import_react55.useState)(
8697
+ const [usePuckStore] = (0, import_react56.useState)(
8633
8698
  () => (0, import_zustand6.createStore)(
8634
8699
  () => generateUsePuck(convertToPickedStore(appStore.getState()))
8635
8700
  )
8636
8701
  );
8637
- (0, import_react55.useEffect)(() => {
8702
+ (0, import_react56.useEffect)(() => {
8638
8703
  return appStore.subscribe(
8639
8704
  (store) => convertToPickedStore(store),
8640
8705
  (pickedStore) => {
@@ -8646,7 +8711,7 @@ var useRegisterUsePuckStore = (appStore) => {
8646
8711
  };
8647
8712
  function createUsePuck() {
8648
8713
  return function usePuck2(selector) {
8649
- const usePuckApi = (0, import_react55.useContext)(UsePuckStoreContext);
8714
+ const usePuckApi = (0, import_react56.useContext)(UsePuckStoreContext);
8650
8715
  if (!usePuckApi) {
8651
8716
  throw new Error("usePuck must be used inside <Puck>.");
8652
8717
  }
@@ -8658,7 +8723,7 @@ function createUsePuck() {
8658
8723
  };
8659
8724
  }
8660
8725
  function usePuck() {
8661
- (0, import_react55.useEffect)(() => {
8726
+ (0, import_react56.useEffect)(() => {
8662
8727
  console.warn(
8663
8728
  "You're using the `usePuck` method without a selector, which may cause unnecessary re-renders. Replace with `createUsePuck` and provide a selector for improved performance."
8664
8729
  );
@@ -8666,7 +8731,7 @@ function usePuck() {
8666
8731
  return createUsePuck()((s) => s);
8667
8732
  }
8668
8733
  function useGetPuck() {
8669
- const usePuckApi = (0, import_react55.useContext)(UsePuckStoreContext);
8734
+ const usePuckApi = (0, import_react56.useContext)(UsePuckStoreContext);
8670
8735
  if (!usePuckApi) {
8671
8736
  throw new Error("usePuckGet must be used inside <Puck>.");
8672
8737
  }
@@ -8678,7 +8743,7 @@ var import_fast_deep_equal3 = __toESM(require("fast-deep-equal"));
8678
8743
 
8679
8744
  // components/Puck/components/Header/index.tsx
8680
8745
  init_react_import();
8681
- var import_react56 = require("react");
8746
+ var import_react57 = require("react");
8682
8747
 
8683
8748
  // components/MenuBar/index.tsx
8684
8749
  init_react_import();
@@ -8760,7 +8825,7 @@ var HeaderInner = () => {
8760
8825
  } = usePropsContext();
8761
8826
  const dispatch = useAppStore((s) => s.dispatch);
8762
8827
  const appStore = useAppStoreApi();
8763
- const defaultHeaderRender = (0, import_react56.useMemo)(() => {
8828
+ const defaultHeaderRender = (0, import_react57.useMemo)(() => {
8764
8829
  if (renderHeader) {
8765
8830
  console.warn(
8766
8831
  "`renderHeader` is deprecated. Please use `overrides.header` and the `usePuck` hook instead"
@@ -8775,7 +8840,7 @@ var HeaderInner = () => {
8775
8840
  }
8776
8841
  return DefaultOverride;
8777
8842
  }, [renderHeader]);
8778
- const defaultHeaderActionsRender = (0, import_react56.useMemo)(() => {
8843
+ const defaultHeaderActionsRender = (0, import_react57.useMemo)(() => {
8779
8844
  if (renderHeaderActions) {
8780
8845
  console.warn(
8781
8846
  "`renderHeaderActions` is deprecated. Please use `overrides.headerActions` and the `usePuck` hook instead."
@@ -8795,7 +8860,7 @@ var HeaderInner = () => {
8795
8860
  const CustomHeaderActions = useAppStore(
8796
8861
  (s) => s.overrides.headerActions || defaultHeaderActionsRender
8797
8862
  );
8798
- const [menuOpen, setMenuOpen] = (0, import_react56.useState)(false);
8863
+ const [menuOpen, setMenuOpen] = (0, import_react57.useState)(false);
8799
8864
  const rootTitle = useAppStore((s) => {
8800
8865
  var _a, _b;
8801
8866
  const rootData = (_a = s.state.indexes.nodes["root"]) == null ? void 0 : _a.data;
@@ -8805,7 +8870,7 @@ var HeaderInner = () => {
8805
8870
  const rightSideBarVisible = useAppStore(
8806
8871
  (s) => s.state.ui.rightSideBarVisible
8807
8872
  );
8808
- const toggleSidebars = (0, import_react56.useCallback)(
8873
+ const toggleSidebars = (0, import_react57.useCallback)(
8809
8874
  (sidebar) => {
8810
8875
  const widerViewport = window.matchMedia("(min-width: 638px)").matches;
8811
8876
  const sideBarVisible = sidebar === "left" ? leftSideBarVisible : rightSideBarVisible;
@@ -8908,14 +8973,14 @@ var HeaderInner = () => {
8908
8973
  }
8909
8974
  );
8910
8975
  };
8911
- var Header = (0, import_react56.memo)(HeaderInner);
8976
+ var Header = (0, import_react57.memo)(HeaderInner);
8912
8977
 
8913
8978
  // components/Puck/components/Sidebar/index.tsx
8914
8979
  init_react_import();
8915
8980
 
8916
8981
  // components/Puck/components/ResizeHandle/index.tsx
8917
8982
  init_react_import();
8918
- var import_react57 = require("react");
8983
+ var import_react58 = require("react");
8919
8984
 
8920
8985
  // css-module:/home/runner/work/puck/puck/packages/core/components/Puck/components/ResizeHandle/styles.module.css#css-module
8921
8986
  init_react_import();
@@ -8932,11 +8997,11 @@ var ResizeHandle = ({
8932
8997
  }) => {
8933
8998
  const { frameRef } = useCanvasFrame();
8934
8999
  const resetAutoZoom = useResetAutoZoom(frameRef);
8935
- const handleRef = (0, import_react57.useRef)(null);
8936
- const isDragging = (0, import_react57.useRef)(false);
8937
- const startX = (0, import_react57.useRef)(0);
8938
- const startWidth = (0, import_react57.useRef)(0);
8939
- const handleMouseMove = (0, import_react57.useCallback)(
9000
+ const handleRef = (0, import_react58.useRef)(null);
9001
+ const isDragging = (0, import_react58.useRef)(false);
9002
+ const startX = (0, import_react58.useRef)(0);
9003
+ const startWidth = (0, import_react58.useRef)(0);
9004
+ const handleMouseMove = (0, import_react58.useCallback)(
8940
9005
  (e) => {
8941
9006
  if (!isDragging.current) return;
8942
9007
  const delta = e.clientX - startX.current;
@@ -8947,7 +9012,7 @@ var ResizeHandle = ({
8947
9012
  },
8948
9013
  [onResize, position]
8949
9014
  );
8950
- const handleMouseUp = (0, import_react57.useCallback)(() => {
9015
+ const handleMouseUp = (0, import_react58.useCallback)(() => {
8951
9016
  var _a;
8952
9017
  if (!isDragging.current) return;
8953
9018
  isDragging.current = false;
@@ -8963,7 +9028,7 @@ var ResizeHandle = ({
8963
9028
  onResizeEnd(finalWidth);
8964
9029
  resetAutoZoom();
8965
9030
  }, [onResizeEnd]);
8966
- const handleMouseDown = (0, import_react57.useCallback)(
9031
+ const handleMouseDown = (0, import_react58.useCallback)(
8967
9032
  (e) => {
8968
9033
  var _a;
8969
9034
  isDragging.current = true;
@@ -9023,14 +9088,14 @@ var Sidebar = ({
9023
9088
 
9024
9089
  // lib/use-sidebar-resize.ts
9025
9090
  init_react_import();
9026
- var import_react58 = require("react");
9091
+ var import_react59 = require("react");
9027
9092
  function useSidebarResize(position, dispatch) {
9028
- const [width, setWidth] = (0, import_react58.useState)(null);
9029
- const sidebarRef = (0, import_react58.useRef)(null);
9093
+ const [width, setWidth] = (0, import_react59.useState)(null);
9094
+ const sidebarRef = (0, import_react59.useRef)(null);
9030
9095
  const storeWidth = useAppStore(
9031
9096
  (s) => position === "left" ? s.state.ui.leftSideBarWidth : s.state.ui.rightSideBarWidth
9032
9097
  );
9033
- (0, import_react58.useEffect)(() => {
9098
+ (0, import_react59.useEffect)(() => {
9034
9099
  if (typeof window !== "undefined" && !storeWidth) {
9035
9100
  try {
9036
9101
  const savedWidths = localStorage.getItem("puck-sidebar-widths");
@@ -9055,12 +9120,12 @@ function useSidebarResize(position, dispatch) {
9055
9120
  }
9056
9121
  }
9057
9122
  }, [dispatch, position, storeWidth]);
9058
- (0, import_react58.useEffect)(() => {
9123
+ (0, import_react59.useEffect)(() => {
9059
9124
  if (storeWidth !== void 0) {
9060
9125
  setWidth(storeWidth);
9061
9126
  }
9062
9127
  }, [storeWidth]);
9063
- const handleResizeEnd = (0, import_react58.useCallback)(
9128
+ const handleResizeEnd = (0, import_react59.useCallback)(
9064
9129
  (width2) => {
9065
9130
  dispatch({
9066
9131
  type: "setUi",
@@ -9115,11 +9180,11 @@ var FieldSideBar = () => {
9115
9180
  );
9116
9181
  return /* @__PURE__ */ (0, import_jsx_runtime46.jsx)(SidebarSection, { noPadding: true, noBorderTop: true, showBreadcrumbs: true, title, children: /* @__PURE__ */ (0, import_jsx_runtime46.jsx)(Fields, {}) });
9117
9182
  };
9118
- var propsContext = (0, import_react59.createContext)({});
9183
+ var propsContext = (0, import_react60.createContext)({});
9119
9184
  function PropsProvider(props) {
9120
9185
  return /* @__PURE__ */ (0, import_jsx_runtime46.jsx)(propsContext.Provider, { value: props, children: props.children });
9121
9186
  }
9122
- var usePropsContext = () => (0, import_react59.useContext)(propsContext);
9187
+ var usePropsContext = () => (0, import_react60.useContext)(propsContext);
9123
9188
  function PuckProvider({ children }) {
9124
9189
  const {
9125
9190
  config,
@@ -9136,14 +9201,14 @@ function PuckProvider({ children }) {
9136
9201
  onAction,
9137
9202
  fieldTransforms
9138
9203
  } = usePropsContext();
9139
- const iframe = (0, import_react59.useMemo)(
9204
+ const iframe = (0, import_react60.useMemo)(
9140
9205
  () => __spreadValues({
9141
9206
  enabled: true,
9142
9207
  waitForStyles: true
9143
9208
  }, _iframe),
9144
9209
  [_iframe]
9145
9210
  );
9146
- const [generatedAppState] = (0, import_react59.useState)(() => {
9211
+ const [generatedAppState] = (0, import_react60.useState)(() => {
9147
9212
  var _a, _b, _c, _d, _e, _f, _g, _h, _i;
9148
9213
  const initial = __spreadValues(__spreadValues({}, defaultAppState.ui), initialUi);
9149
9214
  let clientUiState = {};
@@ -9203,7 +9268,7 @@ function PuckProvider({ children }) {
9203
9268
  return walkAppState(newAppState, config);
9204
9269
  });
9205
9270
  const { appendData = true } = _initialHistory || {};
9206
- const [blendedHistories] = (0, import_react59.useState)(
9271
+ const [blendedHistories] = (0, import_react60.useState)(
9207
9272
  [
9208
9273
  ...(_initialHistory == null ? void 0 : _initialHistory.histories) || [],
9209
9274
  ...appendData ? [{ state: generatedAppState }] : []
@@ -9223,7 +9288,7 @@ function PuckProvider({ children }) {
9223
9288
  overrides,
9224
9289
  plugins
9225
9290
  });
9226
- const loadedFieldTransforms = (0, import_react59.useMemo)(() => {
9291
+ const loadedFieldTransforms = (0, import_react60.useMemo)(() => {
9227
9292
  const _plugins = plugins || [];
9228
9293
  const pluginFieldTransforms = _plugins.reduce(
9229
9294
  (acc, plugin) => __spreadValues(__spreadValues({}, acc), plugin.fieldTransforms),
@@ -9231,7 +9296,7 @@ function PuckProvider({ children }) {
9231
9296
  );
9232
9297
  return __spreadValues(__spreadValues({}, pluginFieldTransforms), fieldTransforms);
9233
9298
  }, [fieldTransforms, plugins]);
9234
- const generateAppStore = (0, import_react59.useCallback)(
9299
+ const generateAppStore = (0, import_react60.useCallback)(
9235
9300
  (state) => {
9236
9301
  return {
9237
9302
  state,
@@ -9257,15 +9322,15 @@ function PuckProvider({ children }) {
9257
9322
  loadedFieldTransforms
9258
9323
  ]
9259
9324
  );
9260
- const [appStore] = (0, import_react59.useState)(
9325
+ const [appStore] = (0, import_react60.useState)(
9261
9326
  () => createAppStore(generateAppStore(initialAppState))
9262
9327
  );
9263
- (0, import_react59.useEffect)(() => {
9328
+ (0, import_react60.useEffect)(() => {
9264
9329
  if (process.env.NODE_ENV !== "production") {
9265
9330
  window.__PUCK_INTERNAL_DO_NOT_USE = { appStore };
9266
9331
  }
9267
9332
  }, [appStore]);
9268
- (0, import_react59.useEffect)(() => {
9333
+ (0, import_react60.useEffect)(() => {
9269
9334
  const state = appStore.getState().state;
9270
9335
  appStore.setState(__spreadValues({}, generateAppStore(state)));
9271
9336
  }, [config, plugins, loadedOverrides, viewports, iframe, onAction, metadata]);
@@ -9274,8 +9339,8 @@ function PuckProvider({ children }) {
9274
9339
  index: initialHistoryIndex,
9275
9340
  initialAppState
9276
9341
  });
9277
- const previousData = (0, import_react59.useRef)(null);
9278
- (0, import_react59.useEffect)(() => {
9342
+ const previousData = (0, import_react60.useRef)(null);
9343
+ (0, import_react60.useEffect)(() => {
9279
9344
  appStore.subscribe(
9280
9345
  (s) => s.state.data,
9281
9346
  (data) => {
@@ -9289,7 +9354,7 @@ function PuckProvider({ children }) {
9289
9354
  }, []);
9290
9355
  useRegisterPermissionsSlice(appStore, permissions);
9291
9356
  const uPuckStore = useRegisterUsePuckStore(appStore);
9292
- (0, import_react59.useEffect)(() => {
9357
+ (0, import_react60.useEffect)(() => {
9293
9358
  const { resolveAndCommitData } = appStore.getState();
9294
9359
  resolveAndCommitData();
9295
9360
  }, []);
@@ -9301,7 +9366,7 @@ function PuckLayout({ children }) {
9301
9366
  dnd,
9302
9367
  initialHistory: _initialHistory
9303
9368
  } = usePropsContext();
9304
- const iframe = (0, import_react59.useMemo)(
9369
+ const iframe = (0, import_react60.useMemo)(
9305
9370
  () => __spreadValues({
9306
9371
  enabled: true,
9307
9372
  waitForStyles: true
@@ -9326,7 +9391,7 @@ function PuckLayout({ children }) {
9326
9391
  sidebarRef: rightSidebarRef,
9327
9392
  handleResizeEnd: handleRightSidebarResizeEnd
9328
9393
  } = useSidebarResize("right", dispatch);
9329
- (0, import_react59.useEffect)(() => {
9394
+ (0, import_react60.useEffect)(() => {
9330
9395
  if (!window.matchMedia("(min-width: 638px)").matches) {
9331
9396
  dispatch({
9332
9397
  type: "setUi",
@@ -9350,17 +9415,18 @@ function PuckLayout({ children }) {
9350
9415
  };
9351
9416
  }, []);
9352
9417
  const overrides = useAppStore((s) => s.overrides);
9353
- const CustomPuck = (0, import_react59.useMemo)(
9418
+ const CustomPuck = (0, import_react60.useMemo)(
9354
9419
  () => overrides.puck || DefaultOverride,
9355
9420
  [overrides]
9356
9421
  );
9357
- const [mounted, setMounted] = (0, import_react59.useState)(false);
9358
- (0, import_react59.useEffect)(() => {
9422
+ const [mounted, setMounted] = (0, import_react60.useState)(false);
9423
+ (0, import_react60.useEffect)(() => {
9359
9424
  setMounted(true);
9360
9425
  }, []);
9361
9426
  const ready = useAppStore((s) => s.status === "READY");
9362
9427
  useMonitorHotkeys();
9363
- (0, import_react59.useEffect)(() => {
9428
+ useDeleteHotkeys();
9429
+ (0, import_react60.useEffect)(() => {
9364
9430
  if (ready && iframe.enabled) {
9365
9431
  const frameDoc = getFrame();
9366
9432
  if (frameDoc) {
@@ -18,7 +18,7 @@ import {
18
18
  setDeep,
19
19
  useGetPuck,
20
20
  usePuck
21
- } from "./chunk-NBNCSA43.mjs";
21
+ } from "./chunk-MYJB3LKU.mjs";
22
22
  import {
23
23
  init_react_import,
24
24
  migrate,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@measured/puck",
3
- "version": "0.21.0-canary.6dae6cb7",
3
+ "version": "0.21.0-canary.cf074bc6",
4
4
  "description": "The open-source visual editor for React",
5
5
  "author": "Chris Villa <chris@puckeditor.com>",
6
6
  "repository": "measuredco/puck",