@reacteditor/core 0.0.6 → 0.0.7

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.
Files changed (38) hide show
  1. package/dist/{Editor-YNFB7B6Z.mjs → Editor-OSAG52QF.mjs} +9 -9
  2. package/dist/{actions-CQmL3wwa.d.mts → actions-BDMhAtxP.d.mts} +2 -1
  3. package/dist/{actions-CQmL3wwa.d.ts → actions-BDMhAtxP.d.ts} +2 -1
  4. package/dist/{chunk-CRF2GWQA.mjs → chunk-AAK2555H.mjs} +3 -3
  5. package/dist/{chunk-6LG4Q4HO.mjs → chunk-EEQGJ6FH.mjs} +1 -1
  6. package/dist/{chunk-VOLQMQPK.mjs → chunk-IIRJMJFU.mjs} +1 -1
  7. package/dist/{chunk-BRDUM7MJ.mjs → chunk-JUC25FB7.mjs} +7 -7
  8. package/dist/{chunk-UB2DES2O.mjs → chunk-M4JDRFYB.mjs} +8 -6
  9. package/dist/{chunk-DB4R5IWG.mjs → chunk-RNRHREWH.mjs} +3 -3
  10. package/dist/{chunk-275EJPEB.mjs → chunk-TI3KC54Y.mjs} +18 -18
  11. package/dist/{chunk-HCFEY5Y7.mjs → chunk-W5I2Z7QS.mjs} +249 -24
  12. package/dist/{chunk-Z6IIVDFY.mjs → chunk-XI7YTBCP.mjs} +1 -1
  13. package/dist/{chunk-WGPCLAZR.mjs → chunk-ZLSPSBV3.mjs} +1 -1
  14. package/dist/{full-24FOTNTB.mjs → full-IHV5BO2L.mjs} +8 -8
  15. package/dist/{index-BOP2qNVA.d.mts → index-BwLKseT7.d.mts} +1 -1
  16. package/dist/{index-_G46lHpL.d.ts → index-DkYXZRPz.d.ts} +1 -1
  17. package/dist/index.d.mts +35 -8
  18. package/dist/index.d.ts +35 -8
  19. package/dist/index.js +284 -52
  20. package/dist/index.mjs +14 -14
  21. package/dist/internal.d.mts +2 -2
  22. package/dist/internal.d.ts +2 -2
  23. package/dist/internal.js +7 -5
  24. package/dist/internal.mjs +2 -2
  25. package/dist/{loaded-6NPDD7SF.mjs → loaded-3NPQWYKN.mjs} +5 -5
  26. package/dist/{loaded-BQVZGQG2.mjs → loaded-FTSXIONQ.mjs} +5 -5
  27. package/dist/{loaded-6IBSSOXD.mjs → loaded-YTQOQIUU.mjs} +5 -5
  28. package/dist/no-external.d.mts +4 -4
  29. package/dist/no-external.d.ts +4 -4
  30. package/dist/no-external.js +284 -52
  31. package/dist/no-external.mjs +14 -14
  32. package/dist/rsc.d.mts +2 -2
  33. package/dist/rsc.d.ts +2 -2
  34. package/dist/rsc.mjs +3 -3
  35. package/dist/{walk-tree-DxSkPLnl.d.ts → walk-tree-BweEZ37Y.d.ts} +1 -1
  36. package/dist/{walk-tree-Dwv3c_9M.d.mts → walk-tree-LcQXXDqe.d.mts} +1 -1
  37. package/package.json +1 -1
  38. package/dist/{chunk-GAUBBDIR.mjs → chunk-JIXMPJZA.mjs} +37 -37
