@reacteditor/core 0.0.9 → 0.0.11

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 (46) hide show
  1. package/README.md +7 -7
  2. package/dist/{Editor-KXEVJBNG.mjs → Editor-GK6JTUPD.mjs} +7 -7
  3. package/dist/{actions-2L-1hQ7r.d.mts → actions-C0LX6bI4.d.mts} +2 -1
  4. package/dist/{actions-2L-1hQ7r.d.ts → actions-C0LX6bI4.d.ts} +2 -1
  5. package/dist/{chunk-LRFRIIKG.mjs → chunk-56I7ST5F.mjs} +1 -1
  6. package/dist/{chunk-DU757QEH.mjs → chunk-74TOLW7F.mjs} +1561 -1266
  7. package/dist/{chunk-IIRJMJFU.mjs → chunk-ERNSJXVF.mjs} +1 -0
  8. package/dist/{chunk-TI3KC54Y.mjs → chunk-II42EKFK.mjs} +47 -1
  9. package/dist/{chunk-AD7BMXAA.mjs → chunk-MJJPWASL.mjs} +1 -1
  10. package/dist/{chunk-U7VW3V3W.mjs → chunk-TGVAC3JP.mjs} +9 -9
  11. package/dist/{chunk-FT6UFK7G.mjs → chunk-X4EUZIHA.mjs} +1 -1
  12. package/dist/{chunk-OIFPBVSF.mjs → chunk-XLVEWZWT.mjs} +1 -1
  13. package/dist/{chunk-AJWRDM22.mjs → chunk-YBG2RYVF.mjs} +5 -5
  14. package/dist/{full-ZFZZ626B.mjs → full-IUPXFMQP.mjs} +6 -6
  15. package/dist/{index-BXuSeNez.d.mts → index-DMbFEg8G.d.mts} +1 -1
  16. package/dist/{index-BNsSzMCj.d.ts → index-DmThy7vE.d.ts} +1 -1
  17. package/dist/index.css +109 -109
  18. package/dist/index.d.mts +155 -17
  19. package/dist/index.d.ts +155 -17
  20. package/dist/index.js +1080 -731
  21. package/dist/index.mjs +31 -15
  22. package/dist/internal.d.mts +2 -2
  23. package/dist/internal.d.ts +2 -2
  24. package/dist/{loaded-GLBLMTBL.mjs → loaded-BT7NIVEO.mjs} +3 -3
  25. package/dist/{loaded-O4QHGE26.mjs → loaded-HVOKDVC3.mjs} +3 -3
  26. package/dist/{loaded-R34BR6I5.mjs → loaded-YFYCF5F4.mjs} +3 -3
  27. package/dist/nextjs.d.mts +38 -0
  28. package/dist/nextjs.d.ts +38 -0
  29. package/dist/nextjs.js +65 -0
  30. package/dist/nextjs.mjs +30 -0
  31. package/dist/no-external.css +109 -109
  32. package/dist/no-external.d.mts +4 -4
  33. package/dist/no-external.d.ts +4 -4
  34. package/dist/no-external.js +1080 -731
  35. package/dist/no-external.mjs +31 -15
  36. package/dist/remix.d.mts +33 -0
  37. package/dist/remix.d.ts +33 -0
  38. package/dist/remix.js +65 -0
  39. package/dist/remix.mjs +30 -0
  40. package/dist/rsc.d.mts +2 -2
  41. package/dist/rsc.d.ts +2 -2
  42. package/dist/rsc.js +49 -0
  43. package/dist/rsc.mjs +6 -2
  44. package/dist/{walk-tree-C9GrSWsR.d.ts → walk-tree-5oDs6qOL.d.mts} +33 -2
  45. package/dist/{walk-tree-4C3ODO3X.d.mts → walk-tree-B1q6t5Jp.d.ts} +33 -2
  46. package/package.json +17 -6