@@ -1846,12 +1846,14 @@ function insertAction(state, action, appStore) {
1846
1846
  const componentConfig = appStore.config.components[action.componentType];
1847
1847
  const isGlobalType = (componentConfig == null ? void 0 : componentConfig.global) === true;
1848
1848
  const defaultProps = (componentConfig == null ? void 0 : componentConfig.defaultProps) || {};
1849
+ const sourceData = action.data ? __spreadProps(__spreadValues({}, action.data), { props: __spreadProps(__spreadValues({}, action.data.props), { id }) }) : __spreadValues({
1850
+ type: action.componentType,
1851
+ props: __spreadProps(__spreadValues({}, defaultProps), { id })
1852
+ }, isGlobalType ? { synced: true } : {});
1849
1853
  const emptyComponentData = populateIds(
1850
- __spreadValues({
1851
- type: action.componentType,
1852
- props: __spreadProps(__spreadValues({}, defaultProps), { id })
1853
- }, isGlobalType ? { synced: true } : {}),
1854
- appStore.config
1854
+ sourceData,
1855
+ appStore.config,
1856
+ !!action.data
1855
1857
  );
1856
1858
  const [parentId] = action.destinationZone.split(":");
1857
1859
  const idsInPath = getIdsForParent(action.destinationZone, state);
@@ -5449,7 +5451,6 @@ __export(no_external_exports, {
5449
5451
  Button: () => Button,
5450
5452
  ComponentList: () => ComponentList,
5451
5453
  Drawer: () => Drawer,
5452
- DropZone: () => DropZone,
5453
5454
  Editor: () => Editor4,
5454
5455
  FieldLabel: () => FieldLabel,
5455
5456
  Group: () => Group,
@@ -5473,6 +5474,7 @@ __export(no_external_exports, {
5473
5474
  transformProps: () => transformProps,
5474
5475
  useEditor: () => useEditor2,
5475
5476
  useGetEditor: () => useGetEditor,
5477
+ usePropsContext: () => usePropsContext,
5476
5478
  walkTree: () => walkTree
5477
5479
  });
5478
5480
  module.exports = __toCommonJS(no_external_exports);
@@ -11274,7 +11276,7 @@ init_IconButton2();
11274
11276
 
11275
11277
  // components/Editor/index.tsx
11276
11278
  init_react_import();
11277
- var import_react93 = require("react");
11279
+ var import_react94 = require("react");
11278
11280
  init_store();
11279
11281
 
11280
11282
  // components/Editor/components/Fields/index.tsx
@@ -12555,8 +12557,134 @@ function resolveDataBySelector(selector, getState, trigger) {
12555
12557
  });
12556
12558
  }
12557
12559
 
12560
+ // lib/editor-commands.ts
12561
+ init_react_import();
12562
+ init_get_item();
12563
+ init_generate_id();
12564
+ init_root_droppable_id();
12565
+ var parentToZone = (parent) => parent ? `${parent.id}:${parent.slot}` : rootDroppableId;
12566
+ var createEditorCommands = (appStore) => {
12567
+ const { getState } = appStore;
12568
+ const getZoneLength = (zone) => {
12569
+ var _a, _b;
12570
+ return (_b = (_a = getState().state.indexes.zones[zone]) == null ? void 0 : _a.contentIds.length) != null ? _b : 0;
12571
+ };
12572
+ const insertComponent2 = ({
12573
+ type,
12574
+ parent,
12575
+ index,
12576
+ data,
12577
+ select = true
12578
+ }) => {
12579
+ var _a;
12580
+ const id = (_a = data == null ? void 0 : data.props.id) != null ? _a : generateId(type);
12581
+ const zone = parentToZone(parent);
12582
+ const destIndex = index != null ? index : getZoneLength(zone);
12583
+ const dispatch = getState().dispatch;
12584
+ dispatch(__spreadValues({
12585
+ type: "insert",
12586
+ componentType: type,
12587
+ destinationIndex: destIndex,
12588
+ destinationZone: zone,
12589
+ id
12590
+ }, data ? { data: __spreadProps(__spreadValues({}, data), { props: __spreadProps(__spreadValues({}, data.props), { id }) }) } : {}));
12591
+ if (select) {
12592
+ dispatch({
12593
+ type: "setUi",
12594
+ ui: { itemSelector: { index: destIndex, zone } }
12595
+ });
12596
+ }
12597
+ return { id };
12598
+ };
12599
+ const removeComponent = (id) => {
12600
+ const sel = getSelectorForId(getState().state, id);
12601
+ if (!(sel == null ? void 0 : sel.zone)) return;
12602
+ getState().dispatch({ type: "remove", index: sel.index, zone: sel.zone });
12603
+ };
12604
+ const duplicateComponent = (id) => {
12605
+ const sel = getSelectorForId(getState().state, id);
12606
+ if (!(sel == null ? void 0 : sel.zone)) return;
12607
+ getState().dispatch({
12608
+ type: "duplicate",
12609
+ sourceIndex: sel.index,
12610
+ sourceZone: sel.zone
12611
+ });
12612
+ };
12613
+ const moveComponent2 = (id, to) => {
12614
+ const sel = getSelectorForId(getState().state, id);
12615
+ if (!(sel == null ? void 0 : sel.zone)) return;
12616
+ getState().dispatch({
12617
+ type: "move",
12618
+ sourceIndex: sel.index,
12619
+ sourceZone: sel.zone,
12620
+ destinationIndex: to.index,
12621
+ destinationZone: parentToZone(to.parent)
12622
+ });
12623
+ };
12624
+ const replaceComponent = (id, data) => {
12625
+ const sel = getSelectorForId(getState().state, id);
12626
+ if (!(sel == null ? void 0 : sel.zone)) return;
12627
+ const existing = getItem(sel, getState().state);
12628
+ if (!existing) return;
12629
+ getState().dispatch({
12630
+ type: "replace",
12631
+ destinationIndex: sel.index,
12632
+ destinationZone: sel.zone,
12633
+ data: __spreadProps(__spreadValues({}, data), { props: __spreadProps(__spreadValues({}, data.props), { id: existing.props.id }) })
12634
+ });
12635
+ };
12636
+ const updateProps = (id, updater) => {
12637
+ const sel = getSelectorForId(getState().state, id);
12638
+ if (!sel) return;
12639
+ const existing = getItem(sel, getState().state);
12640
+ if (!existing) return;
12641
+ const patch = typeof updater === "function" ? updater(existing.props) : updater;
12642
+ getState().dispatch({
12643
+ type: "replace",
12644
+ destinationIndex: sel.index,
12645
+ destinationZone: sel.zone,
12646
+ data: __spreadProps(__spreadValues({}, existing), {
12647
+ props: __spreadProps(__spreadValues(__spreadValues({}, existing.props), patch), { id: existing.props.id })
12648
+ })
12649
+ });
12650
+ };
12651
+ const updateRoot = (updater) => {
12652
+ var _a, _b;
12653
+ const root = (_a = getState().state.data.root) != null ? _a : { props: {} };
12654
+ const prevProps = (_b = root.props) != null ? _b : {};
12655
+ const patch = typeof updater === "function" ? updater(prevProps) : updater;
12656
+ getState().dispatch({
12657
+ type: "replaceRoot",
12658
+ root: __spreadProps(__spreadValues({}, root), { props: __spreadValues(__spreadValues({}, prevProps), patch) })
12659
+ });
12660
+ };
12661
+ const selectComponent = (id) => {
12662
+ const dispatch = getState().dispatch;
12663
+ if (id === null) {
12664
+ dispatch({ type: "setUi", ui: { itemSelector: null } });
12665
+ return;
12666
+ }
12667
+ const sel = getSelectorForId(getState().state, id);
12668
+ if (!(sel == null ? void 0 : sel.zone)) return;
12669
+ dispatch({
12670
+ type: "setUi",
12671
+ ui: { itemSelector: { index: sel.index, zone: sel.zone } }
12672
+ });
12673
+ };
12674
+ return {
12675
+ insertComponent: insertComponent2,
12676
+ removeComponent,
12677
+ duplicateComponent,
12678
+ moveComponent: moveComponent2,
12679
+ replaceComponent,
12680
+ updateProps,
12681
+ updateRoot,
12682
+ selectComponent
12683
+ };
12684
+ };
12685
+
12558
12686
  // lib/use-editor.ts
12559
- var generateUseEditor = (store, getState) => {
12687
+ var generateUseEditor = (store, getState, commands) => {
12560
12688
  const history = {
12561
12689
  back: store.history.back,
12562
12690
  forward: store.history.forward,
@@ -12567,7 +12695,7 @@ var generateUseEditor = (store, getState) => {
12567
12695
  histories: store.history.histories,
12568
12696
  index: store.history.index
12569
12697
  };
12570
- const storeData = {
12698
+ const storeData = __spreadProps(__spreadValues({}, commands), {
12571
12699
  appState: makeStatePublic(store.state),
12572
12700
  config: store.config,
12573
12701
  dispatch: store.dispatch,
@@ -12588,7 +12716,7 @@ var generateUseEditor = (store, getState) => {
12588
12716
  if (!parentNode) return;
12589
12717
  return parentNode.data;
12590
12718
  }
12591
- };
12719
+ });
12592
12720
  storeData.__private = {
12593
12721
  appState: store.state
12594
12722
  };
@@ -12608,11 +12736,13 @@ var convertToPickedStore = (store) => {
12608
12736
  };
12609
12737
  };
12610
12738
  var useRegisterUseEditorStore = (appStore) => {
12739
+ const [commands] = (0, import_react81.useState)(() => createEditorCommands(appStore));
12611
12740
  const [useEditorStore] = (0, import_react81.useState)(
12612
12741
  () => (0, import_zustand7.createStore)(
12613
12742
  () => generateUseEditor(
12614
12743
  convertToPickedStore(appStore.getState()),
12615
- appStore.getState
12744
+ appStore.getState,
12745
+ commands
12616
12746
  )
12617
12747
  )
12618
12748
  );
@@ -12620,10 +12750,12 @@ var useRegisterUseEditorStore = (appStore) => {
12620
12750
  return appStore.subscribe(
12621
12751
  (store) => convertToPickedStore(store),
12622
12752
  (pickedStore) => {
12623
- useEditorStore.setState(generateUseEditor(pickedStore, appStore.getState));
12753
+ useEditorStore.setState(
12754
+ generateUseEditor(pickedStore, appStore.getState, commands)
12755
+ );
12624
12756
  }
12625
12757
  );
12626
- }, []);
12758
+ }, [commands]);
12627
12759
  return useEditorStore;
12628
12760
  };
12629
12761
  function createUseEditor() {
@@ -12708,7 +12840,7 @@ init_to_component();
12708
12840
 
12709
12841
  // components/Editor/components/Layout/index.tsx
12710
12842
  init_react_import();
12711
- var import_react92 = require("react");
12843
+ var import_react93 = require("react");
12712
12844
  init_lib();
12713
12845
 
12714
12846
  // css-module:/Users/rami/Documents/apps/react-editor/packages/core/components/Editor/components/Layout/styles.module.css#css-module
@@ -13638,6 +13770,9 @@ init_react_import();
13638
13770
  var import_react91 = require("react");
13639
13771
  init_use_hotkey();
13640
13772
  init_store();
13773
+
13774
+ // lib/should-block-editing-hotkey.ts
13775
+ init_react_import();
13641
13776
  var isElementVisible = (element) => {
13642
13777
  let current = element;
13643
13778
  while (current && current !== document.body) {
@@ -13649,7 +13784,7 @@ var isElementVisible = (element) => {
13649
13784
  }
13650
13785
  return true;
13651
13786
  };
13652
- var shouldBlockDeleteHotkey = (e) => {
13787
+ var shouldBlockEditingHotkey = (e) => {
13653
13788
  var _a;
13654
13789
  if (e == null ? void 0 : e.defaultPrevented) return true;
13655
13790
  const origin = ((_a = e == null ? void 0 : e.composedPath) == null ? void 0 : _a.call(e)[0]) || (e == null ? void 0 : e.target) || document.activeElement;
@@ -13670,12 +13805,14 @@ var shouldBlockDeleteHotkey = (e) => {
13670
13805
  }
13671
13806
  return false;
13672
13807
  };
13808
+
13809
+ // lib/use-delete-hotkeys.ts
13673
13810
  var useDeleteHotkeys = () => {
13674
13811
  const appStore = useAppStoreApi();
13675
13812
  const deleteSelectedComponent = (0, import_react91.useCallback)(
13676
13813
  (e) => {
13677
13814
  var _a;
13678
- if (shouldBlockDeleteHotkey(e)) {
13815
+ if (shouldBlockEditingHotkey(e)) {
13679
13816
  return false;
13680
13817
  }
13681
13818
  const { state, dispatch, permissions, selectedItem } = appStore.getState();
@@ -13696,6 +13833,100 @@ var useDeleteHotkeys = () => {
13696
13833
  useHotkey({ backspace: true }, deleteSelectedComponent);
13697
13834
  };
13698
13835
 
13836
+ // lib/use-clipboard-hotkeys.ts
13837
+ init_react_import();
13838
+ var import_react92 = require("react");
13839
+ init_use_hotkey();
13840
+ init_store();
13841
+ var CLIPBOARD_MARKER = "reacteditor/component";
13842
+ var isComponentData = (value) => {
13843
+ var _a;
13844
+ if (!value || typeof value !== "object") return false;
13845
+ const v = value;
13846
+ return typeof v.type === "string" && typeof ((_a = v.props) == null ? void 0 : _a.id) === "string";
13847
+ };
13848
+ var parsePayload = (text) => {
13849
+ try {
13850
+ const parsed = JSON.parse(text);
13851
+ if (parsed && typeof parsed === "object" && parsed.__reactEditor === CLIPBOARD_MARKER && isComponentData(parsed.data)) {
13852
+ return parsed.data;
13853
+ }
13854
+ } catch (e) {
13855
+ }
13856
+ return null;
13857
+ };
13858
+ var useClipboardHotkeys = () => {
13859
+ const appStore = useAppStoreApi();
13860
+ const writeSelectionToClipboard = (0, import_react92.useCallback)(() => {
13861
+ var _a;
13862
+ const { selectedItem } = appStore.getState();
13863
+ if (!selectedItem) return false;
13864
+ const payload = {
13865
+ __reactEditor: CLIPBOARD_MARKER,
13866
+ data: selectedItem
13867
+ };
13868
+ (_a = navigator.clipboard) == null ? void 0 : _a.writeText(JSON.stringify(payload)).catch(() => {
13869
+ });
13870
+ return true;
13871
+ }, [appStore]);
13872
+ const copySelectedComponent = (0, import_react92.useCallback)(
13873
+ (e) => {
13874
+ if (shouldBlockEditingHotkey(e)) return false;
13875
+ return writeSelectionToClipboard();
13876
+ },
13877
+ [writeSelectionToClipboard]
13878
+ );
13879
+ const cutSelectedComponent = (0, import_react92.useCallback)(
13880
+ (e) => {
13881
+ var _a;
13882
+ if (shouldBlockEditingHotkey(e)) return false;
13883
+ const { state, dispatch, permissions, selectedItem } = appStore.getState();
13884
+ const sel = (_a = state.ui) == null ? void 0 : _a.itemSelector;
13885
+ if (!(sel == null ? void 0 : sel.zone) || !selectedItem) return false;
13886
+ if (!permissions.getPermissions({ item: selectedItem }).delete)
13887
+ return true;
13888
+ if (!writeSelectionToClipboard()) return false;
13889
+ dispatch({
13890
+ type: "remove",
13891
+ index: sel.index,
13892
+ zone: sel.zone
13893
+ });
13894
+ return true;
13895
+ },
13896
+ [appStore, writeSelectionToClipboard]
13897
+ );
13898
+ const pasteComponent = (0, import_react92.useCallback)(
13899
+ (e) => {
13900
+ var _a, _b;
13901
+ if (shouldBlockEditingHotkey(e)) return false;
13902
+ const { state, dispatch, config } = appStore.getState();
13903
+ const sel = (_a = state.ui) == null ? void 0 : _a.itemSelector;
13904
+ if (!(sel == null ? void 0 : sel.zone)) return false;
13905
+ (_b = navigator.clipboard) == null ? void 0 : _b.readText().then((text) => {
13906
+ const data = parsePayload(text);
13907
+ if (!data) return;
13908
+ if (!config.components[data.type]) return;
13909
+ dispatch({
13910
+ type: "insert",
13911
+ componentType: data.type,
13912
+ destinationIndex: sel.index + 1,
13913
+ destinationZone: sel.zone,
13914
+ data
13915
+ });
13916
+ }).catch(() => {
13917
+ });
13918
+ return true;
13919
+ },
13920
+ [appStore]
13921
+ );
13922
+ useHotkey({ meta: true, c: true }, copySelectedComponent);
13923
+ useHotkey({ ctrl: true, c: true }, copySelectedComponent);
13924
+ useHotkey({ meta: true, v: true }, pasteComponent);
13925
+ useHotkey({ ctrl: true, v: true }, pasteComponent);
13926
+ useHotkey({ meta: true, x: true }, cutSelectedComponent);
13927
+ useHotkey({ ctrl: true, x: true }, cutSelectedComponent);
13928
+ };
13929
+
13699
13930
  // components/Editor/components/Nav/index.tsx
13700
13931
  init_react_import();
13701
13932
 
@@ -13892,7 +14123,7 @@ var Layout = ({ children }) => {
13892
14123
  plugins,
13893
14124
  height
13894
14125
  } = usePropsContext();
13895
- const iframe = (0, import_react92.useMemo)(
14126
+ const iframe = (0, import_react93.useMemo)(
13896
14127
  () => __spreadValues({
13897
14128
  enabled: true,
13898
14129
  waitForStyles: true
@@ -13918,7 +14149,7 @@ var Layout = ({ children }) => {
13918
14149
  sidebarRef: rightSidebarRef,
13919
14150
  handleResizeEnd: handleRightSidebarResizeEnd
13920
14151
  } = useSidebarResize("right", dispatch);
13921
- (0, import_react92.useEffect)(() => {
14152
+ (0, import_react93.useEffect)(() => {
13922
14153
  if (!window.matchMedia("(min-width: 638px)").matches) {
13923
14154
  dispatch({
13924
14155
  type: "setUi",
@@ -13942,17 +14173,17 @@ var Layout = ({ children }) => {
13942
14173
  };
13943
14174
  }, []);
13944
14175
  const overrides = useAppStore((s) => s.overrides);
13945
- const CustomEditor = (0, import_react92.useMemo)(
14176
+ const CustomEditor = (0, import_react93.useMemo)(
13946
14177
  () => overrides.editor || DefaultOverride,
13947
14178
  [overrides]
13948
14179
  );
13949
- const [mounted, setMounted] = (0, import_react92.useState)(false);
13950
- (0, import_react92.useEffect)(() => {
14180
+ const [mounted, setMounted] = (0, import_react93.useState)(false);
14181
+ (0, import_react93.useEffect)(() => {
13951
14182
  setMounted(true);
13952
14183
  }, []);
13953
14184
  const ready = useAppStore((s) => s.status === "READY");
13954
14185
  useMonitorHotkeys();
13955
- (0, import_react92.useEffect)(() => {
14186
+ (0, import_react93.useEffect)(() => {
13956
14187
  if (ready && iframe.enabled) {
13957
14188
  const frameDoc = getFrame();
13958
14189
  if (frameDoc) {
@@ -13962,6 +14193,7 @@ var Layout = ({ children }) => {
13962
14193
  }, [ready, iframe.enabled]);
13963
14194
  usePreviewModeHotkeys();
13964
14195
  useDeleteHotkeys();
14196
+ useClipboardHotkeys();
13965
14197
  const layoutOptions = {};
13966
14198
  if (leftWidth) {
13967
14199
  layoutOptions["--editor-user-left-side-bar-width"] = `${leftWidth}px`;
@@ -13975,15 +14207,15 @@ var Layout = ({ children }) => {
13975
14207
  return (_a = s.state.ui.plugin) == null ? void 0 : _a.current;
13976
14208
  });
13977
14209
  const appStoreApi = useAppStoreApi();
13978
- const [mobilePanelHeightMode, setMobilePanelHeightMode] = (0, import_react92.useState)("toggle");
13979
- const [mobilePanelHeight, setMobilePanelHeight] = (0, import_react92.useState)(
14210
+ const [mobilePanelHeightMode, setMobilePanelHeightMode] = (0, import_react93.useState)("toggle");
14211
+ const [mobilePanelHeight, setMobilePanelHeight] = (0, import_react93.useState)(
13980
14212
  null
13981
14213
  );
13982
- const mobilePanelRef = (0, import_react92.useRef)(null);
13983
- const isDraggingMobile = (0, import_react92.useRef)(false);
13984
- const dragStartY = (0, import_react92.useRef)(0);
13985
- const dragStartHeight = (0, import_react92.useRef)(0);
13986
- const handleMobileDragStart = (0, import_react92.useCallback)(
14214
+ const mobilePanelRef = (0, import_react93.useRef)(null);
14215
+ const isDraggingMobile = (0, import_react93.useRef)(false);
14216
+ const dragStartY = (0, import_react93.useRef)(0);
14217
+ const dragStartHeight = (0, import_react93.useRef)(0);
14218
+ const handleMobileDragStart = (0, import_react93.useCallback)(
13987
14219
  (clientY) => {
13988
14220
  isDraggingMobile.current = true;
13989
14221
  dragStartY.current = clientY;
@@ -13994,7 +14226,7 @@ var Layout = ({ children }) => {
13994
14226
  },
13995
14227
  []
13996
14228
  );
13997
- const handleMobileDragMove = (0, import_react92.useCallback)((clientY) => {
14229
+ const handleMobileDragMove = (0, import_react93.useCallback)((clientY) => {
13998
14230
  if (!isDraggingMobile.current) return;
13999
14231
  const delta = dragStartY.current - clientY;
14000
14232
  const viewportHeight = window.innerHeight;
@@ -14003,13 +14235,13 @@ var Layout = ({ children }) => {
14003
14235
  const newH = Math.min(maxH, Math.max(minH, dragStartHeight.current + delta));
14004
14236
  setMobilePanelHeight(newH);
14005
14237
  }, []);
14006
- const handleMobileDragEnd = (0, import_react92.useCallback)(() => {
14238
+ const handleMobileDragEnd = (0, import_react93.useCallback)(() => {
14007
14239
  if (!isDraggingMobile.current) return;
14008
14240
  isDraggingMobile.current = false;
14009
14241
  document.body.style.userSelect = "";
14010
14242
  document.body.style.touchAction = "";
14011
14243
  }, []);
14012
- (0, import_react92.useEffect)(() => {
14244
+ (0, import_react93.useEffect)(() => {
14013
14245
  const onTouchMove = (e) => {
14014
14246
  if (isDraggingMobile.current) {
14015
14247
  e.preventDefault();
@@ -14035,13 +14267,13 @@ var Layout = ({ children }) => {
14035
14267
  document.removeEventListener("mouseup", onMouseUp);
14036
14268
  };
14037
14269
  }, [handleMobileDragMove, handleMobileDragEnd]);
14038
- const [theme, setTheme] = (0, import_react92.useState)(() => {
14270
+ const [theme, setTheme] = (0, import_react93.useState)(() => {
14039
14271
  if (typeof window === "undefined") return "light";
14040
14272
  const stored = window.localStorage.getItem("editor-theme");
14041
14273
  if (stored === "light" || stored === "dark") return stored;
14042
14274
  return window.matchMedia("(prefers-color-scheme: dark)").matches ? "dark" : "light";
14043
14275
  });
14044
- (0, import_react92.useEffect)(() => {
14276
+ (0, import_react93.useEffect)(() => {
14045
14277
  if (typeof window === "undefined") return;
14046
14278
  window.localStorage.setItem("editor-theme", theme);
14047
14279
  }, [theme]);
@@ -14050,11 +14282,11 @@ var Layout = ({ children }) => {
14050
14282
  };
14051
14283
  const themeIcon = theme === "dark" ? /* @__PURE__ */ (0, import_jsx_runtime92.jsx)(Sun, { size: 18 }) : /* @__PURE__ */ (0, import_jsx_runtime92.jsx)(Moon, { size: 18 });
14052
14284
  const themeLabel = theme === "dark" ? "Switch to light mode" : "Switch to dark mode";
14053
- const hasLegacySideBarPlugin = (0, import_react92.useMemo)(
14285
+ const hasLegacySideBarPlugin = (0, import_react93.useMemo)(
14054
14286
  () => !!(plugins == null ? void 0 : plugins.find((p) => p.name === "legacy-side-bar")),
14055
14287
  [plugins]
14056
14288
  );
14057
- const pluginItems = (0, import_react92.useMemo)(() => {
14289
+ const pluginItems = (0, import_react93.useMemo)(() => {
14058
14290
  const details = {};
14059
14291
  const defaultPlugins = [blocksPlugin(), outlinePlugin()];
14060
14292
  const isLegacy = (plugin) => plugin.name === "legacy-side-bar" ? -1 : 0;
@@ -14101,7 +14333,7 @@ var Layout = ({ children }) => {
14101
14333
  });
14102
14334
  return details;
14103
14335
  }, [plugins, currentPlugin, appStoreApi, leftSideBarVisible]);
14104
- (0, import_react92.useEffect)(() => {
14336
+ (0, import_react93.useEffect)(() => {
14105
14337
  if (!currentPlugin) {
14106
14338
  const names = Object.keys(pluginItems);
14107
14339
  setUi({ plugin: { current: names[0] } });
@@ -14241,11 +14473,11 @@ var Layout = ({ children }) => {
14241
14473
 
14242
14474
  // components/Editor/index.tsx
14243
14475
  var import_jsx_runtime93 = require("react/jsx-runtime");
14244
- var propsContext = (0, import_react93.createContext)({});
14476
+ var propsContext = (0, import_react94.createContext)({});
14245
14477
  function PropsProvider(props) {
14246
14478
  return /* @__PURE__ */ (0, import_jsx_runtime93.jsx)(propsContext.Provider, { value: props, children: props.children });
14247
14479
  }
14248
- var usePropsContext = () => (0, import_react93.useContext)(propsContext);
14480
+ var usePropsContext = () => (0, import_react94.useContext)(propsContext);
14249
14481
  function EditorProvider({ children }) {
14250
14482
  const {
14251
14483
  config,
@@ -14264,14 +14496,14 @@ function EditorProvider({ children }) {
14264
14496
  fullScreenCanvas,
14265
14497
  _experimentalVirtualization
14266
14498
  } = usePropsContext();
14267
- const iframe = (0, import_react93.useMemo)(
14499
+ const iframe = (0, import_react94.useMemo)(
14268
14500
  () => __spreadValues({
14269
14501
  enabled: true,
14270
14502
  waitForStyles: true
14271
14503
  }, _iframe),
14272
14504
  [_iframe]
14273
14505
  );
14274
- const [generatedAppState] = (0, import_react93.useState)(() => {
14506
+ const [generatedAppState] = (0, import_react94.useState)(() => {
14275
14507
  var _a, _b, _c, _d, _e, _f;
14276
14508
  const initial = __spreadValues(__spreadValues({}, defaultAppState.ui), initialUi);
14277
14509
  let clientUiState = {};
@@ -14323,7 +14555,7 @@ function EditorProvider({ children }) {
14323
14555
  return walkAppState(newAppState, config);
14324
14556
  });
14325
14557
  const { appendData = true } = _initialHistory || {};
14326
- const [blendedHistories] = (0, import_react93.useState)(
14558
+ const [blendedHistories] = (0, import_react94.useState)(
14327
14559
  [
14328
14560
  ...(_initialHistory == null ? void 0 : _initialHistory.histories) || [],
14329
14561
  ...appendData ? [{ state: generatedAppState }] : []
@@ -14337,7 +14569,7 @@ function EditorProvider({ children }) {
14337
14569
  });
14338
14570
  })
14339
14571
  );
14340
- const initialHistoryIndex = (0, import_react93.useMemo)(() => {
14572
+ const initialHistoryIndex = (0, import_react94.useMemo)(() => {
14341
14573
  if ((_initialHistory == null ? void 0 : _initialHistory.index) !== void 0 && (_initialHistory == null ? void 0 : _initialHistory.index) >= 0 && (_initialHistory == null ? void 0 : _initialHistory.index) < blendedHistories.length) {
14342
14574
  return _initialHistory == null ? void 0 : _initialHistory.index;
14343
14575
  }
@@ -14348,7 +14580,7 @@ function EditorProvider({ children }) {
14348
14580
  overrides,
14349
14581
  plugins
14350
14582
  });
14351
- const loadedFieldTransforms = (0, import_react93.useMemo)(() => {
14583
+ const loadedFieldTransforms = (0, import_react94.useMemo)(() => {
14352
14584
  const _plugins = plugins || [];
14353
14585
  const pluginFieldTransforms = _plugins.reduce(
14354
14586
  (acc, plugin) => __spreadValues(__spreadValues({}, acc), plugin.fieldTransforms),
@@ -14357,7 +14589,7 @@ function EditorProvider({ children }) {
14357
14589
  return __spreadValues(__spreadValues({}, pluginFieldTransforms), fieldTransforms);
14358
14590
  }, [fieldTransforms, plugins]);
14359
14591
  const instanceId = useSafeId();
14360
- const generateAppStore = (0, import_react93.useCallback)(
14592
+ const generateAppStore = (0, import_react94.useCallback)(
14361
14593
  (state) => {
14362
14594
  return {
14363
14595
  instanceId,
@@ -14389,15 +14621,15 @@ function EditorProvider({ children }) {
14389
14621
  loadedFieldTransforms
14390
14622
  ]
14391
14623
  );
14392
- const [appStore] = (0, import_react93.useState)(
14624
+ const [appStore] = (0, import_react94.useState)(
14393
14625
  () => createAppStore(generateAppStore(initialAppState))
14394
14626
  );
14395
- (0, import_react93.useEffect)(() => {
14627
+ (0, import_react94.useEffect)(() => {
14396
14628
  if (process.env.NODE_ENV !== "production") {
14397
14629
  window.__PUCK_INTERNAL_DO_NOT_USE = { appStore };
14398
14630
  }
14399
14631
  }, [appStore]);
14400
- (0, import_react93.useEffect)(() => {
14632
+ (0, import_react94.useEffect)(() => {
14401
14633
  const state = appStore.getState().state;
14402
14634
  appStore.setState(__spreadValues({}, generateAppStore(state)));
14403
14635
  }, [generateAppStore]);
@@ -14406,8 +14638,8 @@ function EditorProvider({ children }) {
14406
14638
  index: initialHistoryIndex,
14407
14639
  initialAppState
14408
14640
  });
14409
- const previousData = (0, import_react93.useRef)(null);
14410
- (0, import_react93.useEffect)(() => {
14641
+ const previousData = (0, import_react94.useRef)(null);
14642
+ (0, import_react94.useEffect)(() => {
14411
14643
  return appStore.subscribe(
14412
14644
  (s) => s.state.data,
14413
14645
  (data) => {
@@ -14421,7 +14653,7 @@ function EditorProvider({ children }) {
14421
14653
  }, [onChange, config]);
14422
14654
  useRegisterPermissionsSlice(appStore, permissions);
14423
14655
  const uEditorStore = useRegisterUseEditorStore(appStore);
14424
- (0, import_react93.useEffect)(() => {
14656
+ (0, import_react94.useEffect)(() => {
14425
14657
  const { resolveAndCommitData } = appStore.getState();
14426
14658
  setTimeout(() => {
14427
14659
  resolveAndCommitData();
@@ -14732,7 +14964,6 @@ var legacySideBarPlugin = () => ({
14732
14964
  Button,
14733
14965
  ComponentList,
14734
14966
  Drawer,
14735
- DropZone,
14736
14967
  Editor,
14737
14968
  FieldLabel,
14738
14969
  Group,
@@ -14756,6 +14987,7 @@ var legacySideBarPlugin = () => ({
14756
14987
  transformProps,
14757
14988
  useEditor,
14758
14989
  useGetEditor,
14990
+ usePropsContext,
14759
14991
  walkTree
14760
14992
  });
14761
14993
  /*! Bundled license information:
@@ -3,7 +3,6 @@ import {
3
3
  Button,
4
4
  ComponentList,
5
5
  Drawer,
6
- DropZone,
7
6
  Editor,
8
7
  FieldLabel,
9
8
  Render,
@@ -18,14 +17,15 @@ import {
18
17
  renderContext,
19
18
  setDeep,
20
19
  useEditor,
21
- useGetEditor
22
- } from "./chunk-HCFEY5Y7.mjs";
23
- import "./chunk-DB4R5IWG.mjs";
20
+ useGetEditor,
21
+ usePropsContext
22
+ } from "./chunk-W5I2Z7QS.mjs";
23
+ import "./chunk-RNRHREWH.mjs";
24
24
  import {
25
25
  migrate,
26
26
  resolveAllData,
27
27
  transformProps
28
- } from "./chunk-275EJPEB.mjs";
28
+ } from "./chunk-TI3KC54Y.mjs";
29
29
  import "./chunk-6QJ2HF4O.mjs";
30
30
  import {
31
31
  Action,
@@ -35,17 +35,17 @@ import {
35
35
  Label,
36
36
  RichTextMenu,
37
37
  Separator
38
- } from "./chunk-BRDUM7MJ.mjs";
39
- import "./chunk-Z6IIVDFY.mjs";
40
- import "./chunk-6LG4Q4HO.mjs";
41
- import "./chunk-WGPCLAZR.mjs";
42
- import "./chunk-CRF2GWQA.mjs";
43
- import "./chunk-UB2DES2O.mjs";
44
- import "./chunk-VOLQMQPK.mjs";
38
+ } from "./chunk-JUC25FB7.mjs";
39
+ import "./chunk-XI7YTBCP.mjs";
40
+ import "./chunk-EEQGJ6FH.mjs";
41
+ import "./chunk-ZLSPSBV3.mjs";
42
+ import "./chunk-AAK2555H.mjs";
43
+ import "./chunk-M4JDRFYB.mjs";
44
+ import "./chunk-IIRJMJFU.mjs";
45
45
  import "./chunk-Y2EFNT5P.mjs";
46
46
  import {
47
47
  walkTree
48
- } from "./chunk-GAUBBDIR.mjs";
48
+ } from "./chunk-JIXMPJZA.mjs";
49
49
  import {
50
50
  init_react_import
51
51
  } from "./chunk-M6W7YEVX.mjs";
@@ -59,7 +59,6 @@ export {
59
59
  Button,
60
60
  ComponentList,
61
61
  Drawer,
62
- DropZone,
63
62
  Editor,
64
63
  FieldLabel,
65
64
  Group,
@@ -83,5 +82,6 @@ export {
83
82
  transformProps,
84
83
  useEditor,
85
84
  useGetEditor,
85
+ usePropsContext,
86
86
  walkTree
87
87
  };