@@ -1,7 +1,13 @@
1
1
  import {
2
2
  EditorInner,
3
3
  LoadedRichTextMenu
4
- } from "./chunk-AJWRDM22.mjs";
4
+ } from "./chunk-YBG2RYVF.mjs";
5
+ import {
6
+ ActionBar,
7
+ IconButton,
8
+ LoadedRichTextMenuInner,
9
+ Loader
10
+ } from "./chunk-TGVAC3JP.mjs";
5
11
  import {
6
12
  RichTextRenderFallback,
7
13
  SlotRender,
@@ -10,13 +16,7 @@ import {
10
16
  getSlotTransform,
11
17
  useRichtextProps,
12
18
  useSlots
13
- } from "./chunk-TI3KC54Y.mjs";
14
- import {
15
- ActionBar,
16
- IconButton,
17
- LoadedRichTextMenuInner,
18
- Loader
19
- } from "./chunk-U7VW3V3W.mjs";
19
+ } from "./chunk-II42EKFK.mjs";
20
20
  import {
21
21
  Check,
22
22
  ChevronDown,
@@ -60,7 +60,7 @@ import {
60
60
  useRegisterFieldsSlice,
61
61
  useRegisterHistorySlice,
62
62
  useRegisterPermissionsSlice
63
- } from "./chunk-LRFRIIKG.mjs";
63
+ } from "./chunk-56I7ST5F.mjs";
64
64
  import {
65
65
  getItem,
66
66
  insert,
@@ -71,7 +71,7 @@ import {
71
71
  import {
72
72
  defaultAppState,
73
73
  defaultViewports
74
- } from "./chunk-IIRJMJFU.mjs";
74
+ } from "./chunk-ERNSJXVF.mjs";
75
75
  import {
76
76
  get_class_name_factory_default
77
77
  } from "./chunk-Y2EFNT5P.mjs";
@@ -2146,7 +2146,7 @@ EditorFallback.displayName = "EditorFallback";
2146
2146
  // components/AutoField/fields/RichtextField/index.tsx
2147
2147
  import { Fragment as Fragment3, jsx as jsx20 } from "react/jsx-runtime";
2148
2148
  var Editor = lazy(
2149
- () => import("./Editor-KXEVJBNG.mjs").then((m) => ({
2149
+ () => import("./Editor-GK6JTUPD.mjs").then((m) => ({
2150
2150
  default: m.Editor
2151
2151
  }))
2152
2152
  );
@@ -3219,7 +3219,7 @@ init_react_import();
3219
3219
 
3220
3220
  // css-module:/Users/rami/Documents/apps/react-editor/packages/core/components/Drawer/styles.module.css#css-module
3221
3221
  init_react_import();
3222
- var styles_module_default12 = { "Drawer": "_Drawer_146py_1", "Drawer--tile": "_Drawer--tile_146py_8", "Drawer-draggable": "_Drawer-draggable_146py_19", "Drawer-draggableBg": "_Drawer-draggableBg_146py_23", "DrawerItem-draggable": "_DrawerItem-draggable_146py_33", "DrawerItem-icon": "_DrawerItem-icon_146py_50", "DrawerItem--disabled": "_DrawerItem--disabled_146py_56", "DrawerItem": "_DrawerItem_146py_33", "Drawer--isDraggingFrom": "_Drawer--isDraggingFrom_146py_66", "DrawerItem-name": "_DrawerItem-name_146py_91" };
3222
+ var styles_module_default12 = { "Drawer": "_Drawer_1h4db_1", "Drawer--tile": "_Drawer--tile_1h4db_8", "Drawer-draggable": "_Drawer-draggable_1h4db_19", "Drawer-draggableBg": "_Drawer-draggableBg_1h4db_23", "DrawerItem-draggable": "_DrawerItem-draggable_1h4db_33", "DrawerItem-icon": "_DrawerItem-icon_1h4db_50", "DrawerItem--disabled": "_DrawerItem--disabled_1h4db_56", "DrawerItem": "_DrawerItem_1h4db_33", "Drawer--isDraggingFrom": "_Drawer--isDraggingFrom_1h4db_66", "DrawerItem-name": "_DrawerItem-name_1h4db_91" };
3223
3223
 
3224
3224
  // components/Drawer/index.tsx
3225
3225
  import { useMemo as useMemo9, useState as useState11 } from "react";
@@ -4698,7 +4698,7 @@ import {
4698
4698
  } from "react";
4699
4699
  import { jsx as jsx30 } from "react/jsx-runtime";
4700
4700
  var Editor2 = lazy2(
4701
- () => import("./Editor-KXEVJBNG.mjs").then((m) => ({
4701
+ () => import("./Editor-GK6JTUPD.mjs").then((m) => ({
4702
4702
  default: m.Editor
4703
4703
  }))
4704
4704
  );
@@ -5305,15 +5305,6 @@ var DropZoneEdit = forwardRef(
5305
5305
  }
5306
5306
  }
5307
5307
  }, [zoneType, appStoreApi]);
5308
- useEffect16(() => {
5309
- if (zoneType === "dropzone") {
5310
- if (zoneCompound !== rootDroppableId) {
5311
- console.warn(
5312
- "DropZones have been deprecated in favor of slot fields and will be removed in a future version of Editor. Please see the migration guide: https://www.frontend.co/docs/guides/migrations/dropzones-to-slots"
5313
- );
5314
- }
5315
- }
5316
- }, [zoneType]);
5317
5308
  const contentIds = useMemo12(() => {
5318
5309
  return zoneContentIds || [];
5319
5310
  }, [zoneContentIds]);
@@ -6137,1189 +6128,1172 @@ var blocksPlugin = () => ({
6137
6128
  icon: /* @__PURE__ */ jsx37(Plus, {})
6138
6129
  });
6139
6130
 
6140
- // plugins/outline/index.tsx
6131
+ // plugins/fields/index.tsx
6141
6132
  init_react_import();
6142
6133
 
6143
- // components/Editor/components/Outline/index.tsx
6134
+ // components/Breadcrumbs/index.tsx
6144
6135
  init_react_import();
6145
6136
 
6146
- // components/LayerTree/index.tsx
6137
+ // css-module:/Users/rami/Documents/apps/react-editor/packages/core/components/Breadcrumbs/styles.module.css#css-module
6147
6138
  init_react_import();
6139
+ var styles_module_default17 = { "Breadcrumbs": "_Breadcrumbs_1cjxk_1", "Breadcrumbs-breadcrumb": "_Breadcrumbs-breadcrumb_1cjxk_10", "Breadcrumbs-breadcrumbLabel": "_Breadcrumbs-breadcrumbLabel_1cjxk_17" };
6148
6140
 
6149
- // css-module:/Users/rami/Documents/apps/react-editor/packages/core/components/LayerTree/styles.module.css#css-module
6141
+ // lib/use-breadcrumbs.ts
6150
6142
  init_react_import();
6151
- var styles_module_default17 = { "LayerTree": "_LayerTree_3eixb_1", "LayerTree-zoneTitle": "_LayerTree-zoneTitle_3eixb_11", "LayerTree-helper": "_LayerTree-helper_3eixb_17", "Layer": "_Layer_3eixb_1", "Layer-inner": "_Layer-inner_3eixb_34", "Layer--containsZone": "_Layer--containsZone_3eixb_42", "Layer-clickable": "_Layer-clickable_3eixb_46", "Layer--isSelected": "_Layer--isSelected_3eixb_68", "Layer-icon": "_Layer-icon_3eixb_80", "Layer-zoneIcon": "_Layer-zoneIcon_3eixb_81", "Layer-chevron": "_Layer-chevron_3eixb_85", "Layer--childIsSelected": "_Layer--childIsSelected_3eixb_97", "Layer-zones": "_Layer-zones_3eixb_101", "Layer-title": "_Layer-title_3eixb_117", "Layer-name": "_Layer-name_3eixb_130", "Layer--isGlobal": "_Layer--isGlobal_3eixb_150", "Layer--isUnlinked": "_Layer--isUnlinked_3eixb_171", "Layer-unlinkedGlyph": "_Layer-unlinkedGlyph_3eixb_175" };
6143
+ import { useMemo as useMemo15 } from "react";
6144
+ var useBreadcrumbs = (renderCount) => {
6145
+ const selectedId = useAppStore((s) => {
6146
+ var _a;
6147
+ return (_a = s.selectedItem) == null ? void 0 : _a.props.id;
6148
+ });
6149
+ const config = useAppStore((s) => s.config);
6150
+ const path = useAppStore((s) => {
6151
+ var _a;
6152
+ return (_a = s.state.indexes.nodes[selectedId]) == null ? void 0 : _a.path;
6153
+ });
6154
+ const appStore = useAppStoreApi();
6155
+ return useMemo15(() => {
6156
+ const breadcrumbs = (path == null ? void 0 : path.map((zoneCompound) => {
6157
+ var _a, _b, _c, _d;
6158
+ const [componentId] = zoneCompound.split(":");
6159
+ if (componentId === "root") {
6160
+ return {
6161
+ label: ((_a = config == null ? void 0 : config.root) == null ? void 0 : _a.label) || "Page",
6162
+ selector: null
6163
+ };
6164
+ }
6165
+ const node = appStore.getState().state.indexes.nodes[componentId];
6166
+ const parentId = node.path[node.path.length - 1];
6167
+ const contentIds = ((_b = appStore.getState().state.indexes.zones[parentId]) == null ? void 0 : _b.contentIds) || [];
6168
+ const index = contentIds.indexOf(componentId);
6169
+ const label = node ? (_d = (_c = config.components[node.data.type]) == null ? void 0 : _c.label) != null ? _d : node.data.type : "Component";
6170
+ return {
6171
+ label,
6172
+ selector: node ? {
6173
+ index,
6174
+ zone: node.path[node.path.length - 1]
6175
+ } : null
6176
+ };
6177
+ })) || [];
6178
+ if (renderCount) {
6179
+ return breadcrumbs.slice(breadcrumbs.length - renderCount);
6180
+ }
6181
+ return breadcrumbs;
6182
+ }, [path, renderCount]);
6183
+ };
6152
6184
 
6153
- // components/LayerTree/index.tsx
6185
+ // components/Breadcrumbs/index.tsx
6186
+ import { jsx as jsx38, jsxs as jsxs14 } from "react/jsx-runtime";
6187
+ var getClassName22 = get_class_name_factory_default("Breadcrumbs", styles_module_default17);
6188
+ var Breadcrumbs = ({
6189
+ children,
6190
+ numParents = 1
6191
+ }) => {
6192
+ const setUi = useAppStore((s) => s.setUi);
6193
+ const breadcrumbs = useBreadcrumbs(numParents);
6194
+ return /* @__PURE__ */ jsxs14("div", { className: getClassName22(), children: [
6195
+ breadcrumbs.map((breadcrumb, i) => /* @__PURE__ */ jsxs14("div", { className: getClassName22("breadcrumb"), children: [
6196
+ /* @__PURE__ */ jsx38(
6197
+ "button",
6198
+ {
6199
+ type: "button",
6200
+ className: getClassName22("breadcrumbLabel"),
6201
+ onClick: () => setUi({ itemSelector: breadcrumb.selector }),
6202
+ children: breadcrumb.label
6203
+ }
6204
+ ),
6205
+ /* @__PURE__ */ jsx38(ChevronRight, { size: 14 })
6206
+ ] }, i)),
6207
+ children
6208
+ ] });
6209
+ };
6210
+
6211
+ // components/Editor/components/Fields/index.tsx
6212
+ init_react_import();
6213
+
6214
+ // css-module:/Users/rami/Documents/apps/react-editor/packages/core/components/Editor/components/Fields/styles.module.css#css-module
6215
+ init_react_import();
6216
+ var styles_module_default18 = { "EditorFields": "_EditorFields_3dnua_1", "EditorFields--isLoading": "_EditorFields--isLoading_3dnua_6", "EditorFields-loadingOverlay": "_EditorFields-loadingOverlay_3dnua_10", "EditorFields-loadingOverlayInner": "_EditorFields-loadingOverlayInner_3dnua_25", "EditorFields-field": "_EditorFields-field_3dnua_32", "EditorFields--wrapFields": "_EditorFields--wrapFields_3dnua_36", "EditorFields-syncButton": "_EditorFields-syncButton_3dnua_46", "EditorFields-syncButton--unlinked": "_EditorFields-syncButton--unlinked_3dnua_78" };
6217
+
6218
+ // components/Editor/components/Fields/index.tsx
6154
6219
  import {
6155
- forwardRef as forwardRef2,
6220
+ memo as memo8,
6156
6221
  useCallback as useCallback15,
6157
6222
  useContext as useContext11,
6158
- useRef as useRef11
6223
+ useEffect as useEffect19,
6224
+ useMemo as useMemo16
6159
6225
  } from "react";
6160
- import { useVirtualizer as useVirtualizer2 } from "@tanstack/react-virtual";
6161
- import { Fragment as Fragment8, jsx as jsx38, jsxs as jsxs14 } from "react/jsx-runtime";
6162
- var getClassName22 = get_class_name_factory_default("LayerTree", styles_module_default17);
6163
- var getClassNameLayer = get_class_name_factory_default("Layer", styles_module_default17);
6164
- var DEFAULT_LAYER_ROW_HEIGHT = 32;
6165
- var LAYER_TREE_VIRTUALIZATION_OVERSCAN = 8;
6166
- var MIN_VIRTUALIZED_LAYER_COUNT = 25;
6167
- var measuredRowHeights = /* @__PURE__ */ new Map();
6168
- var getZonesByParent = (zones) => {
6169
- return Object.keys(zones).reduce((acc, zone) => {
6170
- const [parentId] = zone.split(":");
6171
- acc[parentId] = [...acc[parentId] || [], zone];
6172
- return acc;
6173
- }, {});
6174
- };
6175
- var getZoneLabel = (zoneCompound, nodes, config, label) => {
6176
- var _a, _b, _c, _d;
6177
- if (label !== void 0) {
6178
- return label;
6179
- }
6180
- const [componentId, slotId] = zoneCompound.split(":");
6181
- if (!slotId) {
6182
- return;
6183
- }
6184
- const componentType = (_a = nodes[componentId]) == null ? void 0 : _a.data.type;
6185
- const configForComponent = componentType && componentType !== rootAreaId ? config.components[componentType] : config.root;
6186
- return (_d = (_c = (_b = configForComponent == null ? void 0 : configForComponent.fields) == null ? void 0 : _b[slotId]) == null ? void 0 : _c.label) != null ? _d : slotId;
6187
- };
6188
- var buildLayerNode = ({
6189
- config,
6190
- itemId,
6191
- index,
6192
- nodes,
6193
- zoneCompound,
6194
- zones,
6195
- zonesByParent
6196
- }) => {
6197
- var _a, _b, _c;
6198
- const nodeData = nodes[itemId];
6199
- const componentType = ((_a = nodeData == null ? void 0 : nodeData.data.type) == null ? void 0 : _a.toString()) || "Component";
6200
- const label = (_c = (_b = config.components[componentType]) == null ? void 0 : _b.label) != null ? _c : componentType;
6201
- const childZoneCompounds = zonesByParent[itemId] || [];
6202
- return {
6203
- childZones: childZoneCompounds.map(
6204
- (childZoneCompound) => buildLayerTree({
6205
- config,
6206
- nodes,
6207
- zoneCompound: childZoneCompound,
6208
- zones,
6209
- zonesByParent
6210
- })
6211
- ),
6212
- componentType,
6213
- index,
6214
- itemId,
6215
- label,
6216
- zoneCompound
6217
- };
6218
- };
6219
- var buildLayerTree = ({
6220
- config,
6221
- label,
6222
- nodes,
6223
- zoneCompound,
6224
- zones,
6225
- zonesByParent = getZonesByParent(zones)
6226
+ import { useShallow as useShallow7 } from "zustand/react/shallow";
6227
+ import { Fragment as Fragment8, jsx as jsx39, jsxs as jsxs15 } from "react/jsx-runtime";
6228
+ var getClassName23 = get_class_name_factory_default("EditorFields", styles_module_default18);
6229
+ var DefaultFields = ({
6230
+ children
6226
6231
  }) => {
6227
- var _a, _b;
6228
- const contentIds = (_b = (_a = zones[zoneCompound]) == null ? void 0 : _a.contentIds) != null ? _b : [];
6229
- return {
6230
- items: contentIds.map(
6231
- (itemId, index) => buildLayerNode({
6232
- config,
6233
- itemId,
6234
- index,
6235
- nodes,
6236
- zoneCompound,
6237
- zones,
6238
- zonesByParent
6239
- })
6240
- ),
6241
- label: getZoneLabel(zoneCompound, nodes, config, label),
6242
- zoneCompound
6243
- };
6232
+ return /* @__PURE__ */ jsx39(Fragment8, { children });
6244
6233
  };
6245
- var getEstimatedRowHeight = (itemId) => {
6246
- var _a;
6247
- return (_a = measuredRowHeights.get(itemId)) != null ? _a : DEFAULT_LAYER_ROW_HEIGHT;
6248
- };
6249
- var cacheMeasuredRowHeight = (itemId, height) => {
6250
- if (height <= 0) {
6234
+ var createOnChange = (fieldName, appStore) => (value, updatedUi) => __async(null, null, function* () {
6235
+ const { dispatch, state, selectedItem, resolveComponentData } = appStore.getState();
6236
+ const { data, ui } = state;
6237
+ const { itemSelector } = ui;
6238
+ const rootProps = data.root.props || data.root;
6239
+ const currentProps = selectedItem ? selectedItem.props : rootProps;
6240
+ const newProps = __spreadProps(__spreadValues({}, currentProps), { [fieldName]: value });
6241
+ if (selectedItem && itemSelector) {
6242
+ const resolved = yield resolveComponentData(
6243
+ __spreadProps(__spreadValues({}, selectedItem), { props: newProps }),
6244
+ "replace"
6245
+ );
6246
+ const latestSelector = getSelectorForId(
6247
+ appStore.getState().state,
6248
+ selectedItem.props.id
6249
+ );
6250
+ if (!latestSelector) return;
6251
+ dispatch({
6252
+ type: "replace",
6253
+ destinationIndex: latestSelector.index,
6254
+ destinationZone: latestSelector.zone || rootDroppableId,
6255
+ data: resolved.node,
6256
+ ui: updatedUi
6257
+ });
6251
6258
  return;
6252
6259
  }
6253
- measuredRowHeights.set(itemId, height);
6254
- };
6255
- var getScrollParent = (el) => {
6256
- var _a;
6257
- let current = (_a = el == null ? void 0 : el.parentElement) != null ? _a : null;
6258
- while (current) {
6259
- const { overflow, overflowY } = getComputedStyle(current);
6260
- if ([overflow, overflowY].some((value) => /auto|scroll/.test(value))) {
6261
- return current;
6262
- }
6263
- current = current.parentElement;
6260
+ if (data.root.props) {
6261
+ dispatch({
6262
+ type: "replaceRoot",
6263
+ root: (yield resolveComponentData(
6264
+ __spreadProps(__spreadValues({}, data.root), { props: newProps }),
6265
+ "replace"
6266
+ )).node,
6267
+ ui: __spreadValues(__spreadValues({}, ui), updatedUi),
6268
+ recordHistory: true
6269
+ });
6270
+ return;
6264
6271
  }
6265
- return null;
6266
- };
6267
- var Layer = forwardRef2(function Layer2({
6268
- childIsSelected,
6269
- dataIndex,
6270
- depth,
6271
- isSelected,
6272
- node,
6273
- selectedId,
6274
- selectedPathIds
6275
- }, ref) {
6276
- const dispatch = useAppStore((s) => s.dispatch);
6277
- const zoneStore = useContext11(ZoneStoreContext);
6278
- const isHovering = useContextStore(
6279
- ZoneStoreContext,
6280
- (s) => s.hoveringComponent === node.itemId
6272
+ dispatch({
6273
+ type: "setData",
6274
+ data: { root: newProps }
6275
+ });
6276
+ });
6277
+ var FieldsChildInner = ({ fieldName }) => {
6278
+ const field = useAppStore((s) => s.fields.fields[fieldName]);
6279
+ const isReadOnly = useAppStore(
6280
+ (s) => ((s.selectedItem ? s.selectedItem.readOnly : s.state.data.root.readOnly) || {})[fieldName]
6281
6281
  );
6282
- const isGlobal = useAppStore(
6283
- (s) => {
6284
- var _a;
6285
- return ((_a = s.config.components[node.componentType]) == null ? void 0 : _a.global) === true;
6286
- }
6282
+ const id = useAppStore((s) => {
6283
+ if (!field) return null;
6284
+ return s.selectedItem ? `${s.selectedItem.props.id}_${field.type}_${fieldName}` : `root_${field.type}_${fieldName}`;
6285
+ });
6286
+ const permissions = useAppStore(
6287
+ useShallow7((s) => {
6288
+ const { selectedItem, permissions: permissions2 } = s;
6289
+ return selectedItem ? permissions2.getPermissions({ item: selectedItem }) : permissions2.getPermissions({ root: true });
6290
+ })
6287
6291
  );
6288
- const isUnlinked = useAppStore(
6292
+ const appStore = useAppStoreApi();
6293
+ const onChange = useCallback15(createOnChange(fieldName, appStore), [
6294
+ fieldName
6295
+ ]);
6296
+ const { visible = true } = field != null ? field : {};
6297
+ const fieldStore = useContext11(fieldContextStore.ctx);
6298
+ useEffect19(() => {
6299
+ return appStore.subscribe(
6300
+ (s) => {
6301
+ var _a;
6302
+ const data = s.getCurrentData();
6303
+ return (_a = data.props) == null ? void 0 : _a[fieldName];
6304
+ },
6305
+ (value) => {
6306
+ fieldStore.setState({ [fieldName]: value });
6307
+ }
6308
+ );
6309
+ }, [appStore, fieldStore]);
6310
+ if (!field || !id || !visible) return null;
6311
+ if (field.type === "slot") return null;
6312
+ return /* @__PURE__ */ jsx39("div", { className: getClassName23("field"), children: /* @__PURE__ */ jsx39(
6313
+ AutoFieldPrivate,
6314
+ {
6315
+ field,
6316
+ name: fieldName,
6317
+ id,
6318
+ readOnly: !permissions.edit || isReadOnly,
6319
+ onChange
6320
+ }
6321
+ ) }, id);
6322
+ };
6323
+ var FieldsChild = ({ fieldName }) => {
6324
+ const appStore = useAppStoreApi();
6325
+ const initialValue = useMemo16(() => {
6326
+ var _a;
6327
+ const value = (_a = appStore.getState().getCurrentData().props) == null ? void 0 : _a[fieldName];
6328
+ return { [fieldName]: value };
6329
+ }, []);
6330
+ return /* @__PURE__ */ jsx39(fieldContextStore.Provider, { value: initialValue, children: /* @__PURE__ */ jsx39(FieldsChildInner, { fieldName }) });
6331
+ };
6332
+ var FieldsChildMemo = memo8(FieldsChild);
6333
+ var GlobalSyncButton = () => {
6334
+ const appStore = useAppStoreApi();
6335
+ const selectedItem = useAppStore((s) => s.selectedItem);
6336
+ const isGlobalType = useAppStore(
6289
6337
  (s) => {
6290
- var _a, _b;
6291
- return ((_b = (_a = s.state.indexes.nodes[node.itemId]) == null ? void 0 : _a.data) == null ? void 0 : _b.synced) === false;
6338
+ var _a;
6339
+ return selectedItem ? ((_a = s.config.components[selectedItem.type]) == null ? void 0 : _a.global) === true : false;
6292
6340
  }
6293
6341
  );
6294
- const containsZone = node.childZones.length > 0;
6295
- const setItemSelector = useCallback15(
6296
- (itemSelector) => {
6297
- dispatch({ type: "setUi", ui: { itemSelector } });
6298
- },
6299
- [dispatch]
6342
+ if (!selectedItem || !isGlobalType) return null;
6343
+ const isUnlinked = selectedItem.synced === false;
6344
+ const onClick = () => __async(null, null, function* () {
6345
+ const { dispatch, state, resolveComponentData } = appStore.getState();
6346
+ const latestSelector = getSelectorForId(state, selectedItem.props.id);
6347
+ if (!latestSelector) return;
6348
+ const resolved = yield resolveComponentData(
6349
+ __spreadProps(__spreadValues({}, selectedItem), { synced: isUnlinked ? true : false }),
6350
+ "replace"
6351
+ );
6352
+ dispatch({
6353
+ type: "replace",
6354
+ destinationIndex: latestSelector.index,
6355
+ destinationZone: latestSelector.zone || rootDroppableId,
6356
+ data: resolved.node
6357
+ });
6358
+ });
6359
+ const syncButtonClass = [
6360
+ getClassName23("syncButton"),
6361
+ isUnlinked ? styles_module_default18["EditorFields-syncButton--unlinked"] : null
6362
+ ].filter(Boolean).join(" ");
6363
+ return /* @__PURE__ */ jsxs15("button", { type: "button", className: syncButtonClass, onClick, children: [
6364
+ /* @__PURE__ */ jsx39(Link, { size: 14 }),
6365
+ /* @__PURE__ */ jsx39("span", { children: isUnlinked ? "Link to shared" : "Linked to shared" })
6366
+ ] });
6367
+ };
6368
+ var FieldsInternal = ({ wrapFields = true }) => {
6369
+ const overrides = useAppStore((s) => s.overrides);
6370
+ const componentResolving = useAppStore((s) => {
6371
+ var _a, _b;
6372
+ const loadingCount = s.selectedItem ? (_a = s.componentState[s.selectedItem.props.id]) == null ? void 0 : _a.loadingCount : (_b = s.componentState["root"]) == null ? void 0 : _b.loadingCount;
6373
+ return (loadingCount != null ? loadingCount : 0) > 0;
6374
+ });
6375
+ const itemSelector = useAppStore(useShallow7((s) => s.state.ui.itemSelector));
6376
+ const id = useAppStore((s) => {
6377
+ var _a;
6378
+ return (_a = s.selectedItem) == null ? void 0 : _a.props.id;
6379
+ });
6380
+ const appStore = useAppStoreApi();
6381
+ useRegisterFieldsSlice(appStore, id);
6382
+ const fieldsLoading = useAppStore((s) => s.fields.loading);
6383
+ const fieldNames = useAppStore(
6384
+ useShallow7((s) => {
6385
+ if (s.fields.id === id) {
6386
+ return Object.keys(s.fields.fields);
6387
+ }
6388
+ return [];
6389
+ })
6300
6390
  );
6301
- const shouldRenderChildren = isSelected || childIsSelected;
6302
- return /* @__PURE__ */ jsxs14(
6303
- "li",
6391
+ const isLoading = fieldsLoading || componentResolving;
6392
+ const Wrapper = useMemo16(() => overrides.fields || DefaultFields, [overrides]);
6393
+ return /* @__PURE__ */ jsxs15(
6394
+ "form",
6304
6395
  {
6305
- ref,
6306
- className: getClassNameLayer({
6307
- childIsSelected,
6308
- containsZone,
6309
- isHovering,
6310
- isSelected,
6311
- isGlobal: isGlobal && !isUnlinked,
6312
- isUnlinked: isGlobal && isUnlinked
6313
- }),
6314
- "data-index": dataIndex,
6315
- "data-editor-layer-tree-id": node.itemId,
6396
+ className: getClassName23({ wrapFields }),
6397
+ onSubmit: (e) => {
6398
+ e.preventDefault();
6399
+ },
6316
6400
  children: [
6317
- /* @__PURE__ */ jsx38("div", { className: getClassNameLayer("inner"), children: /* @__PURE__ */ jsxs14(
6318
- "button",
6319
- {
6320
- type: "button",
6321
- className: getClassNameLayer("clickable"),
6322
- onClick: () => {
6323
- if (isSelected) {
6324
- setItemSelector(null);
6325
- return;
6326
- }
6327
- setItemSelector({
6328
- index: node.index,
6329
- zone: node.zoneCompound
6330
- });
6331
- zoneStore.getState().scrollToComponent(node.itemId);
6332
- },
6333
- onMouseEnter: (e) => {
6334
- e.stopPropagation();
6335
- zoneStore.setState({ hoveringComponent: node.itemId });
6336
- },
6337
- onMouseLeave: (e) => {
6338
- e.stopPropagation();
6339
- zoneStore.setState({ hoveringComponent: null });
6340
- },
6341
- children: [
6342
- /* @__PURE__ */ jsx38(
6343
- "div",
6344
- {
6345
- className: getClassNameLayer("chevron"),
6346
- title: containsZone ? isSelected ? "Collapse" : "Expand" : void 0,
6347
- children: containsZone && /* @__PURE__ */ jsx38(ChevronRight, { size: "12" })
6348
- }
6349
- ),
6350
- /* @__PURE__ */ jsxs14("div", { className: getClassNameLayer("title"), children: [
6351
- /* @__PURE__ */ jsx38("div", { className: getClassNameLayer("icon"), children: /* @__PURE__ */ jsx38(Component, { size: "16" }) }),
6352
- /* @__PURE__ */ jsx38("div", { className: getClassNameLayer("name"), children: node.label }),
6353
- isGlobal && isUnlinked && /* @__PURE__ */ jsx38(
6354
- "div",
6355
- {
6356
- className: getClassNameLayer("unlinkedGlyph"),
6357
- title: "Unlinked from shared",
6358
- children: /* @__PURE__ */ jsx38(Unlink2, { size: "12" })
6359
- }
6360
- )
6361
- ] })
6362
- ]
6363
- }
6364
- ) }),
6365
- containsZone && shouldRenderChildren && node.childZones.map((childZone) => /* @__PURE__ */ jsx38(
6366
- "div",
6367
- {
6368
- className: getClassNameLayer("zones"),
6369
- children: /* @__PURE__ */ jsx38(
6370
- LayerTreeZone,
6371
- {
6372
- depth: depth + 1,
6373
- selectedId,
6374
- selectedPathIds,
6375
- tree: childZone
6376
- }
6377
- )
6378
- },
6379
- childZone.zoneCompound
6380
- ))
6401
+ /* @__PURE__ */ jsxs15(Wrapper, { isLoading, itemSelector, children: [
6402
+ /* @__PURE__ */ jsx39(GlobalSyncButton, {}),
6403
+ fieldNames.map((fieldName) => /* @__PURE__ */ jsx39(FieldsChildMemo, { fieldName }, fieldName))
6404
+ ] }),
6405
+ isLoading && /* @__PURE__ */ jsx39("div", { className: getClassName23("loadingOverlay"), children: /* @__PURE__ */ jsx39("div", { className: getClassName23("loadingOverlayInner"), children: /* @__PURE__ */ jsx39(Loader, { size: 16 }) }) })
6381
6406
  ]
6382
6407
  }
6383
6408
  );
6409
+ };
6410
+ var Fields = memo8(FieldsInternal);
6411
+
6412
+ // css-module:/Users/rami/Documents/apps/react-editor/packages/core/plugins/fields/styles.module.css#css-module
6413
+ init_react_import();
6414
+ var styles_module_default19 = { "FieldsPlugin": "_FieldsPlugin_262zt_1", "FieldsPlugin-header": "_FieldsPlugin-header_262zt_7" };
6415
+
6416
+ // plugins/fields/index.tsx
6417
+ import { jsx as jsx40, jsxs as jsxs16 } from "react/jsx-runtime";
6418
+ var getClassName24 = get_class_name_factory_default("FieldsPlugin", styles_module_default19);
6419
+ var CurrentTitle = () => {
6420
+ const label = useAppStore((s) => {
6421
+ var _a, _b;
6422
+ const selectedItem = s.selectedItem;
6423
+ return selectedItem ? (_b = (_a = s.config.components[selectedItem.type]) == null ? void 0 : _a.label) != null ? _b : selectedItem.type : "Page";
6424
+ });
6425
+ return label;
6426
+ };
6427
+ var fieldsPlugin = ({ desktopSideBar = "right" } = {}) => ({
6428
+ name: "fields",
6429
+ label: "Fields",
6430
+ render: () => /* @__PURE__ */ jsxs16("div", { className: getClassName24(), children: [
6431
+ /* @__PURE__ */ jsx40("div", { className: getClassName24("header"), children: /* @__PURE__ */ jsx40(Breadcrumbs, { numParents: 2, children: /* @__PURE__ */ jsx40(CurrentTitle, {}) }) }),
6432
+ /* @__PURE__ */ jsx40(Fields, {})
6433
+ ] }),
6434
+ icon: /* @__PURE__ */ jsx40(RectangleEllipsis, {}),
6435
+ mobileOnly: desktopSideBar === "right"
6384
6436
  });
6385
- var LayerTreeZone = ({
6386
- depth,
6387
- selectedId,
6388
- selectedPathIds,
6389
- tree
6390
- }) => {
6391
- const shouldVirtualize = depth === 0 && tree.items.length >= MIN_VIRTUALIZED_LAYER_COUNT;
6392
- return /* @__PURE__ */ jsxs14(Fragment8, { children: [
6393
- tree.label && /* @__PURE__ */ jsx38("div", { className: getClassName22("zoneTitle"), children: tree.label }),
6394
- shouldVirtualize ? /* @__PURE__ */ jsx38(
6395
- VirtualizedLayerTreeItems,
6396
- {
6397
- depth,
6398
- selectedId,
6399
- selectedPathIds,
6400
- tree
6401
- }
6402
- ) : /* @__PURE__ */ jsx38(
6403
- StaticLayerTreeItems,
6404
- {
6405
- depth,
6406
- selectedId,
6407
- selectedPathIds,
6408
- tree
6437
+
6438
+ // components/Editor/index.tsx
6439
+ init_react_import();
6440
+ import {
6441
+ createContext as createContext8,
6442
+ useCallback as useCallback25,
6443
+ useContext as useContext15,
6444
+ useEffect as useEffect26,
6445
+ useMemo as useMemo24,
6446
+ useRef as useRef19,
6447
+ useState as useState24
6448
+ } from "react";
6449
+
6450
+ // components/Editor/components/Preview/index.tsx
6451
+ init_react_import();
6452
+ import { useCallback as useCallback16, useEffect as useEffect21, useRef as useRef11, useMemo as useMemo17 } from "react";
6453
+
6454
+ // components/AutoFrame/index.tsx
6455
+ init_react_import();
6456
+ import {
6457
+ createContext as createContext6,
6458
+ useContext as useContext12,
6459
+ useEffect as useEffect20,
6460
+ useState as useState18
6461
+ } from "react";
6462
+ import hash from "object-hash";
6463
+ import { createPortal as createPortal3 } from "react-dom";
6464
+ import { Fragment as Fragment9, jsx as jsx41 } from "react/jsx-runtime";
6465
+ var styleSelector = 'style, link[rel="stylesheet"]';
6466
+ var collectStyles = (doc) => {
6467
+ const collected = [];
6468
+ doc.querySelectorAll(styleSelector).forEach((style) => {
6469
+ if (style.tagName === "STYLE") {
6470
+ const hasContent = !!style.innerHTML.trim();
6471
+ if (hasContent) {
6472
+ collected.push(style);
6409
6473
  }
6410
- )
6411
- ] });
6474
+ } else {
6475
+ collected.push(style);
6476
+ }
6477
+ });
6478
+ return collected;
6412
6479
  };
6413
- var StaticLayerTreeItems = ({
6414
- depth,
6415
- selectedId,
6416
- selectedPathIds,
6417
- tree
6418
- }) => {
6419
- return /* @__PURE__ */ jsxs14("ul", { className: getClassName22(), children: [
6420
- tree.items.length === 0 && /* @__PURE__ */ jsx38("div", { className: getClassName22("helper"), children: "empty" }),
6421
- tree.items.map((node) => /* @__PURE__ */ jsx38(
6422
- Layer,
6423
- {
6424
- childIsSelected: selectedPathIds.has(node.itemId),
6425
- depth,
6426
- isSelected: selectedId === node.itemId,
6427
- node,
6428
- selectedId,
6429
- selectedPathIds
6430
- },
6431
- node.itemId
6432
- ))
6433
- ] });
6434
- };
6435
- var VirtualizedLayerTreeItems = ({
6436
- depth,
6437
- selectedId,
6438
- selectedPathIds,
6439
- tree
6440
- }) => {
6441
- const listRef = useRef11(null);
6442
- const virtualizer = useVirtualizer2({
6443
- count: tree.items.length,
6444
- estimateSize: (index) => getEstimatedRowHeight(tree.items[index].itemId),
6445
- getItemKey: (index) => tree.items[index].itemId,
6446
- getScrollElement: () => getScrollParent(listRef.current),
6447
- overscan: LAYER_TREE_VIRTUALIZATION_OVERSCAN,
6448
- measureElement: (element) => {
6449
- const height = Math.ceil(element.getBoundingClientRect().height);
6450
- const itemId = element.dataset.editorLayerTreeId;
6451
- if (itemId) {
6452
- cacheMeasuredRowHeight(itemId, height);
6453
- }
6454
- return height || DEFAULT_LAYER_ROW_HEIGHT;
6455
- }
6480
+ var getStyleSheet = (el) => {
6481
+ return Array.from(document.styleSheets).find((ss) => {
6482
+ const ownerNode = ss.ownerNode;
6483
+ return ownerNode.href === el.href;
6456
6484
  });
6457
- const virtualItems = virtualizer.getVirtualItems();
6458
- const totalSize = virtualizer.getTotalSize();
6459
- const renderedItems = [];
6460
- let previousEnd = 0;
6461
- let previousIndex = -1;
6462
- virtualItems.forEach((virtualItem) => {
6463
- const node = tree.items[virtualItem.index];
6464
- const gapSize = Math.max(virtualItem.start - previousEnd, 0);
6465
- if (gapSize > 0) {
6466
- renderedItems.push(
6467
- /* @__PURE__ */ jsx38(
6468
- "li",
6469
- {
6470
- "aria-hidden": "true",
6471
- style: { height: `${gapSize}px` }
6472
- },
6473
- `gap:${tree.zoneCompound}:${previousIndex}:${virtualItem.index}`
6474
- )
6485
+ };
6486
+ var getStyles = (styleSheet) => {
6487
+ if (styleSheet) {
6488
+ try {
6489
+ return Array.from(styleSheet.cssRules).map((rule) => rule.cssText).join("");
6490
+ } catch (e) {
6491
+ console.warn(
6492
+ "Access to stylesheet %s is denied. Ignoring\u2026",
6493
+ styleSheet.href
6475
6494
  );
6476
6495
  }
6477
- renderedItems.push(
6478
- /* @__PURE__ */ jsx38(
6479
- Layer,
6480
- {
6481
- childIsSelected: selectedPathIds.has(node.itemId),
6482
- dataIndex: virtualItem.index,
6483
- depth,
6484
- isSelected: selectedId === node.itemId,
6485
- node,
6486
- ref: virtualizer.measureElement,
6487
- selectedId,
6488
- selectedPathIds
6489
- },
6490
- node.itemId
6491
- )
6492
- );
6493
- previousEnd = virtualItem.end;
6494
- previousIndex = virtualItem.index;
6495
- });
6496
- const trailingGap = Math.max(totalSize - previousEnd, 0);
6497
- if (trailingGap > 0) {
6498
- renderedItems.push(
6499
- /* @__PURE__ */ jsx38(
6500
- "li",
6501
- {
6502
- "aria-hidden": "true",
6503
- style: { height: `${trailingGap}px` }
6504
- },
6505
- `gap:${tree.zoneCompound}:${previousIndex}:end`
6506
- )
6507
- );
6508
6496
  }
6509
- return /* @__PURE__ */ jsxs14("ul", { className: getClassName22(), ref: listRef, children: [
6510
- tree.items.length === 0 && /* @__PURE__ */ jsx38("div", { className: getClassName22("helper"), children: "empty" }),
6511
- renderedItems
6512
- ] });
6513
- };
6514
- var LayerTree = ({
6515
- selectedId,
6516
- selectedPathIds,
6517
- trees
6518
- }) => {
6519
- return /* @__PURE__ */ jsx38(Fragment8, { children: trees.map((tree) => /* @__PURE__ */ jsx38(
6520
- LayerTreeZone,
6521
- {
6522
- depth: 0,
6523
- selectedId,
6524
- selectedPathIds,
6525
- tree
6526
- },
6527
- tree.zoneCompound
6528
- )) });
6529
- };
6530
-
6531
- // components/Editor/components/Outline/index.tsx
6532
- import { useMemo as useMemo15 } from "react";
6533
-
6534
- // lib/data/find-zones-for-area.ts
6535
- init_react_import();
6536
- var findZonesForArea = (state, area) => {
6537
- return Object.keys(state.indexes.zones).filter(
6538
- (zone) => zone.split(":")[0] === area
6539
- );
6540
- };
6541
-
6542
- // components/Editor/components/Outline/index.tsx
6543
- import { useShallow as useShallow7 } from "zustand/react/shallow";
6544
- import { jsx as jsx39 } from "react/jsx-runtime";
6545
- var Outline = () => {
6546
- const outlineOverride = useAppStore((s) => s.overrides.outline);
6547
- const config = useAppStore((s) => s.config);
6548
- const nodes = useAppStore((s) => s.state.indexes.nodes);
6549
- const zones = useAppStore((s) => s.state.indexes.zones);
6550
- const selectedId = useAppStore((s) => {
6551
- var _a;
6552
- return ((_a = s.selectedItem) == null ? void 0 : _a.props.id) || null;
6553
- });
6554
- const rootZones = useAppStore(
6555
- useShallow7((s) => findZonesForArea(s.state, "root"))
6556
- );
6557
- const selectedPathIds = useMemo15(() => {
6558
- var _a;
6559
- const selectedPath = selectedId ? (_a = nodes[selectedId]) == null ? void 0 : _a.path : null;
6560
- return new Set(
6561
- (selectedPath == null ? void 0 : selectedPath.map((candidate) => candidate.split(":")[0]).filter(Boolean)) || []
6562
- );
6563
- }, [nodes, selectedId]);
6564
- const trees = useMemo15(
6565
- () => rootZones.map(
6566
- (zoneCompound) => buildLayerTree({
6567
- config,
6568
- label: rootZones.length === 1 ? "" : zoneCompound.split(":")[1],
6569
- nodes,
6570
- zoneCompound,
6571
- zones
6572
- })
6573
- ),
6574
- [config, nodes, rootZones, zones]
6575
- );
6576
- const Wrapper = useMemo15(() => outlineOverride || "div", [outlineOverride]);
6577
- return /* @__PURE__ */ jsx39(Wrapper, { children: /* @__PURE__ */ jsx39(
6578
- LayerTree,
6579
- {
6580
- selectedId,
6581
- selectedPathIds,
6582
- trees
6583
- }
6584
- ) });
6497
+ return "";
6585
6498
  };
6586
-
6587
- // css-module:/Users/rami/Documents/apps/react-editor/packages/core/plugins/outline/styles.module.css#css-module
6588
- init_react_import();
6589
- var styles_module_default18 = { "OutlinePlugin": "_OutlinePlugin_q92j6_1" };
6590
-
6591
- // plugins/outline/index.tsx
6592
- import { jsx as jsx40 } from "react/jsx-runtime";
6593
- var getClassName23 = get_class_name_factory_default("OutlinePlugin", styles_module_default18);
6594
- var outlinePlugin = () => ({
6595
- name: "outline",
6596
- label: "Outline",
6597
- render: () => /* @__PURE__ */ jsx40("div", { className: getClassName23(), children: /* @__PURE__ */ jsx40(Outline, {}) }),
6598
- icon: /* @__PURE__ */ jsx40(Layers, {})
6599
- });
6600
-
6601
- // plugins/fields/index.tsx
6602
- init_react_import();
6603
-
6604
- // components/Breadcrumbs/index.tsx
6605
- init_react_import();
6606
-
6607
- // css-module:/Users/rami/Documents/apps/react-editor/packages/core/components/Breadcrumbs/styles.module.css#css-module
6608
- init_react_import();
6609
- var styles_module_default19 = { "Breadcrumbs": "_Breadcrumbs_1cjxk_1", "Breadcrumbs-breadcrumb": "_Breadcrumbs-breadcrumb_1cjxk_10", "Breadcrumbs-breadcrumbLabel": "_Breadcrumbs-breadcrumbLabel_1cjxk_17" };
6610
-
6611
- // lib/use-breadcrumbs.ts
6612
- init_react_import();
6613
- import { useMemo as useMemo16 } from "react";
6614
- var useBreadcrumbs = (renderCount) => {
6615
- const selectedId = useAppStore((s) => {
6616
- var _a;
6617
- return (_a = s.selectedItem) == null ? void 0 : _a.props.id;
6618
- });
6619
- const config = useAppStore((s) => s.config);
6620
- const path = useAppStore((s) => {
6621
- var _a;
6622
- return (_a = s.state.indexes.nodes[selectedId]) == null ? void 0 : _a.path;
6623
- });
6624
- const appStore = useAppStoreApi();
6625
- return useMemo16(() => {
6626
- const breadcrumbs = (path == null ? void 0 : path.map((zoneCompound) => {
6627
- var _a, _b, _c, _d;
6628
- const [componentId] = zoneCompound.split(":");
6629
- if (componentId === "root") {
6630
- return {
6631
- label: ((_a = config == null ? void 0 : config.root) == null ? void 0 : _a.label) || "Page",
6632
- selector: null
6633
- };
6634
- }
6635
- const node = appStore.getState().state.indexes.nodes[componentId];
6636
- const parentId = node.path[node.path.length - 1];
6637
- const contentIds = ((_b = appStore.getState().state.indexes.zones[parentId]) == null ? void 0 : _b.contentIds) || [];
6638
- const index = contentIds.indexOf(componentId);
6639
- const label = node ? (_d = (_c = config.components[node.data.type]) == null ? void 0 : _c.label) != null ? _d : node.data.type : "Component";
6640
- return {
6641
- label,
6642
- selector: node ? {
6643
- index,
6644
- zone: node.path[node.path.length - 1]
6645
- } : null
6646
- };
6647
- })) || [];
6648
- if (renderCount) {
6649
- return breadcrumbs.slice(breadcrumbs.length - renderCount);
6650
- }
6651
- return breadcrumbs;
6652
- }, [path, renderCount]);
6499
+ var syncAttributes = (sourceElement, targetElement) => {
6500
+ const attributes = sourceElement.attributes;
6501
+ if ((attributes == null ? void 0 : attributes.length) > 0) {
6502
+ Array.from(attributes).forEach((attribute) => {
6503
+ targetElement.setAttribute(attribute.name, attribute.value);
6504
+ });
6505
+ }
6653
6506
  };
6654
-
6655
- // components/Breadcrumbs/index.tsx
6656
- import { jsx as jsx41, jsxs as jsxs15 } from "react/jsx-runtime";
6657
- var getClassName24 = get_class_name_factory_default("Breadcrumbs", styles_module_default19);
6658
- var Breadcrumbs = ({
6507
+ var defer = (fn) => setTimeout(fn, 0);
6508
+ var CopyHostStyles = ({
6659
6509
  children,
6660
- numParents = 1
6510
+ debug = false,
6511
+ onStylesLoaded = () => null
6661
6512
  }) => {
6662
- const setUi = useAppStore((s) => s.setUi);
6663
- const breadcrumbs = useBreadcrumbs(numParents);
6664
- return /* @__PURE__ */ jsxs15("div", { className: getClassName24(), children: [
6665
- breadcrumbs.map((breadcrumb, i) => /* @__PURE__ */ jsxs15("div", { className: getClassName24("breadcrumb"), children: [
6666
- /* @__PURE__ */ jsx41(
6667
- "button",
6668
- {
6669
- type: "button",
6670
- className: getClassName24("breadcrumbLabel"),
6671
- onClick: () => setUi({ itemSelector: breadcrumb.selector }),
6672
- children: breadcrumb.label
6673
- }
6674
- ),
6675
- /* @__PURE__ */ jsx41(ChevronRight, { size: 14 })
6676
- ] }, i)),
6677
- children
6678
- ] });
6679
- };
6680
-
6681
- // components/Editor/components/Fields/index.tsx
6682
- init_react_import();
6683
-
6684
- // css-module:/Users/rami/Documents/apps/react-editor/packages/core/components/Editor/components/Fields/styles.module.css#css-module
6685
- init_react_import();
6686
- var styles_module_default20 = { "EditorFields": "_EditorFields_3dnua_1", "EditorFields--isLoading": "_EditorFields--isLoading_3dnua_6", "EditorFields-loadingOverlay": "_EditorFields-loadingOverlay_3dnua_10", "EditorFields-loadingOverlayInner": "_EditorFields-loadingOverlayInner_3dnua_25", "EditorFields-field": "_EditorFields-field_3dnua_32", "EditorFields--wrapFields": "_EditorFields--wrapFields_3dnua_36", "EditorFields-syncButton": "_EditorFields-syncButton_3dnua_46", "EditorFields-syncButton--unlinked": "_EditorFields-syncButton--unlinked_3dnua_78" };
6687
-
6688
- // components/Editor/components/Fields/index.tsx
6689
- import {
6690
- memo as memo8,
6691
- useCallback as useCallback16,
6692
- useContext as useContext12,
6693
- useEffect as useEffect19,
6694
- useMemo as useMemo17
6695
- } from "react";
6696
- import { useShallow as useShallow8 } from "zustand/react/shallow";
6697
- import { Fragment as Fragment9, jsx as jsx42, jsxs as jsxs16 } from "react/jsx-runtime";
6698
- var getClassName25 = get_class_name_factory_default("EditorFields", styles_module_default20);
6699
- var DefaultFields = ({
6700
- children
6701
- }) => {
6702
- return /* @__PURE__ */ jsx42(Fragment9, { children });
6703
- };
6704
- var createOnChange = (fieldName, appStore) => (value, updatedUi) => __async(null, null, function* () {
6705
- const { dispatch, state, selectedItem, resolveComponentData } = appStore.getState();
6706
- const { data, ui } = state;
6707
- const { itemSelector } = ui;
6708
- const rootProps = data.root.props || data.root;
6709
- const currentProps = selectedItem ? selectedItem.props : rootProps;
6710
- const newProps = __spreadProps(__spreadValues({}, currentProps), { [fieldName]: value });
6711
- if (selectedItem && itemSelector) {
6712
- const resolved = yield resolveComponentData(
6713
- __spreadProps(__spreadValues({}, selectedItem), { props: newProps }),
6714
- "replace"
6715
- );
6716
- const latestSelector = getSelectorForId(
6717
- appStore.getState().state,
6718
- selectedItem.props.id
6719
- );
6720
- if (!latestSelector) return;
6721
- dispatch({
6722
- type: "replace",
6723
- destinationIndex: latestSelector.index,
6724
- destinationZone: latestSelector.zone || rootDroppableId,
6725
- data: resolved.node,
6726
- ui: updatedUi
6513
+ const { document: doc, window: win } = useFrame();
6514
+ useEffect20(() => {
6515
+ if (!win || !doc) {
6516
+ return () => {
6517
+ };
6518
+ }
6519
+ let elements = [];
6520
+ const hashes = {};
6521
+ const lookupEl = (el) => elements.findIndex((elementMap) => elementMap.original === el);
6522
+ const mirrorEl = (el, inlineStyles = false) => __async(null, null, function* () {
6523
+ let mirror;
6524
+ if (el.nodeName === "LINK" && inlineStyles) {
6525
+ mirror = document.createElement("style");
6526
+ mirror.type = "text/css";
6527
+ let styleSheet = getStyleSheet(el);
6528
+ if (!styleSheet) {
6529
+ yield new Promise((resolve) => {
6530
+ const fn = () => {
6531
+ resolve();
6532
+ el.removeEventListener("load", fn);
6533
+ };
6534
+ el.addEventListener("load", fn);
6535
+ });
6536
+ styleSheet = getStyleSheet(el);
6537
+ }
6538
+ const styles2 = getStyles(styleSheet);
6539
+ if (!styles2) {
6540
+ if (debug) {
6541
+ console.warn(
6542
+ `Tried to load styles for link element, but couldn't find them. Skipping...`
6543
+ );
6544
+ }
6545
+ return;
6546
+ }
6547
+ mirror.innerHTML = styles2;
6548
+ mirror.setAttribute("data-href", el.getAttribute("href"));
6549
+ } else {
6550
+ mirror = el.cloneNode(true);
6551
+ }
6552
+ return mirror;
6727
6553
  });
6728
- return;
6729
- }
6730
- if (data.root.props) {
6731
- dispatch({
6732
- type: "replaceRoot",
6733
- root: (yield resolveComponentData(
6734
- __spreadProps(__spreadValues({}, data.root), { props: newProps }),
6735
- "replace"
6736
- )).node,
6737
- ui: __spreadValues(__spreadValues({}, ui), updatedUi),
6738
- recordHistory: true
6554
+ const addEl = (el) => __async(null, null, function* () {
6555
+ const index = lookupEl(el);
6556
+ if (index > -1) {
6557
+ if (debug)
6558
+ console.log(
6559
+ `Tried to add an element that was already mirrored. Updating instead...`
6560
+ );
6561
+ elements[index].mirror.innerText = el.innerText;
6562
+ return;
6563
+ }
6564
+ const mirror = yield mirrorEl(el);
6565
+ if (!mirror) {
6566
+ return;
6567
+ }
6568
+ const elHash = hash(mirror.outerHTML);
6569
+ if (hashes[elHash]) {
6570
+ if (debug)
6571
+ console.log(
6572
+ `iframe already contains element that is being mirrored. Skipping...`
6573
+ );
6574
+ return;
6575
+ }
6576
+ hashes[elHash] = true;
6577
+ doc.head.append(mirror);
6578
+ elements.push({ original: el, mirror });
6579
+ if (debug) console.log(`Added style node ${el.outerHTML}`);
6739
6580
  });
6740
- return;
6741
- }
6742
- dispatch({
6743
- type: "setData",
6744
- data: { root: newProps }
6745
- });
6746
- });
6747
- var FieldsChildInner = ({ fieldName }) => {
6748
- const field = useAppStore((s) => s.fields.fields[fieldName]);
6749
- const isReadOnly = useAppStore(
6750
- (s) => ((s.selectedItem ? s.selectedItem.readOnly : s.state.data.root.readOnly) || {})[fieldName]
6751
- );
6752
- const id = useAppStore((s) => {
6753
- if (!field) return null;
6754
- return s.selectedItem ? `${s.selectedItem.props.id}_${field.type}_${fieldName}` : `root_${field.type}_${fieldName}`;
6755
- });
6756
- const permissions = useAppStore(
6757
- useShallow8((s) => {
6758
- const { selectedItem, permissions: permissions2 } = s;
6759
- return selectedItem ? permissions2.getPermissions({ item: selectedItem }) : permissions2.getPermissions({ root: true });
6760
- })
6761
- );
6762
- const appStore = useAppStoreApi();
6763
- const onChange = useCallback16(createOnChange(fieldName, appStore), [
6764
- fieldName
6765
- ]);
6766
- const { visible = true } = field != null ? field : {};
6767
- const fieldStore = useContext12(fieldContextStore.ctx);
6768
- useEffect19(() => {
6769
- return appStore.subscribe(
6770
- (s) => {
6771
- var _a;
6772
- const data = s.getCurrentData();
6773
- return (_a = data.props) == null ? void 0 : _a[fieldName];
6774
- },
6775
- (value) => {
6776
- fieldStore.setState({ [fieldName]: value });
6581
+ const removeEl = (el) => {
6582
+ var _a, _b;
6583
+ const index = lookupEl(el);
6584
+ if (index === -1) {
6585
+ if (debug)
6586
+ console.log(
6587
+ `Tried to remove an element that did not exist. Skipping...`
6588
+ );
6589
+ return;
6777
6590
  }
6778
- );
6779
- }, [appStore, fieldStore]);
6780
- if (!field || !id || !visible) return null;
6781
- if (field.type === "slot") return null;
6782
- return /* @__PURE__ */ jsx42("div", { className: getClassName25("field"), children: /* @__PURE__ */ jsx42(
6783
- AutoFieldPrivate,
6784
- {
6785
- field,
6786
- name: fieldName,
6787
- id,
6788
- readOnly: !permissions.edit || isReadOnly,
6789
- onChange
6790
- }
6791
- ) }, id);
6792
- };
6793
- var FieldsChild = ({ fieldName }) => {
6794
- const appStore = useAppStoreApi();
6795
- const initialValue = useMemo17(() => {
6796
- var _a;
6797
- const value = (_a = appStore.getState().getCurrentData().props) == null ? void 0 : _a[fieldName];
6798
- return { [fieldName]: value };
6799
- }, []);
6800
- return /* @__PURE__ */ jsx42(fieldContextStore.Provider, { value: initialValue, children: /* @__PURE__ */ jsx42(FieldsChildInner, { fieldName }) });
6801
- };
6802
- var FieldsChildMemo = memo8(FieldsChild);
6803
- var GlobalSyncButton = () => {
6804
- const appStore = useAppStoreApi();
6805
- const selectedItem = useAppStore((s) => s.selectedItem);
6806
- const isGlobalType = useAppStore(
6807
- (s) => {
6808
- var _a;
6809
- return selectedItem ? ((_a = s.config.components[selectedItem.type]) == null ? void 0 : _a.global) === true : false;
6810
- }
6811
- );
6812
- if (!selectedItem || !isGlobalType) return null;
6813
- const isUnlinked = selectedItem.synced === false;
6814
- const onClick = () => __async(null, null, function* () {
6815
- const { dispatch, state, resolveComponentData } = appStore.getState();
6816
- const latestSelector = getSelectorForId(state, selectedItem.props.id);
6817
- if (!latestSelector) return;
6818
- const resolved = yield resolveComponentData(
6819
- __spreadProps(__spreadValues({}, selectedItem), { synced: isUnlinked ? true : false }),
6820
- "replace"
6821
- );
6822
- dispatch({
6823
- type: "replace",
6824
- destinationIndex: latestSelector.index,
6825
- destinationZone: latestSelector.zone || rootDroppableId,
6826
- data: resolved.node
6591
+ const elHash = hash(el.outerHTML);
6592
+ (_b = (_a = elements[index]) == null ? void 0 : _a.mirror) == null ? void 0 : _b.remove();
6593
+ delete hashes[elHash];
6594
+ if (debug) console.log(`Removed style node ${el.outerHTML}`);
6595
+ };
6596
+ const observer = new MutationObserver((mutations) => {
6597
+ mutations.forEach((mutation) => {
6598
+ if (mutation.type === "childList") {
6599
+ mutation.addedNodes.forEach((node) => {
6600
+ if (node.nodeType === Node.TEXT_NODE || node.nodeType === Node.ELEMENT_NODE) {
6601
+ const el = node.nodeType === Node.TEXT_NODE ? node.parentElement : node;
6602
+ if (el && el.matches(styleSelector)) {
6603
+ defer(() => addEl(el));
6604
+ }
6605
+ }
6606
+ });
6607
+ mutation.removedNodes.forEach((node) => {
6608
+ if (node.nodeType === Node.TEXT_NODE || node.nodeType === Node.ELEMENT_NODE) {
6609
+ const el = node.nodeType === Node.TEXT_NODE ? node.parentElement : node;
6610
+ if (el && el.matches(styleSelector)) {
6611
+ defer(() => removeEl(el));
6612
+ }
6613
+ }
6614
+ });
6615
+ }
6616
+ });
6827
6617
  });
6828
- });
6829
- const syncButtonClass = [
6830
- getClassName25("syncButton"),
6831
- isUnlinked ? styles_module_default20["EditorFields-syncButton--unlinked"] : null
6832
- ].filter(Boolean).join(" ");
6833
- return /* @__PURE__ */ jsxs16("button", { type: "button", className: syncButtonClass, onClick, children: [
6834
- /* @__PURE__ */ jsx42(Link, { size: 14 }),
6835
- /* @__PURE__ */ jsx42("span", { children: isUnlinked ? "Link to shared" : "Linked to shared" })
6836
- ] });
6618
+ const parentDocument = win.parent.document;
6619
+ const collectedStyles = collectStyles(parentDocument);
6620
+ const hrefs = [];
6621
+ let stylesLoaded = 0;
6622
+ const parentHtml = parentDocument.getElementsByTagName("html")[0];
6623
+ syncAttributes(parentHtml, doc.documentElement);
6624
+ const parentBody = parentDocument.getElementsByTagName("body")[0];
6625
+ syncAttributes(parentBody, doc.body);
6626
+ doc.documentElement.style.colorScheme = "light";
6627
+ doc.documentElement.style.background = "#ffffff";
6628
+ Promise.all(
6629
+ collectedStyles.map((styleNode, i) => __async(null, null, function* () {
6630
+ if (styleNode.nodeName === "LINK") {
6631
+ const linkHref = styleNode.href;
6632
+ if (hrefs.indexOf(linkHref) > -1) {
6633
+ return;
6634
+ }
6635
+ hrefs.push(linkHref);
6636
+ }
6637
+ const mirror = yield mirrorEl(styleNode);
6638
+ if (!mirror) return;
6639
+ elements.push({ original: styleNode, mirror });
6640
+ return mirror;
6641
+ }))
6642
+ ).then((mirrorStyles) => {
6643
+ const filtered = mirrorStyles.filter(
6644
+ (el) => typeof el !== "undefined"
6645
+ );
6646
+ filtered.forEach((mirror) => {
6647
+ mirror.onload = () => {
6648
+ stylesLoaded = stylesLoaded + 1;
6649
+ if (stylesLoaded >= filtered.length) {
6650
+ onStylesLoaded();
6651
+ }
6652
+ };
6653
+ mirror.onerror = () => {
6654
+ console.warn(`AutoFrame couldn't load a stylesheet`);
6655
+ stylesLoaded = stylesLoaded + 1;
6656
+ if (stylesLoaded >= filtered.length) {
6657
+ onStylesLoaded();
6658
+ }
6659
+ };
6660
+ });
6661
+ doc.head.innerHTML = "";
6662
+ doc.head.append(...filtered);
6663
+ filtered.forEach((mirror) => {
6664
+ if (mirror.nodeName === "STYLE") {
6665
+ stylesLoaded = stylesLoaded + 1;
6666
+ }
6667
+ });
6668
+ if (stylesLoaded >= filtered.length) {
6669
+ onStylesLoaded();
6670
+ }
6671
+ observer.observe(parentDocument.head, { childList: true, subtree: true });
6672
+ filtered.forEach((el) => {
6673
+ const elHash = hash(el.outerHTML);
6674
+ hashes[elHash] = true;
6675
+ });
6676
+ });
6677
+ return () => {
6678
+ observer.disconnect();
6679
+ };
6680
+ }, []);
6681
+ return /* @__PURE__ */ jsx41(Fragment9, { children });
6837
6682
  };
6838
- var FieldsInternal = ({ wrapFields = true }) => {
6839
- const overrides = useAppStore((s) => s.overrides);
6840
- const componentResolving = useAppStore((s) => {
6841
- var _a, _b;
6842
- const loadingCount = s.selectedItem ? (_a = s.componentState[s.selectedItem.props.id]) == null ? void 0 : _a.loadingCount : (_b = s.componentState["root"]) == null ? void 0 : _b.loadingCount;
6843
- return (loadingCount != null ? loadingCount : 0) > 0;
6844
- });
6845
- const itemSelector = useAppStore(useShallow8((s) => s.state.ui.itemSelector));
6846
- const id = useAppStore((s) => {
6847
- var _a;
6848
- return (_a = s.selectedItem) == null ? void 0 : _a.props.id;
6849
- });
6850
- const appStore = useAppStoreApi();
6851
- useRegisterFieldsSlice(appStore, id);
6852
- const fieldsLoading = useAppStore((s) => s.fields.loading);
6853
- const fieldNames = useAppStore(
6854
- useShallow8((s) => {
6855
- if (s.fields.id === id) {
6856
- return Object.keys(s.fields.fields);
6683
+ var autoFrameContext = createContext6({});
6684
+ var useFrame = () => useContext12(autoFrameContext);
6685
+ function AutoFrame(_a) {
6686
+ var _b = _a, {
6687
+ children,
6688
+ className,
6689
+ debug,
6690
+ id,
6691
+ onReady = () => {
6692
+ },
6693
+ onNotReady = () => {
6694
+ },
6695
+ frameRef
6696
+ } = _b, props = __objRest(_b, [
6697
+ "children",
6698
+ "className",
6699
+ "debug",
6700
+ "id",
6701
+ "onReady",
6702
+ "onNotReady",
6703
+ "frameRef"
6704
+ ]);
6705
+ const [loaded, setLoaded] = useState18(false);
6706
+ const [ctx, setCtx] = useState18({});
6707
+ const [mountTarget, setMountTarget] = useState18();
6708
+ const [stylesLoaded, setStylesLoaded] = useState18(false);
6709
+ useEffect20(() => {
6710
+ var _a2;
6711
+ if (frameRef.current) {
6712
+ const doc = frameRef.current.contentDocument;
6713
+ const win = frameRef.current.contentWindow;
6714
+ setCtx({
6715
+ document: doc || void 0,
6716
+ window: win || void 0
6717
+ });
6718
+ setMountTarget(
6719
+ (_a2 = frameRef.current.contentDocument) == null ? void 0 : _a2.getElementById("frame-root")
6720
+ );
6721
+ if (doc && win && stylesLoaded) {
6722
+ onReady();
6723
+ } else {
6724
+ onNotReady();
6857
6725
  }
6858
- return [];
6726
+ }
6727
+ }, [frameRef, loaded, stylesLoaded]);
6728
+ return /* @__PURE__ */ jsx41(
6729
+ "iframe",
6730
+ __spreadProps(__spreadValues({}, props), {
6731
+ className,
6732
+ id,
6733
+ srcDoc: '<!DOCTYPE html><html><head></head><body><div id="frame-root" data-editor-entry></div></body></html>',
6734
+ ref: frameRef,
6735
+ onLoad: () => {
6736
+ setLoaded(true);
6737
+ },
6738
+ children: /* @__PURE__ */ jsx41(autoFrameContext.Provider, { value: ctx, children: loaded && mountTarget && /* @__PURE__ */ jsx41(
6739
+ CopyHostStyles,
6740
+ {
6741
+ debug,
6742
+ onStylesLoaded: () => setStylesLoaded(true),
6743
+ children: createPortal3(children, mountTarget)
6744
+ }
6745
+ ) })
6859
6746
  })
6860
6747
  );
6861
- const isLoading = fieldsLoading || componentResolving;
6862
- const Wrapper = useMemo17(() => overrides.fields || DefaultFields, [overrides]);
6863
- return /* @__PURE__ */ jsxs16(
6864
- "form",
6748
+ }
6749
+ AutoFrame.displayName = "AutoFrame";
6750
+ var AutoFrame_default = AutoFrame;
6751
+
6752
+ // css-module:/Users/rami/Documents/apps/react-editor/packages/core/components/Editor/components/Preview/styles.module.css#css-module
6753
+ init_react_import();
6754
+ var styles_module_default20 = { "EditorPreview": "_EditorPreview_xou64_1", "EditorPreview-frame": "_EditorPreview-frame_xou64_6" };
6755
+
6756
+ // components/Editor/components/Preview/index.tsx
6757
+ import { Fragment as Fragment10, jsx as jsx42 } from "react/jsx-runtime";
6758
+ var getClassName25 = get_class_name_factory_default("EditorPreview", styles_module_default20);
6759
+ var Preview2 = ({ id = "editor-preview" }) => {
6760
+ const dispatch = useAppStore((s) => s.dispatch);
6761
+ const root = useAppStore((s) => s.state.data.root);
6762
+ const config = useAppStore((s) => s.config);
6763
+ const setStatus = useAppStore((s) => s.setStatus);
6764
+ const iframe = useAppStore((s) => s.iframe);
6765
+ const overrides = useAppStore((s) => s.overrides);
6766
+ const metadata = useAppStore((s) => s.metadata);
6767
+ const renderData = useAppStore(
6768
+ (s) => s.state.ui.previewMode === "edit" ? null : s.state.data
6769
+ );
6770
+ const Page = useCallback16(
6771
+ (pageProps) => {
6772
+ var _a, _b, _c, _d;
6773
+ const propsWithSlots = useSlots(
6774
+ config,
6775
+ { type: "root", props: pageProps },
6776
+ DropZoneEditPure
6777
+ );
6778
+ const richtextProps = useRichtextProps(
6779
+ (_b = (_a = config.root) == null ? void 0 : _a.fields) != null ? _b : {},
6780
+ pageProps
6781
+ );
6782
+ return ((_c = config.root) == null ? void 0 : _c.render) ? (_d = config.root) == null ? void 0 : _d.render(__spreadValues(__spreadValues({
6783
+ id: "editor-root"
6784
+ }, propsWithSlots), richtextProps)) : /* @__PURE__ */ jsx42(Fragment10, { children: propsWithSlots.children });
6785
+ },
6786
+ [config]
6787
+ );
6788
+ const Frame = useMemo17(() => overrides.iframe, [overrides]);
6789
+ const rootProps = root.props || root;
6790
+ const ref = useRef11(null);
6791
+ const inner = !renderData ? /* @__PURE__ */ jsx42(
6792
+ Page,
6793
+ __spreadProps(__spreadValues({}, rootProps), {
6794
+ editor: {
6795
+ renderDropZone: DropZonePure,
6796
+ isEditing: true,
6797
+ dragRef: null,
6798
+ metadata
6799
+ },
6800
+ editMode: true,
6801
+ children: /* @__PURE__ */ jsx42(DropZonePure, { zone: rootDroppableId })
6802
+ })
6803
+ ) : /* @__PURE__ */ jsx42(Render, { data: renderData, config, metadata });
6804
+ useEffect21(() => {
6805
+ if (!iframe.enabled) {
6806
+ setStatus("READY");
6807
+ }
6808
+ }, [iframe.enabled]);
6809
+ return /* @__PURE__ */ jsx42(
6810
+ "div",
6865
6811
  {
6866
- className: getClassName25({ wrapFields }),
6867
- onSubmit: (e) => {
6868
- e.preventDefault();
6812
+ className: getClassName25(),
6813
+ id,
6814
+ "data-editor-preview": true,
6815
+ onClick: (e) => {
6816
+ const el = e.target;
6817
+ if (!el.hasAttribute("data-editor-component") && !el.hasAttribute("data-editor-dropzone")) {
6818
+ dispatch({ type: "setUi", ui: { itemSelector: null } });
6819
+ }
6869
6820
  },
6870
- children: [
6871
- /* @__PURE__ */ jsxs16(Wrapper, { isLoading, itemSelector, children: [
6872
- /* @__PURE__ */ jsx42(GlobalSyncButton, {}),
6873
- fieldNames.map((fieldName) => /* @__PURE__ */ jsx42(FieldsChildMemo, { fieldName }, fieldName))
6874
- ] }),
6875
- isLoading && /* @__PURE__ */ jsx42("div", { className: getClassName25("loadingOverlay"), children: /* @__PURE__ */ jsx42("div", { className: getClassName25("loadingOverlayInner"), children: /* @__PURE__ */ jsx42(Loader, { size: 16 }) }) })
6876
- ]
6821
+ children: iframe.enabled ? /* @__PURE__ */ jsx42(
6822
+ AutoFrame_default,
6823
+ {
6824
+ id: "preview-frame",
6825
+ className: getClassName25("frame"),
6826
+ "data-rfd-iframe": true,
6827
+ onReady: () => {
6828
+ setStatus("READY");
6829
+ },
6830
+ onNotReady: () => {
6831
+ setStatus("MOUNTED");
6832
+ },
6833
+ frameRef: ref,
6834
+ children: /* @__PURE__ */ jsx42(autoFrameContext.Consumer, { children: ({ document: document2 }) => {
6835
+ if (Frame) {
6836
+ return /* @__PURE__ */ jsx42(Frame, { document: document2, children: inner });
6837
+ }
6838
+ return inner;
6839
+ } })
6840
+ }
6841
+ ) : /* @__PURE__ */ jsx42(
6842
+ "div",
6843
+ {
6844
+ id: "preview-frame",
6845
+ className: getClassName25("frame"),
6846
+ ref,
6847
+ "data-editor-entry": true,
6848
+ children: inner
6849
+ }
6850
+ )
6877
6851
  }
6878
6852
  );
6879
6853
  };
6880
- var Fields = memo8(FieldsInternal);
6881
6854
 
6882
- // css-module:/Users/rami/Documents/apps/react-editor/packages/core/plugins/fields/styles.module.css#css-module
6855
+ // components/Editor/components/Outline/index.tsx
6883
6856
  init_react_import();
6884
- var styles_module_default21 = { "FieldsPlugin": "_FieldsPlugin_262zt_1", "FieldsPlugin-header": "_FieldsPlugin-header_262zt_7" };
6885
-
6886
- // plugins/fields/index.tsx
6887
- import { jsx as jsx43, jsxs as jsxs17 } from "react/jsx-runtime";
6888
- var getClassName26 = get_class_name_factory_default("FieldsPlugin", styles_module_default21);
6889
- var CurrentTitle = () => {
6890
- const label = useAppStore((s) => {
6891
- var _a, _b;
6892
- const selectedItem = s.selectedItem;
6893
- return selectedItem ? (_b = (_a = s.config.components[selectedItem.type]) == null ? void 0 : _a.label) != null ? _b : selectedItem.type : "Page";
6894
- });
6895
- return label;
6896
- };
6897
- var fieldsPlugin = ({ desktopSideBar = "right" } = {}) => ({
6898
- name: "fields",
6899
- label: "Fields",
6900
- render: () => /* @__PURE__ */ jsxs17("div", { className: getClassName26(), children: [
6901
- /* @__PURE__ */ jsx43("div", { className: getClassName26("header"), children: /* @__PURE__ */ jsx43(Breadcrumbs, { numParents: 2, children: /* @__PURE__ */ jsx43(CurrentTitle, {}) }) }),
6902
- /* @__PURE__ */ jsx43(Fields, {})
6903
- ] }),
6904
- icon: /* @__PURE__ */ jsx43(RectangleEllipsis, {}),
6905
- mobileOnly: desktopSideBar === "right"
6906
- });
6907
6857
 
6908
- // components/Editor/index.tsx
6858
+ // components/LayerTree/index.tsx
6909
6859
  init_react_import();
6910
- import {
6911
- createContext as createContext8,
6912
- useCallback as useCallback25,
6913
- useContext as useContext15,
6914
- useEffect as useEffect26,
6915
- useMemo as useMemo24,
6916
- useRef as useRef19,
6917
- useState as useState24
6918
- } from "react";
6919
6860
 
6920
- // components/Editor/components/Preview/index.tsx
6861
+ // css-module:/Users/rami/Documents/apps/react-editor/packages/core/components/LayerTree/styles.module.css#css-module
6921
6862
  init_react_import();
6922
- import { useCallback as useCallback17, useEffect as useEffect21, useRef as useRef12, useMemo as useMemo18 } from "react";
6863
+ var styles_module_default21 = { "LayerTree": "_LayerTree_3eixb_1", "LayerTree-zoneTitle": "_LayerTree-zoneTitle_3eixb_11", "LayerTree-helper": "_LayerTree-helper_3eixb_17", "Layer": "_Layer_3eixb_1", "Layer-inner": "_Layer-inner_3eixb_34", "Layer--containsZone": "_Layer--containsZone_3eixb_42", "Layer-clickable": "_Layer-clickable_3eixb_46", "Layer--isSelected": "_Layer--isSelected_3eixb_68", "Layer-icon": "_Layer-icon_3eixb_80", "Layer-zoneIcon": "_Layer-zoneIcon_3eixb_81", "Layer-chevron": "_Layer-chevron_3eixb_85", "Layer--childIsSelected": "_Layer--childIsSelected_3eixb_97", "Layer-zones": "_Layer-zones_3eixb_101", "Layer-title": "_Layer-title_3eixb_117", "Layer-name": "_Layer-name_3eixb_130", "Layer--isGlobal": "_Layer--isGlobal_3eixb_150", "Layer--isUnlinked": "_Layer--isUnlinked_3eixb_171", "Layer-unlinkedGlyph": "_Layer-unlinkedGlyph_3eixb_175" };
6923
6864
 
6924
- // components/AutoFrame/index.tsx
6925
- init_react_import();
6865
+ // components/LayerTree/index.tsx
6926
6866
  import {
6927
- createContext as createContext6,
6867
+ forwardRef as forwardRef2,
6868
+ useCallback as useCallback17,
6928
6869
  useContext as useContext13,
6929
- useEffect as useEffect20,
6930
- useState as useState18
6870
+ useRef as useRef12
6931
6871
  } from "react";
6932
- import hash from "object-hash";
6933
- import { createPortal as createPortal3 } from "react-dom";
6934
- import { Fragment as Fragment10, jsx as jsx44 } from "react/jsx-runtime";
6935
- var styleSelector = 'style, link[rel="stylesheet"]';
6936
- var collectStyles = (doc) => {
6937
- const collected = [];
6938
- doc.querySelectorAll(styleSelector).forEach((style) => {
6939
- if (style.tagName === "STYLE") {
6940
- const hasContent = !!style.innerHTML.trim();
6941
- if (hasContent) {
6942
- collected.push(style);
6943
- }
6944
- } else {
6945
- collected.push(style);
6946
- }
6947
- });
6948
- return collected;
6872
+ import { useVirtualizer as useVirtualizer2 } from "@tanstack/react-virtual";
6873
+ import { Fragment as Fragment11, jsx as jsx43, jsxs as jsxs17 } from "react/jsx-runtime";
6874
+ var getClassName26 = get_class_name_factory_default("LayerTree", styles_module_default21);
6875
+ var getClassNameLayer = get_class_name_factory_default("Layer", styles_module_default21);
6876
+ var DEFAULT_LAYER_ROW_HEIGHT = 32;
6877
+ var LAYER_TREE_VIRTUALIZATION_OVERSCAN = 8;
6878
+ var MIN_VIRTUALIZED_LAYER_COUNT = 25;
6879
+ var measuredRowHeights = /* @__PURE__ */ new Map();
6880
+ var getZonesByParent = (zones) => {
6881
+ return Object.keys(zones).reduce((acc, zone) => {
6882
+ const [parentId] = zone.split(":");
6883
+ acc[parentId] = [...acc[parentId] || [], zone];
6884
+ return acc;
6885
+ }, {});
6886
+ };
6887
+ var getZoneLabel = (zoneCompound, nodes, config, label) => {
6888
+ var _a, _b, _c, _d;
6889
+ if (label !== void 0) {
6890
+ return label;
6891
+ }
6892
+ const [componentId, slotId] = zoneCompound.split(":");
6893
+ if (!slotId) {
6894
+ return;
6895
+ }
6896
+ const componentType = (_a = nodes[componentId]) == null ? void 0 : _a.data.type;
6897
+ const configForComponent = componentType && componentType !== rootAreaId ? config.components[componentType] : config.root;
6898
+ return (_d = (_c = (_b = configForComponent == null ? void 0 : configForComponent.fields) == null ? void 0 : _b[slotId]) == null ? void 0 : _c.label) != null ? _d : slotId;
6899
+ };
6900
+ var buildLayerNode = ({
6901
+ config,
6902
+ itemId,
6903
+ index,
6904
+ nodes,
6905
+ zoneCompound,
6906
+ zones,
6907
+ zonesByParent
6908
+ }) => {
6909
+ var _a, _b, _c;
6910
+ const nodeData = nodes[itemId];
6911
+ const componentType = ((_a = nodeData == null ? void 0 : nodeData.data.type) == null ? void 0 : _a.toString()) || "Component";
6912
+ const label = (_c = (_b = config.components[componentType]) == null ? void 0 : _b.label) != null ? _c : componentType;
6913
+ const childZoneCompounds = zonesByParent[itemId] || [];
6914
+ return {
6915
+ childZones: childZoneCompounds.map(
6916
+ (childZoneCompound) => buildLayerTree({
6917
+ config,
6918
+ nodes,
6919
+ zoneCompound: childZoneCompound,
6920
+ zones,
6921
+ zonesByParent
6922
+ })
6923
+ ),
6924
+ componentType,
6925
+ index,
6926
+ itemId,
6927
+ label,
6928
+ zoneCompound
6929
+ };
6949
6930
  };
6950
- var getStyleSheet = (el) => {
6951
- return Array.from(document.styleSheets).find((ss) => {
6952
- const ownerNode = ss.ownerNode;
6953
- return ownerNode.href === el.href;
6954
- });
6931
+ var buildLayerTree = ({
6932
+ config,
6933
+ label,
6934
+ nodes,
6935
+ zoneCompound,
6936
+ zones,
6937
+ zonesByParent = getZonesByParent(zones)
6938
+ }) => {
6939
+ var _a, _b;
6940
+ const contentIds = (_b = (_a = zones[zoneCompound]) == null ? void 0 : _a.contentIds) != null ? _b : [];
6941
+ return {
6942
+ items: contentIds.map(
6943
+ (itemId, index) => buildLayerNode({
6944
+ config,
6945
+ itemId,
6946
+ index,
6947
+ nodes,
6948
+ zoneCompound,
6949
+ zones,
6950
+ zonesByParent
6951
+ })
6952
+ ),
6953
+ label: getZoneLabel(zoneCompound, nodes, config, label),
6954
+ zoneCompound
6955
+ };
6955
6956
  };
6956
- var getStyles = (styleSheet) => {
6957
- if (styleSheet) {
6958
- try {
6959
- return Array.from(styleSheet.cssRules).map((rule) => rule.cssText).join("");
6960
- } catch (e) {
6961
- console.warn(
6962
- "Access to stylesheet %s is denied. Ignoring\u2026",
6963
- styleSheet.href
6964
- );
6965
- }
6957
+ var getEstimatedRowHeight = (itemId) => {
6958
+ var _a;
6959
+ return (_a = measuredRowHeights.get(itemId)) != null ? _a : DEFAULT_LAYER_ROW_HEIGHT;
6960
+ };
6961
+ var cacheMeasuredRowHeight = (itemId, height) => {
6962
+ if (height <= 0) {
6963
+ return;
6966
6964
  }
6967
- return "";
6965
+ measuredRowHeights.set(itemId, height);
6968
6966
  };
6969
- var syncAttributes = (sourceElement, targetElement) => {
6970
- const attributes = sourceElement.attributes;
6971
- if ((attributes == null ? void 0 : attributes.length) > 0) {
6972
- Array.from(attributes).forEach((attribute) => {
6973
- targetElement.setAttribute(attribute.name, attribute.value);
6974
- });
6967
+ var getScrollParent = (el) => {
6968
+ var _a;
6969
+ let current = (_a = el == null ? void 0 : el.parentElement) != null ? _a : null;
6970
+ while (current) {
6971
+ const { overflow, overflowY } = getComputedStyle(current);
6972
+ if ([overflow, overflowY].some((value) => /auto|scroll/.test(value))) {
6973
+ return current;
6974
+ }
6975
+ current = current.parentElement;
6975
6976
  }
6977
+ return null;
6976
6978
  };
6977
- var defer = (fn) => setTimeout(fn, 0);
6978
- var CopyHostStyles = ({
6979
- children,
6980
- debug = false,
6981
- onStylesLoaded = () => null
6982
- }) => {
6983
- const { document: doc, window: win } = useFrame();
6984
- useEffect20(() => {
6985
- if (!win || !doc) {
6986
- return () => {
6987
- };
6979
+ var Layer = forwardRef2(function Layer2({
6980
+ childIsSelected,
6981
+ dataIndex,
6982
+ depth,
6983
+ isSelected,
6984
+ node,
6985
+ selectedId,
6986
+ selectedPathIds
6987
+ }, ref) {
6988
+ const dispatch = useAppStore((s) => s.dispatch);
6989
+ const zoneStore = useContext13(ZoneStoreContext);
6990
+ const isHovering = useContextStore(
6991
+ ZoneStoreContext,
6992
+ (s) => s.hoveringComponent === node.itemId
6993
+ );
6994
+ const isGlobal = useAppStore(
6995
+ (s) => {
6996
+ var _a;
6997
+ return ((_a = s.config.components[node.componentType]) == null ? void 0 : _a.global) === true;
6988
6998
  }
6989
- let elements = [];
6990
- const hashes = {};
6991
- const lookupEl = (el) => elements.findIndex((elementMap) => elementMap.original === el);
6992
- const mirrorEl = (el, inlineStyles = false) => __async(null, null, function* () {
6993
- let mirror;
6994
- if (el.nodeName === "LINK" && inlineStyles) {
6995
- mirror = document.createElement("style");
6996
- mirror.type = "text/css";
6997
- let styleSheet = getStyleSheet(el);
6998
- if (!styleSheet) {
6999
- yield new Promise((resolve) => {
7000
- const fn = () => {
7001
- resolve();
7002
- el.removeEventListener("load", fn);
7003
- };
7004
- el.addEventListener("load", fn);
7005
- });
7006
- styleSheet = getStyleSheet(el);
7007
- }
7008
- const styles2 = getStyles(styleSheet);
7009
- if (!styles2) {
7010
- if (debug) {
7011
- console.warn(
7012
- `Tried to load styles for link element, but couldn't find them. Skipping...`
7013
- );
7014
- }
7015
- return;
7016
- }
7017
- mirror.innerHTML = styles2;
7018
- mirror.setAttribute("data-href", el.getAttribute("href"));
7019
- } else {
7020
- mirror = el.cloneNode(true);
7021
- }
7022
- return mirror;
7023
- });
7024
- const addEl = (el) => __async(null, null, function* () {
7025
- const index = lookupEl(el);
7026
- if (index > -1) {
7027
- if (debug)
7028
- console.log(
7029
- `Tried to add an element that was already mirrored. Updating instead...`
7030
- );
7031
- elements[index].mirror.innerText = el.innerText;
7032
- return;
7033
- }
7034
- const mirror = yield mirrorEl(el);
7035
- if (!mirror) {
7036
- return;
7037
- }
7038
- const elHash = hash(mirror.outerHTML);
7039
- if (hashes[elHash]) {
7040
- if (debug)
7041
- console.log(
7042
- `iframe already contains element that is being mirrored. Skipping...`
7043
- );
7044
- return;
7045
- }
7046
- hashes[elHash] = true;
7047
- doc.head.append(mirror);
7048
- elements.push({ original: el, mirror });
7049
- if (debug) console.log(`Added style node ${el.outerHTML}`);
7050
- });
7051
- const removeEl = (el) => {
7052
- var _a, _b;
7053
- const index = lookupEl(el);
7054
- if (index === -1) {
7055
- if (debug)
7056
- console.log(
7057
- `Tried to remove an element that did not exist. Skipping...`
7058
- );
7059
- return;
7060
- }
7061
- const elHash = hash(el.outerHTML);
7062
- (_b = (_a = elements[index]) == null ? void 0 : _a.mirror) == null ? void 0 : _b.remove();
7063
- delete hashes[elHash];
7064
- if (debug) console.log(`Removed style node ${el.outerHTML}`);
7065
- };
7066
- const observer = new MutationObserver((mutations) => {
7067
- mutations.forEach((mutation) => {
7068
- if (mutation.type === "childList") {
7069
- mutation.addedNodes.forEach((node) => {
7070
- if (node.nodeType === Node.TEXT_NODE || node.nodeType === Node.ELEMENT_NODE) {
7071
- const el = node.nodeType === Node.TEXT_NODE ? node.parentElement : node;
7072
- if (el && el.matches(styleSelector)) {
7073
- defer(() => addEl(el));
7074
- }
7075
- }
7076
- });
7077
- mutation.removedNodes.forEach((node) => {
7078
- if (node.nodeType === Node.TEXT_NODE || node.nodeType === Node.ELEMENT_NODE) {
7079
- const el = node.nodeType === Node.TEXT_NODE ? node.parentElement : node;
7080
- if (el && el.matches(styleSelector)) {
7081
- defer(() => removeEl(el));
7082
- }
7083
- }
7084
- });
7085
- }
7086
- });
7087
- });
7088
- const parentDocument = win.parent.document;
7089
- const collectedStyles = collectStyles(parentDocument);
7090
- const hrefs = [];
7091
- let stylesLoaded = 0;
7092
- const parentHtml = parentDocument.getElementsByTagName("html")[0];
7093
- syncAttributes(parentHtml, doc.documentElement);
7094
- const parentBody = parentDocument.getElementsByTagName("body")[0];
7095
- syncAttributes(parentBody, doc.body);
7096
- doc.documentElement.style.colorScheme = "light";
7097
- doc.documentElement.style.background = "#ffffff";
7098
- Promise.all(
7099
- collectedStyles.map((styleNode, i) => __async(null, null, function* () {
7100
- if (styleNode.nodeName === "LINK") {
7101
- const linkHref = styleNode.href;
7102
- if (hrefs.indexOf(linkHref) > -1) {
7103
- return;
7104
- }
7105
- hrefs.push(linkHref);
7106
- }
7107
- const mirror = yield mirrorEl(styleNode);
7108
- if (!mirror) return;
7109
- elements.push({ original: styleNode, mirror });
7110
- return mirror;
7111
- }))
7112
- ).then((mirrorStyles) => {
7113
- const filtered = mirrorStyles.filter(
7114
- (el) => typeof el !== "undefined"
7115
- );
7116
- filtered.forEach((mirror) => {
7117
- mirror.onload = () => {
7118
- stylesLoaded = stylesLoaded + 1;
7119
- if (stylesLoaded >= filtered.length) {
7120
- onStylesLoaded();
7121
- }
7122
- };
7123
- mirror.onerror = () => {
7124
- console.warn(`AutoFrame couldn't load a stylesheet`);
7125
- stylesLoaded = stylesLoaded + 1;
7126
- if (stylesLoaded >= filtered.length) {
7127
- onStylesLoaded();
6999
+ );
7000
+ const isUnlinked = useAppStore(
7001
+ (s) => {
7002
+ var _a, _b;
7003
+ return ((_b = (_a = s.state.indexes.nodes[node.itemId]) == null ? void 0 : _a.data) == null ? void 0 : _b.synced) === false;
7004
+ }
7005
+ );
7006
+ const containsZone = node.childZones.length > 0;
7007
+ const setItemSelector = useCallback17(
7008
+ (itemSelector) => {
7009
+ dispatch({ type: "setUi", ui: { itemSelector } });
7010
+ },
7011
+ [dispatch]
7012
+ );
7013
+ const shouldRenderChildren = isSelected || childIsSelected;
7014
+ return /* @__PURE__ */ jsxs17(
7015
+ "li",
7016
+ {
7017
+ ref,
7018
+ className: getClassNameLayer({
7019
+ childIsSelected,
7020
+ containsZone,
7021
+ isHovering,
7022
+ isSelected,
7023
+ isGlobal: isGlobal && !isUnlinked,
7024
+ isUnlinked: isGlobal && isUnlinked
7025
+ }),
7026
+ "data-index": dataIndex,
7027
+ "data-editor-layer-tree-id": node.itemId,
7028
+ children: [
7029
+ /* @__PURE__ */ jsx43("div", { className: getClassNameLayer("inner"), children: /* @__PURE__ */ jsxs17(
7030
+ "button",
7031
+ {
7032
+ type: "button",
7033
+ className: getClassNameLayer("clickable"),
7034
+ onClick: () => {
7035
+ if (isSelected) {
7036
+ setItemSelector(null);
7037
+ return;
7038
+ }
7039
+ setItemSelector({
7040
+ index: node.index,
7041
+ zone: node.zoneCompound
7042
+ });
7043
+ zoneStore.getState().scrollToComponent(node.itemId);
7044
+ },
7045
+ onMouseEnter: (e) => {
7046
+ e.stopPropagation();
7047
+ zoneStore.setState({ hoveringComponent: node.itemId });
7048
+ },
7049
+ onMouseLeave: (e) => {
7050
+ e.stopPropagation();
7051
+ zoneStore.setState({ hoveringComponent: null });
7052
+ },
7053
+ children: [
7054
+ /* @__PURE__ */ jsx43(
7055
+ "div",
7056
+ {
7057
+ className: getClassNameLayer("chevron"),
7058
+ title: containsZone ? isSelected ? "Collapse" : "Expand" : void 0,
7059
+ children: containsZone && /* @__PURE__ */ jsx43(ChevronRight, { size: "12" })
7060
+ }
7061
+ ),
7062
+ /* @__PURE__ */ jsxs17("div", { className: getClassNameLayer("title"), children: [
7063
+ /* @__PURE__ */ jsx43("div", { className: getClassNameLayer("icon"), children: /* @__PURE__ */ jsx43(Component, { size: "16" }) }),
7064
+ /* @__PURE__ */ jsx43("div", { className: getClassNameLayer("name"), children: node.label }),
7065
+ isGlobal && isUnlinked && /* @__PURE__ */ jsx43(
7066
+ "div",
7067
+ {
7068
+ className: getClassNameLayer("unlinkedGlyph"),
7069
+ title: "Unlinked from shared",
7070
+ children: /* @__PURE__ */ jsx43(Unlink2, { size: "12" })
7071
+ }
7072
+ )
7073
+ ] })
7074
+ ]
7128
7075
  }
7129
- };
7130
- });
7131
- doc.head.innerHTML = "";
7132
- doc.head.append(...filtered);
7133
- filtered.forEach((mirror) => {
7134
- if (mirror.nodeName === "STYLE") {
7135
- stylesLoaded = stylesLoaded + 1;
7136
- }
7137
- });
7138
- if (stylesLoaded >= filtered.length) {
7139
- onStylesLoaded();
7076
+ ) }),
7077
+ containsZone && shouldRenderChildren && node.childZones.map((childZone) => /* @__PURE__ */ jsx43(
7078
+ "div",
7079
+ {
7080
+ className: getClassNameLayer("zones"),
7081
+ children: /* @__PURE__ */ jsx43(
7082
+ LayerTreeZone,
7083
+ {
7084
+ depth: depth + 1,
7085
+ selectedId,
7086
+ selectedPathIds,
7087
+ tree: childZone
7088
+ }
7089
+ )
7090
+ },
7091
+ childZone.zoneCompound
7092
+ ))
7093
+ ]
7094
+ }
7095
+ );
7096
+ });
7097
+ var LayerTreeZone = ({
7098
+ depth,
7099
+ selectedId,
7100
+ selectedPathIds,
7101
+ tree
7102
+ }) => {
7103
+ const shouldVirtualize = depth === 0 && tree.items.length >= MIN_VIRTUALIZED_LAYER_COUNT;
7104
+ return /* @__PURE__ */ jsxs17(Fragment11, { children: [
7105
+ tree.label && /* @__PURE__ */ jsx43("div", { className: getClassName26("zoneTitle"), children: tree.label }),
7106
+ shouldVirtualize ? /* @__PURE__ */ jsx43(
7107
+ VirtualizedLayerTreeItems,
7108
+ {
7109
+ depth,
7110
+ selectedId,
7111
+ selectedPathIds,
7112
+ tree
7140
7113
  }
7141
- observer.observe(parentDocument.head, { childList: true, subtree: true });
7142
- filtered.forEach((el) => {
7143
- const elHash = hash(el.outerHTML);
7144
- hashes[elHash] = true;
7145
- });
7146
- });
7147
- return () => {
7148
- observer.disconnect();
7149
- };
7150
- }, []);
7151
- return /* @__PURE__ */ jsx44(Fragment10, { children });
7114
+ ) : /* @__PURE__ */ jsx43(
7115
+ StaticLayerTreeItems,
7116
+ {
7117
+ depth,
7118
+ selectedId,
7119
+ selectedPathIds,
7120
+ tree
7121
+ }
7122
+ )
7123
+ ] });
7152
7124
  };
7153
- var autoFrameContext = createContext6({});
7154
- var useFrame = () => useContext13(autoFrameContext);
7155
- function AutoFrame(_a) {
7156
- var _b = _a, {
7157
- children,
7158
- className,
7159
- debug,
7160
- id,
7161
- onReady = () => {
7162
- },
7163
- onNotReady = () => {
7164
- },
7165
- frameRef
7166
- } = _b, props = __objRest(_b, [
7167
- "children",
7168
- "className",
7169
- "debug",
7170
- "id",
7171
- "onReady",
7172
- "onNotReady",
7173
- "frameRef"
7174
- ]);
7175
- const [loaded, setLoaded] = useState18(false);
7176
- const [ctx, setCtx] = useState18({});
7177
- const [mountTarget, setMountTarget] = useState18();
7178
- const [stylesLoaded, setStylesLoaded] = useState18(false);
7179
- useEffect20(() => {
7180
- var _a2;
7181
- if (frameRef.current) {
7182
- const doc = frameRef.current.contentDocument;
7183
- const win = frameRef.current.contentWindow;
7184
- setCtx({
7185
- document: doc || void 0,
7186
- window: win || void 0
7187
- });
7188
- setMountTarget(
7189
- (_a2 = frameRef.current.contentDocument) == null ? void 0 : _a2.getElementById("frame-root")
7190
- );
7191
- if (doc && win && stylesLoaded) {
7192
- onReady();
7193
- } else {
7194
- onNotReady();
7125
+ var StaticLayerTreeItems = ({
7126
+ depth,
7127
+ selectedId,
7128
+ selectedPathIds,
7129
+ tree
7130
+ }) => {
7131
+ return /* @__PURE__ */ jsxs17("ul", { className: getClassName26(), children: [
7132
+ tree.items.length === 0 && /* @__PURE__ */ jsx43("div", { className: getClassName26("helper"), children: "empty" }),
7133
+ tree.items.map((node) => /* @__PURE__ */ jsx43(
7134
+ Layer,
7135
+ {
7136
+ childIsSelected: selectedPathIds.has(node.itemId),
7137
+ depth,
7138
+ isSelected: selectedId === node.itemId,
7139
+ node,
7140
+ selectedId,
7141
+ selectedPathIds
7142
+ },
7143
+ node.itemId
7144
+ ))
7145
+ ] });
7146
+ };
7147
+ var VirtualizedLayerTreeItems = ({
7148
+ depth,
7149
+ selectedId,
7150
+ selectedPathIds,
7151
+ tree
7152
+ }) => {
7153
+ const listRef = useRef12(null);
7154
+ const virtualizer = useVirtualizer2({
7155
+ count: tree.items.length,
7156
+ estimateSize: (index) => getEstimatedRowHeight(tree.items[index].itemId),
7157
+ getItemKey: (index) => tree.items[index].itemId,
7158
+ getScrollElement: () => getScrollParent(listRef.current),
7159
+ overscan: LAYER_TREE_VIRTUALIZATION_OVERSCAN,
7160
+ measureElement: (element) => {
7161
+ const height = Math.ceil(element.getBoundingClientRect().height);
7162
+ const itemId = element.dataset.editorLayerTreeId;
7163
+ if (itemId) {
7164
+ cacheMeasuredRowHeight(itemId, height);
7195
7165
  }
7166
+ return height || DEFAULT_LAYER_ROW_HEIGHT;
7196
7167
  }
7197
- }, [frameRef, loaded, stylesLoaded]);
7198
- return /* @__PURE__ */ jsx44(
7199
- "iframe",
7200
- __spreadProps(__spreadValues({}, props), {
7201
- className,
7202
- id,
7203
- srcDoc: '<!DOCTYPE html><html><head></head><body><div id="frame-root" data-editor-entry></div></body></html>',
7204
- ref: frameRef,
7205
- onLoad: () => {
7206
- setLoaded(true);
7207
- },
7208
- children: /* @__PURE__ */ jsx44(autoFrameContext.Provider, { value: ctx, children: loaded && mountTarget && /* @__PURE__ */ jsx44(
7209
- CopyHostStyles,
7168
+ });
7169
+ const virtualItems = virtualizer.getVirtualItems();
7170
+ const totalSize = virtualizer.getTotalSize();
7171
+ const renderedItems = [];
7172
+ let previousEnd = 0;
7173
+ let previousIndex = -1;
7174
+ virtualItems.forEach((virtualItem) => {
7175
+ const node = tree.items[virtualItem.index];
7176
+ const gapSize = Math.max(virtualItem.start - previousEnd, 0);
7177
+ if (gapSize > 0) {
7178
+ renderedItems.push(
7179
+ /* @__PURE__ */ jsx43(
7180
+ "li",
7181
+ {
7182
+ "aria-hidden": "true",
7183
+ style: { height: `${gapSize}px` }
7184
+ },
7185
+ `gap:${tree.zoneCompound}:${previousIndex}:${virtualItem.index}`
7186
+ )
7187
+ );
7188
+ }
7189
+ renderedItems.push(
7190
+ /* @__PURE__ */ jsx43(
7191
+ Layer,
7192
+ {
7193
+ childIsSelected: selectedPathIds.has(node.itemId),
7194
+ dataIndex: virtualItem.index,
7195
+ depth,
7196
+ isSelected: selectedId === node.itemId,
7197
+ node,
7198
+ ref: virtualizer.measureElement,
7199
+ selectedId,
7200
+ selectedPathIds
7201
+ },
7202
+ node.itemId
7203
+ )
7204
+ );
7205
+ previousEnd = virtualItem.end;
7206
+ previousIndex = virtualItem.index;
7207
+ });
7208
+ const trailingGap = Math.max(totalSize - previousEnd, 0);
7209
+ if (trailingGap > 0) {
7210
+ renderedItems.push(
7211
+ /* @__PURE__ */ jsx43(
7212
+ "li",
7210
7213
  {
7211
- debug,
7212
- onStylesLoaded: () => setStylesLoaded(true),
7213
- children: createPortal3(children, mountTarget)
7214
- }
7215
- ) })
7216
- })
7217
- );
7218
- }
7219
- AutoFrame.displayName = "AutoFrame";
7220
- var AutoFrame_default = AutoFrame;
7214
+ "aria-hidden": "true",
7215
+ style: { height: `${trailingGap}px` }
7216
+ },
7217
+ `gap:${tree.zoneCompound}:${previousIndex}:end`
7218
+ )
7219
+ );
7220
+ }
7221
+ return /* @__PURE__ */ jsxs17("ul", { className: getClassName26(), ref: listRef, children: [
7222
+ tree.items.length === 0 && /* @__PURE__ */ jsx43("div", { className: getClassName26("helper"), children: "empty" }),
7223
+ renderedItems
7224
+ ] });
7225
+ };
7226
+ var LayerTree = ({
7227
+ selectedId,
7228
+ selectedPathIds,
7229
+ trees
7230
+ }) => {
7231
+ return /* @__PURE__ */ jsx43(Fragment11, { children: trees.map((tree) => /* @__PURE__ */ jsx43(
7232
+ LayerTreeZone,
7233
+ {
7234
+ depth: 0,
7235
+ selectedId,
7236
+ selectedPathIds,
7237
+ tree
7238
+ },
7239
+ tree.zoneCompound
7240
+ )) });
7241
+ };
7221
7242
 
7222
- // css-module:/Users/rami/Documents/apps/react-editor/packages/core/components/Editor/components/Preview/styles.module.css#css-module
7243
+ // components/Editor/components/Outline/index.tsx
7244
+ import { useMemo as useMemo18 } from "react";
7245
+
7246
+ // lib/data/find-zones-for-area.ts
7223
7247
  init_react_import();
7224
- var styles_module_default22 = { "EditorPreview": "_EditorPreview_xou64_1", "EditorPreview-frame": "_EditorPreview-frame_xou64_6" };
7248
+ var findZonesForArea = (state, area) => {
7249
+ return Object.keys(state.indexes.zones).filter(
7250
+ (zone) => zone.split(":")[0] === area
7251
+ );
7252
+ };
7225
7253
 
7226
- // components/Editor/components/Preview/index.tsx
7227
- import { Fragment as Fragment11, jsx as jsx45 } from "react/jsx-runtime";
7228
- var getClassName27 = get_class_name_factory_default("EditorPreview", styles_module_default22);
7229
- var Preview2 = ({ id = "editor-preview" }) => {
7230
- const dispatch = useAppStore((s) => s.dispatch);
7231
- const root = useAppStore((s) => s.state.data.root);
7254
+ // components/Editor/components/Outline/index.tsx
7255
+ import { useShallow as useShallow8 } from "zustand/react/shallow";
7256
+ import { jsx as jsx44 } from "react/jsx-runtime";
7257
+ var Outline = () => {
7258
+ const outlineOverride = useAppStore((s) => s.overrides.outline);
7232
7259
  const config = useAppStore((s) => s.config);
7233
- const setStatus = useAppStore((s) => s.setStatus);
7234
- const iframe = useAppStore((s) => s.iframe);
7235
- const overrides = useAppStore((s) => s.overrides);
7236
- const metadata = useAppStore((s) => s.metadata);
7237
- const renderData = useAppStore(
7238
- (s) => s.state.ui.previewMode === "edit" ? null : s.state.data
7260
+ const nodes = useAppStore((s) => s.state.indexes.nodes);
7261
+ const zones = useAppStore((s) => s.state.indexes.zones);
7262
+ const selectedId = useAppStore((s) => {
7263
+ var _a;
7264
+ return ((_a = s.selectedItem) == null ? void 0 : _a.props.id) || null;
7265
+ });
7266
+ const rootZones = useAppStore(
7267
+ useShallow8((s) => findZonesForArea(s.state, "root"))
7239
7268
  );
7240
- const Page = useCallback17(
7241
- (pageProps) => {
7242
- var _a, _b, _c, _d;
7243
- const propsWithSlots = useSlots(
7269
+ const selectedPathIds = useMemo18(() => {
7270
+ var _a;
7271
+ const selectedPath = selectedId ? (_a = nodes[selectedId]) == null ? void 0 : _a.path : null;
7272
+ return new Set(
7273
+ (selectedPath == null ? void 0 : selectedPath.map((candidate) => candidate.split(":")[0]).filter(Boolean)) || []
7274
+ );
7275
+ }, [nodes, selectedId]);
7276
+ const trees = useMemo18(
7277
+ () => rootZones.map(
7278
+ (zoneCompound) => buildLayerTree({
7244
7279
  config,
7245
- { type: "root", props: pageProps },
7246
- DropZoneEditPure
7247
- );
7248
- const richtextProps = useRichtextProps(
7249
- (_b = (_a = config.root) == null ? void 0 : _a.fields) != null ? _b : {},
7250
- pageProps
7251
- );
7252
- return ((_c = config.root) == null ? void 0 : _c.render) ? (_d = config.root) == null ? void 0 : _d.render(__spreadValues(__spreadValues({
7253
- id: "editor-root"
7254
- }, propsWithSlots), richtextProps)) : /* @__PURE__ */ jsx45(Fragment11, { children: propsWithSlots.children });
7255
- },
7256
- [config]
7280
+ label: rootZones.length === 1 ? "" : zoneCompound.split(":")[1],
7281
+ nodes,
7282
+ zoneCompound,
7283
+ zones
7284
+ })
7285
+ ),
7286
+ [config, nodes, rootZones, zones]
7257
7287
  );
7258
- const Frame = useMemo18(() => overrides.iframe, [overrides]);
7259
- const rootProps = root.props || root;
7260
- const ref = useRef12(null);
7261
- const inner = !renderData ? /* @__PURE__ */ jsx45(
7262
- Page,
7263
- __spreadProps(__spreadValues({}, rootProps), {
7264
- editor: {
7265
- renderDropZone: DropZonePure,
7266
- isEditing: true,
7267
- dragRef: null,
7268
- metadata
7269
- },
7270
- editMode: true,
7271
- children: /* @__PURE__ */ jsx45(DropZonePure, { zone: rootDroppableId })
7272
- })
7273
- ) : /* @__PURE__ */ jsx45(Render, { data: renderData, config, metadata });
7274
- useEffect21(() => {
7275
- if (!iframe.enabled) {
7276
- setStatus("READY");
7277
- }
7278
- }, [iframe.enabled]);
7279
- return /* @__PURE__ */ jsx45(
7280
- "div",
7288
+ const Wrapper = useMemo18(() => outlineOverride || "div", [outlineOverride]);
7289
+ return /* @__PURE__ */ jsx44(Wrapper, { children: /* @__PURE__ */ jsx44(
7290
+ LayerTree,
7281
7291
  {
7282
- className: getClassName27(),
7283
- id,
7284
- "data-editor-preview": true,
7285
- onClick: (e) => {
7286
- const el = e.target;
7287
- if (!el.hasAttribute("data-editor-component") && !el.hasAttribute("data-editor-dropzone")) {
7288
- dispatch({ type: "setUi", ui: { itemSelector: null } });
7289
- }
7290
- },
7291
- children: iframe.enabled ? /* @__PURE__ */ jsx45(
7292
- AutoFrame_default,
7293
- {
7294
- id: "preview-frame",
7295
- className: getClassName27("frame"),
7296
- "data-rfd-iframe": true,
7297
- onReady: () => {
7298
- setStatus("READY");
7299
- },
7300
- onNotReady: () => {
7301
- setStatus("MOUNTED");
7302
- },
7303
- frameRef: ref,
7304
- children: /* @__PURE__ */ jsx45(autoFrameContext.Consumer, { children: ({ document: document2 }) => {
7305
- if (Frame) {
7306
- return /* @__PURE__ */ jsx45(Frame, { document: document2, children: inner });
7307
- }
7308
- return inner;
7309
- } })
7310
- }
7311
- ) : /* @__PURE__ */ jsx45(
7312
- "div",
7313
- {
7314
- id: "preview-frame",
7315
- className: getClassName27("frame"),
7316
- ref,
7317
- "data-editor-entry": true,
7318
- children: inner
7319
- }
7320
- )
7292
+ selectedId,
7293
+ selectedPathIds,
7294
+ trees
7321
7295
  }
7322
- );
7296
+ ) });
7323
7297
  };
7324
7298
 
7325
7299
  // lib/use-loaded-overrides.ts
@@ -7429,7 +7403,7 @@ import {
7429
7403
 
7430
7404
  // css-module:/Users/rami/Documents/apps/react-editor/packages/core/components/Editor/components/Layout/styles.module.css#css-module
7431
7405
  init_react_import();
7432
- var styles_module_default23 = { "Editor": "_Editor_1ty8s_19", "Editor-portal": "_Editor-portal_1ty8s_32", "EditorLayout": "_EditorLayout_1ty8s_37", "EditorLayout-inner": "_EditorLayout-inner_1ty8s_41", "Editor--hidePlugins": "_Editor--hidePlugins_1ty8s_73", "EditorLayout--mounted": "_EditorLayout--mounted_1ty8s_78", "EditorLayout--mobilePanelHeightToggle": "_EditorLayout--mobilePanelHeightToggle_1ty8s_82", "EditorLayout--leftSideBarVisible": "_EditorLayout--leftSideBarVisible_1ty8s_82", "EditorLayout--mobilePanelCustomHeight": "_EditorLayout--mobilePanelCustomHeight_1ty8s_87", "EditorLayout--mobilePanelHeightMinContent": "_EditorLayout--mobilePanelHeightMinContent_1ty8s_105", "EditorLayout--rightSideBarVisible": "_EditorLayout--rightSideBarVisible_1ty8s_127", "EditorLayout-mounted": "_EditorLayout-mounted_1ty8s_146", "EditorLayout-nav": "_EditorLayout-nav_1ty8s_187", "Editor-fieldSideBarToolbar": "_Editor-fieldSideBarToolbar_1ty8s_203", "Editor-fieldSideBarHistory": "_Editor-fieldSideBarHistory_1ty8s_213", "Editor-fieldSideBarActions": "_Editor-fieldSideBarActions_1ty8s_219", "EditorLayout-mobilePanel": "_EditorLayout-mobilePanel_1ty8s_225", "EditorLayout-mobilePanelContent": "_EditorLayout-mobilePanelContent_1ty8s_245", "EditorLayout-mobileDragHandle": "_EditorLayout-mobileDragHandle_1ty8s_252", "EditorLayout-mobileDragHandlePill": "_EditorLayout-mobileDragHandlePill_1ty8s_266", "EditorPluginTab": "_EditorPluginTab_1ty8s_273", "EditorPluginTab--visible": "_EditorPluginTab--visible_1ty8s_279", "EditorPluginTab-body": "_EditorPluginTab-body_1ty8s_284" };
7406
+ var styles_module_default22 = { "Editor": "_Editor_1ty8s_19", "Editor-portal": "_Editor-portal_1ty8s_32", "EditorLayout": "_EditorLayout_1ty8s_37", "EditorLayout-inner": "_EditorLayout-inner_1ty8s_41", "Editor--hidePlugins": "_Editor--hidePlugins_1ty8s_73", "EditorLayout--mounted": "_EditorLayout--mounted_1ty8s_78", "EditorLayout--mobilePanelHeightToggle": "_EditorLayout--mobilePanelHeightToggle_1ty8s_82", "EditorLayout--leftSideBarVisible": "_EditorLayout--leftSideBarVisible_1ty8s_82", "EditorLayout--mobilePanelCustomHeight": "_EditorLayout--mobilePanelCustomHeight_1ty8s_87", "EditorLayout--mobilePanelHeightMinContent": "_EditorLayout--mobilePanelHeightMinContent_1ty8s_105", "EditorLayout--rightSideBarVisible": "_EditorLayout--rightSideBarVisible_1ty8s_127", "EditorLayout-mounted": "_EditorLayout-mounted_1ty8s_146", "EditorLayout-nav": "_EditorLayout-nav_1ty8s_187", "Editor-fieldSideBarToolbar": "_Editor-fieldSideBarToolbar_1ty8s_203", "Editor-fieldSideBarHistory": "_Editor-fieldSideBarHistory_1ty8s_213", "Editor-fieldSideBarActions": "_Editor-fieldSideBarActions_1ty8s_219", "EditorLayout-mobilePanel": "_EditorLayout-mobilePanel_1ty8s_225", "EditorLayout-mobilePanelContent": "_EditorLayout-mobilePanelContent_1ty8s_245", "EditorLayout-mobileDragHandle": "_EditorLayout-mobileDragHandle_1ty8s_252", "EditorLayout-mobileDragHandlePill": "_EditorLayout-mobileDragHandlePill_1ty8s_266", "EditorPluginTab": "_EditorPluginTab_1ty8s_273", "EditorPluginTab--visible": "_EditorPluginTab--visible_1ty8s_279", "EditorPluginTab-body": "_EditorPluginTab-body_1ty8s_284" };
7433
7407
 
7434
7408
  // lib/use-inject-css.ts
7435
7409
  init_react_import();
@@ -7460,8 +7434,8 @@ var useInjectGlobalCss = (iframeEnabled) => {
7460
7434
 
7461
7435
  // components/DefaultOverride/index.tsx
7462
7436
  init_react_import();
7463
- import { Fragment as Fragment12, jsx as jsx46 } from "react/jsx-runtime";
7464
- var DefaultOverride = ({ children }) => /* @__PURE__ */ jsx46(Fragment12, { children });
7437
+ import { Fragment as Fragment12, jsx as jsx45 } from "react/jsx-runtime";
7438
+ var DefaultOverride = ({ children }) => /* @__PURE__ */ jsx45(Fragment12, { children });
7465
7439
 
7466
7440
  // lib/use-preview-mode-hotkeys.ts
7467
7441
  init_react_import();
@@ -7486,11 +7460,11 @@ init_react_import();
7486
7460
 
7487
7461
  // css-module:/Users/rami/Documents/apps/react-editor/packages/core/components/SidebarSection/styles.module.css#css-module
7488
7462
  init_react_import();
7489
- var styles_module_default24 = { "SidebarSection": "_SidebarSection_tt2oy_1", "SidebarSection-title": "_SidebarSection-title_tt2oy_12", "SidebarSection--noBorderTop": "_SidebarSection--noBorderTop_tt2oy_20", "SidebarSection-content": "_SidebarSection-content_tt2oy_24", "SidebarSection-breadcrumbLabel": "_SidebarSection-breadcrumbLabel_tt2oy_33", "SidebarSection-breadcrumbs": "_SidebarSection-breadcrumbs_tt2oy_62", "SidebarSection-breadcrumb": "_SidebarSection-breadcrumb_tt2oy_33", "SidebarSection-heading": "_SidebarSection-heading_tt2oy_74", "SidebarSection-loadingOverlay": "_SidebarSection-loadingOverlay_tt2oy_88" };
7463
+ var styles_module_default23 = { "SidebarSection": "_SidebarSection_tt2oy_1", "SidebarSection-title": "_SidebarSection-title_tt2oy_12", "SidebarSection--noBorderTop": "_SidebarSection--noBorderTop_tt2oy_20", "SidebarSection-content": "_SidebarSection-content_tt2oy_24", "SidebarSection-breadcrumbLabel": "_SidebarSection-breadcrumbLabel_tt2oy_33", "SidebarSection-breadcrumbs": "_SidebarSection-breadcrumbs_tt2oy_62", "SidebarSection-breadcrumb": "_SidebarSection-breadcrumb_tt2oy_33", "SidebarSection-heading": "_SidebarSection-heading_tt2oy_74", "SidebarSection-loadingOverlay": "_SidebarSection-loadingOverlay_tt2oy_88" };
7490
7464
 
7491
7465
  // components/SidebarSection/index.tsx
7492
- import { jsx as jsx47, jsxs as jsxs18 } from "react/jsx-runtime";
7493
- var getClassName28 = get_class_name_factory_default("SidebarSection", styles_module_default24);
7466
+ import { jsx as jsx46, jsxs as jsxs18 } from "react/jsx-runtime";
7467
+ var getClassName27 = get_class_name_factory_default("SidebarSection", styles_module_default23);
7494
7468
  var SidebarSection = ({
7495
7469
  children,
7496
7470
  title,
@@ -7499,13 +7473,13 @@ var SidebarSection = ({
7499
7473
  noBorderTop,
7500
7474
  isLoading
7501
7475
  }) => {
7502
- return /* @__PURE__ */ jsxs18("div", { className: getClassName28({ noBorderTop }), style: { background }, children: [
7503
- /* @__PURE__ */ jsx47("div", { className: getClassName28("title"), children: /* @__PURE__ */ jsxs18("div", { className: getClassName28("breadcrumbs"), children: [
7504
- showBreadcrumbs && /* @__PURE__ */ jsx47(Breadcrumbs, {}),
7505
- /* @__PURE__ */ jsx47("div", { className: getClassName28("heading"), children: /* @__PURE__ */ jsx47(Heading, { rank: "2", size: "xs", children: title }) })
7476
+ return /* @__PURE__ */ jsxs18("div", { className: getClassName27({ noBorderTop }), style: { background }, children: [
7477
+ /* @__PURE__ */ jsx46("div", { className: getClassName27("title"), children: /* @__PURE__ */ jsxs18("div", { className: getClassName27("breadcrumbs"), children: [
7478
+ showBreadcrumbs && /* @__PURE__ */ jsx46(Breadcrumbs, {}),
7479
+ /* @__PURE__ */ jsx46("div", { className: getClassName27("heading"), children: /* @__PURE__ */ jsx46(Heading, { rank: "2", size: "xs", children: title }) })
7506
7480
  ] }) }),
7507
- /* @__PURE__ */ jsx47("div", { className: getClassName28("content"), children }),
7508
- isLoading && /* @__PURE__ */ jsx47("div", { className: getClassName28("loadingOverlay"), children: /* @__PURE__ */ jsx47(Loader, { size: 32 }) })
7481
+ /* @__PURE__ */ jsx46("div", { className: getClassName27("content"), children }),
7482
+ isLoading && /* @__PURE__ */ jsx46("div", { className: getClassName27("loadingOverlay"), children: /* @__PURE__ */ jsx46(Loader, { size: 32 }) })
7509
7483
  ] });
7510
7484
  };
7511
7485
 
@@ -7529,11 +7503,11 @@ import { Combobox as ComboboxPrimitive } from "@base-ui/react";
7529
7503
 
7530
7504
  // css-module:/Users/rami/Documents/apps/react-editor/packages/core/components/ui/Combobox/styles.module.css#css-module
7531
7505
  init_react_import();
7532
- var styles_module_default25 = { "EditorCombobox-input": "_EditorCombobox-input_12a2a_4", "EditorCombobox-trigger": "_EditorCombobox-trigger_12a2a_21", "EditorCombobox-triggerIcon": "_EditorCombobox-triggerIcon_12a2a_42", "EditorCombobox-positioner": "_EditorCombobox-positioner_12a2a_46", "EditorCombobox-content": "_EditorCombobox-content_12a2a_50", "EditorCombobox-list": "_EditorCombobox-list_12a2a_65", "EditorCombobox-item": "_EditorCombobox-item_12a2a_71", "EditorCombobox-itemIndicator": "_EditorCombobox-itemIndicator_12a2a_97", "EditorCombobox-empty": "_EditorCombobox-empty_12a2a_110" };
7506
+ var styles_module_default24 = { "EditorCombobox-input": "_EditorCombobox-input_12a2a_4", "EditorCombobox-trigger": "_EditorCombobox-trigger_12a2a_21", "EditorCombobox-triggerIcon": "_EditorCombobox-triggerIcon_12a2a_42", "EditorCombobox-positioner": "_EditorCombobox-positioner_12a2a_46", "EditorCombobox-content": "_EditorCombobox-content_12a2a_50", "EditorCombobox-list": "_EditorCombobox-list_12a2a_65", "EditorCombobox-item": "_EditorCombobox-item_12a2a_71", "EditorCombobox-itemIndicator": "_EditorCombobox-itemIndicator_12a2a_97", "EditorCombobox-empty": "_EditorCombobox-empty_12a2a_110" };
7533
7507
 
7534
7508
  // components/ui/Combobox/index.tsx
7535
- import { jsx as jsx48, jsxs as jsxs19 } from "react/jsx-runtime";
7536
- var getClassName29 = get_class_name_factory_default("EditorCombobox", styles_module_default25);
7509
+ import { jsx as jsx47, jsxs as jsxs19 } from "react/jsx-runtime";
7510
+ var getClassName28 = get_class_name_factory_default("EditorCombobox", styles_module_default24);
7537
7511
  var join = (...values) => values.filter(Boolean).join(" ");
7538
7512
  var mergeClassName = (base, override) => {
7539
7513
  if (!override) return base;
@@ -7549,11 +7523,11 @@ function ComboboxInput(_a) {
7549
7523
  } = _b, props = __objRest(_b, [
7550
7524
  "className"
7551
7525
  ]);
7552
- return /* @__PURE__ */ jsx48(
7526
+ return /* @__PURE__ */ jsx47(
7553
7527
  ComboboxPrimitive.Input,
7554
7528
  __spreadValues({
7555
7529
  "data-slot": "combobox-input",
7556
- className: mergeClassName(getClassName29("input"), className)
7530
+ className: mergeClassName(getClassName28("input"), className)
7557
7531
  }, props)
7558
7532
  );
7559
7533
  }
@@ -7573,19 +7547,19 @@ function ComboboxContent(_a) {
7573
7547
  "alignOffset",
7574
7548
  "children"
7575
7549
  ]);
7576
- return /* @__PURE__ */ jsx48(ComboboxPrimitive.Portal, { children: /* @__PURE__ */ jsx48(
7550
+ return /* @__PURE__ */ jsx47(ComboboxPrimitive.Portal, { children: /* @__PURE__ */ jsx47(
7577
7551
  ComboboxPrimitive.Positioner,
7578
7552
  {
7579
7553
  side,
7580
7554
  sideOffset,
7581
7555
  align,
7582
7556
  alignOffset,
7583
- className: getClassName29("positioner"),
7584
- children: /* @__PURE__ */ jsx48(
7557
+ className: getClassName28("positioner"),
7558
+ children: /* @__PURE__ */ jsx47(
7585
7559
  ComboboxPrimitive.Popup,
7586
7560
  __spreadProps(__spreadValues({
7587
7561
  "data-slot": "combobox-content",
7588
- className: mergeClassName(getClassName29("content"), className)
7562
+ className: mergeClassName(getClassName28("content"), className)
7589
7563
  }, props), {
7590
7564
  children
7591
7565
  })
@@ -7599,11 +7573,11 @@ function ComboboxList(_a) {
7599
7573
  } = _b, props = __objRest(_b, [
7600
7574
  "className"
7601
7575
  ]);
7602
- return /* @__PURE__ */ jsx48(
7576
+ return /* @__PURE__ */ jsx47(
7603
7577
  ComboboxPrimitive.List,
7604
7578
  __spreadValues({
7605
7579
  "data-slot": "combobox-list",
7606
- className: mergeClassName(getClassName29("list"), className)
7580
+ className: mergeClassName(getClassName28("list"), className)
7607
7581
  }, props)
7608
7582
  );
7609
7583
  }
@@ -7619,10 +7593,10 @@ function ComboboxItem(_a) {
7619
7593
  ComboboxPrimitive.Item,
7620
7594
  __spreadProps(__spreadValues({
7621
7595
  "data-slot": "combobox-item",
7622
- className: mergeClassName(getClassName29("item"), className)
7596
+ className: mergeClassName(getClassName28("item"), className)
7623
7597
  }, props), {
7624
7598
  children: [
7625
- /* @__PURE__ */ jsx48("span", { className: getClassName29("itemIndicator"), children: /* @__PURE__ */ jsx48(ComboboxPrimitive.ItemIndicator, { children: /* @__PURE__ */ jsx48(Check, { size: 14 }) }) }),
7599
+ /* @__PURE__ */ jsx47("span", { className: getClassName28("itemIndicator"), children: /* @__PURE__ */ jsx47(ComboboxPrimitive.ItemIndicator, { children: /* @__PURE__ */ jsx47(Check, { size: 14 }) }) }),
7626
7600
  children
7627
7601
  ]
7628
7602
  })
@@ -7634,27 +7608,27 @@ function ComboboxEmpty(_a) {
7634
7608
  } = _b, props = __objRest(_b, [
7635
7609
  "className"
7636
7610
  ]);
7637
- return /* @__PURE__ */ jsx48(
7611
+ return /* @__PURE__ */ jsx47(
7638
7612
  ComboboxPrimitive.Empty,
7639
7613
  __spreadValues({
7640
7614
  "data-slot": "combobox-empty",
7641
- className: mergeClassName(getClassName29("empty"), className)
7615
+ className: mergeClassName(getClassName28("empty"), className)
7642
7616
  }, props)
7643
7617
  );
7644
7618
  }
7645
7619
 
7646
7620
  // css-module:/Users/rami/Documents/apps/react-editor/packages/core/components/BrowserBar/styles.module.css#css-module
7647
7621
  init_react_import();
7648
- var styles_module_default26 = { "BrowserBar": "_BrowserBar_x10eb_1", "BrowserBar-urlTrigger": "_BrowserBar-urlTrigger_x10eb_16", "BrowserBar-urlIcon": "_BrowserBar-urlIcon_x10eb_46", "BrowserBar-urlText": "_BrowserBar-urlText_x10eb_51", "BrowserBar-urlInput": "_BrowserBar-urlInput_x10eb_63", "BrowserBar-itemPath": "_BrowserBar-itemPath_x10eb_69", "BrowserBar-itemTitle": "_BrowserBar-itemTitle_x10eb_74", "BrowserBar-actions": "_BrowserBar-actions_x10eb_82", "BrowserBar-deviceIcon": "_BrowserBar-deviceIcon_x10eb_89" };
7622
+ var styles_module_default25 = { "BrowserBar": "_BrowserBar_x10eb_1", "BrowserBar-urlTrigger": "_BrowserBar-urlTrigger_x10eb_16", "BrowserBar-urlIcon": "_BrowserBar-urlIcon_x10eb_46", "BrowserBar-urlText": "_BrowserBar-urlText_x10eb_51", "BrowserBar-urlInput": "_BrowserBar-urlInput_x10eb_63", "BrowserBar-itemPath": "_BrowserBar-itemPath_x10eb_69", "BrowserBar-itemTitle": "_BrowserBar-itemTitle_x10eb_74", "BrowserBar-actions": "_BrowserBar-actions_x10eb_82", "BrowserBar-deviceIcon": "_BrowserBar-deviceIcon_x10eb_89" };
7649
7623
 
7650
7624
  // components/BrowserBar/index.tsx
7651
- import { jsx as jsx49, jsxs as jsxs20 } from "react/jsx-runtime";
7625
+ import { jsx as jsx48, jsxs as jsxs20 } from "react/jsx-runtime";
7652
7626
  var normalizeRoute = (raw) => {
7653
7627
  const trimmed = raw.trim();
7654
7628
  if (!trimmed) return trimmed;
7655
7629
  return trimmed.startsWith("/") ? trimmed : `/${trimmed}`;
7656
7630
  };
7657
- var getClassName30 = get_class_name_factory_default("BrowserBar", styles_module_default26);
7631
+ var getClassName29 = get_class_name_factory_default("BrowserBar", styles_module_default25);
7658
7632
  var DEVICE_VIEWPORTS = {
7659
7633
  desktop: { width: "100%", height: "auto", icon: "Monitor", label: "Desktop" },
7660
7634
  mobile: { width: 360, height: "auto", icon: "Smartphone", label: "Mobile" }
@@ -7662,7 +7636,7 @@ var DEVICE_VIEWPORTS = {
7662
7636
  var BrowserBar = ({
7663
7637
  onViewportChange
7664
7638
  }) => {
7665
- const { routes, currentPath, onRouteChange } = usePropsContext();
7639
+ const { routes, currentRoute, onRouteChange } = usePropsContext();
7666
7640
  const viewports = useAppStore((s) => s.state.ui.viewports);
7667
7641
  const dispatch = useAppStore((s) => s.dispatch);
7668
7642
  const leftSideBarVisible = useAppStore((s) => s.state.ui.leftSideBarVisible);
@@ -7688,24 +7662,24 @@ var BrowserBar = ({
7688
7662
  const setDevice = (device) => {
7689
7663
  onViewportChange == null ? void 0 : onViewportChange(DEVICE_VIEWPORTS[device]);
7690
7664
  };
7691
- const showRoutePicker = !!routes && currentPath !== void 0 && !!onRouteChange;
7692
- const [inputValue, setInputValue] = useState20(currentPath != null ? currentPath : "");
7693
- const lastSyncedPath = useRef13(currentPath);
7694
- if (lastSyncedPath.current !== currentPath) {
7695
- lastSyncedPath.current = currentPath;
7696
- setInputValue(currentPath != null ? currentPath : "");
7665
+ const showRoutePicker = !!routes && currentRoute !== void 0 && !!onRouteChange;
7666
+ const [inputValue, setInputValue] = useState20(currentRoute != null ? currentRoute : "");
7667
+ const lastSyncedPath = useRef13(currentRoute);
7668
+ if (lastSyncedPath.current !== currentRoute) {
7669
+ lastSyncedPath.current = currentRoute;
7670
+ setInputValue(currentRoute != null ? currentRoute : "");
7697
7671
  }
7698
7672
  const submit = (raw) => {
7699
7673
  const next = normalizeRoute(raw);
7700
- if (!next || next === currentPath) return;
7674
+ if (!next || next === currentRoute) return;
7701
7675
  void (onRouteChange == null ? void 0 : onRouteChange(next));
7702
7676
  };
7703
- return /* @__PURE__ */ jsxs20("div", { className: getClassName30(), children: [
7677
+ return /* @__PURE__ */ jsxs20("div", { className: getClassName29(), children: [
7704
7678
  showRoutePicker ? /* @__PURE__ */ jsxs20(
7705
7679
  Combobox,
7706
7680
  {
7707
- items: routes.map((r) => r.path),
7708
- value: currentPath,
7681
+ items: routes,
7682
+ value: currentRoute,
7709
7683
  onValueChange: (next) => {
7710
7684
  if (typeof next === "string") submit(next);
7711
7685
  },
@@ -7716,17 +7690,17 @@ var BrowserBar = ({
7716
7690
  /* @__PURE__ */ jsxs20(
7717
7691
  "form",
7718
7692
  {
7719
- className: getClassName30("urlTrigger"),
7693
+ className: getClassName29("urlTrigger"),
7720
7694
  onSubmit: (event) => {
7721
7695
  event.preventDefault();
7722
7696
  submit(inputValue);
7723
7697
  },
7724
7698
  children: [
7725
- /* @__PURE__ */ jsx49(Globe, { className: getClassName30("urlIcon"), size: 14 }),
7726
- /* @__PURE__ */ jsx49(
7699
+ /* @__PURE__ */ jsx48(Globe, { className: getClassName29("urlIcon"), size: 14 }),
7700
+ /* @__PURE__ */ jsx48(
7727
7701
  ComboboxInput,
7728
7702
  {
7729
- className: getClassName30("urlInput"),
7703
+ className: getClassName29("urlInput"),
7730
7704
  placeholder: "/",
7731
7705
  spellCheck: false,
7732
7706
  autoCorrect: "off",
@@ -7737,38 +7711,32 @@ var BrowserBar = ({
7737
7711
  }
7738
7712
  ),
7739
7713
  /* @__PURE__ */ jsxs20(ComboboxContent, { children: [
7740
- /* @__PURE__ */ jsx49(ComboboxEmpty, { children: "Press Enter to go to this path" }),
7741
- /* @__PURE__ */ jsx49(ComboboxList, { children: (path) => {
7742
- const route = routes.find((r) => r.path === path);
7743
- return /* @__PURE__ */ jsxs20(ComboboxItem, { value: path, children: [
7744
- /* @__PURE__ */ jsx49("span", { className: getClassName30("itemPath"), children: path }),
7745
- (route == null ? void 0 : route.title) ? /* @__PURE__ */ jsx49("span", { className: getClassName30("itemTitle"), children: route.title }) : null
7746
- ] }, path);
7747
- } })
7714
+ /* @__PURE__ */ jsx48(ComboboxEmpty, { children: "Press Enter to go to this path" }),
7715
+ /* @__PURE__ */ jsx48(ComboboxList, { children: (path) => /* @__PURE__ */ jsx48(ComboboxItem, { value: path, children: /* @__PURE__ */ jsx48("span", { className: getClassName29("itemPath"), children: path }) }, path) })
7748
7716
  ] })
7749
7717
  ]
7750
7718
  }
7751
- ) : /* @__PURE__ */ jsxs20("div", { className: getClassName30("urlTrigger"), children: [
7752
- /* @__PURE__ */ jsx49(Globe, { className: getClassName30("urlIcon"), size: 14 }),
7753
- /* @__PURE__ */ jsx49("span", { className: getClassName30("urlText"), children: "/" })
7719
+ ) : /* @__PURE__ */ jsxs20("div", { className: getClassName29("urlTrigger"), children: [
7720
+ /* @__PURE__ */ jsx48(Globe, { className: getClassName29("urlIcon"), size: 14 }),
7721
+ /* @__PURE__ */ jsx48("span", { className: getClassName29("urlText"), children: "/" })
7754
7722
  ] }),
7755
- /* @__PURE__ */ jsxs20("div", { className: getClassName30("actions"), children: [
7756
- /* @__PURE__ */ jsx49(
7723
+ /* @__PURE__ */ jsxs20("div", { className: getClassName29("actions"), children: [
7724
+ /* @__PURE__ */ jsx48(
7757
7725
  IconButton,
7758
7726
  {
7759
7727
  type: "button",
7760
7728
  title: activeDevice === "desktop" ? "Switch to mobile viewport" : "Switch to desktop viewport",
7761
7729
  onClick: () => setDevice(activeDevice === "desktop" ? "mobile" : "desktop"),
7762
- children: /* @__PURE__ */ jsx49("span", { className: getClassName30("deviceIcon"), children: activeDevice === "desktop" ? /* @__PURE__ */ jsx49(Monitor, { size: 16 }) : /* @__PURE__ */ jsx49(Smartphone, { size: 16 }) })
7730
+ children: /* @__PURE__ */ jsx48("span", { className: getClassName29("deviceIcon"), children: activeDevice === "desktop" ? /* @__PURE__ */ jsx48(Monitor, { size: 16 }) : /* @__PURE__ */ jsx48(Smartphone, { size: 16 }) })
7763
7731
  }
7764
7732
  ),
7765
- /* @__PURE__ */ jsx49(
7733
+ /* @__PURE__ */ jsx48(
7766
7734
  IconButton,
7767
7735
  {
7768
7736
  type: "button",
7769
7737
  title: isFullScreen ? "Exit full screen" : "Enter full screen",
7770
7738
  onClick: toggleFullScreen,
7771
- children: /* @__PURE__ */ jsx49("span", { className: getClassName30("deviceIcon"), children: isFullScreen ? /* @__PURE__ */ jsx49(Minimize, { size: 16 }) : /* @__PURE__ */ jsx49(Maximize, { size: 16 }) })
7739
+ children: /* @__PURE__ */ jsx48("span", { className: getClassName29("deviceIcon"), children: isFullScreen ? /* @__PURE__ */ jsx48(Minimize, { size: 16 }) : /* @__PURE__ */ jsx48(Maximize, { size: 16 }) })
7772
7740
  }
7773
7741
  )
7774
7742
  ] })
@@ -7777,7 +7745,7 @@ var BrowserBar = ({
7777
7745
 
7778
7746
  // css-module:/Users/rami/Documents/apps/react-editor/packages/core/components/Editor/components/Canvas/styles.module.css#css-module
7779
7747
  init_react_import();
7780
- var styles_module_default27 = { "EditorCanvas": "_EditorCanvas_es8bv_1", "EditorCanvas-controls": "_EditorCanvas-controls_es8bv_17", "EditorCanvas--fullScreen": "_EditorCanvas--fullScreen_es8bv_22", "EditorCanvas-inner": "_EditorCanvas-inner_es8bv_33", "EditorCanvas-rootColumn": "_EditorCanvas-rootColumn_es8bv_46", "EditorCanvas-root": "_EditorCanvas-root_es8bv_46", "EditorCanvas--ready": "_EditorCanvas--ready_es8bv_83", "EditorCanvas-loader": "_EditorCanvas-loader_es8bv_88", "EditorCanvas--showLoader": "_EditorCanvas--showLoader_es8bv_100", "EditorCanvas-browserBar": "_EditorCanvas-browserBar_es8bv_109", "EditorCanvas-zoomControls": "_EditorCanvas-zoomControls_es8bv_114" };
7748
+ var styles_module_default26 = { "EditorCanvas": "_EditorCanvas_es8bv_1", "EditorCanvas-controls": "_EditorCanvas-controls_es8bv_17", "EditorCanvas--fullScreen": "_EditorCanvas--fullScreen_es8bv_22", "EditorCanvas-inner": "_EditorCanvas-inner_es8bv_33", "EditorCanvas-rootColumn": "_EditorCanvas-rootColumn_es8bv_46", "EditorCanvas-root": "_EditorCanvas-root_es8bv_46", "EditorCanvas--ready": "_EditorCanvas--ready_es8bv_83", "EditorCanvas-loader": "_EditorCanvas-loader_es8bv_88", "EditorCanvas--showLoader": "_EditorCanvas--showLoader_es8bv_100", "EditorCanvas-browserBar": "_EditorCanvas-browserBar_es8bv_109", "EditorCanvas-zoomControls": "_EditorCanvas-zoomControls_es8bv_114" };
7781
7749
 
7782
7750
  // components/Editor/components/Canvas/index.tsx
7783
7751
  import { useShallow as useShallow9 } from "zustand/react/shallow";
@@ -7790,7 +7758,7 @@ import {
7790
7758
  useRef as useRef14,
7791
7759
  useMemo as useMemo21
7792
7760
  } from "react";
7793
- import { jsx as jsx50 } from "react/jsx-runtime";
7761
+ import { jsx as jsx49 } from "react/jsx-runtime";
7794
7762
  var FrameContext = createContext7(null);
7795
7763
  var FrameProvider = ({
7796
7764
  children
@@ -7802,7 +7770,7 @@ var FrameProvider = ({
7802
7770
  }),
7803
7771
  []
7804
7772
  );
7805
- return /* @__PURE__ */ jsx50(FrameContext.Provider, { value, children });
7773
+ return /* @__PURE__ */ jsx49(FrameContext.Provider, { value, children });
7806
7774
  };
7807
7775
  var useCanvasFrame = () => {
7808
7776
  const context = useContext14(FrameContext);
@@ -7813,8 +7781,8 @@ var useCanvasFrame = () => {
7813
7781
  };
7814
7782
 
7815
7783
  // components/Editor/components/Canvas/index.tsx
7816
- import { Fragment as Fragment13, jsx as jsx51, jsxs as jsxs21 } from "react/jsx-runtime";
7817
- var getClassName31 = get_class_name_factory_default("EditorCanvas", styles_module_default27);
7784
+ import { Fragment as Fragment13, jsx as jsx50, jsxs as jsxs21 } from "react/jsx-runtime";
7785
+ var getClassName30 = get_class_name_factory_default("EditorCanvas", styles_module_default26);
7818
7786
  var ZOOM_STEP = 0.15;
7819
7787
  var MIN_ZOOM = 0.25;
7820
7788
  var MAX_ZOOM = 3;
@@ -7856,7 +7824,7 @@ var Canvas = () => {
7856
7824
  const [showTransition, setShowTransition] = useState21(false);
7857
7825
  const isResizingRef = useRef15(false);
7858
7826
  const defaultRender = useMemo22(() => {
7859
- const EditorDefault = ({ children }) => /* @__PURE__ */ jsx51(Fragment13, { children });
7827
+ const EditorDefault = ({ children }) => /* @__PURE__ */ jsx50(Fragment13, { children });
7860
7828
  return EditorDefault;
7861
7829
  }, []);
7862
7830
  const CustomPreview = useMemo22(
@@ -7978,10 +7946,10 @@ var Canvas = () => {
7978
7946
  appStoreApi,
7979
7947
  setUi
7980
7948
  ]);
7981
- return /* @__PURE__ */ jsx51(
7949
+ return /* @__PURE__ */ jsx50(
7982
7950
  "div",
7983
7951
  {
7984
- className: getClassName31({
7952
+ className: getClassName30({
7985
7953
  ready: status === "READY" || !iframe.enabled || !iframe.waitForStyles,
7986
7954
  showLoader,
7987
7955
  fullScreen: fullScreenCanvas
@@ -7996,16 +7964,16 @@ var Canvas = () => {
7996
7964
  });
7997
7965
  }
7998
7966
  },
7999
- children: /* @__PURE__ */ jsxs21("div", { className: getClassName31("inner"), ref: frameRef, children: [
8000
- !disableZoomControls && /* @__PURE__ */ jsxs21("div", { className: getClassName31("zoomControls"), children: [
8001
- /* @__PURE__ */ jsx51(IconButton, { type: "button", title: "Zoom out", onClick: zoomOut, children: /* @__PURE__ */ jsx51(Minus, { size: 14 }) }),
8002
- /* @__PURE__ */ jsx51(IconButton, { type: "button", title: "Reset zoom", onClick: resetZoom, children: /* @__PURE__ */ jsx51(RotateCcw, { size: 14 }) }),
8003
- /* @__PURE__ */ jsx51(IconButton, { type: "button", title: "Zoom in", onClick: zoomIn, children: /* @__PURE__ */ jsx51(Plus, { size: 14 }) })
7967
+ children: /* @__PURE__ */ jsxs21("div", { className: getClassName30("inner"), ref: frameRef, children: [
7968
+ !disableZoomControls && /* @__PURE__ */ jsxs21("div", { className: getClassName30("zoomControls"), children: [
7969
+ /* @__PURE__ */ jsx50(IconButton, { type: "button", title: "Zoom out", onClick: zoomOut, children: /* @__PURE__ */ jsx50(Minus, { size: 14 }) }),
7970
+ /* @__PURE__ */ jsx50(IconButton, { type: "button", title: "Reset zoom", onClick: resetZoom, children: /* @__PURE__ */ jsx50(RotateCcw, { size: 14 }) }),
7971
+ /* @__PURE__ */ jsx50(IconButton, { type: "button", title: "Zoom in", onClick: zoomIn, children: /* @__PURE__ */ jsx50(Plus, { size: 14 }) })
8004
7972
  ] }),
8005
7973
  /* @__PURE__ */ jsxs21(
8006
7974
  "div",
8007
7975
  {
8008
- className: getClassName31("rootColumn"),
7976
+ className: getClassName30("rootColumn"),
8009
7977
  style: {
8010
7978
  width: iframe.enabled ? viewports.current.width : "100%",
8011
7979
  transform: disableZoomControls ? void 0 : `scale(${canvasZoom})`,
@@ -8013,7 +7981,7 @@ var Canvas = () => {
8013
7981
  transition: showTransition ? `width ${TRANSITION_DURATION}ms ease-out, transform ${TRANSITION_DURATION}ms ease-out` : disableZoomControls ? void 0 : "transform 150ms ease-out"
8014
7982
  },
8015
7983
  children: [
8016
- iframe.enabled && /* @__PURE__ */ jsx51("div", { className: getClassName31("browserBar"), children: /* @__PURE__ */ jsx51(
7984
+ iframe.enabled && /* @__PURE__ */ jsx50("div", { className: getClassName30("browserBar"), children: /* @__PURE__ */ jsx50(
8017
7985
  BrowserBar,
8018
7986
  {
8019
7987
  onViewportChange: (viewport) => {
@@ -8030,23 +7998,23 @@ var Canvas = () => {
8030
7998
  }
8031
7999
  }
8032
8000
  ) }),
8033
- /* @__PURE__ */ jsx51(
8001
+ /* @__PURE__ */ jsx50(
8034
8002
  "div",
8035
8003
  {
8036
- className: getClassName31("root"),
8004
+ className: getClassName30("root"),
8037
8005
  suppressHydrationWarning: true,
8038
8006
  id: "editor-canvas-root",
8039
8007
  onTransitionEnd: () => {
8040
8008
  setShowTransition(false);
8041
8009
  isResizingRef.current = false;
8042
8010
  },
8043
- children: /* @__PURE__ */ jsx51(CustomPreview, { children: /* @__PURE__ */ jsx51(Preview2, {}) })
8011
+ children: /* @__PURE__ */ jsx50(CustomPreview, { children: /* @__PURE__ */ jsx50(Preview2, {}) })
8044
8012
  }
8045
8013
  )
8046
8014
  ]
8047
8015
  }
8048
8016
  ),
8049
- /* @__PURE__ */ jsx51("div", { className: getClassName31("loader"), children: /* @__PURE__ */ jsx51(Loader, { size: 24 }) })
8017
+ /* @__PURE__ */ jsx50("div", { className: getClassName30("loader"), children: /* @__PURE__ */ jsx50(Loader, { size: 24 }) })
8050
8018
  ] })
8051
8019
  }
8052
8020
  );
@@ -8142,11 +8110,11 @@ import { useCallback as useCallback21, useRef as useRef17 } from "react";
8142
8110
 
8143
8111
  // css-module:/Users/rami/Documents/apps/react-editor/packages/core/components/Editor/components/ResizeHandle/styles.module.css#css-module
8144
8112
  init_react_import();
8145
- var styles_module_default28 = { "ResizeHandle": "_ResizeHandle_1u3rv_2", "ResizeHandle--left": "_ResizeHandle--left_1u3rv_16", "ResizeHandle--right": "_ResizeHandle--right_1u3rv_20" };
8113
+ var styles_module_default27 = { "ResizeHandle": "_ResizeHandle_1u3rv_2", "ResizeHandle--left": "_ResizeHandle--left_1u3rv_16", "ResizeHandle--right": "_ResizeHandle--right_1u3rv_20" };
8146
8114
 
8147
8115
  // components/Editor/components/ResizeHandle/index.tsx
8148
- import { jsx as jsx52 } from "react/jsx-runtime";
8149
- var getClassName32 = get_class_name_factory_default("ResizeHandle", styles_module_default28);
8116
+ import { jsx as jsx51 } from "react/jsx-runtime";
8117
+ var getClassName31 = get_class_name_factory_default("ResizeHandle", styles_module_default27);
8150
8118
  var ResizeHandle = ({
8151
8119
  position,
8152
8120
  sidebarRef,
@@ -8201,11 +8169,11 @@ var ResizeHandle = ({
8201
8169
  },
8202
8170
  [position, handleMouseMove, handleMouseUp]
8203
8171
  );
8204
- return /* @__PURE__ */ jsx52(
8172
+ return /* @__PURE__ */ jsx51(
8205
8173
  "div",
8206
8174
  {
8207
8175
  ref: handleRef,
8208
- className: getClassName32({ [position]: true }),
8176
+ className: getClassName31({ [position]: true }),
8209
8177
  onMouseDown: handleMouseDown
8210
8178
  }
8211
8179
  );
@@ -8213,11 +8181,11 @@ var ResizeHandle = ({
8213
8181
 
8214
8182
  // css-module:/Users/rami/Documents/apps/react-editor/packages/core/components/Editor/components/Sidebar/styles.module.css#css-module
8215
8183
  init_react_import();
8216
- var styles_module_default29 = { "Sidebar": "_Sidebar_14k7q_1", "Sidebar--isVisible": "_Sidebar--isVisible_14k7q_9", "Sidebar--left": "_Sidebar--left_14k7q_13", "Sidebar--right": "_Sidebar--right_14k7q_25", "Sidebar-resizeHandle": "_Sidebar-resizeHandle_14k7q_37" };
8184
+ var styles_module_default28 = { "Sidebar": "_Sidebar_14k7q_1", "Sidebar--isVisible": "_Sidebar--isVisible_14k7q_9", "Sidebar--left": "_Sidebar--left_14k7q_13", "Sidebar--right": "_Sidebar--right_14k7q_25", "Sidebar-resizeHandle": "_Sidebar-resizeHandle_14k7q_37" };
8217
8185
 
8218
8186
  // components/Editor/components/Sidebar/index.tsx
8219
- import { Fragment as Fragment14, jsx as jsx53, jsxs as jsxs22 } from "react/jsx-runtime";
8220
- var getClassName33 = get_class_name_factory_default("Sidebar", styles_module_default29);
8187
+ import { Fragment as Fragment14, jsx as jsx52, jsxs as jsxs22 } from "react/jsx-runtime";
8188
+ var getClassName32 = get_class_name_factory_default("Sidebar", styles_module_default28);
8221
8189
  var Sidebar = ({
8222
8190
  position,
8223
8191
  sidebarRef,
@@ -8227,15 +8195,15 @@ var Sidebar = ({
8227
8195
  children
8228
8196
  }) => {
8229
8197
  return /* @__PURE__ */ jsxs22(Fragment14, { children: [
8230
- /* @__PURE__ */ jsx53(
8198
+ /* @__PURE__ */ jsx52(
8231
8199
  "div",
8232
8200
  {
8233
8201
  ref: sidebarRef,
8234
- className: getClassName33({ [position]: true, isVisible }),
8202
+ className: getClassName32({ [position]: true, isVisible }),
8235
8203
  children
8236
8204
  }
8237
8205
  ),
8238
- /* @__PURE__ */ jsx53("div", { className: `${getClassName33("resizeHandle")}`, children: /* @__PURE__ */ jsx53(
8206
+ /* @__PURE__ */ jsx52("div", { className: `${getClassName32("resizeHandle")}`, children: /* @__PURE__ */ jsx52(
8239
8207
  ResizeHandle,
8240
8208
  {
8241
8209
  position,
@@ -8410,12 +8378,12 @@ init_react_import();
8410
8378
 
8411
8379
  // css-module:/Users/rami/Documents/apps/react-editor/packages/core/components/Editor/components/Nav/styles.module.css#css-module
8412
8380
  init_react_import();
8413
- var styles_module_default30 = { "Nav": "_Nav_1g4tk_1", "Nav-list": "_Nav-list_1g4tk_18", "Nav-footer": "_Nav-footer_1g4tk_42", "NavItem-link": "_NavItem-link_1g4tk_55", "NavItem-linkLabel": "_NavItem-linkLabel_1g4tk_83", "NavItem": "_NavItem_1g4tk_55", "NavItem-linkIcon": "_NavItem-linkIcon_1g4tk_108", "NavItem--active": "_NavItem--active_1g4tk_121", "NavItem--mobileOnly": "_NavItem--mobileOnly_1g4tk_132", "NavItem--desktopOnly": "_NavItem--desktopOnly_1g4tk_137" };
8381
+ var styles_module_default29 = { "Nav": "_Nav_1g4tk_1", "Nav-list": "_Nav-list_1g4tk_18", "Nav-footer": "_Nav-footer_1g4tk_42", "NavItem-link": "_NavItem-link_1g4tk_55", "NavItem-linkLabel": "_NavItem-linkLabel_1g4tk_83", "NavItem": "_NavItem_1g4tk_55", "NavItem-linkIcon": "_NavItem-linkIcon_1g4tk_108", "NavItem--active": "_NavItem--active_1g4tk_121", "NavItem--mobileOnly": "_NavItem--mobileOnly_1g4tk_132", "NavItem--desktopOnly": "_NavItem--desktopOnly_1g4tk_137" };
8414
8382
 
8415
8383
  // components/Editor/components/Nav/index.tsx
8416
- import { jsx as jsx54, jsxs as jsxs23 } from "react/jsx-runtime";
8417
- var getClassName34 = get_class_name_factory_default("Nav", styles_module_default30);
8418
- var getClassNameItem3 = get_class_name_factory_default("NavItem", styles_module_default30);
8384
+ import { jsx as jsx53, jsxs as jsxs23 } from "react/jsx-runtime";
8385
+ var getClassName33 = get_class_name_factory_default("Nav", styles_module_default29);
8386
+ var getClassNameItem3 = get_class_name_factory_default("NavItem", styles_module_default29);
8419
8387
  var MenuItem = ({
8420
8388
  label,
8421
8389
  icon,
@@ -8424,7 +8392,7 @@ var MenuItem = ({
8424
8392
  mobileOnly,
8425
8393
  desktopOnly
8426
8394
  }) => {
8427
- return /* @__PURE__ */ jsx54(
8395
+ return /* @__PURE__ */ jsx53(
8428
8396
  "li",
8429
8397
  {
8430
8398
  className: getClassNameItem3({
@@ -8433,8 +8401,8 @@ var MenuItem = ({
8433
8401
  desktopOnly
8434
8402
  }),
8435
8403
  children: onClick && /* @__PURE__ */ jsxs23("div", { className: getClassNameItem3("link"), onClick, children: [
8436
- icon && /* @__PURE__ */ jsx54("span", { className: getClassNameItem3("linkIcon"), children: icon }),
8437
- /* @__PURE__ */ jsx54("span", { className: getClassNameItem3("linkLabel"), children: label })
8404
+ icon && /* @__PURE__ */ jsx53("span", { className: getClassNameItem3("linkIcon"), children: icon }),
8405
+ /* @__PURE__ */ jsx53("span", { className: getClassNameItem3("linkLabel"), children: label })
8438
8406
  ] })
8439
8407
  }
8440
8408
  );
@@ -8443,20 +8411,20 @@ var Nav = ({
8443
8411
  items,
8444
8412
  footer
8445
8413
  }) => {
8446
- return /* @__PURE__ */ jsxs23("nav", { className: getClassName34(), children: [
8447
- /* @__PURE__ */ jsx54("ul", { className: getClassName34("list"), children: Object.entries(items).map(([key, item]) => /* @__PURE__ */ jsx54(MenuItem, __spreadValues({}, item), key)) }),
8448
- footer && /* @__PURE__ */ jsx54("div", { className: getClassName34("footer"), children: footer })
8414
+ return /* @__PURE__ */ jsxs23("nav", { className: getClassName33(), children: [
8415
+ /* @__PURE__ */ jsx53("ul", { className: getClassName33("list"), children: Object.entries(items).map(([key, item]) => /* @__PURE__ */ jsx53(MenuItem, __spreadValues({}, item), key)) }),
8416
+ footer && /* @__PURE__ */ jsx53("div", { className: getClassName33("footer"), children: footer })
8449
8417
  ] });
8450
8418
  };
8451
8419
 
8452
8420
  // components/Editor/components/Layout/index.tsx
8453
- import { Fragment as Fragment15, jsx as jsx55, jsxs as jsxs24 } from "react/jsx-runtime";
8454
- var getClassName35 = get_class_name_factory_default("Editor", styles_module_default23);
8455
- var getLayoutClassName = get_class_name_factory_default("EditorLayout", styles_module_default23);
8456
- var getPluginTabClassName = get_class_name_factory_default("EditorPluginTab", styles_module_default23);
8421
+ import { Fragment as Fragment15, jsx as jsx54, jsxs as jsxs24 } from "react/jsx-runtime";
8422
+ var getClassName34 = get_class_name_factory_default("Editor", styles_module_default22);
8423
+ var getLayoutClassName = get_class_name_factory_default("EditorLayout", styles_module_default22);
8424
+ var getPluginTabClassName = get_class_name_factory_default("EditorPluginTab", styles_module_default22);
8457
8425
  var FieldSideBarToolbar = () => {
8458
8426
  const appStore = useAppStoreApi();
8459
- const { onPublish } = usePropsContext();
8427
+ const { onPublish, currentRoute } = usePropsContext();
8460
8428
  const back = useAppStore((s) => s.history.back);
8461
8429
  const forward = useAppStore((s) => s.history.forward);
8462
8430
  const hasFuture = useAppStore((s) => s.history.hasFuture());
@@ -8464,35 +8432,35 @@ var FieldSideBarToolbar = () => {
8464
8432
  const CustomHeaderActions = useAppStore(
8465
8433
  (s) => s.overrides.headerActions || DefaultOverride
8466
8434
  );
8467
- return /* @__PURE__ */ jsxs24("div", { className: getClassName35("fieldSideBarToolbar"), children: [
8468
- /* @__PURE__ */ jsxs24("div", { className: getClassName35("fieldSideBarHistory"), children: [
8469
- /* @__PURE__ */ jsx55(
8435
+ return /* @__PURE__ */ jsxs24("div", { className: getClassName34("fieldSideBarToolbar"), children: [
8436
+ /* @__PURE__ */ jsxs24("div", { className: getClassName34("fieldSideBarHistory"), children: [
8437
+ /* @__PURE__ */ jsx54(
8470
8438
  IconButton,
8471
8439
  {
8472
8440
  type: "button",
8473
8441
  title: "undo",
8474
8442
  disabled: !hasPast,
8475
8443
  onClick: back,
8476
- children: /* @__PURE__ */ jsx55(Undo2, { size: 18 })
8444
+ children: /* @__PURE__ */ jsx54(Undo2, { size: 18 })
8477
8445
  }
8478
8446
  ),
8479
- /* @__PURE__ */ jsx55(
8447
+ /* @__PURE__ */ jsx54(
8480
8448
  IconButton,
8481
8449
  {
8482
8450
  type: "button",
8483
8451
  title: "redo",
8484
8452
  disabled: !hasFuture,
8485
8453
  onClick: forward,
8486
- children: /* @__PURE__ */ jsx55(Redo2, { size: 18 })
8454
+ children: /* @__PURE__ */ jsx54(Redo2, { size: 18 })
8487
8455
  }
8488
8456
  )
8489
8457
  ] }),
8490
- /* @__PURE__ */ jsx55("div", { className: getClassName35("fieldSideBarActions"), children: /* @__PURE__ */ jsx55(CustomHeaderActions, { children: /* @__PURE__ */ jsx55(
8458
+ /* @__PURE__ */ jsx54("div", { className: getClassName34("fieldSideBarActions"), children: /* @__PURE__ */ jsx54(CustomHeaderActions, { children: /* @__PURE__ */ jsx54(
8491
8459
  Button,
8492
8460
  {
8493
8461
  onClick: () => {
8494
8462
  const data = appStore.getState().state.data;
8495
- onPublish && onPublish(data);
8463
+ onPublish && onPublish(data, currentRoute);
8496
8464
  },
8497
8465
  children: "Publish"
8498
8466
  }
@@ -8507,8 +8475,8 @@ var FieldSideBar = () => {
8507
8475
  }
8508
8476
  );
8509
8477
  return /* @__PURE__ */ jsxs24(Fragment15, { children: [
8510
- /* @__PURE__ */ jsx55(FieldSideBarToolbar, {}),
8511
- /* @__PURE__ */ jsx55(SidebarSection, { noBorderTop: true, showBreadcrumbs: true, title, children: /* @__PURE__ */ jsx55(Fields, {}) })
8478
+ /* @__PURE__ */ jsx54(FieldSideBarToolbar, {}),
8479
+ /* @__PURE__ */ jsx54(SidebarSection, { noBorderTop: true, showBreadcrumbs: true, title, children: /* @__PURE__ */ jsx54(Fields, {}) })
8512
8480
  ] });
8513
8481
  };
8514
8482
  var PluginTab = ({
@@ -8516,7 +8484,7 @@ var PluginTab = ({
8516
8484
  visible,
8517
8485
  mobileOnly
8518
8486
  }) => {
8519
- return /* @__PURE__ */ jsx55("div", { className: getPluginTabClassName({ visible, mobileOnly }), children: /* @__PURE__ */ jsx55("div", { className: getPluginTabClassName("body"), children }) });
8487
+ return /* @__PURE__ */ jsx54("div", { className: getPluginTabClassName({ visible, mobileOnly }), children: /* @__PURE__ */ jsx54("div", { className: getPluginTabClassName("body"), children }) });
8520
8488
  };
8521
8489
  var Layout = ({ children }) => {
8522
8490
  const {
@@ -8539,6 +8507,7 @@ var Layout = ({ children }) => {
8539
8507
  const rightSideBarVisible = useAppStore(
8540
8508
  (s) => s.state.ui.rightSideBarVisible
8541
8509
  );
8510
+ const navBarVisible = useAppStore((s) => s.state.ui.navBarVisible);
8542
8511
  const instanceId = useAppStore((s) => s.instanceId);
8543
8512
  const {
8544
8513
  width: leftWidth,
@@ -8683,7 +8652,7 @@ var Layout = ({ children }) => {
8683
8652
  const toggleTheme = () => {
8684
8653
  setTheme((t) => t === "dark" ? "light" : "dark");
8685
8654
  };
8686
- const themeIcon = theme === "dark" ? /* @__PURE__ */ jsx55(Sun, { size: 18 }) : /* @__PURE__ */ jsx55(Moon, { size: 18 });
8655
+ const themeIcon = theme === "dark" ? /* @__PURE__ */ jsx54(Sun, { size: 18 }) : /* @__PURE__ */ jsx54(Moon, { size: 18 });
8687
8656
  const themeLabel = theme === "dark" ? "Switch to light mode" : "Switch to dark mode";
8688
8657
  const hasLegacySideBarPlugin = useMemo23(
8689
8658
  () => !!(plugins == null ? void 0 : plugins.find((p) => p.name === "legacy-side-bar")),
@@ -8691,7 +8660,7 @@ var Layout = ({ children }) => {
8691
8660
  );
8692
8661
  const pluginItems = useMemo23(() => {
8693
8662
  const details = {};
8694
- const defaultPlugins = [blocksPlugin(), outlinePlugin()];
8663
+ const defaultPlugins = [blocksPlugin()];
8695
8664
  const isLegacy = (plugin) => plugin.name === "legacy-side-bar" ? -1 : 0;
8696
8665
  const combinedPlugins = [
8697
8666
  ...defaultPlugins,
@@ -8708,7 +8677,7 @@ var Layout = ({ children }) => {
8708
8677
  }
8709
8678
  details[plugin.name] = {
8710
8679
  label: (_a = plugin.label) != null ? _a : plugin.name,
8711
- icon: (_b = plugin.icon) != null ? _b : /* @__PURE__ */ jsx55(ToyBrick, {}),
8680
+ icon: (_b = plugin.icon) != null ? _b : /* @__PURE__ */ jsx54(ToyBrick, {}),
8712
8681
  onClick: () => {
8713
8682
  var _a2;
8714
8683
  setMobilePanelHeightMode((_a2 = plugin.mobilePanelHeight) != null ? _a2 : "toggle");
@@ -8750,14 +8719,14 @@ var Layout = ({ children }) => {
8750
8719
  return /* @__PURE__ */ jsxs24(
8751
8720
  "div",
8752
8721
  {
8753
- className: `Editor ${getClassName35({
8722
+ className: `Editor ${getClassName34({
8754
8723
  hidePlugins: hasLegacySideBarPlugin
8755
8724
  })}`,
8756
8725
  id: instanceId,
8757
8726
  "data-theme": theme,
8758
8727
  style: { height },
8759
8728
  children: [
8760
- /* @__PURE__ */ jsx55(DragDropContext, { disableAutoScroll: dnd == null ? void 0 : dnd.disableAutoScroll, children: /* @__PURE__ */ jsx55(CustomEditor, { children: children || /* @__PURE__ */ jsx55(FrameProvider, { children: /* @__PURE__ */ jsx55(
8729
+ /* @__PURE__ */ jsx54(DragDropContext, { disableAutoScroll: dnd == null ? void 0 : dnd.disableAutoScroll, children: /* @__PURE__ */ jsx54(CustomEditor, { children: children || /* @__PURE__ */ jsx54(FrameProvider, { children: /* @__PURE__ */ jsx54(
8761
8730
  "div",
8762
8731
  {
8763
8732
  className: getLayoutClassName({
@@ -8775,11 +8744,11 @@ var Layout = ({ children }) => {
8775
8744
  className: getLayoutClassName("inner"),
8776
8745
  style: __spreadValues(__spreadValues({}, layoutOptions), mobilePanelStyle),
8777
8746
  children: [
8778
- /* @__PURE__ */ jsx55("div", { className: getLayoutClassName("nav"), children: /* @__PURE__ */ jsx55(
8747
+ navBarVisible && /* @__PURE__ */ jsx54("div", { className: getLayoutClassName("nav"), children: /* @__PURE__ */ jsx54(
8779
8748
  Nav,
8780
8749
  {
8781
8750
  items: pluginItems,
8782
- footer: /* @__PURE__ */ jsx55(
8751
+ footer: /* @__PURE__ */ jsx54(
8783
8752
  IconButton,
8784
8753
  {
8785
8754
  type: "button",
@@ -8796,13 +8765,13 @@ var Layout = ({ children }) => {
8796
8765
  ref: mobilePanelRef,
8797
8766
  className: getLayoutClassName("mobilePanel"),
8798
8767
  children: [
8799
- /* @__PURE__ */ jsx55(
8768
+ /* @__PURE__ */ jsx54(
8800
8769
  "div",
8801
8770
  {
8802
8771
  className: getLayoutClassName("mobileDragHandle"),
8803
8772
  onTouchStart: (e) => handleMobileDragStart(e.touches[0].clientY),
8804
8773
  onMouseDown: (e) => handleMobileDragStart(e.clientY),
8805
- children: /* @__PURE__ */ jsx55(
8774
+ children: /* @__PURE__ */ jsx54(
8806
8775
  "div",
8807
8776
  {
8808
8777
  className: getLayoutClassName("mobileDragHandlePill")
@@ -8810,17 +8779,17 @@ var Layout = ({ children }) => {
8810
8779
  )
8811
8780
  }
8812
8781
  ),
8813
- /* @__PURE__ */ jsx55(
8782
+ /* @__PURE__ */ jsx54(
8814
8783
  "div",
8815
8784
  {
8816
8785
  className: getLayoutClassName("mobilePanelContent"),
8817
8786
  children: Object.entries(pluginItems).map(
8818
- ([id, { mobileOnly, render: Render2 }]) => /* @__PURE__ */ jsx55(
8787
+ ([id, { mobileOnly, render: Render2 }]) => /* @__PURE__ */ jsx54(
8819
8788
  PluginTab,
8820
8789
  {
8821
8790
  visible: currentPlugin === id,
8822
8791
  mobileOnly,
8823
- children: /* @__PURE__ */ jsx55(Render2, {})
8792
+ children: /* @__PURE__ */ jsx54(Render2, {})
8824
8793
  },
8825
8794
  id
8826
8795
  )
@@ -8830,7 +8799,7 @@ var Layout = ({ children }) => {
8830
8799
  ]
8831
8800
  }
8832
8801
  ),
8833
- /* @__PURE__ */ jsx55(
8802
+ /* @__PURE__ */ jsx54(
8834
8803
  Sidebar,
8835
8804
  {
8836
8805
  position: "left",
@@ -8839,20 +8808,20 @@ var Layout = ({ children }) => {
8839
8808
  onResize: setLeftWidth,
8840
8809
  onResizeEnd: handleLeftSidebarResizeEnd,
8841
8810
  children: Object.entries(pluginItems).map(
8842
- ([id, { mobileOnly, render: Render2, label }]) => /* @__PURE__ */ jsx55(
8811
+ ([id, { mobileOnly, render: Render2, label }]) => /* @__PURE__ */ jsx54(
8843
8812
  PluginTab,
8844
8813
  {
8845
8814
  visible: currentPlugin === id,
8846
8815
  mobileOnly,
8847
- children: /* @__PURE__ */ jsx55(Render2, {})
8816
+ children: /* @__PURE__ */ jsx54(Render2, {})
8848
8817
  },
8849
8818
  id
8850
8819
  )
8851
8820
  )
8852
8821
  }
8853
8822
  ),
8854
- /* @__PURE__ */ jsx55(Canvas, {}),
8855
- !hasDesktopFieldsPlugin && /* @__PURE__ */ jsx55(
8823
+ /* @__PURE__ */ jsx54(Canvas, {}),
8824
+ !hasDesktopFieldsPlugin && /* @__PURE__ */ jsx54(
8856
8825
  Sidebar,
8857
8826
  {
8858
8827
  position: "right",
@@ -8860,7 +8829,7 @@ var Layout = ({ children }) => {
8860
8829
  isVisible: rightSideBarVisible,
8861
8830
  onResize: setRightWidth,
8862
8831
  onResizeEnd: handleRightSidebarResizeEnd,
8863
- children: /* @__PURE__ */ jsx55(FieldSideBar, {})
8832
+ children: /* @__PURE__ */ jsx54(FieldSideBar, {})
8864
8833
  }
8865
8834
  )
8866
8835
  ]
@@ -8868,17 +8837,17 @@ var Layout = ({ children }) => {
8868
8837
  )
8869
8838
  }
8870
8839
  ) }) }) }),
8871
- /* @__PURE__ */ jsx55("div", { id: "editor-portal-root", className: getClassName35("portal") })
8840
+ /* @__PURE__ */ jsx54("div", { id: "editor-portal-root", className: getClassName34("portal") })
8872
8841
  ]
8873
8842
  }
8874
8843
  );
8875
8844
  };
8876
8845
 
8877
8846
  // components/Editor/index.tsx
8878
- import { jsx as jsx56 } from "react/jsx-runtime";
8847
+ import { jsx as jsx55 } from "react/jsx-runtime";
8879
8848
  var propsContext = createContext8({});
8880
8849
  function PropsProvider(props) {
8881
- return /* @__PURE__ */ jsx56(propsContext.Provider, { value: props, children: props.children });
8850
+ return /* @__PURE__ */ jsx55(propsContext.Provider, { value: props, children: props.children });
8882
8851
  }
8883
8852
  var usePropsContext = () => useContext15(propsContext);
8884
8853
  function EditorProvider({ children }) {
@@ -9062,10 +9031,10 @@ function EditorProvider({ children }) {
9062
9031
  resolveAndCommitData();
9063
9032
  }, 0);
9064
9033
  }, []);
9065
- return /* @__PURE__ */ jsx56(appStoreContext.Provider, { value: appStore, children: /* @__PURE__ */ jsx56(UseEditorStoreContext.Provider, { value: uEditorStore, children }) });
9034
+ return /* @__PURE__ */ jsx55(appStoreContext.Provider, { value: appStore, children: /* @__PURE__ */ jsx55(UseEditorStoreContext.Provider, { value: uEditorStore, children }) });
9066
9035
  }
9067
9036
  function Editor3(props) {
9068
- return /* @__PURE__ */ jsx56(PropsProvider, __spreadProps(__spreadValues({}, props), { children: /* @__PURE__ */ jsx56(EditorProvider, __spreadProps(__spreadValues({}, props), { children: /* @__PURE__ */ jsx56(Layout, { children: props.children }) })) }));
9037
+ return /* @__PURE__ */ jsx55(PropsProvider, __spreadProps(__spreadValues({}, props), { children: /* @__PURE__ */ jsx55(EditorProvider, __spreadProps(__spreadValues({}, props), { children: /* @__PURE__ */ jsx55(Layout, { children: props.children }) })) }));
9069
9038
  }
9070
9039
  Editor3.Components = Components;
9071
9040
  Editor3.Fields = Fields;
@@ -9073,6 +9042,309 @@ Editor3.Layout = Layout;
9073
9042
  Editor3.Outline = Outline;
9074
9043
  Editor3.Preview = Preview2;
9075
9044
 
9045
+ // lib/use-stable-value.ts
9046
+ init_react_import();
9047
+ import { useRef as useRef20 } from "react";
9048
+ import { deepEqual as deepEqual3 } from "fast-equals";
9049
+ var useStableValue = (value) => {
9050
+ const ref = useRef20(value);
9051
+ if (!deepEqual3(ref.current, value)) {
9052
+ ref.current = value;
9053
+ }
9054
+ return ref.current;
9055
+ };
9056
+
9057
+ // components/App/context.ts
9058
+ init_react_import();
9059
+ import { createContext as createContext9, useContext as useContext16, useMemo as useMemo25 } from "react";
9060
+ import { matchRoutes, useLocation, useNavigate } from "react-router";
9061
+ var appConfigContext = createContext9(null);
9062
+ var useAppConfigContext = () => {
9063
+ const ctx = useContext16(appConfigContext);
9064
+ if (!ctx) {
9065
+ throw new Error("useApp must be called inside an <AppProvider> or <App>");
9066
+ }
9067
+ return ctx;
9068
+ };
9069
+ var stripPrefix = (path, prefix) => {
9070
+ if (path === prefix) return "/";
9071
+ if (!path.startsWith(`${prefix}/`)) return path;
9072
+ const rest = path.slice(prefix.length);
9073
+ return rest.startsWith("/") ? rest : `/${rest}`;
9074
+ };
9075
+ var useApp = () => {
9076
+ const cfg = useAppConfigContext();
9077
+ const location = useLocation();
9078
+ const rrNavigate = useNavigate();
9079
+ const currentPath = location.pathname || "/";
9080
+ const isEditing = cfg.editorPath !== null && (currentPath === cfg.editorPath || currentPath.startsWith(`${cfg.editorPath}/`));
9081
+ const matchRoute = isEditing ? stripPrefix(currentPath, cfg.editorPath) : currentPath;
9082
+ const matched = useMemo25(() => {
9083
+ const routeKeys = Object.keys(cfg.pages);
9084
+ if (routeKeys.length === 0) return null;
9085
+ const matches = matchRoutes(
9086
+ routeKeys.map((path) => ({ path })),
9087
+ matchRoute
9088
+ );
9089
+ if (!matches || matches.length === 0) return null;
9090
+ const last = matches[matches.length - 1];
9091
+ const key = last.route.path;
9092
+ return {
9093
+ route: key,
9094
+ params: last.params,
9095
+ data: cfg.pages[key]
9096
+ };
9097
+ }, [cfg.pages, matchRoute]);
9098
+ const routes = useMemo25(() => Object.keys(cfg.pages), [cfg.pages]);
9099
+ const navigate = (route) => {
9100
+ const target = isEditing && cfg.editorPath ? `${cfg.editorPath}${route === "/" ? "" : route}` || "/" : route;
9101
+ rrNavigate(target || "/");
9102
+ };
9103
+ return __spreadProps(__spreadValues({}, cfg), {
9104
+ routes,
9105
+ currentPath,
9106
+ isEditing,
9107
+ matchRoute,
9108
+ matched,
9109
+ navigate
9110
+ });
9111
+ };
9112
+
9113
+ // components/App/AppProvider.tsx
9114
+ init_react_import();
9115
+ import { useMemo as useMemo26 } from "react";
9116
+ import {
9117
+ BrowserRouter,
9118
+ HashRouter,
9119
+ MemoryRouter,
9120
+ StaticRouter
9121
+ } from "react-router";
9122
+ import { jsx as jsx56 } from "react/jsx-runtime";
9123
+ var EDITOR_PATH = "/editor";
9124
+ var isServer = typeof window === "undefined";
9125
+ function AppProvider({
9126
+ config,
9127
+ pages,
9128
+ editorPath = EDITOR_PATH,
9129
+ router = "browser",
9130
+ currentPath,
9131
+ children
9132
+ }) {
9133
+ const stablePages = useStableValue(pages);
9134
+ const resolvedEditorPath = editorPath === null ? null : editorPath || EDITOR_PATH;
9135
+ const ctxValue = useMemo26(
9136
+ () => ({
9137
+ config,
9138
+ pages: stablePages,
9139
+ editorPath: resolvedEditorPath
9140
+ }),
9141
+ [config, stablePages, resolvedEditorPath]
9142
+ );
9143
+ const inner = /* @__PURE__ */ jsx56(appConfigContext.Provider, { value: ctxValue, children });
9144
+ if (isServer) {
9145
+ return /* @__PURE__ */ jsx56(StaticRouter, { location: currentPath != null ? currentPath : "/", children: inner });
9146
+ }
9147
+ if (router === "hash") {
9148
+ return /* @__PURE__ */ jsx56(HashRouter, { children: inner });
9149
+ }
9150
+ if (router === "memory") {
9151
+ return /* @__PURE__ */ jsx56(MemoryRouter, { initialEntries: [currentPath != null ? currentPath : "/"], children: inner });
9152
+ }
9153
+ return /* @__PURE__ */ jsx56(BrowserRouter, { children: inner });
9154
+ }
9155
+
9156
+ // components/App/App.tsx
9157
+ init_react_import();
9158
+ import { Route, Routes } from "react-router";
9159
+ import { Fragment as Fragment16, jsx as jsx57, jsxs as jsxs25 } from "react/jsx-runtime";
9160
+ var joinEditorPath = (editorPath, route) => {
9161
+ if (route === "/") return editorPath;
9162
+ return `${editorPath}${route}`;
9163
+ };
9164
+ var DefaultNotFound = () => /* @__PURE__ */ jsx57(
9165
+ "div",
9166
+ {
9167
+ style: {
9168
+ display: "flex",
9169
+ height: "100vh",
9170
+ textAlign: "center",
9171
+ justifyContent: "center",
9172
+ alignItems: "center"
9173
+ },
9174
+ children: /* @__PURE__ */ jsxs25("div", { children: [
9175
+ /* @__PURE__ */ jsx57("h1", { children: "404" }),
9176
+ /* @__PURE__ */ jsx57("p", { children: "No page matches this route." })
9177
+ ] })
9178
+ }
9179
+ );
9180
+ function RenderForKey({
9181
+ routeKey,
9182
+ metadata
9183
+ }) {
9184
+ const { config, pages } = useApp();
9185
+ const data = pages[routeKey];
9186
+ if (!data) return null;
9187
+ return /* @__PURE__ */ jsx57(
9188
+ Render,
9189
+ {
9190
+ config,
9191
+ data,
9192
+ metadata
9193
+ },
9194
+ routeKey
9195
+ );
9196
+ }
9197
+ function EditorForKey({
9198
+ routeKey,
9199
+ editorProps,
9200
+ children
9201
+ }) {
9202
+ const { config, pages, routes, navigate } = useApp();
9203
+ const data = pages[routeKey];
9204
+ if (!data) return null;
9205
+ return /* @__PURE__ */ jsx57(
9206
+ Editor3,
9207
+ {
9208
+ config,
9209
+ data,
9210
+ ui: editorProps.ui,
9211
+ plugins: editorProps.plugins,
9212
+ overrides: editorProps.overrides,
9213
+ fieldTransforms: editorProps.fieldTransforms,
9214
+ metadata: editorProps.metadata,
9215
+ iframe: editorProps.iframe,
9216
+ viewports: editorProps.viewports,
9217
+ permissions: editorProps.permissions,
9218
+ onChange: editorProps.onChange,
9219
+ onPublish: editorProps.onPublish,
9220
+ onAction: editorProps.onAction,
9221
+ renderHeader: editorProps.renderHeader,
9222
+ renderHeaderActions: editorProps.renderHeaderActions,
9223
+ title: editorProps.title,
9224
+ dnd: editorProps.dnd,
9225
+ initialHistory: editorProps.initialHistory,
9226
+ height: editorProps.height,
9227
+ fullScreenCanvas: editorProps.fullScreenCanvas,
9228
+ disableZoomControls: editorProps.disableZoomControls,
9229
+ _experimentalVirtualization: editorProps._experimentalVirtualization,
9230
+ routes,
9231
+ currentRoute: routeKey,
9232
+ onRouteChange: (next) => navigate(next),
9233
+ children
9234
+ },
9235
+ routeKey
9236
+ );
9237
+ }
9238
+ function AppRender({ metadata, renderNotFound }) {
9239
+ const { pages, isEditing } = useApp();
9240
+ if (isEditing) return null;
9241
+ const routeKeys = Object.keys(pages);
9242
+ return /* @__PURE__ */ jsxs25(Routes, { children: [
9243
+ routeKeys.map((routeKey) => /* @__PURE__ */ jsx57(
9244
+ Route,
9245
+ {
9246
+ path: routeKey,
9247
+ element: /* @__PURE__ */ jsx57(
9248
+ RenderForKey,
9249
+ {
9250
+ routeKey,
9251
+ metadata
9252
+ }
9253
+ )
9254
+ },
9255
+ `render:${routeKey}`
9256
+ )),
9257
+ /* @__PURE__ */ jsx57(
9258
+ Route,
9259
+ {
9260
+ path: "*",
9261
+ element: renderNotFound ? /* @__PURE__ */ jsx57(Fragment16, { children: renderNotFound() }) : /* @__PURE__ */ jsx57(DefaultNotFound, {})
9262
+ }
9263
+ )
9264
+ ] });
9265
+ }
9266
+ function AppEditor(props) {
9267
+ const _a = props, { children, renderNotFound } = _a, editorProps = __objRest(_a, ["children", "renderNotFound"]);
9268
+ const { pages, isEditing, editorPath } = useApp();
9269
+ if (!isEditing || editorPath === null) return null;
9270
+ const routeKeys = Object.keys(pages);
9271
+ return /* @__PURE__ */ jsxs25(Routes, { children: [
9272
+ routeKeys.map((routeKey) => /* @__PURE__ */ jsx57(
9273
+ Route,
9274
+ {
9275
+ path: joinEditorPath(editorPath, routeKey),
9276
+ element: /* @__PURE__ */ jsx57(
9277
+ EditorForKey,
9278
+ {
9279
+ routeKey,
9280
+ editorProps,
9281
+ children
9282
+ }
9283
+ )
9284
+ },
9285
+ `edit:${routeKey}`
9286
+ )),
9287
+ /* @__PURE__ */ jsx57(
9288
+ Route,
9289
+ {
9290
+ path: "*",
9291
+ element: renderNotFound ? /* @__PURE__ */ jsx57(Fragment16, { children: renderNotFound() }) : /* @__PURE__ */ jsx57(DefaultNotFound, {})
9292
+ }
9293
+ )
9294
+ ] });
9295
+ }
9296
+ function DefaultAppLayout(props) {
9297
+ const _a = props, { renderNotFound } = _a, editorProps = __objRest(_a, ["renderNotFound"]);
9298
+ return /* @__PURE__ */ jsxs25(Fragment16, { children: [
9299
+ /* @__PURE__ */ jsx57(
9300
+ AppRender,
9301
+ {
9302
+ metadata: editorProps.metadata,
9303
+ renderNotFound
9304
+ }
9305
+ ),
9306
+ /* @__PURE__ */ jsx57(AppEditor, __spreadProps(__spreadValues({}, editorProps), { renderNotFound }))
9307
+ ] });
9308
+ }
9309
+ function App(props) {
9310
+ const _a = props, {
9311
+ config,
9312
+ pages,
9313
+ currentPath,
9314
+ editorPath,
9315
+ router,
9316
+ children
9317
+ } = _a, layoutProps = __objRest(_a, [
9318
+ "config",
9319
+ "pages",
9320
+ "currentPath",
9321
+ "editorPath",
9322
+ "router",
9323
+ "children"
9324
+ ]);
9325
+ return /* @__PURE__ */ jsx57(
9326
+ AppProvider,
9327
+ {
9328
+ config,
9329
+ pages,
9330
+ currentPath,
9331
+ editorPath,
9332
+ router,
9333
+ children: children != null ? children : /* @__PURE__ */ jsx57(DefaultAppLayout, __spreadValues({}, layoutProps))
9334
+ }
9335
+ );
9336
+ }
9337
+ App.Render = AppRender;
9338
+ App.Editor = AppEditor;
9339
+
9340
+ // components/App/use-route-params.ts
9341
+ init_react_import();
9342
+ import { useParams } from "react-router";
9343
+ var useRouteParams = useParams;
9344
+
9345
+ // components/App/index.ts
9346
+ init_react_import();
9347
+
9076
9348
  // lib/page-metadata.ts
9077
9349
  init_react_import();
9078
9350
  function pageMetadata(data) {
@@ -9096,14 +9368,31 @@ function pageMetadata(data) {
9096
9368
  return out;
9097
9369
  }
9098
9370
 
9371
+ // plugins/outline/index.tsx
9372
+ init_react_import();
9373
+
9374
+ // css-module:/Users/rami/Documents/apps/react-editor/packages/core/plugins/outline/styles.module.css#css-module
9375
+ init_react_import();
9376
+ var styles_module_default30 = { "OutlinePlugin": "_OutlinePlugin_q92j6_1" };
9377
+
9378
+ // plugins/outline/index.tsx
9379
+ import { jsx as jsx58 } from "react/jsx-runtime";
9380
+ var getClassName35 = get_class_name_factory_default("OutlinePlugin", styles_module_default30);
9381
+ var outlinePlugin = () => ({
9382
+ name: "outline",
9383
+ label: "Outline",
9384
+ render: () => /* @__PURE__ */ jsx58("div", { className: getClassName35(), children: /* @__PURE__ */ jsx58(Outline, {}) }),
9385
+ icon: /* @__PURE__ */ jsx58(Layers, {})
9386
+ });
9387
+
9099
9388
  // plugins/legacy-side-bar/index.tsx
9100
9389
  init_react_import();
9101
- import { jsx as jsx57, jsxs as jsxs25 } from "react/jsx-runtime";
9390
+ import { jsx as jsx59, jsxs as jsxs26 } from "react/jsx-runtime";
9102
9391
  var legacySideBarPlugin = () => ({
9103
9392
  name: "legacy-side-bar",
9104
- render: () => /* @__PURE__ */ jsxs25("div", { style: { overflowY: "auto" }, children: [
9105
- /* @__PURE__ */ jsx57(SidebarSection, { title: "Components", noBorderTop: true, children: /* @__PURE__ */ jsx57(Components, {}) }),
9106
- /* @__PURE__ */ jsx57(SidebarSection, { title: "Outline", children: /* @__PURE__ */ jsx57(Outline, {}) })
9393
+ render: () => /* @__PURE__ */ jsxs26("div", { style: { overflowY: "auto" }, children: [
9394
+ /* @__PURE__ */ jsx59(SidebarSection, { title: "Components", noBorderTop: true, children: /* @__PURE__ */ jsx59(Components, {}) }),
9395
+ /* @__PURE__ */ jsx59(SidebarSection, { title: "Outline", children: /* @__PURE__ */ jsx59(Outline, {}) })
9107
9396
  ] })
9108
9397
  });
9109
9398
 
@@ -9164,10 +9453,16 @@ export {
9164
9453
  useEditor,
9165
9454
  useGetEditor,
9166
9455
  blocksPlugin,
9167
- outlinePlugin,
9168
9456
  fieldsPlugin,
9169
9457
  usePropsContext,
9170
9458
  Editor3 as Editor,
9459
+ useStableValue,
9460
+ appConfigContext,
9461
+ useApp,
9462
+ AppProvider,
9463
+ App,
9464
+ useRouteParams,
9171
9465
  pageMetadata,
9466
+ outlinePlugin,
9172
9467
  legacySideBarPlugin
9173
9468
  };