@reacteditor/core 0.0.15 → 0.0.16

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.
@@ -1,13 +1,13 @@
1
1
  import {
2
2
  EditorInner,
3
3
  LoadedRichTextMenu
4
- } from "./chunk-647NZJYM.mjs";
4
+ } from "./chunk-5QKQ3LQJ.mjs";
5
5
  import {
6
6
  ActionBar,
7
7
  IconButton,
8
8
  LoadedRichTextMenuInner,
9
9
  Loader
10
- } from "./chunk-TFAZFGYZ.mjs";
10
+ } from "./chunk-Q667J2EG.mjs";
11
11
  import {
12
12
  RichTextRenderFallback,
13
13
  SlotRender,
@@ -16,7 +16,7 @@ import {
16
16
  getSlotTransform,
17
17
  useRichtextProps,
18
18
  useSlots
19
- } from "./chunk-3CGBQNX4.mjs";
19
+ } from "./chunk-4L7H4JV4.mjs";
20
20
  import {
21
21
  Check,
22
22
  ChevronDown,
@@ -42,7 +42,6 @@ import {
42
42
  SlidersHorizontal,
43
43
  Smartphone,
44
44
  Sun,
45
- Tablet,
46
45
  ToyBrick,
47
46
  Trash,
48
47
  Undo2,
@@ -50,7 +49,7 @@ import {
50
49
  X,
51
50
  appStoreContext,
52
51
  createAppStore,
53
- defaultViewports,
52
+ getBox,
54
53
  monitorHotkeys,
55
54
  reorder,
56
55
  replace,
@@ -61,7 +60,7 @@ import {
61
60
  useRegisterFieldsSlice,
62
61
  useRegisterHistorySlice,
63
62
  useRegisterPermissionsSlice
64
- } from "./chunk-T43H325W.mjs";
63
+ } from "./chunk-JHURG5NN.mjs";
65
64
  import {
66
65
  getItem,
67
66
  insert,
@@ -70,8 +69,9 @@ import {
70
69
  populateIds
71
70
  } from "./chunk-M4JDRFYB.mjs";
72
71
  import {
73
- defaultAppState
74
- } from "./chunk-NPC7A3V3.mjs";
72
+ defaultAppState,
73
+ defaultViewports
74
+ } from "./chunk-FTVOCMGV.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-7UIJWCPN.mjs").then((m) => ({
2149
+ () => import("./Editor-J7XDD77B.mjs").then((m) => ({
2150
2150
  default: m.Editor
2151
2151
  }))
2152
2152
  );
@@ -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-7UIJWCPN.mjs").then((m) => ({
4701
+ () => import("./Editor-J7XDD77B.mjs").then((m) => ({
4702
4702
  default: m.Editor
4703
4703
  }))
4704
4704
  );
@@ -6013,6 +6013,121 @@ function useGetEditor() {
6013
6013
  return useEditorApi.getState;
6014
6014
  }
6015
6015
 
6016
+ // plugins/blocks/index.tsx
6017
+ init_react_import();
6018
+
6019
+ // components/Editor/components/Components/index.tsx
6020
+ init_react_import();
6021
+ import { useMemo as useMemo14, useState as useState17 } from "react";
6022
+
6023
+ // css-module:/Users/rami/Documents/apps/react-editor/packages/core/components/Editor/components/Components/styles.module.css#css-module
6024
+ init_react_import();
6025
+ var styles_module_default15 = { "Components-search": "_Components-search_recer_1", "Components-searchIcon": "_Components-searchIcon_recer_8", "Components-searchInput": "_Components-searchInput_recer_16", "Components-empty": "_Components-empty_recer_39" };
6026
+
6027
+ // components/Editor/components/Components/index.tsx
6028
+ import { jsx as jsx36, jsxs as jsxs13 } from "react/jsx-runtime";
6029
+ var getClassName20 = get_class_name_factory_default("Components", styles_module_default15);
6030
+ var Components = () => {
6031
+ var _a;
6032
+ const overrides = useAppStore((s) => s.overrides);
6033
+ const components = useAppStore((s) => s.config.components);
6034
+ const categoriesConfig = useAppStore((s) => s.config.categories);
6035
+ const [search, setSearch] = useState17("");
6036
+ const Wrapper = useMemo14(() => {
6037
+ if (overrides.components) {
6038
+ console.warn(
6039
+ "The `components` override has been deprecated and renamed to `drawer`"
6040
+ );
6041
+ }
6042
+ return overrides.components || overrides.drawer || "div";
6043
+ }, [overrides]);
6044
+ const groups = useMemo14(() => {
6045
+ var _a2;
6046
+ const query = search.trim().toLowerCase();
6047
+ const entries = Object.entries(components != null ? components : {}).filter(([name, conf]) => {
6048
+ var _a3;
6049
+ if (!query) return true;
6050
+ const label = ((_a3 = conf.label) != null ? _a3 : name).toLowerCase();
6051
+ return label.includes(query);
6052
+ });
6053
+ if (!entries.length) return [];
6054
+ const buckets = /* @__PURE__ */ new Map();
6055
+ for (const entry of entries) {
6056
+ const [, conf] = entry;
6057
+ const key = conf.category;
6058
+ const bucket = (_a2 = buckets.get(key)) != null ? _a2 : [];
6059
+ bucket.push(entry);
6060
+ buckets.set(key, bucket);
6061
+ }
6062
+ return Array.from(buckets.entries());
6063
+ }, [components, search]);
6064
+ return /* @__PURE__ */ jsxs13(Wrapper, { children: [
6065
+ /* @__PURE__ */ jsxs13("div", { className: getClassName20("search"), children: [
6066
+ /* @__PURE__ */ jsx36("div", { className: getClassName20("searchIcon"), children: /* @__PURE__ */ jsx36(Search, { size: 14 }) }),
6067
+ /* @__PURE__ */ jsx36(
6068
+ "input",
6069
+ {
6070
+ type: "search",
6071
+ className: getClassName20("searchInput"),
6072
+ placeholder: "search",
6073
+ value: search,
6074
+ onChange: (e) => setSearch(e.target.value)
6075
+ }
6076
+ )
6077
+ ] }),
6078
+ groups.length === 0 ? /* @__PURE__ */ jsx36("div", { className: getClassName20("empty"), children: "No results match your search" }) : groups.length <= 1 && !((_a = groups[0]) == null ? void 0 : _a[0]) ? /* @__PURE__ */ jsx36(ComponentList, { id: "all", children: groups[0][1].map(([name, conf]) => {
6079
+ var _a2;
6080
+ return /* @__PURE__ */ jsx36(
6081
+ ComponentList.Item,
6082
+ {
6083
+ name,
6084
+ label: (_a2 = conf.label) != null ? _a2 : name,
6085
+ icon: conf.icon
6086
+ },
6087
+ name
6088
+ );
6089
+ }) }) : groups.map(([category, entries]) => {
6090
+ var _a2, _b;
6091
+ const categoryKey = category != null ? category : "other";
6092
+ const title = (_b = (_a2 = categoriesConfig == null ? void 0 : categoriesConfig[categoryKey]) == null ? void 0 : _a2.title) != null ? _b : category != null ? category : "Other";
6093
+ return /* @__PURE__ */ jsx36(
6094
+ ComponentList,
6095
+ {
6096
+ id: categoryKey,
6097
+ title,
6098
+ children: entries.map(([name, conf]) => {
6099
+ var _a3;
6100
+ return /* @__PURE__ */ jsx36(
6101
+ ComponentList.Item,
6102
+ {
6103
+ name,
6104
+ label: (_a3 = conf.label) != null ? _a3 : name,
6105
+ icon: conf.icon
6106
+ },
6107
+ name
6108
+ );
6109
+ })
6110
+ },
6111
+ categoryKey
6112
+ );
6113
+ })
6114
+ ] });
6115
+ };
6116
+
6117
+ // css-module:/Users/rami/Documents/apps/react-editor/packages/core/plugins/blocks/styles.module.css#css-module
6118
+ init_react_import();
6119
+ var styles_module_default16 = { "BlocksPlugin": "_BlocksPlugin_15ud0_1" };
6120
+
6121
+ // plugins/blocks/index.tsx
6122
+ import { jsx as jsx37 } from "react/jsx-runtime";
6123
+ var getClassName21 = get_class_name_factory_default("BlocksPlugin", styles_module_default16);
6124
+ var blocksPlugin = () => ({
6125
+ name: "blocks",
6126
+ label: "Blocks",
6127
+ render: () => /* @__PURE__ */ jsx37("div", { className: getClassName21(), children: /* @__PURE__ */ jsx37(Components, {}) }),
6128
+ icon: /* @__PURE__ */ jsx37(Plus, {})
6129
+ });
6130
+
6016
6131
  // plugins/fields/index.tsx
6017
6132
  init_react_import();
6018
6133
 
@@ -6021,11 +6136,11 @@ init_react_import();
6021
6136
 
6022
6137
  // css-module:/Users/rami/Documents/apps/react-editor/packages/core/components/Breadcrumbs/styles.module.css#css-module
6023
6138
  init_react_import();
6024
- var styles_module_default15 = { "Breadcrumbs": "_Breadcrumbs_1cjxk_1", "Breadcrumbs-breadcrumb": "_Breadcrumbs-breadcrumb_1cjxk_10", "Breadcrumbs-breadcrumbLabel": "_Breadcrumbs-breadcrumbLabel_1cjxk_17" };
6139
+ var styles_module_default17 = { "Breadcrumbs": "_Breadcrumbs_1cjxk_1", "Breadcrumbs-breadcrumb": "_Breadcrumbs-breadcrumb_1cjxk_10", "Breadcrumbs-breadcrumbLabel": "_Breadcrumbs-breadcrumbLabel_1cjxk_17" };
6025
6140
 
6026
6141
  // lib/use-breadcrumbs.ts
6027
6142
  init_react_import();
6028
- import { useMemo as useMemo14 } from "react";
6143
+ import { useMemo as useMemo15 } from "react";
6029
6144
  var useBreadcrumbs = (renderCount) => {
6030
6145
  const selectedId = useAppStore((s) => {
6031
6146
  var _a;
@@ -6037,7 +6152,7 @@ var useBreadcrumbs = (renderCount) => {
6037
6152
  return (_a = s.state.indexes.nodes[selectedId]) == null ? void 0 : _a.path;
6038
6153
  });
6039
6154
  const appStore = useAppStoreApi();
6040
- return useMemo14(() => {
6155
+ return useMemo15(() => {
6041
6156
  const breadcrumbs = (path == null ? void 0 : path.map((zoneCompound) => {
6042
6157
  var _a, _b, _c, _d;
6043
6158
  const [componentId] = zoneCompound.split(":");
@@ -6068,26 +6183,26 @@ var useBreadcrumbs = (renderCount) => {
6068
6183
  };
6069
6184
 
6070
6185
  // components/Breadcrumbs/index.tsx
6071
- import { jsx as jsx36, jsxs as jsxs13 } from "react/jsx-runtime";
6072
- var getClassName20 = get_class_name_factory_default("Breadcrumbs", styles_module_default15);
6186
+ import { jsx as jsx38, jsxs as jsxs14 } from "react/jsx-runtime";
6187
+ var getClassName22 = get_class_name_factory_default("Breadcrumbs", styles_module_default17);
6073
6188
  var Breadcrumbs = ({
6074
6189
  children,
6075
6190
  numParents = 1
6076
6191
  }) => {
6077
6192
  const setUi = useAppStore((s) => s.setUi);
6078
6193
  const breadcrumbs = useBreadcrumbs(numParents);
6079
- return /* @__PURE__ */ jsxs13("div", { className: getClassName20(), children: [
6080
- breadcrumbs.map((breadcrumb, i) => /* @__PURE__ */ jsxs13("div", { className: getClassName20("breadcrumb"), children: [
6081
- /* @__PURE__ */ jsx36(
6194
+ return /* @__PURE__ */ jsxs14("div", { className: getClassName22(), children: [
6195
+ breadcrumbs.map((breadcrumb, i) => /* @__PURE__ */ jsxs14("div", { className: getClassName22("breadcrumb"), children: [
6196
+ /* @__PURE__ */ jsx38(
6082
6197
  "button",
6083
6198
  {
6084
6199
  type: "button",
6085
- className: getClassName20("breadcrumbLabel"),
6200
+ className: getClassName22("breadcrumbLabel"),
6086
6201
  onClick: () => setUi({ itemSelector: breadcrumb.selector }),
6087
6202
  children: breadcrumb.label
6088
6203
  }
6089
6204
  ),
6090
- /* @__PURE__ */ jsx36(ChevronRight, { size: 14 })
6205
+ /* @__PURE__ */ jsx38(ChevronRight, { size: 14 })
6091
6206
  ] }, i)),
6092
6207
  children
6093
6208
  ] });
@@ -6098,7 +6213,7 @@ init_react_import();
6098
6213
 
6099
6214
  // css-module:/Users/rami/Documents/apps/react-editor/packages/core/components/Editor/components/Fields/styles.module.css#css-module
6100
6215
  init_react_import();
6101
- var styles_module_default16 = { "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" };
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" };
6102
6217
 
6103
6218
  // components/Editor/components/Fields/index.tsx
6104
6219
  import {
@@ -6106,15 +6221,15 @@ import {
6106
6221
  useCallback as useCallback15,
6107
6222
  useContext as useContext11,
6108
6223
  useEffect as useEffect19,
6109
- useMemo as useMemo15
6224
+ useMemo as useMemo16
6110
6225
  } from "react";
6111
6226
  import { useShallow as useShallow7 } from "zustand/react/shallow";
6112
- import { Fragment as Fragment8, jsx as jsx37, jsxs as jsxs14 } from "react/jsx-runtime";
6113
- var getClassName21 = get_class_name_factory_default("EditorFields", styles_module_default16);
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);
6114
6229
  var DefaultFields = ({
6115
6230
  children
6116
6231
  }) => {
6117
- return /* @__PURE__ */ jsx37(Fragment8, { children });
6232
+ return /* @__PURE__ */ jsx39(Fragment8, { children });
6118
6233
  };
6119
6234
  var createOnChange = (fieldName, appStore) => (value, updatedUi) => __async(null, null, function* () {
6120
6235
  const { dispatch, state, selectedItem, resolveComponentData } = appStore.getState();
@@ -6194,7 +6309,7 @@ var FieldsChildInner = ({ fieldName }) => {
6194
6309
  }, [appStore, fieldStore]);
6195
6310
  if (!field || !id || !visible) return null;
6196
6311
  if (field.type === "slot") return null;
6197
- return /* @__PURE__ */ jsx37("div", { className: getClassName21("field"), children: /* @__PURE__ */ jsx37(
6312
+ return /* @__PURE__ */ jsx39("div", { className: getClassName23("field"), children: /* @__PURE__ */ jsx39(
6198
6313
  AutoFieldPrivate,
6199
6314
  {
6200
6315
  field,
@@ -6207,12 +6322,12 @@ var FieldsChildInner = ({ fieldName }) => {
6207
6322
  };
6208
6323
  var FieldsChild = ({ fieldName }) => {
6209
6324
  const appStore = useAppStoreApi();
6210
- const initialValue = useMemo15(() => {
6325
+ const initialValue = useMemo16(() => {
6211
6326
  var _a;
6212
6327
  const value = (_a = appStore.getState().getCurrentData().props) == null ? void 0 : _a[fieldName];
6213
6328
  return { [fieldName]: value };
6214
6329
  }, []);
6215
- return /* @__PURE__ */ jsx37(fieldContextStore.Provider, { value: initialValue, children: /* @__PURE__ */ jsx37(FieldsChildInner, { fieldName }) });
6330
+ return /* @__PURE__ */ jsx39(fieldContextStore.Provider, { value: initialValue, children: /* @__PURE__ */ jsx39(FieldsChildInner, { fieldName }) });
6216
6331
  };
6217
6332
  var FieldsChildMemo = memo8(FieldsChild);
6218
6333
  var GlobalSyncButton = () => {
@@ -6242,12 +6357,12 @@ var GlobalSyncButton = () => {
6242
6357
  });
6243
6358
  });
6244
6359
  const syncButtonClass = [
6245
- getClassName21("syncButton"),
6246
- isUnlinked ? styles_module_default16["EditorFields-syncButton--unlinked"] : null
6360
+ getClassName23("syncButton"),
6361
+ isUnlinked ? styles_module_default18["EditorFields-syncButton--unlinked"] : null
6247
6362
  ].filter(Boolean).join(" ");
6248
- return /* @__PURE__ */ jsxs14("button", { type: "button", className: syncButtonClass, onClick, children: [
6249
- /* @__PURE__ */ jsx37(Link, { size: 14 }),
6250
- /* @__PURE__ */ jsx37("span", { children: isUnlinked ? "Link to shared" : "Linked to shared" })
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" })
6251
6366
  ] });
6252
6367
  };
6253
6368
  var FieldsInternal = ({ wrapFields = true }) => {
@@ -6274,20 +6389,20 @@ var FieldsInternal = ({ wrapFields = true }) => {
6274
6389
  })
6275
6390
  );
6276
6391
  const isLoading = fieldsLoading || componentResolving;
6277
- const Wrapper = useMemo15(() => overrides.fields || DefaultFields, [overrides]);
6278
- return /* @__PURE__ */ jsxs14(
6392
+ const Wrapper = useMemo16(() => overrides.fields || DefaultFields, [overrides]);
6393
+ return /* @__PURE__ */ jsxs15(
6279
6394
  "form",
6280
6395
  {
6281
- className: getClassName21({ wrapFields }),
6396
+ className: getClassName23({ wrapFields }),
6282
6397
  onSubmit: (e) => {
6283
6398
  e.preventDefault();
6284
6399
  },
6285
6400
  children: [
6286
- /* @__PURE__ */ jsxs14(Wrapper, { isLoading, itemSelector, children: [
6287
- /* @__PURE__ */ jsx37(GlobalSyncButton, {}),
6288
- fieldNames.map((fieldName) => /* @__PURE__ */ jsx37(FieldsChildMemo, { fieldName }, fieldName))
6401
+ /* @__PURE__ */ jsxs15(Wrapper, { isLoading, itemSelector, children: [
6402
+ /* @__PURE__ */ jsx39(GlobalSyncButton, {}),
6403
+ fieldNames.map((fieldName) => /* @__PURE__ */ jsx39(FieldsChildMemo, { fieldName }, fieldName))
6289
6404
  ] }),
6290
- isLoading && /* @__PURE__ */ jsx37("div", { className: getClassName21("loadingOverlay"), children: /* @__PURE__ */ jsx37("div", { className: getClassName21("loadingOverlayInner"), children: /* @__PURE__ */ jsx37(Loader, { size: 16 }) }) })
6405
+ isLoading && /* @__PURE__ */ jsx39("div", { className: getClassName23("loadingOverlay"), children: /* @__PURE__ */ jsx39("div", { className: getClassName23("loadingOverlayInner"), children: /* @__PURE__ */ jsx39(Loader, { size: 16 }) }) })
6291
6406
  ]
6292
6407
  }
6293
6408
  );
@@ -6296,11 +6411,11 @@ var Fields = memo8(FieldsInternal);
6296
6411
 
6297
6412
  // css-module:/Users/rami/Documents/apps/react-editor/packages/core/plugins/fields/styles.module.css#css-module
6298
6413
  init_react_import();
6299
- var styles_module_default17 = { "FieldsPlugin": "_FieldsPlugin_262zt_1", "FieldsPlugin-header": "_FieldsPlugin-header_262zt_7" };
6414
+ var styles_module_default19 = { "FieldsPlugin": "_FieldsPlugin_262zt_1", "FieldsPlugin-header": "_FieldsPlugin-header_262zt_7" };
6300
6415
 
6301
6416
  // plugins/fields/index.tsx
6302
- import { jsx as jsx38, jsxs as jsxs15 } from "react/jsx-runtime";
6303
- var getClassName22 = get_class_name_factory_default("FieldsPlugin", styles_module_default17);
6417
+ import { jsx as jsx40, jsxs as jsxs16 } from "react/jsx-runtime";
6418
+ var getClassName24 = get_class_name_factory_default("FieldsPlugin", styles_module_default19);
6304
6419
  var CurrentTitle = () => {
6305
6420
  const label = useAppStore((s) => {
6306
6421
  var _a, _b;
@@ -6312,124 +6427,26 @@ var CurrentTitle = () => {
6312
6427
  var fieldsPlugin = ({ desktopSideBar = "right" } = {}) => ({
6313
6428
  name: "fields",
6314
6429
  label: "Fields",
6315
- render: () => /* @__PURE__ */ jsxs15("div", { className: getClassName22(), children: [
6316
- /* @__PURE__ */ jsx38("div", { className: getClassName22("header"), children: /* @__PURE__ */ jsx38(Breadcrumbs, { numParents: 2, children: /* @__PURE__ */ jsx38(CurrentTitle, {}) }) }),
6317
- /* @__PURE__ */ jsx38(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, {})
6318
6433
  ] }),
6319
- icon: /* @__PURE__ */ jsx38(RectangleEllipsis, {}),
6434
+ icon: /* @__PURE__ */ jsx40(RectangleEllipsis, {}),
6320
6435
  mobileOnly: desktopSideBar === "right"
6321
6436
  });
6322
6437
 
6323
6438
  // components/Editor/index.tsx
6324
6439
  init_react_import();
6325
6440
  import {
6326
- createContext as createContext9,
6327
- useCallback as useCallback22,
6328
- useContext as useContext16,
6329
- useEffect as useEffect25,
6330
- useMemo as useMemo23,
6331
- useRef as useRef16,
6332
- useState as useState23
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
6333
6448
  } from "react";
6334
6449
 
6335
- // components/Editor/components/Components/index.tsx
6336
- init_react_import();
6337
- import { useMemo as useMemo16, useState as useState17 } from "react";
6338
-
6339
- // css-module:/Users/rami/Documents/apps/react-editor/packages/core/components/Editor/components/Components/styles.module.css#css-module
6340
- init_react_import();
6341
- var styles_module_default18 = { "Components-search": "_Components-search_recer_1", "Components-searchIcon": "_Components-searchIcon_recer_8", "Components-searchInput": "_Components-searchInput_recer_16", "Components-empty": "_Components-empty_recer_39" };
6342
-
6343
- // components/Editor/components/Components/index.tsx
6344
- import { jsx as jsx39, jsxs as jsxs16 } from "react/jsx-runtime";
6345
- var getClassName23 = get_class_name_factory_default("Components", styles_module_default18);
6346
- var Components = () => {
6347
- var _a;
6348
- const overrides = useAppStore((s) => s.overrides);
6349
- const components = useAppStore((s) => s.config.components);
6350
- const categoriesConfig = useAppStore((s) => s.config.categories);
6351
- const [search, setSearch] = useState17("");
6352
- const Wrapper = useMemo16(() => {
6353
- if (overrides.components) {
6354
- console.warn(
6355
- "The `components` override has been deprecated and renamed to `drawer`"
6356
- );
6357
- }
6358
- return overrides.components || overrides.drawer || "div";
6359
- }, [overrides]);
6360
- const groups = useMemo16(() => {
6361
- var _a2;
6362
- const query = search.trim().toLowerCase();
6363
- const entries = Object.entries(components != null ? components : {}).filter(([name, conf]) => {
6364
- var _a3;
6365
- if (!query) return true;
6366
- const label = ((_a3 = conf.label) != null ? _a3 : name).toLowerCase();
6367
- return label.includes(query);
6368
- });
6369
- if (!entries.length) return [];
6370
- const buckets = /* @__PURE__ */ new Map();
6371
- for (const entry of entries) {
6372
- const [, conf] = entry;
6373
- const key = conf.category;
6374
- const bucket = (_a2 = buckets.get(key)) != null ? _a2 : [];
6375
- bucket.push(entry);
6376
- buckets.set(key, bucket);
6377
- }
6378
- return Array.from(buckets.entries());
6379
- }, [components, search]);
6380
- return /* @__PURE__ */ jsxs16(Wrapper, { children: [
6381
- /* @__PURE__ */ jsxs16("div", { className: getClassName23("search"), children: [
6382
- /* @__PURE__ */ jsx39("div", { className: getClassName23("searchIcon"), children: /* @__PURE__ */ jsx39(Search, { size: 14 }) }),
6383
- /* @__PURE__ */ jsx39(
6384
- "input",
6385
- {
6386
- type: "search",
6387
- className: getClassName23("searchInput"),
6388
- placeholder: "search",
6389
- value: search,
6390
- onChange: (e) => setSearch(e.target.value)
6391
- }
6392
- )
6393
- ] }),
6394
- groups.length === 0 ? /* @__PURE__ */ jsx39("div", { className: getClassName23("empty"), children: "No results match your search" }) : groups.length <= 1 && !((_a = groups[0]) == null ? void 0 : _a[0]) ? /* @__PURE__ */ jsx39(ComponentList, { id: "all", children: groups[0][1].map(([name, conf]) => {
6395
- var _a2;
6396
- return /* @__PURE__ */ jsx39(
6397
- ComponentList.Item,
6398
- {
6399
- name,
6400
- label: (_a2 = conf.label) != null ? _a2 : name,
6401
- icon: conf.icon
6402
- },
6403
- name
6404
- );
6405
- }) }) : groups.map(([category, entries]) => {
6406
- var _a2, _b;
6407
- const categoryKey = category != null ? category : "other";
6408
- const title = (_b = (_a2 = categoriesConfig == null ? void 0 : categoriesConfig[categoryKey]) == null ? void 0 : _a2.title) != null ? _b : category != null ? category : "Other";
6409
- return /* @__PURE__ */ jsx39(
6410
- ComponentList,
6411
- {
6412
- id: categoryKey,
6413
- title,
6414
- children: entries.map(([name, conf]) => {
6415
- var _a3;
6416
- return /* @__PURE__ */ jsx39(
6417
- ComponentList.Item,
6418
- {
6419
- name,
6420
- label: (_a3 = conf.label) != null ? _a3 : name,
6421
- icon: conf.icon
6422
- },
6423
- name
6424
- );
6425
- })
6426
- },
6427
- categoryKey
6428
- );
6429
- })
6430
- ] });
6431
- };
6432
-
6433
6450
  // components/Editor/components/Preview/index.tsx
6434
6451
  init_react_import();
6435
6452
  import { useCallback as useCallback16, useEffect as useEffect21, useRef as useRef11, useMemo as useMemo17 } from "react";
@@ -6444,7 +6461,7 @@ import {
6444
6461
  } from "react";
6445
6462
  import hash from "object-hash";
6446
6463
  import { createPortal as createPortal3 } from "react-dom";
6447
- import { Fragment as Fragment9, jsx as jsx40 } from "react/jsx-runtime";
6464
+ import { Fragment as Fragment9, jsx as jsx41 } from "react/jsx-runtime";
6448
6465
  var styleSelector = 'style, link[rel="stylesheet"]';
6449
6466
  var collectStyles = (doc) => {
6450
6467
  const collected = [];
@@ -6661,7 +6678,7 @@ var CopyHostStyles = ({
6661
6678
  observer.disconnect();
6662
6679
  };
6663
6680
  }, []);
6664
- return /* @__PURE__ */ jsx40(Fragment9, { children });
6681
+ return /* @__PURE__ */ jsx41(Fragment9, { children });
6665
6682
  };
6666
6683
  var autoFrameContext = createContext6({});
6667
6684
  var useFrame = () => useContext12(autoFrameContext);
@@ -6708,60 +6725,17 @@ function AutoFrame(_a) {
6708
6725
  }
6709
6726
  }
6710
6727
  }, [frameRef, loaded, stylesLoaded]);
6711
- useEffect20(() => {
6712
- const doc = ctx.document;
6713
- const iframeEl = frameRef.current;
6714
- if (!doc || !iframeEl || !stylesLoaded) return;
6715
- let scheduled = false;
6716
- const update = () => {
6717
- if (scheduled) return;
6718
- scheduled = true;
6719
- requestAnimationFrame(() => {
6720
- scheduled = false;
6721
- const html = doc.documentElement;
6722
- const body = doc.body;
6723
- if (!html || !body) return;
6724
- iframeEl.style.height = "0px";
6725
- const height = Math.max(
6726
- body.scrollHeight,
6727
- body.offsetHeight,
6728
- html.scrollHeight,
6729
- html.offsetHeight
6730
- );
6731
- if (height > 0) {
6732
- iframeEl.style.height = `${height}px`;
6733
- }
6734
- });
6735
- };
6736
- update();
6737
- const observer = new ResizeObserver(update);
6738
- observer.observe(doc.body);
6739
- observer.observe(doc.documentElement);
6740
- const iframeObserver = new ResizeObserver(update);
6741
- iframeObserver.observe(iframeEl);
6742
- const mutationObserver = new MutationObserver(update);
6743
- mutationObserver.observe(doc.body, {
6744
- attributes: true,
6745
- childList: true,
6746
- subtree: true
6747
- });
6748
- return () => {
6749
- observer.disconnect();
6750
- iframeObserver.disconnect();
6751
- mutationObserver.disconnect();
6752
- };
6753
- }, [ctx.document, frameRef, stylesLoaded]);
6754
- return /* @__PURE__ */ jsx40(
6728
+ return /* @__PURE__ */ jsx41(
6755
6729
  "iframe",
6756
6730
  __spreadProps(__spreadValues({}, props), {
6757
6731
  className,
6758
6732
  id,
6759
- srcDoc: '<!DOCTYPE html><html><head><meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1, minimum-scale=1, user-scalable=no" /></head><body style="touch-action:none"><div id="frame-root" data-editor-entry></div></body></html>',
6733
+ srcDoc: '<!DOCTYPE html><html><head></head><body><div id="frame-root" data-editor-entry></div></body></html>',
6760
6734
  ref: frameRef,
6761
6735
  onLoad: () => {
6762
6736
  setLoaded(true);
6763
6737
  },
6764
- children: /* @__PURE__ */ jsx40(autoFrameContext.Provider, { value: ctx, children: loaded && mountTarget && /* @__PURE__ */ jsx40(
6738
+ children: /* @__PURE__ */ jsx41(autoFrameContext.Provider, { value: ctx, children: loaded && mountTarget && /* @__PURE__ */ jsx41(
6765
6739
  CopyHostStyles,
6766
6740
  {
6767
6741
  debug,
@@ -6777,11 +6751,11 @@ var AutoFrame_default = AutoFrame;
6777
6751
 
6778
6752
  // css-module:/Users/rami/Documents/apps/react-editor/packages/core/components/Editor/components/Preview/styles.module.css#css-module
6779
6753
  init_react_import();
6780
- var styles_module_default19 = { "EditorPreview": "_EditorPreview_xou64_1", "EditorPreview-frame": "_EditorPreview-frame_xou64_6" };
6754
+ var styles_module_default20 = { "EditorPreview": "_EditorPreview_1ybfe_1", "EditorPreview-frame": "_EditorPreview-frame_1ybfe_6" };
6781
6755
 
6782
6756
  // components/Editor/components/Preview/index.tsx
6783
- import { Fragment as Fragment10, jsx as jsx41 } from "react/jsx-runtime";
6784
- var getClassName24 = get_class_name_factory_default("EditorPreview", styles_module_default19);
6757
+ import { Fragment as Fragment10, jsx as jsx42 } from "react/jsx-runtime";
6758
+ var getClassName25 = get_class_name_factory_default("EditorPreview", styles_module_default20);
6785
6759
  var Preview2 = ({ id = "editor-preview" }) => {
6786
6760
  const dispatch = useAppStore((s) => s.dispatch);
6787
6761
  const root = useAppStore((s) => s.state.data.root);
@@ -6807,14 +6781,14 @@ var Preview2 = ({ id = "editor-preview" }) => {
6807
6781
  );
6808
6782
  return ((_c = config.root) == null ? void 0 : _c.render) ? (_d = config.root) == null ? void 0 : _d.render(__spreadValues(__spreadValues({
6809
6783
  id: "editor-root"
6810
- }, propsWithSlots), richtextProps)) : /* @__PURE__ */ jsx41(Fragment10, { children: propsWithSlots.children });
6784
+ }, propsWithSlots), richtextProps)) : /* @__PURE__ */ jsx42(Fragment10, { children: propsWithSlots.children });
6811
6785
  },
6812
6786
  [config]
6813
6787
  );
6814
6788
  const Frame = useMemo17(() => overrides.iframe, [overrides]);
6815
6789
  const rootProps = root.props || root;
6816
6790
  const ref = useRef11(null);
6817
- const inner = !renderData ? /* @__PURE__ */ jsx41(
6791
+ const inner = !renderData ? /* @__PURE__ */ jsx42(
6818
6792
  Page,
6819
6793
  __spreadProps(__spreadValues({}, rootProps), {
6820
6794
  editor: {
@@ -6824,18 +6798,18 @@ var Preview2 = ({ id = "editor-preview" }) => {
6824
6798
  metadata
6825
6799
  },
6826
6800
  editMode: true,
6827
- children: /* @__PURE__ */ jsx41(DropZonePure, { zone: rootDroppableId })
6801
+ children: /* @__PURE__ */ jsx42(DropZonePure, { zone: rootDroppableId })
6828
6802
  })
6829
- ) : /* @__PURE__ */ jsx41(Render, { data: renderData, config, metadata });
6803
+ ) : /* @__PURE__ */ jsx42(Render, { data: renderData, config, metadata });
6830
6804
  useEffect21(() => {
6831
6805
  if (!iframe.enabled) {
6832
6806
  setStatus("READY");
6833
6807
  }
6834
6808
  }, [iframe.enabled]);
6835
- return /* @__PURE__ */ jsx41(
6809
+ return /* @__PURE__ */ jsx42(
6836
6810
  "div",
6837
6811
  {
6838
- className: getClassName24(),
6812
+ className: getClassName25(),
6839
6813
  id,
6840
6814
  "data-editor-preview": true,
6841
6815
  onClick: (e) => {
@@ -6844,11 +6818,11 @@ var Preview2 = ({ id = "editor-preview" }) => {
6844
6818
  dispatch({ type: "setUi", ui: { itemSelector: null } });
6845
6819
  }
6846
6820
  },
6847
- children: iframe.enabled ? /* @__PURE__ */ jsx41(
6821
+ children: iframe.enabled ? /* @__PURE__ */ jsx42(
6848
6822
  AutoFrame_default,
6849
6823
  {
6850
6824
  id: "preview-frame",
6851
- className: getClassName24("frame"),
6825
+ className: getClassName25("frame"),
6852
6826
  "data-rfd-iframe": true,
6853
6827
  onReady: () => {
6854
6828
  setStatus("READY");
@@ -6857,18 +6831,18 @@ var Preview2 = ({ id = "editor-preview" }) => {
6857
6831
  setStatus("MOUNTED");
6858
6832
  },
6859
6833
  frameRef: ref,
6860
- children: /* @__PURE__ */ jsx41(autoFrameContext.Consumer, { children: ({ document: document2 }) => {
6834
+ children: /* @__PURE__ */ jsx42(autoFrameContext.Consumer, { children: ({ document: document2 }) => {
6861
6835
  if (Frame) {
6862
- return /* @__PURE__ */ jsx41(Frame, { document: document2, children: inner });
6836
+ return /* @__PURE__ */ jsx42(Frame, { document: document2, children: inner });
6863
6837
  }
6864
6838
  return inner;
6865
6839
  } })
6866
6840
  }
6867
- ) : /* @__PURE__ */ jsx41(
6841
+ ) : /* @__PURE__ */ jsx42(
6868
6842
  "div",
6869
6843
  {
6870
6844
  id: "preview-frame",
6871
- className: getClassName24("frame"),
6845
+ className: getClassName25("frame"),
6872
6846
  ref,
6873
6847
  "data-editor-entry": true,
6874
6848
  children: inner
@@ -6886,7 +6860,7 @@ init_react_import();
6886
6860
 
6887
6861
  // css-module:/Users/rami/Documents/apps/react-editor/packages/core/components/LayerTree/styles.module.css#css-module
6888
6862
  init_react_import();
6889
- var styles_module_default20 = { "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" };
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" };
6890
6864
 
6891
6865
  // components/LayerTree/index.tsx
6892
6866
  import {
@@ -6896,9 +6870,9 @@ import {
6896
6870
  useRef as useRef12
6897
6871
  } from "react";
6898
6872
  import { useVirtualizer as useVirtualizer2 } from "@tanstack/react-virtual";
6899
- import { Fragment as Fragment11, jsx as jsx42, jsxs as jsxs17 } from "react/jsx-runtime";
6900
- var getClassName25 = get_class_name_factory_default("LayerTree", styles_module_default20);
6901
- var getClassNameLayer = get_class_name_factory_default("Layer", styles_module_default20);
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);
6902
6876
  var DEFAULT_LAYER_ROW_HEIGHT = 32;
6903
6877
  var LAYER_TREE_VIRTUALIZATION_OVERSCAN = 8;
6904
6878
  var MIN_VIRTUALIZED_LAYER_COUNT = 25;
@@ -7052,7 +7026,7 @@ var Layer = forwardRef2(function Layer2({
7052
7026
  "data-index": dataIndex,
7053
7027
  "data-editor-layer-tree-id": node.itemId,
7054
7028
  children: [
7055
- /* @__PURE__ */ jsx42("div", { className: getClassNameLayer("inner"), children: /* @__PURE__ */ jsxs17(
7029
+ /* @__PURE__ */ jsx43("div", { className: getClassNameLayer("inner"), children: /* @__PURE__ */ jsxs17(
7056
7030
  "button",
7057
7031
  {
7058
7032
  type: "button",
@@ -7077,34 +7051,34 @@ var Layer = forwardRef2(function Layer2({
7077
7051
  zoneStore.setState({ hoveringComponent: null });
7078
7052
  },
7079
7053
  children: [
7080
- /* @__PURE__ */ jsx42(
7054
+ /* @__PURE__ */ jsx43(
7081
7055
  "div",
7082
7056
  {
7083
7057
  className: getClassNameLayer("chevron"),
7084
7058
  title: containsZone ? isSelected ? "Collapse" : "Expand" : void 0,
7085
- children: containsZone && /* @__PURE__ */ jsx42(ChevronRight, { size: "12" })
7059
+ children: containsZone && /* @__PURE__ */ jsx43(ChevronRight, { size: "12" })
7086
7060
  }
7087
7061
  ),
7088
7062
  /* @__PURE__ */ jsxs17("div", { className: getClassNameLayer("title"), children: [
7089
- /* @__PURE__ */ jsx42("div", { className: getClassNameLayer("icon"), children: /* @__PURE__ */ jsx42(Component, { size: "16" }) }),
7090
- /* @__PURE__ */ jsx42("div", { className: getClassNameLayer("name"), children: node.label }),
7091
- isGlobal && isUnlinked && /* @__PURE__ */ jsx42(
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(
7092
7066
  "div",
7093
7067
  {
7094
7068
  className: getClassNameLayer("unlinkedGlyph"),
7095
7069
  title: "Unlinked from shared",
7096
- children: /* @__PURE__ */ jsx42(Unlink2, { size: "12" })
7070
+ children: /* @__PURE__ */ jsx43(Unlink2, { size: "12" })
7097
7071
  }
7098
7072
  )
7099
7073
  ] })
7100
7074
  ]
7101
7075
  }
7102
7076
  ) }),
7103
- containsZone && shouldRenderChildren && node.childZones.map((childZone) => /* @__PURE__ */ jsx42(
7077
+ containsZone && shouldRenderChildren && node.childZones.map((childZone) => /* @__PURE__ */ jsx43(
7104
7078
  "div",
7105
7079
  {
7106
7080
  className: getClassNameLayer("zones"),
7107
- children: /* @__PURE__ */ jsx42(
7081
+ children: /* @__PURE__ */ jsx43(
7108
7082
  LayerTreeZone,
7109
7083
  {
7110
7084
  depth: depth + 1,
@@ -7128,8 +7102,8 @@ var LayerTreeZone = ({
7128
7102
  }) => {
7129
7103
  const shouldVirtualize = depth === 0 && tree.items.length >= MIN_VIRTUALIZED_LAYER_COUNT;
7130
7104
  return /* @__PURE__ */ jsxs17(Fragment11, { children: [
7131
- tree.label && /* @__PURE__ */ jsx42("div", { className: getClassName25("zoneTitle"), children: tree.label }),
7132
- shouldVirtualize ? /* @__PURE__ */ jsx42(
7105
+ tree.label && /* @__PURE__ */ jsx43("div", { className: getClassName26("zoneTitle"), children: tree.label }),
7106
+ shouldVirtualize ? /* @__PURE__ */ jsx43(
7133
7107
  VirtualizedLayerTreeItems,
7134
7108
  {
7135
7109
  depth,
@@ -7137,7 +7111,7 @@ var LayerTreeZone = ({
7137
7111
  selectedPathIds,
7138
7112
  tree
7139
7113
  }
7140
- ) : /* @__PURE__ */ jsx42(
7114
+ ) : /* @__PURE__ */ jsx43(
7141
7115
  StaticLayerTreeItems,
7142
7116
  {
7143
7117
  depth,
@@ -7154,9 +7128,9 @@ var StaticLayerTreeItems = ({
7154
7128
  selectedPathIds,
7155
7129
  tree
7156
7130
  }) => {
7157
- return /* @__PURE__ */ jsxs17("ul", { className: getClassName25(), children: [
7158
- tree.items.length === 0 && /* @__PURE__ */ jsx42("div", { className: getClassName25("helper"), children: "empty" }),
7159
- tree.items.map((node) => /* @__PURE__ */ jsx42(
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(
7160
7134
  Layer,
7161
7135
  {
7162
7136
  childIsSelected: selectedPathIds.has(node.itemId),
@@ -7202,7 +7176,7 @@ var VirtualizedLayerTreeItems = ({
7202
7176
  const gapSize = Math.max(virtualItem.start - previousEnd, 0);
7203
7177
  if (gapSize > 0) {
7204
7178
  renderedItems.push(
7205
- /* @__PURE__ */ jsx42(
7179
+ /* @__PURE__ */ jsx43(
7206
7180
  "li",
7207
7181
  {
7208
7182
  "aria-hidden": "true",
@@ -7213,7 +7187,7 @@ var VirtualizedLayerTreeItems = ({
7213
7187
  );
7214
7188
  }
7215
7189
  renderedItems.push(
7216
- /* @__PURE__ */ jsx42(
7190
+ /* @__PURE__ */ jsx43(
7217
7191
  Layer,
7218
7192
  {
7219
7193
  childIsSelected: selectedPathIds.has(node.itemId),
@@ -7234,7 +7208,7 @@ var VirtualizedLayerTreeItems = ({
7234
7208
  const trailingGap = Math.max(totalSize - previousEnd, 0);
7235
7209
  if (trailingGap > 0) {
7236
7210
  renderedItems.push(
7237
- /* @__PURE__ */ jsx42(
7211
+ /* @__PURE__ */ jsx43(
7238
7212
  "li",
7239
7213
  {
7240
7214
  "aria-hidden": "true",
@@ -7244,8 +7218,8 @@ var VirtualizedLayerTreeItems = ({
7244
7218
  )
7245
7219
  );
7246
7220
  }
7247
- return /* @__PURE__ */ jsxs17("ul", { className: getClassName25(), ref: listRef, children: [
7248
- tree.items.length === 0 && /* @__PURE__ */ jsx42("div", { className: getClassName25("helper"), children: "empty" }),
7221
+ return /* @__PURE__ */ jsxs17("ul", { className: getClassName26(), ref: listRef, children: [
7222
+ tree.items.length === 0 && /* @__PURE__ */ jsx43("div", { className: getClassName26("helper"), children: "empty" }),
7249
7223
  renderedItems
7250
7224
  ] });
7251
7225
  };
@@ -7254,7 +7228,7 @@ var LayerTree = ({
7254
7228
  selectedPathIds,
7255
7229
  trees
7256
7230
  }) => {
7257
- return /* @__PURE__ */ jsx42(Fragment11, { children: trees.map((tree) => /* @__PURE__ */ jsx42(
7231
+ return /* @__PURE__ */ jsx43(Fragment11, { children: trees.map((tree) => /* @__PURE__ */ jsx43(
7258
7232
  LayerTreeZone,
7259
7233
  {
7260
7234
  depth: 0,
@@ -7279,7 +7253,7 @@ var findZonesForArea = (state, area) => {
7279
7253
 
7280
7254
  // components/Editor/components/Outline/index.tsx
7281
7255
  import { useShallow as useShallow8 } from "zustand/react/shallow";
7282
- import { jsx as jsx43 } from "react/jsx-runtime";
7256
+ import { jsx as jsx44 } from "react/jsx-runtime";
7283
7257
  var Outline = () => {
7284
7258
  const outlineOverride = useAppStore((s) => s.overrides.outline);
7285
7259
  const config = useAppStore((s) => s.config);
@@ -7312,7 +7286,7 @@ var Outline = () => {
7312
7286
  [config, nodes, rootZones, zones]
7313
7287
  );
7314
7288
  const Wrapper = useMemo18(() => outlineOverride || "div", [outlineOverride]);
7315
- return /* @__PURE__ */ jsx43(Wrapper, { children: /* @__PURE__ */ jsx43(
7289
+ return /* @__PURE__ */ jsx44(Wrapper, { children: /* @__PURE__ */ jsx44(
7316
7290
  LayerTree,
7317
7291
  {
7318
7292
  selectedId,
@@ -7419,11 +7393,17 @@ function splitGlobals(data, config) {
7419
7393
 
7420
7394
  // components/Editor/components/Layout/index.tsx
7421
7395
  init_react_import();
7422
- import { useEffect as useEffect24, useMemo as useMemo22, useState as useState22 } from "react";
7396
+ import {
7397
+ useCallback as useCallback24,
7398
+ useEffect as useEffect25,
7399
+ useMemo as useMemo23,
7400
+ useRef as useRef18,
7401
+ useState as useState23
7402
+ } from "react";
7423
7403
 
7424
7404
  // css-module:/Users/rami/Documents/apps/react-editor/packages/core/components/Editor/components/Layout/styles.module.css#css-module
7425
7405
  init_react_import();
7426
- var styles_module_default21 = { "Editor": "_Editor_1d9v5_8", "Editor-portal": "_Editor-portal_1d9v5_21", "EditorLayout": "_EditorLayout_1d9v5_26", "EditorLayout-inner": "_EditorLayout-inner_1d9v5_30", "EditorLayout--navBarVisible": "_EditorLayout--navBarVisible_1d9v5_44", "EditorLayout-header": "_EditorLayout-header_1d9v5_49", "EditorLayout-headerStart": "_EditorLayout-headerStart_1d9v5_62", "EditorLayout-headerCenter": "_EditorLayout-headerCenter_1d9v5_70", "EditorLayout-headerEnd": "_EditorLayout-headerEnd_1d9v5_81", "EditorLayout-headerHistory": "_EditorLayout-headerHistory_1d9v5_91", "EditorPluginTab": "_EditorPluginTab_1d9v5_110", "EditorPluginTab--visible": "_EditorPluginTab--visible_1d9v5_116", "EditorPluginTab-body": "_EditorPluginTab-body_1d9v5_121" };
7406
+ var styles_module_default22 = { "Editor": "_Editor_l0swf_19", "Editor-portal": "_Editor-portal_l0swf_32", "EditorLayout": "_EditorLayout_l0swf_37", "EditorLayout-inner": "_EditorLayout-inner_l0swf_41", "Editor--hidePlugins": "_Editor--hidePlugins_l0swf_72", "EditorLayout--navBarVisible": "_EditorLayout--navBarVisible_l0swf_73", "EditorLayout--mounted": "_EditorLayout--mounted_l0swf_82", "EditorLayout--mobilePanelHeightToggle": "_EditorLayout--mobilePanelHeightToggle_l0swf_86", "EditorLayout--leftSideBarVisible": "_EditorLayout--leftSideBarVisible_l0swf_86", "EditorLayout--mobilePanelCustomHeight": "_EditorLayout--mobilePanelCustomHeight_l0swf_91", "EditorLayout--mobilePanelHeightMinContent": "_EditorLayout--mobilePanelHeightMinContent_l0swf_109", "EditorLayout--rightSideBarVisible": "_EditorLayout--rightSideBarVisible_l0swf_129", "EditorLayout-mounted": "_EditorLayout-mounted_l0swf_146", "EditorLayout-header": "_EditorLayout-header_l0swf_187", "EditorHeader": "_EditorHeader_l0swf_194", "EditorHeader-plugins": "_EditorHeader-plugins_l0swf_221", "EditorHeader-pluginItem": "_EditorHeader-pluginItem_l0swf_235", "EditorHeader-pluginItem--mobileOnly": "_EditorHeader-pluginItem--mobileOnly_l0swf_241", "EditorHeader-pluginItem--desktopOnly": "_EditorHeader-pluginItem--desktopOnly_l0swf_246", "EditorHeader-urlBarSlot": "_EditorHeader-urlBarSlot_l0swf_256", "EditorHeader-actions": "_EditorHeader-actions_l0swf_274", "EditorHeader-history": "_EditorHeader-history_l0swf_282", "EditorLayout-mobilePanel": "_EditorLayout-mobilePanel_l0swf_288", "EditorLayout-mobilePanelContent": "_EditorLayout-mobilePanelContent_l0swf_308", "EditorLayout-mobileDragHandle": "_EditorLayout-mobileDragHandle_l0swf_315", "EditorLayout-mobileDragHandlePill": "_EditorLayout-mobileDragHandlePill_l0swf_329", "EditorPluginTab": "_EditorPluginTab_l0swf_336", "EditorPluginTab--visible": "_EditorPluginTab--visible_l0swf_342", "EditorPluginTab-body": "_EditorPluginTab-body_l0swf_347" };
7427
7407
 
7428
7408
  // lib/use-inject-css.ts
7429
7409
  init_react_import();
@@ -7454,8 +7434,8 @@ var useInjectGlobalCss = (iframeEnabled) => {
7454
7434
 
7455
7435
  // components/DefaultOverride/index.tsx
7456
7436
  init_react_import();
7457
- import { Fragment as Fragment12, jsx as jsx44 } from "react/jsx-runtime";
7458
- var DefaultOverride = ({ children }) => /* @__PURE__ */ jsx44(Fragment12, { children });
7437
+ import { Fragment as Fragment12, jsx as jsx45 } from "react/jsx-runtime";
7438
+ var DefaultOverride = ({ children }) => /* @__PURE__ */ jsx45(Fragment12, { children });
7459
7439
 
7460
7440
  // lib/use-preview-mode-hotkeys.ts
7461
7441
  init_react_import();
@@ -7480,11 +7460,11 @@ init_react_import();
7480
7460
 
7481
7461
  // css-module:/Users/rami/Documents/apps/react-editor/packages/core/components/SidebarSection/styles.module.css#css-module
7482
7462
  init_react_import();
7483
- var styles_module_default22 = { "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" };
7484
7464
 
7485
7465
  // components/SidebarSection/index.tsx
7486
- import { jsx as jsx45, jsxs as jsxs18 } from "react/jsx-runtime";
7487
- var getClassName26 = get_class_name_factory_default("SidebarSection", styles_module_default22);
7466
+ import { jsx as jsx46, jsxs as jsxs18 } from "react/jsx-runtime";
7467
+ var getClassName27 = get_class_name_factory_default("SidebarSection", styles_module_default23);
7488
7468
  var SidebarSection = ({
7489
7469
  children,
7490
7470
  title,
@@ -7493,15 +7473,13 @@ var SidebarSection = ({
7493
7473
  noBorderTop,
7494
7474
  isLoading
7495
7475
  }) => {
7496
- const showTitleBar = title !== null && title !== void 0;
7497
- const showBreadcrumbsRow = !!showBreadcrumbs;
7498
- return /* @__PURE__ */ jsxs18("div", { className: getClassName26({ noBorderTop }), style: { background }, children: [
7499
- (showTitleBar || showBreadcrumbsRow) && /* @__PURE__ */ jsx45("div", { className: getClassName26("title"), children: /* @__PURE__ */ jsxs18("div", { className: getClassName26("breadcrumbs"), children: [
7500
- showBreadcrumbsRow && /* @__PURE__ */ jsx45(Breadcrumbs, {}),
7501
- showTitleBar && /* @__PURE__ */ jsx45("div", { className: getClassName26("heading"), children: /* @__PURE__ */ jsx45(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 }) })
7502
7480
  ] }) }),
7503
- /* @__PURE__ */ jsx45("div", { className: getClassName26("content"), children }),
7504
- isLoading && /* @__PURE__ */ jsx45("div", { className: getClassName26("loadingOverlay"), children: /* @__PURE__ */ jsx45(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 }) })
7505
7483
  ] });
7506
7484
  };
7507
7485
 
@@ -7510,102 +7488,323 @@ init_react_import();
7510
7488
  import {
7511
7489
  useCallback as useCallback19,
7512
7490
  useEffect as useEffect23,
7513
- useMemo as useMemo21,
7514
- useRef as useRef14,
7515
- useState as useState20
7491
+ useMemo as useMemo22,
7492
+ useRef as useRef15,
7493
+ useState as useState21
7516
7494
  } from "react";
7517
- import {
7518
- TransformWrapper,
7519
- TransformComponent,
7520
- useTransformComponent,
7521
- useTransformEffect
7522
- } from "react-zoom-pan-pinch";
7523
7495
 
7524
- // css-module:/Users/rami/Documents/apps/react-editor/packages/core/components/Editor/components/Canvas/styles.module.css#css-module
7496
+ // components/BrowserBar/index.tsx
7525
7497
  init_react_import();
7526
- var styles_module_default23 = { "EditorCanvas": "_EditorCanvas_1h1vv_1", "EditorCanvas--fullScreen": "_EditorCanvas--fullScreen_1h1vv_11", "EditorCanvas--canvasFullScreen": "_EditorCanvas--canvasFullScreen_1h1vv_31", "EditorCanvas-inner": "_EditorCanvas-inner_1h1vv_38", "EditorCanvas-bar": "_EditorCanvas-bar_1h1vv_50", "EditorCanvas-zoomViewport": "_EditorCanvas-zoomViewport_1h1vv_60", "EditorCanvas-rootColumn": "_EditorCanvas-rootColumn_1h1vv_69", "EditorCanvas-frame": "_EditorCanvas-frame_1h1vv_74", "EditorCanvas-root": "_EditorCanvas-root_1h1vv_69", "EditorCanvas--ready": "_EditorCanvas--ready_1h1vv_98", "EditorCanvas-loader": "_EditorCanvas-loader_1h1vv_103", "EditorCanvas--showLoader": "_EditorCanvas--showLoader_1h1vv_115", "EditorCanvas-toolbar": "_EditorCanvas-toolbar_1h1vv_128", "EditorCanvas-toolbarDivider": "_EditorCanvas-toolbarDivider_1h1vv_144", "EditorCanvas-zoomLevel": "_EditorCanvas-zoomLevel_1h1vv_152" };
7527
-
7528
- // components/Editor/components/Canvas/index.tsx
7529
- import { useShallow as useShallow9 } from "zustand/react/shallow";
7498
+ import { useMemo as useMemo20, useRef as useRef13, useState as useState20 } from "react";
7530
7499
 
7531
- // lib/frame-context.tsx
7500
+ // components/ui/Combobox/index.tsx
7532
7501
  init_react_import();
7533
- import {
7534
- createContext as createContext7,
7535
- useContext as useContext14,
7536
- useRef as useRef13,
7537
- useMemo as useMemo20
7538
- } from "react";
7539
- import { jsx as jsx46 } from "react/jsx-runtime";
7540
- var FrameContext = createContext7(null);
7541
- var FrameProvider = ({
7542
- children
7543
- }) => {
7544
- const frameRef = useRef13(null);
7545
- const value = useMemo20(
7546
- () => ({
7547
- frameRef
7548
- }),
7549
- []
7550
- );
7551
- return /* @__PURE__ */ jsx46(FrameContext.Provider, { value, children });
7552
- };
7553
- var useCanvasFrame = () => {
7554
- const context = useContext14(FrameContext);
7555
- if (context === null) {
7556
- throw new Error("useCanvasFrame must be used within a FrameProvider");
7557
- }
7558
- return context;
7559
- };
7502
+ import { Combobox as ComboboxPrimitive } from "@base-ui/react";
7560
7503
 
7561
- // lib/theme-context.tsx
7504
+ // css-module:/Users/rami/Documents/apps/react-editor/packages/core/components/ui/Combobox/styles.module.css#css-module
7562
7505
  init_react_import();
7563
- import { createContext as createContext8, useContext as useContext15 } from "react";
7564
- var ThemeContext = createContext8({
7565
- theme: "light",
7566
- toggleTheme: () => {
7567
- }
7568
- });
7569
- var useEditorTheme = () => useContext15(ThemeContext);
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" };
7570
7507
 
7571
- // components/Editor/components/Canvas/index.tsx
7572
- import { Fragment as Fragment13, jsx as jsx47, jsxs as jsxs19 } from "react/jsx-runtime";
7573
- var getClassName27 = get_class_name_factory_default("EditorCanvas", styles_module_default23);
7574
- var MIN_ZOOM = 0.25;
7575
- var MAX_ZOOM = 3;
7576
- var PREVIEW_MAX_WIDTH = 1200;
7577
- var DEVICE_VIEWPORTS = {
7578
- desktop: { width: "100%", height: "auto", label: "Desktop" },
7579
- tablet: { width: 768, height: "auto", label: "Tablet" },
7580
- mobile: { width: 360, height: "auto", label: "Mobile" }
7581
- };
7582
- var DEVICE_ORDER = ["desktop", "tablet", "mobile"];
7583
- var DEVICE_ICONS = {
7584
- desktop: /* @__PURE__ */ jsx47(Monitor, { size: 14 }),
7585
- tablet: /* @__PURE__ */ jsx47(Tablet, { size: 14 }),
7586
- mobile: /* @__PURE__ */ jsx47(Smartphone, { size: 14 })
7587
- };
7588
- var ZoomConfigSync = () => {
7589
- const appStoreApi = useAppStoreApi();
7590
- useTransformEffect((ref) => {
7591
- const { zoomConfig, setZoomConfig } = appStoreApi.getState();
7592
- if (zoomConfig.zoom !== ref.state.scale) {
7593
- setZoomConfig(__spreadProps(__spreadValues({}, zoomConfig), { zoom: ref.state.scale }));
7594
- }
7595
- });
7596
- return null;
7597
- };
7598
- var ZoomLevel = ({ className }) => {
7599
- const scale = useTransformComponent((ctx) => ctx.state.scale);
7600
- return /* @__PURE__ */ jsx47("span", { className, children: `${Math.round(scale * 100)}%` });
7508
+ // components/ui/Combobox/index.tsx
7509
+ import { jsx as jsx47, jsxs as jsxs19 } from "react/jsx-runtime";
7510
+ var getClassName28 = get_class_name_factory_default("EditorCombobox", styles_module_default24);
7511
+ var join = (...values) => values.filter(Boolean).join(" ");
7512
+ var mergeClassName = (base, override) => {
7513
+ if (!override) return base;
7514
+ if (typeof override === "function") {
7515
+ return (state) => join(base, override(state));
7516
+ }
7517
+ return join(base, override);
7601
7518
  };
7602
- var Canvas = () => {
7603
- const { frameRef } = useCanvasFrame();
7604
- const { disableZoomControls } = usePropsContext();
7605
- const {
7519
+ var Combobox = ComboboxPrimitive.Root;
7520
+ function ComboboxInput(_a) {
7521
+ var _b = _a, {
7522
+ className
7523
+ } = _b, props = __objRest(_b, [
7524
+ "className"
7525
+ ]);
7526
+ return /* @__PURE__ */ jsx47(
7527
+ ComboboxPrimitive.Input,
7528
+ __spreadValues({
7529
+ "data-slot": "combobox-input",
7530
+ className: mergeClassName(getClassName28("input"), className)
7531
+ }, props)
7532
+ );
7533
+ }
7534
+ function ComboboxContent(_a) {
7535
+ var _b = _a, {
7536
+ className,
7537
+ side = "bottom",
7538
+ sideOffset = 4,
7539
+ align = "start",
7540
+ alignOffset = 0,
7541
+ children
7542
+ } = _b, props = __objRest(_b, [
7543
+ "className",
7544
+ "side",
7545
+ "sideOffset",
7546
+ "align",
7547
+ "alignOffset",
7548
+ "children"
7549
+ ]);
7550
+ return /* @__PURE__ */ jsx47(ComboboxPrimitive.Portal, { children: /* @__PURE__ */ jsx47(
7551
+ ComboboxPrimitive.Positioner,
7552
+ {
7553
+ side,
7554
+ sideOffset,
7555
+ align,
7556
+ alignOffset,
7557
+ className: getClassName28("positioner"),
7558
+ children: /* @__PURE__ */ jsx47(
7559
+ ComboboxPrimitive.Popup,
7560
+ __spreadProps(__spreadValues({
7561
+ "data-slot": "combobox-content",
7562
+ className: mergeClassName(getClassName28("content"), className)
7563
+ }, props), {
7564
+ children
7565
+ })
7566
+ )
7567
+ }
7568
+ ) });
7569
+ }
7570
+ function ComboboxList(_a) {
7571
+ var _b = _a, {
7572
+ className
7573
+ } = _b, props = __objRest(_b, [
7574
+ "className"
7575
+ ]);
7576
+ return /* @__PURE__ */ jsx47(
7577
+ ComboboxPrimitive.List,
7578
+ __spreadValues({
7579
+ "data-slot": "combobox-list",
7580
+ className: mergeClassName(getClassName28("list"), className)
7581
+ }, props)
7582
+ );
7583
+ }
7584
+ function ComboboxItem(_a) {
7585
+ var _b = _a, {
7586
+ className,
7587
+ children
7588
+ } = _b, props = __objRest(_b, [
7589
+ "className",
7590
+ "children"
7591
+ ]);
7592
+ return /* @__PURE__ */ jsxs19(
7593
+ ComboboxPrimitive.Item,
7594
+ __spreadProps(__spreadValues({
7595
+ "data-slot": "combobox-item",
7596
+ className: mergeClassName(getClassName28("item"), className)
7597
+ }, props), {
7598
+ children: [
7599
+ /* @__PURE__ */ jsx47("span", { className: getClassName28("itemIndicator"), children: /* @__PURE__ */ jsx47(ComboboxPrimitive.ItemIndicator, { children: /* @__PURE__ */ jsx47(Check, { size: 14 }) }) }),
7600
+ children
7601
+ ]
7602
+ })
7603
+ );
7604
+ }
7605
+ function ComboboxEmpty(_a) {
7606
+ var _b = _a, {
7607
+ className
7608
+ } = _b, props = __objRest(_b, [
7609
+ "className"
7610
+ ]);
7611
+ return /* @__PURE__ */ jsx47(
7612
+ ComboboxPrimitive.Empty,
7613
+ __spreadValues({
7614
+ "data-slot": "combobox-empty",
7615
+ className: mergeClassName(getClassName28("empty"), className)
7616
+ }, props)
7617
+ );
7618
+ }
7619
+
7620
+ // css-module:/Users/rami/Documents/apps/react-editor/packages/core/components/BrowserBar/styles.module.css#css-module
7621
+ init_react_import();
7622
+ var styles_module_default25 = { "BrowserBar": "_BrowserBar_glswb_1", "BrowserBar-urlTrigger": "_BrowserBar-urlTrigger_glswb_16", "BrowserBar-urlIcon": "_BrowserBar-urlIcon_glswb_46", "BrowserBar-urlText": "_BrowserBar-urlText_glswb_51", "BrowserBar-urlInput": "_BrowserBar-urlInput_glswb_63", "BrowserBar-itemPath": "_BrowserBar-itemPath_glswb_69", "BrowserBar-itemTitle": "_BrowserBar-itemTitle_glswb_74", "BrowserBar-actions": "_BrowserBar-actions_glswb_82", "BrowserBar-deviceIcon": "_BrowserBar-deviceIcon_glswb_92" };
7623
+
7624
+ // components/BrowserBar/index.tsx
7625
+ import { jsx as jsx48, jsxs as jsxs20 } from "react/jsx-runtime";
7626
+ var normalizeRoute = (raw) => {
7627
+ const trimmed = raw.trim();
7628
+ if (!trimmed) return trimmed;
7629
+ return trimmed.startsWith("/") ? trimmed : `/${trimmed}`;
7630
+ };
7631
+ var getClassName29 = get_class_name_factory_default("BrowserBar", styles_module_default25);
7632
+ var DEVICE_VIEWPORTS = {
7633
+ desktop: { width: "100%", height: "auto", icon: "Monitor", label: "Desktop" },
7634
+ mobile: { width: 360, height: "auto", icon: "Smartphone", label: "Mobile" }
7635
+ };
7636
+ var UrlBar = () => {
7637
+ const { routes, currentRoute, onRouteChange } = usePropsContext();
7638
+ const chrome = useChromeConfig();
7639
+ const showRoutePicker = !!routes && currentRoute !== void 0 && !!onRouteChange;
7640
+ const [inputValue, setInputValue] = useState20(currentRoute != null ? currentRoute : "");
7641
+ const lastSyncedPath = useRef13(currentRoute);
7642
+ if (lastSyncedPath.current !== currentRoute) {
7643
+ lastSyncedPath.current = currentRoute;
7644
+ setInputValue(currentRoute != null ? currentRoute : "");
7645
+ }
7646
+ const submit = (raw) => {
7647
+ const next = normalizeRoute(raw);
7648
+ if (!next || next === currentRoute) return;
7649
+ void (onRouteChange == null ? void 0 : onRouteChange(next));
7650
+ };
7651
+ if (!chrome.showUrlBar) return null;
7652
+ if (showRoutePicker) {
7653
+ return /* @__PURE__ */ jsxs20(
7654
+ Combobox,
7655
+ {
7656
+ items: routes,
7657
+ value: currentRoute,
7658
+ onValueChange: (next) => {
7659
+ if (typeof next === "string") submit(next);
7660
+ },
7661
+ inputValue,
7662
+ onInputValueChange: (next) => setInputValue(next),
7663
+ autoHighlight: false,
7664
+ children: [
7665
+ /* @__PURE__ */ jsxs20(
7666
+ "form",
7667
+ {
7668
+ className: getClassName29("urlTrigger"),
7669
+ onSubmit: (event) => {
7670
+ event.preventDefault();
7671
+ submit(inputValue);
7672
+ },
7673
+ children: [
7674
+ /* @__PURE__ */ jsx48(Globe, { className: getClassName29("urlIcon"), size: 14 }),
7675
+ /* @__PURE__ */ jsx48(
7676
+ ComboboxInput,
7677
+ {
7678
+ className: getClassName29("urlInput"),
7679
+ placeholder: "/",
7680
+ spellCheck: false,
7681
+ autoCorrect: "off",
7682
+ autoCapitalize: "off"
7683
+ }
7684
+ )
7685
+ ]
7686
+ }
7687
+ ),
7688
+ /* @__PURE__ */ jsxs20(ComboboxContent, { children: [
7689
+ /* @__PURE__ */ jsx48(ComboboxEmpty, { children: "Press Enter to go to this path" }),
7690
+ /* @__PURE__ */ jsx48(ComboboxList, { children: (path) => /* @__PURE__ */ jsx48(ComboboxItem, { value: path, children: /* @__PURE__ */ jsx48("span", { className: getClassName29("itemPath"), children: path }) }, path) })
7691
+ ] })
7692
+ ]
7693
+ }
7694
+ );
7695
+ }
7696
+ return /* @__PURE__ */ jsxs20("div", { className: getClassName29("urlTrigger"), children: [
7697
+ /* @__PURE__ */ jsx48(Globe, { className: getClassName29("urlIcon"), size: 14 }),
7698
+ /* @__PURE__ */ jsx48("span", { className: getClassName29("urlText"), children: "/" })
7699
+ ] });
7700
+ };
7701
+ var DeviceToggle = ({
7702
+ onViewportChange
7703
+ }) => {
7704
+ const chrome = useChromeConfig();
7705
+ const viewports = useAppStore((s) => s.state.ui.viewports);
7706
+ const activeDevice = useMemo20(() => {
7707
+ const w = viewports.current.width;
7708
+ if (typeof w === "number" && w <= 640) return "mobile";
7709
+ return "desktop";
7710
+ }, [viewports.current.width]);
7711
+ if (!chrome.showDeviceToggle) return null;
7712
+ return /* @__PURE__ */ jsx48(
7713
+ IconButton,
7714
+ {
7715
+ type: "button",
7716
+ title: activeDevice === "desktop" ? "Switch to mobile viewport" : "Switch to desktop viewport",
7717
+ onClick: () => onViewportChange == null ? void 0 : onViewportChange(
7718
+ DEVICE_VIEWPORTS[activeDevice === "desktop" ? "mobile" : "desktop"]
7719
+ ),
7720
+ children: /* @__PURE__ */ jsx48("span", { className: getClassName29("deviceIcon"), children: activeDevice === "desktop" ? /* @__PURE__ */ jsx48(Monitor, { size: 14 }) : /* @__PURE__ */ jsx48(Smartphone, { size: 14 }) })
7721
+ }
7722
+ );
7723
+ };
7724
+ var FullScreenToggle = () => {
7725
+ const chrome = useChromeConfig();
7726
+ const dispatch = useAppStore((s) => s.dispatch);
7727
+ const isFullScreen = useAppStore(
7728
+ (s) => {
7729
+ var _a;
7730
+ return (_a = s.state.ui.canvasFullScreen) != null ? _a : false;
7731
+ }
7732
+ );
7733
+ if (!chrome.showFullScreenToggle) return null;
7734
+ return /* @__PURE__ */ jsx48(
7735
+ IconButton,
7736
+ {
7737
+ type: "button",
7738
+ title: isFullScreen ? "Exit full screen" : "Enter full screen",
7739
+ onClick: () => dispatch({ type: "setUi", ui: { canvasFullScreen: !isFullScreen } }),
7740
+ children: /* @__PURE__ */ jsx48("span", { className: getClassName29("deviceIcon"), children: isFullScreen ? /* @__PURE__ */ jsx48(Minimize, { size: 14 }) : /* @__PURE__ */ jsx48(Maximize, { size: 14 }) })
7741
+ }
7742
+ );
7743
+ };
7744
+
7745
+ // css-module:/Users/rami/Documents/apps/react-editor/packages/core/components/Editor/components/Canvas/styles.module.css#css-module
7746
+ init_react_import();
7747
+ var styles_module_default26 = { "EditorCanvas": "_EditorCanvas_10xv6_1", "EditorCanvas--fullScreen": "_EditorCanvas--fullScreen_10xv6_24", "EditorCanvas--canvasFullScreen": "_EditorCanvas--canvasFullScreen_10xv6_40", "EditorCanvas-inner": "_EditorCanvas-inner_10xv6_47", "EditorCanvas-rootColumn": "_EditorCanvas-rootColumn_10xv6_56", "EditorCanvas-root": "_EditorCanvas-root_10xv6_56", "EditorCanvas--ready": "_EditorCanvas--ready_10xv6_93", "EditorCanvas-loader": "_EditorCanvas-loader_10xv6_98", "EditorCanvas--showLoader": "_EditorCanvas--showLoader_10xv6_110", "EditorCanvas-bottomBar": "_EditorCanvas-bottomBar_10xv6_119", "EditorCanvas-bottomBarPill": "_EditorCanvas-bottomBarPill_10xv6_131", "EditorCanvas-bottomBarDivider": "_EditorCanvas-bottomBarDivider_10xv6_144", "EditorCanvas-zoomLevel": "_EditorCanvas-zoomLevel_10xv6_151" };
7748
+
7749
+ // components/Editor/components/Canvas/index.tsx
7750
+ import { useShallow as useShallow9 } from "zustand/react/shallow";
7751
+
7752
+ // lib/frame-context.tsx
7753
+ init_react_import();
7754
+ import {
7755
+ createContext as createContext7,
7756
+ useContext as useContext14,
7757
+ useRef as useRef14,
7758
+ useMemo as useMemo21
7759
+ } from "react";
7760
+ import { jsx as jsx49 } from "react/jsx-runtime";
7761
+ var FrameContext = createContext7(null);
7762
+ var FrameProvider = ({
7763
+ children
7764
+ }) => {
7765
+ const frameRef = useRef14(null);
7766
+ const value = useMemo21(
7767
+ () => ({
7768
+ frameRef
7769
+ }),
7770
+ []
7771
+ );
7772
+ return /* @__PURE__ */ jsx49(FrameContext.Provider, { value, children });
7773
+ };
7774
+ var useCanvasFrame = () => {
7775
+ const context = useContext14(FrameContext);
7776
+ if (context === null) {
7777
+ throw new Error("useCanvasFrame must be used within a FrameProvider");
7778
+ }
7779
+ return context;
7780
+ };
7781
+
7782
+ // components/Editor/components/Canvas/index.tsx
7783
+ import { Fragment as Fragment13, jsx as jsx50, jsxs as jsxs21 } from "react/jsx-runtime";
7784
+ var getClassName30 = get_class_name_factory_default("EditorCanvas", styles_module_default26);
7785
+ var ZOOM_STEP = 0.15;
7786
+ var MIN_ZOOM = 0.25;
7787
+ var MAX_ZOOM = 3;
7788
+ var TRANSITION_DURATION = 150;
7789
+ var Canvas = ({
7790
+ themeIcon,
7791
+ themeLabel,
7792
+ onToggleTheme
7793
+ } = {}) => {
7794
+ var _a, _b;
7795
+ const { frameRef } = useCanvasFrame();
7796
+ const chrome = useChromeConfig();
7797
+ const {
7798
+ viewports: viewportOptions = defaultViewports,
7799
+ ui: uiProp,
7800
+ disableZoomControls
7801
+ } = usePropsContext();
7802
+ const {
7606
7803
  dispatch,
7607
7804
  overrides,
7608
7805
  setUi,
7806
+ zoomConfig,
7807
+ setZoomConfig,
7609
7808
  status,
7610
7809
  iframe,
7611
7810
  fullScreenCanvas
@@ -7614,6 +7813,8 @@ var Canvas = () => {
7614
7813
  dispatch: s.dispatch,
7615
7814
  overrides: s.overrides,
7616
7815
  setUi: s.setUi,
7816
+ zoomConfig: s.zoomConfig,
7817
+ setZoomConfig: s.setZoomConfig,
7617
7818
  status: s.status,
7618
7819
  iframe: s.iframe,
7619
7820
  fullScreenCanvas: s.fullScreenCanvas
@@ -7622,203 +7823,143 @@ var Canvas = () => {
7622
7823
  const viewports = useAppStore((s) => s.state.ui.viewports);
7623
7824
  const canvasFullScreen = useAppStore(
7624
7825
  (s) => {
7625
- var _a;
7626
- return (_a = s.state.ui.canvasFullScreen) != null ? _a : false;
7826
+ var _a2;
7827
+ return (_a2 = s.state.ui.canvasFullScreen) != null ? _a2 : false;
7627
7828
  }
7628
7829
  );
7629
- const chrome = useChromeConfig();
7630
- const { theme, toggleTheme } = useEditorTheme();
7631
- const toggleFullScreen = useCallback19(
7632
- () => setUi({ canvasFullScreen: !canvasFullScreen }),
7633
- [setUi, canvasFullScreen]
7634
- );
7635
- const activeDevice = useMemo21(() => {
7636
- const w = viewports.current.width;
7637
- if (w === "100%") return "desktop";
7638
- if (typeof w === "number" && w <= 640) return "mobile";
7639
- return "tablet";
7640
- }, [viewports.current.width]);
7641
- const cycleDevice = useCallback19(() => {
7642
- const next = DEVICE_ORDER[(DEVICE_ORDER.indexOf(activeDevice) + 1) % DEVICE_ORDER.length];
7643
- const v = DEVICE_VIEWPORTS[next];
7644
- setUi({
7645
- viewports: __spreadProps(__spreadValues({}, viewports), {
7646
- current: { width: v.width, height: v.height }
7647
- })
7648
- });
7649
- }, [activeDevice, setUi, viewports]);
7650
- const nextDeviceLabel = DEVICE_VIEWPORTS[DEVICE_ORDER[(DEVICE_ORDER.indexOf(activeDevice) + 1) % DEVICE_ORDER.length]].label;
7651
- const transformRef = useRef14(null);
7652
- const defaultRender = useMemo21(() => {
7653
- const EditorDefault = ({ children }) => /* @__PURE__ */ jsx47(Fragment13, { children });
7830
+ const [canvasZoom, setCanvasZoom] = useState21(1);
7831
+ const zoomIn = () => setCanvasZoom((z) => Math.min(z + ZOOM_STEP, MAX_ZOOM));
7832
+ const zoomOut = () => setCanvasZoom((z) => Math.max(z - ZOOM_STEP, MIN_ZOOM));
7833
+ const resetZoom = () => setCanvasZoom(1);
7834
+ const [showTransition, setShowTransition] = useState21(false);
7835
+ const isResizingRef = useRef15(false);
7836
+ const defaultRender = useMemo22(() => {
7837
+ const EditorDefault = ({ children }) => /* @__PURE__ */ jsx50(Fragment13, { children });
7654
7838
  return EditorDefault;
7655
7839
  }, []);
7656
- const CustomPreview = useMemo21(
7840
+ const CustomPreview = useMemo22(
7657
7841
  () => overrides.preview || defaultRender,
7658
7842
  [overrides]
7659
7843
  );
7660
- const [showLoader, setShowLoader] = useState20(false);
7844
+ const getFrameDimensions = useCallback19(() => {
7845
+ if (frameRef.current) {
7846
+ const frame = frameRef.current;
7847
+ const box = getBox(frame);
7848
+ return { width: box.contentBox.width, height: box.contentBox.height };
7849
+ }
7850
+ return { width: 0, height: 0 };
7851
+ }, [frameRef]);
7852
+ useEffect23(() => {
7853
+ const { height: frameHeight } = getFrameDimensions();
7854
+ if (viewports.current.height === "auto") {
7855
+ setZoomConfig(__spreadProps(__spreadValues({}, zoomConfig), { zoom: 1, rootHeight: frameHeight }));
7856
+ }
7857
+ }, [getFrameDimensions, setZoomConfig, viewports.current.height]);
7858
+ const [showLoader, setShowLoader] = useState21(false);
7661
7859
  useEffect23(() => {
7662
7860
  setTimeout(() => {
7663
7861
  setShowLoader(true);
7664
7862
  }, 500);
7665
7863
  }, []);
7666
- const centerFrame = useCallback19(() => {
7667
- let canceled = false;
7668
- requestAnimationFrame(() => {
7669
- if (canceled) return;
7670
- requestAnimationFrame(() => {
7671
- if (canceled) return;
7672
- const ref = transformRef.current;
7673
- const wrapper = ref == null ? void 0 : ref.instance.wrapperComponent;
7674
- if (!ref || !wrapper) return;
7675
- const wrapperW = wrapper.clientWidth;
7676
- const x = Math.max(0, (wrapperW - PREVIEW_MAX_WIDTH) / 2);
7677
- ref.setTransform(x, 16, 1, 0);
7678
- });
7679
- });
7680
- return () => {
7681
- canceled = true;
7682
- };
7683
- }, []);
7684
- useEffect23(() => {
7685
- return centerFrame();
7686
- }, [centerFrame, viewports.current.width]);
7687
- const handleZoomIn = useCallback19(
7688
- () => {
7689
- var _a;
7690
- return (_a = transformRef.current) == null ? void 0 : _a.zoomIn();
7691
- },
7692
- []
7693
- );
7694
- const handleZoomOut = useCallback19(
7695
- () => {
7696
- var _a;
7697
- return (_a = transformRef.current) == null ? void 0 : _a.zoomOut();
7698
- },
7699
- []
7700
- );
7701
- const handleResetZoom = useCallback19(() => {
7702
- centerFrame();
7703
- }, [centerFrame]);
7704
- useEffect23(() => {
7705
- var _a;
7706
- const handler = (e) => {
7707
- var _a2;
7708
- e.preventDefault();
7709
- const ref = transformRef.current;
7710
- if (!ref) return;
7711
- const isPinch = e.ctrlKey || e.metaKey;
7712
- if (isPinch) {
7713
- const wrapper = ref.instance.wrapperComponent;
7714
- if (!wrapper) return;
7715
- const factor = e.deltaY < 0 ? 1.05 : 1 / 1.05;
7716
- const currentScale = ref.state.scale;
7717
- const newScale = Math.max(
7718
- MIN_ZOOM,
7719
- Math.min(MAX_ZOOM, currentScale * factor)
7720
- );
7721
- if (newScale === currentScale) return;
7722
- const wrapperRect = wrapper.getBoundingClientRect();
7723
- const isIframeEvent = ((_a2 = e.target) == null ? void 0 : _a2.ownerDocument) !== document;
7724
- let cursorX;
7725
- let cursorY;
7726
- if (isIframeEvent) {
7727
- const iframeEl = document.getElementById(
7728
- "preview-frame"
7729
- );
7730
- const iframeRect = iframeEl == null ? void 0 : iframeEl.getBoundingClientRect();
7731
- if (!iframeRect) return;
7732
- cursorX = iframeRect.left + e.clientX * currentScale - wrapperRect.left;
7733
- cursorY = iframeRect.top + e.clientY * currentScale - wrapperRect.top;
7734
- } else {
7735
- cursorX = e.clientX - wrapperRect.left;
7736
- cursorY = e.clientY - wrapperRect.top;
7737
- }
7738
- const ratio = newScale / currentScale;
7739
- const newPositionX = cursorX - (cursorX - ref.state.positionX) * ratio;
7740
- const newPositionY = cursorY - (cursorY - ref.state.positionY) * ratio;
7741
- ref.setTransform(newPositionX, newPositionY, newScale, 0);
7742
- return;
7743
- }
7744
- ref.setTransform(
7745
- ref.state.positionX - e.deltaX,
7746
- ref.state.positionY - e.deltaY,
7747
- ref.state.scale,
7748
- 0
7749
- );
7750
- };
7751
- const cleanups = [];
7752
- const onWindowWheel = (e) => {
7753
- if (e.ctrlKey || e.metaKey) e.preventDefault();
7754
- };
7755
- window.addEventListener("wheel", onWindowWheel, { passive: false });
7756
- cleanups.push(
7757
- () => window.removeEventListener("wheel", onWindowWheel)
7864
+ const appStoreApi = useAppStoreApi();
7865
+ const autoSelectingRef = useRef15(true);
7866
+ const pickClosestViewport = useCallback19(() => {
7867
+ var _a2, _b2;
7868
+ if (typeof window === "undefined") return null;
7869
+ const viewportWidth = window.innerWidth;
7870
+ const frameWidth = (_a2 = frameRef.current) == null ? void 0 : _a2.getBoundingClientRect().width;
7871
+ if (!viewportWidth) return null;
7872
+ if (!frameWidth) return null;
7873
+ if (viewportOptions.length === 0) return null;
7874
+ const fullWidthViewport = Object.values(viewportOptions).find(
7875
+ (v) => v.width === "100%"
7758
7876
  );
7759
- const viewportEl = (_a = frameRef.current) == null ? void 0 : _a.firstElementChild;
7760
- if (viewportEl) {
7761
- viewportEl.addEventListener("wheel", handler, { passive: false });
7762
- cleanups.push(
7763
- () => viewportEl.removeEventListener("wheel", handler)
7764
- );
7765
- }
7877
+ const viewportDifferences = Object.entries(viewportOptions).filter(([_, value]) => value.width !== "100%").map(([key, value]) => ({
7878
+ key,
7879
+ diff: Math.abs(
7880
+ viewportWidth - (typeof value.width === "string" ? viewportWidth : value.width)
7881
+ ),
7882
+ value
7883
+ })).sort((a, b) => a.diff > b.diff ? 1 : -1);
7884
+ let closestViewport = (_b2 = viewportDifferences[0]) == null ? void 0 : _b2.value;
7885
+ if (!closestViewport) return null;
7886
+ if (closestViewport.width < frameWidth && fullWidthViewport) {
7887
+ closestViewport = fullWidthViewport;
7888
+ }
7889
+ return closestViewport;
7890
+ }, [viewportOptions, frameRef]);
7891
+ useEffect23(() => {
7892
+ var _a2;
7893
+ if (typeof window === "undefined") return;
7894
+ if ((_a2 = uiProp == null ? void 0 : uiProp.viewports) == null ? void 0 : _a2.current) return;
7895
+ const closestViewport = pickClosestViewport();
7896
+ if (!closestViewport) return;
7766
7897
  if (iframe.enabled) {
7767
- const tryAttach = () => {
7768
- const el = document.getElementById(
7769
- "preview-frame"
7770
- );
7771
- const doc = el == null ? void 0 : el.contentDocument;
7772
- const win = el == null ? void 0 : el.contentWindow;
7773
- if (!doc || !win) return false;
7774
- const opts = { passive: false, capture: true };
7775
- doc.addEventListener("wheel", handler, opts);
7776
- win.addEventListener("wheel", handler, opts);
7777
- cleanups.push(() => {
7778
- doc.removeEventListener("wheel", handler, opts);
7779
- win.removeEventListener("wheel", handler, opts);
7780
- });
7781
- return true;
7898
+ const s = appStoreApi.getState();
7899
+ const appState = {
7900
+ state: __spreadProps(__spreadValues({}, s.state), {
7901
+ ui: __spreadProps(__spreadValues({}, s.state.ui), {
7902
+ viewports: __spreadProps(__spreadValues({}, s.state.ui.viewports), {
7903
+ current: __spreadProps(__spreadValues({}, s.state.ui.viewports.current), {
7904
+ height: (closestViewport == null ? void 0 : closestViewport.height) || "auto",
7905
+ width: closestViewport == null ? void 0 : closestViewport.width
7906
+ })
7907
+ })
7908
+ })
7909
+ })
7782
7910
  };
7783
- if (!tryAttach()) {
7784
- const interval = window.setInterval(() => {
7785
- if (tryAttach()) window.clearInterval(interval);
7786
- }, 100);
7787
- cleanups.push(() => window.clearInterval(interval));
7911
+ let history = s.history;
7912
+ if (s.history.histories.length === 1) {
7913
+ history = __spreadProps(__spreadValues({}, history), { histories: [appState] });
7788
7914
  }
7915
+ appStoreApi.setState(__spreadProps(__spreadValues({}, appState), { history }));
7789
7916
  }
7790
- return () => {
7791
- cleanups.forEach((fn) => fn());
7792
- };
7793
- }, [iframe.enabled, frameRef]);
7794
- const previewWidth = !iframe.enabled ? "100%" : viewports.current.width === "100%" ? PREVIEW_MAX_WIDTH : viewports.current.width;
7795
- const frameContents = /* @__PURE__ */ jsx47(
7796
- "div",
7797
- {
7798
- className: getClassName27("rootColumn"),
7799
- style: { width: PREVIEW_MAX_WIDTH },
7800
- children: /* @__PURE__ */ jsx47(
7801
- "div",
7802
- {
7803
- className: getClassName27("frame"),
7804
- style: { width: previewWidth, margin: "0 auto" },
7805
- children: /* @__PURE__ */ jsx47(
7806
- "div",
7807
- {
7808
- className: getClassName27("root"),
7809
- suppressHydrationWarning: true,
7810
- id: "editor-canvas-root",
7811
- children: /* @__PURE__ */ jsx47(CustomPreview, { children: /* @__PURE__ */ jsx47(Preview2, {}) })
7812
- }
7813
- )
7814
- }
7815
- )
7816
- }
7817
- );
7818
- return /* @__PURE__ */ jsx47(
7917
+ }, [
7918
+ pickClosestViewport,
7919
+ frameRef.current,
7920
+ iframe,
7921
+ appStoreApi,
7922
+ (_a = uiProp == null ? void 0 : uiProp.viewports) == null ? void 0 : _a.current
7923
+ ]);
7924
+ useEffect23(() => {
7925
+ var _a2;
7926
+ if (typeof window === "undefined") return;
7927
+ if (!iframe.enabled) return;
7928
+ if ((_a2 = uiProp == null ? void 0 : uiProp.viewports) == null ? void 0 : _a2.current) return;
7929
+ const target = frameRef.current;
7930
+ if (!target) return;
7931
+ const observer = new ResizeObserver(() => {
7932
+ if (!autoSelectingRef.current) return;
7933
+ const closestViewport = pickClosestViewport();
7934
+ if (!closestViewport) return;
7935
+ const s = appStoreApi.getState();
7936
+ const current = s.state.ui.viewports.current;
7937
+ if (current.width === closestViewport.width && current.height === (closestViewport.height || "auto")) {
7938
+ return;
7939
+ }
7940
+ setUi({
7941
+ viewports: __spreadProps(__spreadValues({}, s.state.ui.viewports), {
7942
+ current: __spreadProps(__spreadValues({}, current), {
7943
+ width: closestViewport.width,
7944
+ height: closestViewport.height || "auto"
7945
+ })
7946
+ })
7947
+ });
7948
+ });
7949
+ observer.observe(target);
7950
+ return () => observer.disconnect();
7951
+ }, [
7952
+ pickClosestViewport,
7953
+ frameRef,
7954
+ iframe.enabled,
7955
+ (_b = uiProp == null ? void 0 : uiProp.viewports) == null ? void 0 : _b.current,
7956
+ appStoreApi,
7957
+ setUi
7958
+ ]);
7959
+ return /* @__PURE__ */ jsx50(
7819
7960
  "div",
7820
7961
  {
7821
- className: getClassName27({
7962
+ className: getClassName30({
7822
7963
  ready: status === "READY" || !iframe.enabled || !iframe.waitForStyles,
7823
7964
  showLoader,
7824
7965
  fullScreen: fullScreenCanvas,
@@ -7834,119 +7975,291 @@ var Canvas = () => {
7834
7975
  });
7835
7976
  }
7836
7977
  },
7837
- children: /* @__PURE__ */ jsxs19("div", { className: getClassName27("inner"), ref: frameRef, children: [
7838
- /* @__PURE__ */ jsx47("div", { className: getClassName27("zoomViewport"), children: disableZoomControls ? frameContents : /* @__PURE__ */ jsxs19(
7839
- TransformWrapper,
7978
+ children: /* @__PURE__ */ jsxs21("div", { className: getClassName30("inner"), ref: frameRef, children: [
7979
+ /* @__PURE__ */ jsx50(
7980
+ "div",
7840
7981
  {
7841
- ref: transformRef,
7842
- minScale: MIN_ZOOM,
7843
- maxScale: MAX_ZOOM,
7844
- initialScale: 1,
7845
- doubleClick: { disabled: true },
7846
- limitToBounds: false,
7847
- wheel: { disabled: true },
7848
- pinch: { step: 5 },
7849
- panning: { velocityDisabled: true },
7850
- trackPadPanning: { velocityDisabled: true },
7851
- alignmentAnimation: { disabled: true },
7852
- autoAlignment: { disabled: true, sizeX: 0, sizeY: 0 },
7853
- children: [
7854
- /* @__PURE__ */ jsx47(ZoomConfigSync, {}),
7855
- /* @__PURE__ */ jsxs19("div", { className: getClassName27("toolbar"), children: [
7856
- chrome.showThemeToggle && /* @__PURE__ */ jsxs19(Fragment13, { children: [
7857
- /* @__PURE__ */ jsx47(
7858
- IconButton,
7859
- {
7860
- type: "button",
7861
- title: theme === "dark" ? "Switch to light mode" : "Switch to dark mode",
7862
- onClick: toggleTheme,
7863
- children: theme === "dark" ? /* @__PURE__ */ jsx47(Sun, { size: 14 }) : /* @__PURE__ */ jsx47(Moon, { size: 14 })
7864
- }
7865
- ),
7866
- (chrome.showDeviceToggle || chrome.showFullScreenToggle) && /* @__PURE__ */ jsx47("div", { className: getClassName27("toolbarDivider") })
7867
- ] }),
7868
- chrome.showDeviceToggle && /* @__PURE__ */ jsx47(
7869
- IconButton,
7870
- {
7871
- type: "button",
7872
- title: `Switch to ${nextDeviceLabel} viewport`,
7873
- onClick: cycleDevice,
7874
- children: DEVICE_ICONS[activeDevice]
7875
- }
7876
- ),
7877
- chrome.showFullScreenToggle && /* @__PURE__ */ jsx47(
7878
- IconButton,
7879
- {
7880
- type: "button",
7881
- title: canvasFullScreen ? "Exit full screen" : "Enter full screen",
7882
- onClick: toggleFullScreen,
7883
- children: canvasFullScreen ? /* @__PURE__ */ jsx47(Minimize, { size: 14 }) : /* @__PURE__ */ jsx47(Maximize, { size: 14 })
7884
- }
7885
- ),
7886
- (chrome.showDeviceToggle || chrome.showFullScreenToggle) && /* @__PURE__ */ jsx47("div", { className: getClassName27("toolbarDivider") }),
7887
- /* @__PURE__ */ jsx47(
7888
- IconButton,
7889
- {
7890
- type: "button",
7891
- title: "Zoom out",
7892
- onClick: handleZoomOut,
7893
- children: /* @__PURE__ */ jsx47(Minus, { size: 14 })
7894
- }
7895
- ),
7896
- /* @__PURE__ */ jsx47(ZoomLevel, { className: getClassName27("zoomLevel") }),
7897
- /* @__PURE__ */ jsx47(
7898
- IconButton,
7899
- {
7900
- type: "button",
7901
- title: "Zoom in",
7902
- onClick: handleZoomIn,
7903
- children: /* @__PURE__ */ jsx47(Plus, { size: 14 })
7904
- }
7905
- ),
7906
- /* @__PURE__ */ jsx47(
7907
- IconButton,
7908
- {
7909
- type: "button",
7910
- title: "Reset zoom",
7911
- onClick: handleResetZoom,
7912
- children: /* @__PURE__ */ jsx47(RotateCcw, { size: 14 })
7913
- }
7914
- )
7915
- ] }),
7916
- /* @__PURE__ */ jsx47(
7917
- TransformComponent,
7918
- {
7919
- infinite: true,
7920
- wrapperStyle: { width: "100%", height: "100%" },
7921
- children: frameContents
7922
- }
7923
- )
7924
- ]
7982
+ className: getClassName30("rootColumn"),
7983
+ style: {
7984
+ width: iframe.enabled ? viewports.current.width : "100%",
7985
+ transform: disableZoomControls ? void 0 : `scale(${canvasZoom})`,
7986
+ transformOrigin: disableZoomControls ? void 0 : "center center",
7987
+ transition: showTransition ? `width ${TRANSITION_DURATION}ms ease-out, transform ${TRANSITION_DURATION}ms ease-out` : disableZoomControls ? void 0 : "transform 150ms ease-out"
7988
+ },
7989
+ children: /* @__PURE__ */ jsx50(
7990
+ "div",
7991
+ {
7992
+ className: getClassName30("root"),
7993
+ suppressHydrationWarning: true,
7994
+ id: "editor-canvas-root",
7995
+ onTransitionEnd: () => {
7996
+ setShowTransition(false);
7997
+ isResizingRef.current = false;
7998
+ },
7999
+ children: /* @__PURE__ */ jsx50(CustomPreview, { children: /* @__PURE__ */ jsx50(Preview2, {}) })
8000
+ }
8001
+ )
7925
8002
  }
7926
- ) }),
7927
- /* @__PURE__ */ jsx47("div", { className: getClassName27("loader"), children: /* @__PURE__ */ jsx47(Loader, { size: 24 }) })
8003
+ ),
8004
+ /* @__PURE__ */ jsx50("div", { className: getClassName30("bottomBar"), children: /* @__PURE__ */ jsxs21("div", { className: getClassName30("bottomBarPill"), children: [
8005
+ chrome.showThemeToggle && onToggleTheme && /* @__PURE__ */ jsx50(
8006
+ IconButton,
8007
+ {
8008
+ type: "button",
8009
+ title: themeLabel != null ? themeLabel : "Toggle theme",
8010
+ onClick: onToggleTheme,
8011
+ children: themeIcon
8012
+ }
8013
+ ),
8014
+ /* @__PURE__ */ jsx50(
8015
+ DeviceToggle,
8016
+ {
8017
+ onViewportChange: (viewport) => {
8018
+ autoSelectingRef.current = false;
8019
+ setShowTransition(true);
8020
+ isResizingRef.current = true;
8021
+ const uiViewport = __spreadProps(__spreadValues({}, viewport), {
8022
+ height: viewport.height || "auto",
8023
+ zoom: 1
8024
+ });
8025
+ setUi({
8026
+ viewports: __spreadProps(__spreadValues({}, viewports), { current: uiViewport })
8027
+ });
8028
+ }
8029
+ }
8030
+ ),
8031
+ /* @__PURE__ */ jsx50(FullScreenToggle, {}),
8032
+ !disableZoomControls && /* @__PURE__ */ jsxs21(Fragment13, { children: [
8033
+ /* @__PURE__ */ jsx50("span", { className: getClassName30("bottomBarDivider") }),
8034
+ /* @__PURE__ */ jsx50(
8035
+ IconButton,
8036
+ {
8037
+ type: "button",
8038
+ title: "Zoom out",
8039
+ onClick: zoomOut,
8040
+ children: /* @__PURE__ */ jsx50(Minus, { size: 14 })
8041
+ }
8042
+ ),
8043
+ /* @__PURE__ */ jsxs21("span", { className: getClassName30("zoomLevel"), children: [
8044
+ Math.round(canvasZoom * 100),
8045
+ "%"
8046
+ ] }),
8047
+ /* @__PURE__ */ jsx50(IconButton, { type: "button", title: "Zoom in", onClick: zoomIn, children: /* @__PURE__ */ jsx50(Plus, { size: 14 }) }),
8048
+ /* @__PURE__ */ jsx50(
8049
+ IconButton,
8050
+ {
8051
+ type: "button",
8052
+ title: "Reset zoom",
8053
+ onClick: resetZoom,
8054
+ children: /* @__PURE__ */ jsx50(RotateCcw, { size: 14 })
8055
+ }
8056
+ )
8057
+ ] })
8058
+ ] }) }),
8059
+ /* @__PURE__ */ jsx50("div", { className: getClassName30("loader"), children: /* @__PURE__ */ jsx50(Loader, { size: 24 }) })
7928
8060
  ] })
7929
8061
  }
7930
8062
  );
7931
8063
  };
7932
8064
 
8065
+ // lib/use-sidebar-resize.ts
8066
+ init_react_import();
8067
+ import { useCallback as useCallback20, useEffect as useEffect24, useRef as useRef16, useState as useState22 } from "react";
8068
+ function useSidebarResize(position, dispatch) {
8069
+ const [width, setWidth] = useState22(null);
8070
+ const sidebarRef = useRef16(null);
8071
+ const storeWidth = useAppStore(
8072
+ (s) => position === "left" ? s.state.ui.leftSideBarWidth : s.state.ui.rightSideBarWidth
8073
+ );
8074
+ useEffect24(() => {
8075
+ if (typeof window !== "undefined" && !storeWidth) {
8076
+ try {
8077
+ const savedWidths = localStorage.getItem("editor-sidebar-widths");
8078
+ if (savedWidths) {
8079
+ const widths = JSON.parse(savedWidths);
8080
+ const savedWidth = widths[position];
8081
+ const key = position === "left" ? "leftSideBarWidth" : "rightSideBarWidth";
8082
+ if (savedWidth) {
8083
+ dispatch({
8084
+ type: "setUi",
8085
+ ui: {
8086
+ [key]: savedWidth
8087
+ }
8088
+ });
8089
+ }
8090
+ }
8091
+ } catch (error) {
8092
+ console.error(
8093
+ `Failed to load ${position} sidebar width from localStorage`,
8094
+ error
8095
+ );
8096
+ }
8097
+ }
8098
+ }, [dispatch, position, storeWidth]);
8099
+ useEffect24(() => {
8100
+ if (storeWidth !== void 0) {
8101
+ setWidth(storeWidth);
8102
+ }
8103
+ }, [storeWidth]);
8104
+ const handleResizeEnd = useCallback20(
8105
+ (width2) => {
8106
+ dispatch({
8107
+ type: "setUi",
8108
+ ui: {
8109
+ [position === "left" ? "leftSideBarWidth" : "rightSideBarWidth"]: width2
8110
+ }
8111
+ });
8112
+ let widths = {};
8113
+ try {
8114
+ const savedWidths = localStorage.getItem("editor-sidebar-widths");
8115
+ widths = savedWidths ? JSON.parse(savedWidths) : {};
8116
+ } catch (error) {
8117
+ console.error(
8118
+ `Failed to save ${position} sidebar width to localStorage`,
8119
+ error
8120
+ );
8121
+ } finally {
8122
+ localStorage.setItem(
8123
+ "editor-sidebar-widths",
8124
+ JSON.stringify(__spreadProps(__spreadValues({}, widths), {
8125
+ [position]: width2
8126
+ }))
8127
+ );
8128
+ }
8129
+ window.dispatchEvent(
8130
+ new CustomEvent("viewportchange", {
8131
+ bubbles: true,
8132
+ cancelable: false
8133
+ })
8134
+ );
8135
+ },
8136
+ [dispatch, position]
8137
+ );
8138
+ return {
8139
+ width,
8140
+ setWidth,
8141
+ sidebarRef,
8142
+ handleResizeEnd
8143
+ };
8144
+ }
8145
+
7933
8146
  // components/Editor/components/Sidebar/index.tsx
7934
8147
  init_react_import();
7935
8148
 
8149
+ // components/Editor/components/ResizeHandle/index.tsx
8150
+ init_react_import();
8151
+ import { useCallback as useCallback21, useRef as useRef17 } from "react";
8152
+
8153
+ // css-module:/Users/rami/Documents/apps/react-editor/packages/core/components/Editor/components/ResizeHandle/styles.module.css#css-module
8154
+ init_react_import();
8155
+ var styles_module_default27 = { "ResizeHandle": "_ResizeHandle_1u3rv_2", "ResizeHandle--left": "_ResizeHandle--left_1u3rv_16", "ResizeHandle--right": "_ResizeHandle--right_1u3rv_20" };
8156
+
8157
+ // components/Editor/components/ResizeHandle/index.tsx
8158
+ import { jsx as jsx51 } from "react/jsx-runtime";
8159
+ var getClassName31 = get_class_name_factory_default("ResizeHandle", styles_module_default27);
8160
+ var ResizeHandle = ({
8161
+ position,
8162
+ sidebarRef,
8163
+ onResize,
8164
+ onResizeEnd
8165
+ }) => {
8166
+ const handleRef = useRef17(null);
8167
+ const isDragging = useRef17(false);
8168
+ const startX = useRef17(0);
8169
+ const startWidth = useRef17(0);
8170
+ const handleMouseMove = useCallback21(
8171
+ (e) => {
8172
+ if (!isDragging.current) return;
8173
+ const delta = e.clientX - startX.current;
8174
+ const newWidth = position === "left" ? startWidth.current + delta : startWidth.current - delta;
8175
+ const width = Math.max(192, newWidth);
8176
+ onResize(width);
8177
+ e.preventDefault();
8178
+ },
8179
+ [onResize, position]
8180
+ );
8181
+ const handleMouseUp = useCallback21(() => {
8182
+ var _a;
8183
+ if (!isDragging.current) return;
8184
+ isDragging.current = false;
8185
+ document.body.style.cursor = "";
8186
+ document.body.style.userSelect = "";
8187
+ const overlay = document.getElementById("resize-overlay");
8188
+ if (overlay) {
8189
+ document.body.removeChild(overlay);
8190
+ }
8191
+ document.removeEventListener("mousemove", handleMouseMove);
8192
+ document.removeEventListener("mouseup", handleMouseUp);
8193
+ const finalWidth = ((_a = sidebarRef.current) == null ? void 0 : _a.getBoundingClientRect().width) || 0;
8194
+ onResizeEnd(finalWidth);
8195
+ }, [onResizeEnd]);
8196
+ const handleMouseDown = useCallback21(
8197
+ (e) => {
8198
+ var _a;
8199
+ isDragging.current = true;
8200
+ startX.current = e.clientX;
8201
+ startWidth.current = ((_a = sidebarRef.current) == null ? void 0 : _a.getBoundingClientRect().width) || 0;
8202
+ document.body.style.cursor = "col-resize";
8203
+ document.body.style.userSelect = "none";
8204
+ const overlay = document.createElement("div");
8205
+ overlay.id = "resize-overlay";
8206
+ overlay.setAttribute("data-resize-overlay", "");
8207
+ document.body.appendChild(overlay);
8208
+ document.addEventListener("mousemove", handleMouseMove);
8209
+ document.addEventListener("mouseup", handleMouseUp);
8210
+ e.preventDefault();
8211
+ },
8212
+ [position, handleMouseMove, handleMouseUp]
8213
+ );
8214
+ return /* @__PURE__ */ jsx51(
8215
+ "div",
8216
+ {
8217
+ ref: handleRef,
8218
+ className: getClassName31({ [position]: true }),
8219
+ onMouseDown: handleMouseDown
8220
+ }
8221
+ );
8222
+ };
8223
+
7936
8224
  // css-module:/Users/rami/Documents/apps/react-editor/packages/core/components/Editor/components/Sidebar/styles.module.css#css-module
7937
8225
  init_react_import();
7938
- var styles_module_default24 = { "Sidebar": "_Sidebar_1ynke_8", "Sidebar--left": "_Sidebar--left_1ynke_20", "Sidebar--right": "_Sidebar--right_1ynke_25", "Sidebar-body": "_Sidebar-body_1ynke_30" };
8226
+ 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" };
7939
8227
 
7940
8228
  // components/Editor/components/Sidebar/index.tsx
7941
- import { jsx as jsx48 } from "react/jsx-runtime";
7942
- var getClassName28 = get_class_name_factory_default("Sidebar", styles_module_default24);
7943
- var Sidebar = ({ position, children }) => {
7944
- return /* @__PURE__ */ jsx48("aside", { className: getClassName28({ [position]: true }), children: /* @__PURE__ */ jsx48("div", { className: getClassName28("body"), children }) });
8229
+ import { Fragment as Fragment14, jsx as jsx52, jsxs as jsxs22 } from "react/jsx-runtime";
8230
+ var getClassName32 = get_class_name_factory_default("Sidebar", styles_module_default28);
8231
+ var Sidebar = ({
8232
+ position,
8233
+ sidebarRef,
8234
+ isVisible,
8235
+ onResize,
8236
+ onResizeEnd,
8237
+ children
8238
+ }) => {
8239
+ return /* @__PURE__ */ jsxs22(Fragment14, { children: [
8240
+ /* @__PURE__ */ jsx52(
8241
+ "div",
8242
+ {
8243
+ ref: sidebarRef,
8244
+ className: getClassName32({ [position]: true, isVisible }),
8245
+ children
8246
+ }
8247
+ ),
8248
+ /* @__PURE__ */ jsx52("div", { className: `${getClassName32("resizeHandle")}`, children: /* @__PURE__ */ jsx52(
8249
+ ResizeHandle,
8250
+ {
8251
+ position,
8252
+ sidebarRef,
8253
+ onResize,
8254
+ onResizeEnd
8255
+ }
8256
+ ) })
8257
+ ] });
7945
8258
  };
7946
8259
 
7947
8260
  // lib/use-delete-hotkeys.ts
7948
8261
  init_react_import();
7949
- import { useCallback as useCallback20 } from "react";
8262
+ import { useCallback as useCallback22 } from "react";
7950
8263
 
7951
8264
  // lib/should-block-editing-hotkey.ts
7952
8265
  init_react_import();
@@ -7986,7 +8299,7 @@ var shouldBlockEditingHotkey = (e) => {
7986
8299
  // lib/use-delete-hotkeys.ts
7987
8300
  var useDeleteHotkeys = () => {
7988
8301
  const appStore = useAppStoreApi();
7989
- const deleteSelectedComponent = useCallback20(
8302
+ const deleteSelectedComponent = useCallback22(
7990
8303
  (e) => {
7991
8304
  var _a;
7992
8305
  if (shouldBlockEditingHotkey(e)) {
@@ -8012,397 +8325,198 @@ var useDeleteHotkeys = () => {
8012
8325
 
8013
8326
  // lib/use-clipboard-hotkeys.ts
8014
8327
  init_react_import();
8015
- import { useCallback as useCallback21 } from "react";
8016
- var CLIPBOARD_MARKER = "reacteditor/component";
8017
- var isComponentData = (value) => {
8018
- var _a;
8019
- if (!value || typeof value !== "object") return false;
8020
- const v = value;
8021
- return typeof v.type === "string" && typeof ((_a = v.props) == null ? void 0 : _a.id) === "string";
8022
- };
8023
- var parsePayload = (text) => {
8024
- try {
8025
- const parsed = JSON.parse(text);
8026
- if (parsed && typeof parsed === "object" && parsed.__reactEditor === CLIPBOARD_MARKER && isComponentData(parsed.data)) {
8027
- return parsed.data;
8028
- }
8029
- } catch (e) {
8030
- }
8031
- return null;
8032
- };
8033
- var useClipboardHotkeys = () => {
8034
- const appStore = useAppStoreApi();
8035
- const writeSelectionToClipboard = useCallback21(() => {
8036
- var _a;
8037
- const { selectedItem } = appStore.getState();
8038
- if (!selectedItem) return false;
8039
- const payload = {
8040
- __reactEditor: CLIPBOARD_MARKER,
8041
- data: selectedItem
8042
- };
8043
- (_a = navigator.clipboard) == null ? void 0 : _a.writeText(JSON.stringify(payload)).catch(() => {
8044
- });
8045
- return true;
8046
- }, [appStore]);
8047
- const copySelectedComponent = useCallback21(
8048
- (e) => {
8049
- if (shouldBlockEditingHotkey(e)) return false;
8050
- return writeSelectionToClipboard();
8051
- },
8052
- [writeSelectionToClipboard]
8053
- );
8054
- const cutSelectedComponent = useCallback21(
8055
- (e) => {
8056
- var _a;
8057
- if (shouldBlockEditingHotkey(e)) return false;
8058
- const { state, dispatch, permissions, selectedItem } = appStore.getState();
8059
- const sel = (_a = state.ui) == null ? void 0 : _a.itemSelector;
8060
- if (!(sel == null ? void 0 : sel.zone) || !selectedItem) return false;
8061
- if (!permissions.getPermissions({ item: selectedItem }).delete)
8062
- return true;
8063
- if (!writeSelectionToClipboard()) return false;
8064
- dispatch({
8065
- type: "remove",
8066
- index: sel.index,
8067
- zone: sel.zone
8068
- });
8069
- return true;
8070
- },
8071
- [appStore, writeSelectionToClipboard]
8072
- );
8073
- const pasteComponent = useCallback21(
8074
- (e) => {
8075
- var _a, _b;
8076
- if (shouldBlockEditingHotkey(e)) return false;
8077
- const { state, dispatch, config } = appStore.getState();
8078
- const sel = (_a = state.ui) == null ? void 0 : _a.itemSelector;
8079
- if (!(sel == null ? void 0 : sel.zone)) return false;
8080
- (_b = navigator.clipboard) == null ? void 0 : _b.readText().then((text) => {
8081
- const data = parsePayload(text);
8082
- if (!data) return;
8083
- if (!config.components[data.type]) return;
8084
- dispatch({
8085
- type: "insert",
8086
- componentType: data.type,
8087
- destinationIndex: sel.index + 1,
8088
- destinationZone: sel.zone,
8089
- data
8090
- });
8091
- }).catch(() => {
8092
- });
8093
- return true;
8094
- },
8095
- [appStore]
8096
- );
8097
- useHotkey({ meta: true, c: true }, copySelectedComponent);
8098
- useHotkey({ ctrl: true, c: true }, copySelectedComponent);
8099
- useHotkey({ meta: true, v: true }, pasteComponent);
8100
- useHotkey({ ctrl: true, v: true }, pasteComponent);
8101
- useHotkey({ meta: true, x: true }, cutSelectedComponent);
8102
- useHotkey({ ctrl: true, x: true }, cutSelectedComponent);
8103
- };
8104
-
8105
- // components/Editor/components/Nav/index.tsx
8106
- init_react_import();
8107
-
8108
- // css-module:/Users/rami/Documents/apps/react-editor/packages/core/components/Editor/components/Nav/styles.module.css#css-module
8109
- init_react_import();
8110
- var styles_module_default25 = { "Nav": "_Nav_1ft0o_1", "Nav--horizontal": "_Nav--horizontal_1ft0o_20", "Nav-list": "_Nav-list_1ft0o_36", "Nav-footer": "_Nav-footer_1ft0o_83", "NavItem-link": "_NavItem-link_1ft0o_96", "NavItem-linkLabel": "_NavItem-linkLabel_1ft0o_124", "NavItem": "_NavItem_1ft0o_96", "NavItem-linkIcon": "_NavItem-linkIcon_1ft0o_149", "NavItem--active": "_NavItem--active_1ft0o_162", "NavItem--mobileOnly": "_NavItem--mobileOnly_1ft0o_173", "NavItem--desktopOnly": "_NavItem--desktopOnly_1ft0o_178" };
8111
-
8112
- // components/Editor/components/Nav/index.tsx
8113
- import { jsx as jsx49, jsxs as jsxs20 } from "react/jsx-runtime";
8114
- var getClassName29 = get_class_name_factory_default("Nav", styles_module_default25);
8115
- var getClassNameItem3 = get_class_name_factory_default("NavItem", styles_module_default25);
8116
- var MenuItem = ({
8117
- label,
8118
- icon,
8119
- onClick,
8120
- isActive,
8121
- mobileOnly,
8122
- desktopOnly
8123
- }) => {
8124
- return /* @__PURE__ */ jsx49(
8125
- "li",
8126
- {
8127
- className: getClassNameItem3({
8128
- active: isActive,
8129
- mobileOnly,
8130
- desktopOnly
8131
- }),
8132
- children: onClick && /* @__PURE__ */ jsxs20("div", { className: getClassNameItem3("link"), onClick, children: [
8133
- icon && /* @__PURE__ */ jsx49("span", { className: getClassNameItem3("linkIcon"), children: icon }),
8134
- /* @__PURE__ */ jsx49("span", { className: getClassNameItem3("linkLabel"), children: label })
8135
- ] })
8136
- }
8137
- );
8138
- };
8139
- var Nav = ({
8140
- items,
8141
- footer,
8142
- orientation = "vertical"
8143
- }) => {
8144
- return /* @__PURE__ */ jsxs20("nav", { className: getClassName29({ horizontal: orientation === "horizontal" }), children: [
8145
- /* @__PURE__ */ jsx49("ul", { className: getClassName29("list"), children: Object.entries(items).map(([key, item]) => /* @__PURE__ */ jsx49(MenuItem, __spreadValues({}, item), key)) }),
8146
- footer && /* @__PURE__ */ jsx49("div", { className: getClassName29("footer"), children: footer })
8147
- ] });
8148
- };
8149
-
8150
- // components/BrowserBar/index.tsx
8151
- init_react_import();
8152
- import { useRef as useRef15, useState as useState21 } from "react";
8153
-
8154
- // components/ui/Combobox/index.tsx
8155
- init_react_import();
8156
- import { Combobox as ComboboxPrimitive } from "@base-ui/react";
8157
-
8158
- // css-module:/Users/rami/Documents/apps/react-editor/packages/core/components/ui/Combobox/styles.module.css#css-module
8159
- init_react_import();
8160
- var styles_module_default26 = { "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" };
8161
-
8162
- // components/ui/Combobox/index.tsx
8163
- import { jsx as jsx50, jsxs as jsxs21 } from "react/jsx-runtime";
8164
- var getClassName30 = get_class_name_factory_default("EditorCombobox", styles_module_default26);
8165
- var join = (...values) => values.filter(Boolean).join(" ");
8166
- var mergeClassName = (base, override) => {
8167
- if (!override) return base;
8168
- if (typeof override === "function") {
8169
- return (state) => join(base, override(state));
8170
- }
8171
- return join(base, override);
8172
- };
8173
- var Combobox = ComboboxPrimitive.Root;
8174
- function ComboboxInput(_a) {
8175
- var _b = _a, {
8176
- className
8177
- } = _b, props = __objRest(_b, [
8178
- "className"
8179
- ]);
8180
- return /* @__PURE__ */ jsx50(
8181
- ComboboxPrimitive.Input,
8182
- __spreadValues({
8183
- "data-slot": "combobox-input",
8184
- className: mergeClassName(getClassName30("input"), className)
8185
- }, props)
8186
- );
8187
- }
8188
- function ComboboxContent(_a) {
8189
- var _b = _a, {
8190
- className,
8191
- side = "bottom",
8192
- sideOffset = 4,
8193
- align = "start",
8194
- alignOffset = 0,
8195
- children
8196
- } = _b, props = __objRest(_b, [
8197
- "className",
8198
- "side",
8199
- "sideOffset",
8200
- "align",
8201
- "alignOffset",
8202
- "children"
8203
- ]);
8204
- return /* @__PURE__ */ jsx50(ComboboxPrimitive.Portal, { children: /* @__PURE__ */ jsx50(
8205
- ComboboxPrimitive.Positioner,
8206
- {
8207
- side,
8208
- sideOffset,
8209
- align,
8210
- alignOffset,
8211
- className: getClassName30("positioner"),
8212
- children: /* @__PURE__ */ jsx50(
8213
- ComboboxPrimitive.Popup,
8214
- __spreadProps(__spreadValues({
8215
- "data-slot": "combobox-content",
8216
- className: mergeClassName(getClassName30("content"), className)
8217
- }, props), {
8218
- children
8219
- })
8220
- )
8221
- }
8222
- ) });
8223
- }
8224
- function ComboboxList(_a) {
8225
- var _b = _a, {
8226
- className
8227
- } = _b, props = __objRest(_b, [
8228
- "className"
8229
- ]);
8230
- return /* @__PURE__ */ jsx50(
8231
- ComboboxPrimitive.List,
8232
- __spreadValues({
8233
- "data-slot": "combobox-list",
8234
- className: mergeClassName(getClassName30("list"), className)
8235
- }, props)
8236
- );
8237
- }
8238
- function ComboboxItem(_a) {
8239
- var _b = _a, {
8240
- className,
8241
- children
8242
- } = _b, props = __objRest(_b, [
8243
- "className",
8244
- "children"
8245
- ]);
8246
- return /* @__PURE__ */ jsxs21(
8247
- ComboboxPrimitive.Item,
8248
- __spreadProps(__spreadValues({
8249
- "data-slot": "combobox-item",
8250
- className: mergeClassName(getClassName30("item"), className)
8251
- }, props), {
8252
- children: [
8253
- /* @__PURE__ */ jsx50("span", { className: getClassName30("itemIndicator"), children: /* @__PURE__ */ jsx50(ComboboxPrimitive.ItemIndicator, { children: /* @__PURE__ */ jsx50(Check, { size: 14 }) }) }),
8254
- children
8255
- ]
8256
- })
8257
- );
8258
- }
8259
- function ComboboxEmpty(_a) {
8260
- var _b = _a, {
8261
- className
8262
- } = _b, props = __objRest(_b, [
8263
- "className"
8264
- ]);
8265
- return /* @__PURE__ */ jsx50(
8266
- ComboboxPrimitive.Empty,
8267
- __spreadValues({
8268
- "data-slot": "combobox-empty",
8269
- className: mergeClassName(getClassName30("empty"), className)
8270
- }, props)
8271
- );
8272
- }
8273
-
8274
- // css-module:/Users/rami/Documents/apps/react-editor/packages/core/components/BrowserBar/styles.module.css#css-module
8275
- init_react_import();
8276
- var styles_module_default27 = { "BrowserBar": "_BrowserBar_ey7dt_3", "BrowserBar-urlTrigger": "_BrowserBar-urlTrigger_ey7dt_13", "BrowserBar-urlIcon": "_BrowserBar-urlIcon_ey7dt_43", "BrowserBar-urlText": "_BrowserBar-urlText_ey7dt_48", "BrowserBar-urlInput": "_BrowserBar-urlInput_ey7dt_60", "BrowserBar-itemPath": "_BrowserBar-itemPath_ey7dt_66", "BrowserBar-itemTitle": "_BrowserBar-itemTitle_ey7dt_71" };
8277
-
8278
- // components/BrowserBar/index.tsx
8279
- import { jsx as jsx51, jsxs as jsxs22 } from "react/jsx-runtime";
8280
- var normalizeRoute = (raw) => {
8281
- const trimmed = raw.trim();
8282
- if (!trimmed) return trimmed;
8283
- return trimmed.startsWith("/") ? trimmed : `/${trimmed}`;
8328
+ import { useCallback as useCallback23 } from "react";
8329
+ var CLIPBOARD_MARKER = "reacteditor/component";
8330
+ var isComponentData = (value) => {
8331
+ var _a;
8332
+ if (!value || typeof value !== "object") return false;
8333
+ const v = value;
8334
+ return typeof v.type === "string" && typeof ((_a = v.props) == null ? void 0 : _a.id) === "string";
8284
8335
  };
8285
- var getClassName31 = get_class_name_factory_default("BrowserBar", styles_module_default27);
8286
- var BrowserBar = ({}) => {
8287
- const { routes, currentRoute, onRouteChange } = usePropsContext();
8288
- const chrome = useChromeConfig();
8289
- const showRoutePicker = !!routes && currentRoute !== void 0 && !!onRouteChange;
8290
- const [inputValue, setInputValue] = useState21(currentRoute != null ? currentRoute : "");
8291
- const lastSyncedPath = useRef15(currentRoute);
8292
- if (lastSyncedPath.current !== currentRoute) {
8293
- lastSyncedPath.current = currentRoute;
8294
- setInputValue(currentRoute != null ? currentRoute : "");
8295
- }
8296
- const submit = (raw) => {
8297
- const next = normalizeRoute(raw);
8298
- if (!next || next === currentRoute) return;
8299
- void (onRouteChange == null ? void 0 : onRouteChange(next));
8300
- };
8301
- if (!chrome.showUrlBar) return null;
8302
- return /* @__PURE__ */ jsx51("div", { className: getClassName31(), children: showRoutePicker ? /* @__PURE__ */ jsxs22(
8303
- Combobox,
8304
- {
8305
- items: routes,
8306
- value: currentRoute,
8307
- onValueChange: (next) => {
8308
- if (typeof next === "string") submit(next);
8309
- },
8310
- inputValue,
8311
- onInputValueChange: (next) => setInputValue(next),
8312
- autoHighlight: false,
8313
- children: [
8314
- /* @__PURE__ */ jsxs22(
8315
- "form",
8316
- {
8317
- className: getClassName31("urlTrigger"),
8318
- onSubmit: (event) => {
8319
- event.preventDefault();
8320
- submit(inputValue);
8321
- },
8322
- children: [
8323
- /* @__PURE__ */ jsx51(Globe, { className: getClassName31("urlIcon"), size: 14 }),
8324
- /* @__PURE__ */ jsx51(
8325
- ComboboxInput,
8326
- {
8327
- className: getClassName31("urlInput"),
8328
- placeholder: "/",
8329
- spellCheck: false,
8330
- autoCorrect: "off",
8331
- autoCapitalize: "off"
8332
- }
8333
- )
8334
- ]
8335
- }
8336
- ),
8337
- /* @__PURE__ */ jsxs22(ComboboxContent, { children: [
8338
- /* @__PURE__ */ jsx51(ComboboxEmpty, { children: "Press Enter to go to this path" }),
8339
- /* @__PURE__ */ jsx51(ComboboxList, { children: (path) => /* @__PURE__ */ jsx51(ComboboxItem, { value: path, children: /* @__PURE__ */ jsx51("span", { className: getClassName31("itemPath"), children: path }) }, path) })
8340
- ] })
8341
- ]
8336
+ var parsePayload = (text) => {
8337
+ try {
8338
+ const parsed = JSON.parse(text);
8339
+ if (parsed && typeof parsed === "object" && parsed.__reactEditor === CLIPBOARD_MARKER && isComponentData(parsed.data)) {
8340
+ return parsed.data;
8342
8341
  }
8343
- ) : /* @__PURE__ */ jsxs22("div", { className: getClassName31("urlTrigger"), children: [
8344
- /* @__PURE__ */ jsx51(Globe, { className: getClassName31("urlIcon"), size: 14 }),
8345
- /* @__PURE__ */ jsx51("span", { className: getClassName31("urlText"), children: "/" })
8346
- ] }) });
8342
+ } catch (e) {
8343
+ }
8344
+ return null;
8345
+ };
8346
+ var useClipboardHotkeys = () => {
8347
+ const appStore = useAppStoreApi();
8348
+ const writeSelectionToClipboard = useCallback23(() => {
8349
+ var _a;
8350
+ const { selectedItem } = appStore.getState();
8351
+ if (!selectedItem) return false;
8352
+ const payload = {
8353
+ __reactEditor: CLIPBOARD_MARKER,
8354
+ data: selectedItem
8355
+ };
8356
+ (_a = navigator.clipboard) == null ? void 0 : _a.writeText(JSON.stringify(payload)).catch(() => {
8357
+ });
8358
+ return true;
8359
+ }, [appStore]);
8360
+ const copySelectedComponent = useCallback23(
8361
+ (e) => {
8362
+ if (shouldBlockEditingHotkey(e)) return false;
8363
+ return writeSelectionToClipboard();
8364
+ },
8365
+ [writeSelectionToClipboard]
8366
+ );
8367
+ const cutSelectedComponent = useCallback23(
8368
+ (e) => {
8369
+ var _a;
8370
+ if (shouldBlockEditingHotkey(e)) return false;
8371
+ const { state, dispatch, permissions, selectedItem } = appStore.getState();
8372
+ const sel = (_a = state.ui) == null ? void 0 : _a.itemSelector;
8373
+ if (!(sel == null ? void 0 : sel.zone) || !selectedItem) return false;
8374
+ if (!permissions.getPermissions({ item: selectedItem }).delete)
8375
+ return true;
8376
+ if (!writeSelectionToClipboard()) return false;
8377
+ dispatch({
8378
+ type: "remove",
8379
+ index: sel.index,
8380
+ zone: sel.zone
8381
+ });
8382
+ return true;
8383
+ },
8384
+ [appStore, writeSelectionToClipboard]
8385
+ );
8386
+ const pasteComponent = useCallback23(
8387
+ (e) => {
8388
+ var _a, _b;
8389
+ if (shouldBlockEditingHotkey(e)) return false;
8390
+ const { state, dispatch, config } = appStore.getState();
8391
+ const sel = (_a = state.ui) == null ? void 0 : _a.itemSelector;
8392
+ if (!(sel == null ? void 0 : sel.zone)) return false;
8393
+ (_b = navigator.clipboard) == null ? void 0 : _b.readText().then((text) => {
8394
+ const data = parsePayload(text);
8395
+ if (!data) return;
8396
+ if (!config.components[data.type]) return;
8397
+ dispatch({
8398
+ type: "insert",
8399
+ componentType: data.type,
8400
+ destinationIndex: sel.index + 1,
8401
+ destinationZone: sel.zone,
8402
+ data
8403
+ });
8404
+ }).catch(() => {
8405
+ });
8406
+ return true;
8407
+ },
8408
+ [appStore]
8409
+ );
8410
+ useHotkey({ meta: true, c: true }, copySelectedComponent);
8411
+ useHotkey({ ctrl: true, c: true }, copySelectedComponent);
8412
+ useHotkey({ meta: true, v: true }, pasteComponent);
8413
+ useHotkey({ ctrl: true, v: true }, pasteComponent);
8414
+ useHotkey({ meta: true, x: true }, cutSelectedComponent);
8415
+ useHotkey({ ctrl: true, x: true }, cutSelectedComponent);
8347
8416
  };
8348
8417
 
8349
8418
  // components/Editor/components/Layout/index.tsx
8350
- import { jsx as jsx52, jsxs as jsxs23 } from "react/jsx-runtime";
8351
- var getClassName32 = get_class_name_factory_default("Editor", styles_module_default21);
8352
- var getLayoutClassName = get_class_name_factory_default("EditorLayout", styles_module_default21);
8353
- var getPluginTabClassName = get_class_name_factory_default("EditorPluginTab", styles_module_default21);
8354
- var FieldSideBarBody = () => /* @__PURE__ */ jsx52(SidebarSection, { noBorderTop: true, title: null, children: /* @__PURE__ */ jsx52(Fields, {}) });
8355
- var HeaderPublish = () => {
8419
+ import { jsx as jsx53, jsxs as jsxs23 } from "react/jsx-runtime";
8420
+ var getClassName33 = get_class_name_factory_default("Editor", styles_module_default22);
8421
+ var getLayoutClassName = get_class_name_factory_default("EditorLayout", styles_module_default22);
8422
+ var getPluginTabClassName = get_class_name_factory_default("EditorPluginTab", styles_module_default22);
8423
+ var getHeaderClassName = get_class_name_factory_default("EditorHeader", styles_module_default22);
8424
+ var TopHeader = ({
8425
+ pluginItems
8426
+ }) => {
8356
8427
  const appStore = useAppStoreApi();
8357
8428
  const { onPublish, currentRoute } = usePropsContext();
8358
- const CustomHeaderActions = useAppStore(
8359
- (s) => s.overrides.headerActions || DefaultOverride
8360
- );
8361
- return /* @__PURE__ */ jsx52(CustomHeaderActions, { children: /* @__PURE__ */ jsx52(
8362
- Button,
8363
- {
8364
- onClick: () => {
8365
- const data = appStore.getState().state.data;
8366
- onPublish && onPublish(data, currentRoute);
8367
- },
8368
- children: "Publish"
8369
- }
8370
- ) });
8371
- };
8372
- var HeaderHistory = () => {
8429
+ const chrome = useChromeConfig();
8373
8430
  const back = useAppStore((s) => s.history.back);
8374
8431
  const forward = useAppStore((s) => s.history.forward);
8375
8432
  const hasFuture = useAppStore((s) => s.history.hasFuture());
8376
8433
  const hasPast = useAppStore((s) => s.history.hasPast());
8377
- return /* @__PURE__ */ jsxs23("div", { className: getLayoutClassName("headerHistory"), children: [
8378
- /* @__PURE__ */ jsx52(IconButton, { type: "button", title: "Undo", disabled: !hasPast, onClick: back, children: /* @__PURE__ */ jsx52(Undo2, { size: 16 }) }),
8379
- /* @__PURE__ */ jsx52(
8380
- IconButton,
8434
+ const CustomHeaderActions = useAppStore(
8435
+ (s) => s.overrides.headerActions || DefaultOverride
8436
+ );
8437
+ return /* @__PURE__ */ jsxs23("header", { className: getHeaderClassName(), children: [
8438
+ /* @__PURE__ */ jsx53("div", { className: getHeaderClassName("plugins"), children: Object.entries(pluginItems).map(([key, item]) => /* @__PURE__ */ jsx53(
8439
+ "span",
8381
8440
  {
8382
- type: "button",
8383
- title: "Redo",
8384
- disabled: !hasFuture,
8385
- onClick: forward,
8386
- children: /* @__PURE__ */ jsx52(Redo2, { size: 16 })
8387
- }
8388
- )
8441
+ className: getHeaderClassName("pluginItem", {
8442
+ mobileOnly: item.mobileOnly,
8443
+ desktopOnly: item.desktopOnly
8444
+ }),
8445
+ children: /* @__PURE__ */ jsx53(
8446
+ IconButton,
8447
+ {
8448
+ type: "button",
8449
+ title: item.label,
8450
+ onClick: item.onClick,
8451
+ active: item.isActive,
8452
+ children: item.icon
8453
+ }
8454
+ )
8455
+ },
8456
+ key
8457
+ )) }),
8458
+ /* @__PURE__ */ jsx53("div", { className: getHeaderClassName("urlBarSlot"), children: /* @__PURE__ */ jsx53(UrlBar, {}) }),
8459
+ /* @__PURE__ */ jsxs23("div", { className: getHeaderClassName("actions"), children: [
8460
+ chrome.showHistoryControls && /* @__PURE__ */ jsxs23("div", { className: getHeaderClassName("history"), children: [
8461
+ /* @__PURE__ */ jsx53(
8462
+ IconButton,
8463
+ {
8464
+ type: "button",
8465
+ title: "undo",
8466
+ disabled: !hasPast,
8467
+ onClick: back,
8468
+ children: /* @__PURE__ */ jsx53(Undo2, { size: 18 })
8469
+ }
8470
+ ),
8471
+ /* @__PURE__ */ jsx53(
8472
+ IconButton,
8473
+ {
8474
+ type: "button",
8475
+ title: "redo",
8476
+ disabled: !hasFuture,
8477
+ onClick: forward,
8478
+ children: /* @__PURE__ */ jsx53(Redo2, { size: 18 })
8479
+ }
8480
+ )
8481
+ ] }),
8482
+ /* @__PURE__ */ jsx53(CustomHeaderActions, { children: /* @__PURE__ */ jsx53(
8483
+ Button,
8484
+ {
8485
+ onClick: () => {
8486
+ const data = appStore.getState().state.data;
8487
+ onPublish && onPublish(data, currentRoute);
8488
+ },
8489
+ children: "Publish"
8490
+ }
8491
+ ) })
8492
+ ] })
8389
8493
  ] });
8390
8494
  };
8495
+ var FieldSideBar = () => {
8496
+ const title = useAppStore(
8497
+ (s) => {
8498
+ var _a, _b, _c;
8499
+ return s.selectedItem ? (_b = (_a = s.config.components[s.selectedItem.type]) == null ? void 0 : _a["label"]) != null ? _b : s.selectedItem.type.toString() : ((_c = s.config.root) == null ? void 0 : _c.label) || "Page";
8500
+ }
8501
+ );
8502
+ return /* @__PURE__ */ jsx53(SidebarSection, { noBorderTop: true, showBreadcrumbs: true, title, children: /* @__PURE__ */ jsx53(Fields, {}) });
8503
+ };
8391
8504
  var PluginTab = ({
8392
8505
  children,
8393
8506
  visible,
8394
8507
  mobileOnly
8395
8508
  }) => {
8396
- return /* @__PURE__ */ jsx52("div", { className: getPluginTabClassName({ visible, mobileOnly }), children: /* @__PURE__ */ jsx52("div", { className: getPluginTabClassName("body"), children }) });
8509
+ return /* @__PURE__ */ jsx53("div", { className: getPluginTabClassName({ visible, mobileOnly }), children: /* @__PURE__ */ jsx53("div", { className: getPluginTabClassName("body"), children }) });
8397
8510
  };
8398
8511
  var Layout = ({ children }) => {
8399
8512
  const {
8400
8513
  iframe: _iframe,
8401
8514
  dnd,
8515
+ initialHistory: _initialHistory,
8402
8516
  plugins,
8403
8517
  height
8404
8518
  } = usePropsContext();
8405
- const iframe = useMemo22(
8519
+ const iframe = useMemo23(
8406
8520
  () => __spreadValues({
8407
8521
  enabled: true,
8408
8522
  waitForStyles: true
@@ -8410,7 +8524,7 @@ var Layout = ({ children }) => {
8410
8524
  [_iframe]
8411
8525
  );
8412
8526
  useInjectGlobalCss(iframe.enabled);
8413
- const setUi = useAppStore((s) => s.setUi);
8527
+ const dispatch = useAppStore((s) => s.dispatch);
8414
8528
  const leftSideBarVisible = useAppStore((s) => s.state.ui.leftSideBarVisible);
8415
8529
  const rightSideBarVisible = useAppStore(
8416
8530
  (s) => s.state.ui.rightSideBarVisible
@@ -8418,14 +8532,53 @@ var Layout = ({ children }) => {
8418
8532
  const chrome = useChromeConfig();
8419
8533
  const navBarVisible = chrome.showNavBar;
8420
8534
  const instanceId = useAppStore((s) => s.instanceId);
8535
+ const {
8536
+ width: leftWidth,
8537
+ setWidth: setLeftWidth,
8538
+ sidebarRef: leftSidebarRef,
8539
+ handleResizeEnd: handleLeftSidebarResizeEnd
8540
+ } = useSidebarResize("left", dispatch);
8541
+ const {
8542
+ width: rightWidth,
8543
+ setWidth: setRightWidth,
8544
+ sidebarRef: rightSidebarRef,
8545
+ handleResizeEnd: handleRightSidebarResizeEnd
8546
+ } = useSidebarResize("right", dispatch);
8547
+ useEffect25(() => {
8548
+ if (!window.matchMedia("(min-width: 638px)").matches) {
8549
+ dispatch({
8550
+ type: "setUi",
8551
+ ui: {
8552
+ leftSideBarVisible: false,
8553
+ rightSideBarVisible: false
8554
+ }
8555
+ });
8556
+ }
8557
+ const handleResize = () => {
8558
+ if (!window.matchMedia("(min-width: 638px)").matches) {
8559
+ dispatch({
8560
+ type: "setUi",
8561
+ ui: (ui) => __spreadValues(__spreadValues({}, ui), ui.rightSideBarVisible ? { leftSideBarVisible: false } : {})
8562
+ });
8563
+ }
8564
+ };
8565
+ window.addEventListener("resize", handleResize);
8566
+ return () => {
8567
+ window.removeEventListener("resize", handleResize);
8568
+ };
8569
+ }, []);
8421
8570
  const overrides = useAppStore((s) => s.overrides);
8422
- const CustomEditor = useMemo22(
8571
+ const CustomEditor = useMemo23(
8423
8572
  () => overrides.editor || DefaultOverride,
8424
8573
  [overrides]
8425
8574
  );
8575
+ const [mounted, setMounted] = useState23(false);
8576
+ useEffect25(() => {
8577
+ setMounted(true);
8578
+ }, []);
8426
8579
  const ready = useAppStore((s) => s.status === "READY");
8427
8580
  useMonitorHotkeys();
8428
- useEffect24(() => {
8581
+ useEffect25(() => {
8429
8582
  if (ready && iframe.enabled) {
8430
8583
  const frameDoc = getFrame();
8431
8584
  if (frameDoc) {
@@ -8436,36 +8589,106 @@ var Layout = ({ children }) => {
8436
8589
  usePreviewModeHotkeys();
8437
8590
  useDeleteHotkeys();
8438
8591
  useClipboardHotkeys();
8592
+ const layoutOptions = {};
8593
+ if (leftWidth) {
8594
+ layoutOptions["--editor-user-left-side-bar-width"] = `${leftWidth}px`;
8595
+ }
8596
+ if (rightWidth) {
8597
+ layoutOptions["--editor-user-right-side-bar-width"] = `${rightWidth}px`;
8598
+ }
8599
+ const setUi = useAppStore((s) => s.setUi);
8439
8600
  const currentPlugin = useAppStore((s) => {
8440
8601
  var _a;
8441
8602
  return (_a = s.state.ui.plugin) == null ? void 0 : _a.current;
8442
8603
  });
8443
8604
  const appStoreApi = useAppStoreApi();
8444
- const [theme, setTheme] = useState22(() => {
8605
+ const [mobilePanelHeightMode, setMobilePanelHeightMode] = useState23("toggle");
8606
+ const [mobilePanelHeight, setMobilePanelHeight] = useState23(
8607
+ null
8608
+ );
8609
+ const mobilePanelRef = useRef18(null);
8610
+ const isDraggingMobile = useRef18(false);
8611
+ const dragStartY = useRef18(0);
8612
+ const dragStartHeight = useRef18(0);
8613
+ const handleMobileDragStart = useCallback24(
8614
+ (clientY) => {
8615
+ isDraggingMobile.current = true;
8616
+ dragStartY.current = clientY;
8617
+ const panel = mobilePanelRef.current;
8618
+ dragStartHeight.current = panel ? panel.getBoundingClientRect().height : 0;
8619
+ document.body.style.userSelect = "none";
8620
+ document.body.style.touchAction = "none";
8621
+ },
8622
+ []
8623
+ );
8624
+ const handleMobileDragMove = useCallback24((clientY) => {
8625
+ if (!isDraggingMobile.current) return;
8626
+ const delta = dragStartY.current - clientY;
8627
+ const viewportHeight = window.innerHeight;
8628
+ const minH = viewportHeight * 0.15;
8629
+ const maxH = viewportHeight * 0.75;
8630
+ const newH = Math.min(maxH, Math.max(minH, dragStartHeight.current + delta));
8631
+ setMobilePanelHeight(newH);
8632
+ }, []);
8633
+ const handleMobileDragEnd = useCallback24(() => {
8634
+ if (!isDraggingMobile.current) return;
8635
+ isDraggingMobile.current = false;
8636
+ document.body.style.userSelect = "";
8637
+ document.body.style.touchAction = "";
8638
+ }, []);
8639
+ useEffect25(() => {
8640
+ const onTouchMove = (e) => {
8641
+ if (isDraggingMobile.current) {
8642
+ e.preventDefault();
8643
+ handleMobileDragMove(e.touches[0].clientY);
8644
+ }
8645
+ };
8646
+ const onTouchEnd = () => handleMobileDragEnd();
8647
+ const onMouseMove = (e) => {
8648
+ if (isDraggingMobile.current) {
8649
+ e.preventDefault();
8650
+ handleMobileDragMove(e.clientY);
8651
+ }
8652
+ };
8653
+ const onMouseUp = () => handleMobileDragEnd();
8654
+ document.addEventListener("touchmove", onTouchMove, { passive: false });
8655
+ document.addEventListener("touchend", onTouchEnd);
8656
+ document.addEventListener("mousemove", onMouseMove);
8657
+ document.addEventListener("mouseup", onMouseUp);
8658
+ return () => {
8659
+ document.removeEventListener("touchmove", onTouchMove);
8660
+ document.removeEventListener("touchend", onTouchEnd);
8661
+ document.removeEventListener("mousemove", onMouseMove);
8662
+ document.removeEventListener("mouseup", onMouseUp);
8663
+ };
8664
+ }, [handleMobileDragMove, handleMobileDragEnd]);
8665
+ const [theme, setTheme] = useState23(() => {
8445
8666
  if (typeof window === "undefined") return "light";
8446
8667
  const stored = window.localStorage.getItem("editor-theme");
8447
8668
  if (stored === "light" || stored === "dark") return stored;
8448
8669
  return window.matchMedia("(prefers-color-scheme: dark)").matches ? "dark" : "light";
8449
8670
  });
8450
- useEffect24(() => {
8671
+ useEffect25(() => {
8451
8672
  if (typeof window === "undefined") return;
8452
8673
  window.localStorage.setItem("editor-theme", theme);
8453
8674
  }, [theme]);
8454
8675
  const toggleTheme = () => {
8455
8676
  setTheme((t) => t === "dark" ? "light" : "dark");
8456
8677
  };
8457
- const themeIcon = theme === "dark" ? /* @__PURE__ */ jsx52(Sun, { size: 18 }) : /* @__PURE__ */ jsx52(Moon, { size: 18 });
8678
+ const themeIcon = theme === "dark" ? /* @__PURE__ */ jsx53(Sun, { size: 14 }) : /* @__PURE__ */ jsx53(Moon, { size: 14 });
8458
8679
  const themeLabel = theme === "dark" ? "Switch to light mode" : "Switch to dark mode";
8459
- const hasLegacySideBarPlugin = useMemo22(
8680
+ const hasLegacySideBarPlugin = useMemo23(
8460
8681
  () => !!(plugins == null ? void 0 : plugins.find((p) => p.name === "legacy-side-bar")),
8461
8682
  [plugins]
8462
8683
  );
8463
- const pluginItems = useMemo22(() => {
8684
+ const pluginItems = useMemo23(() => {
8464
8685
  const details = {};
8686
+ const defaultPlugins = [blocksPlugin()];
8465
8687
  const isLegacy = (plugin) => plugin.name === "legacy-side-bar" ? -1 : 0;
8466
- const combinedPlugins = [...plugins != null ? plugins : []].sort(
8467
- (a, b) => isLegacy(a) - isLegacy(b)
8468
- );
8688
+ const combinedPlugins = [
8689
+ ...defaultPlugins,
8690
+ ...plugins != null ? plugins : []
8691
+ ].sort((a, b) => isLegacy(a) - isLegacy(b));
8469
8692
  if (!(plugins == null ? void 0 : plugins.some((p) => p.name === "fields"))) {
8470
8693
  combinedPlugins.push(fieldsPlugin());
8471
8694
  }
@@ -8477,15 +8700,23 @@ var Layout = ({ children }) => {
8477
8700
  }
8478
8701
  details[plugin.name] = {
8479
8702
  label: (_a = plugin.label) != null ? _a : plugin.name,
8480
- icon: (_b = plugin.icon) != null ? _b : /* @__PURE__ */ jsx52(ToyBrick, {}),
8703
+ icon: (_b = plugin.icon) != null ? _b : /* @__PURE__ */ jsx53(ToyBrick, {}),
8481
8704
  onClick: () => {
8705
+ var _a2;
8706
+ setMobilePanelHeightMode((_a2 = plugin.mobilePanelHeight) != null ? _a2 : "toggle");
8482
8707
  if (plugin.name === currentPlugin) {
8483
- setUi({ leftSideBarVisible: !leftSideBarVisible });
8484
- } else if (plugin.name) {
8485
- setUi({
8486
- plugin: { current: plugin.name },
8487
- leftSideBarVisible: true
8488
- });
8708
+ if (leftSideBarVisible) {
8709
+ setUi({ leftSideBarVisible: false });
8710
+ } else {
8711
+ setUi({ leftSideBarVisible: true });
8712
+ }
8713
+ } else {
8714
+ if (plugin.name) {
8715
+ setUi({
8716
+ plugin: { current: plugin.name },
8717
+ leftSideBarVisible: true
8718
+ });
8719
+ }
8489
8720
  }
8490
8721
  },
8491
8722
  isActive: leftSideBarVisible && currentPlugin === plugin.name,
@@ -8497,65 +8728,141 @@ var Layout = ({ children }) => {
8497
8728
  });
8498
8729
  return details;
8499
8730
  }, [plugins, currentPlugin, appStoreApi, leftSideBarVisible]);
8500
- useEffect24(() => {
8731
+ useEffect25(() => {
8501
8732
  if (!currentPlugin) {
8502
8733
  const names = Object.keys(pluginItems);
8503
8734
  setUi({ plugin: { current: names[0] } });
8504
8735
  }
8505
8736
  }, [pluginItems, currentPlugin]);
8506
8737
  const hasDesktopFieldsPlugin = pluginItems["fields"] && pluginItems["fields"].mobileOnly === false;
8507
- return /* @__PURE__ */ jsx52(ThemeContext.Provider, { value: { theme, toggleTheme }, children: /* @__PURE__ */ jsxs23(
8738
+ const mobilePanelStyle = {};
8739
+ if (mobilePanelHeight && leftSideBarVisible) {
8740
+ mobilePanelStyle["--editor-mobile-panel-height"] = `${mobilePanelHeight}px`;
8741
+ }
8742
+ return /* @__PURE__ */ jsxs23(
8508
8743
  "div",
8509
8744
  {
8510
- className: `Editor ${getClassName32({
8745
+ className: `Editor ${getClassName33({
8511
8746
  hidePlugins: hasLegacySideBarPlugin
8512
8747
  })}`,
8513
8748
  id: instanceId,
8514
8749
  "data-theme": theme,
8515
8750
  style: { height },
8516
8751
  children: [
8517
- /* @__PURE__ */ jsx52(DragDropContext, { disableAutoScroll: dnd == null ? void 0 : dnd.disableAutoScroll, children: /* @__PURE__ */ jsx52(CustomEditor, { children: children || /* @__PURE__ */ jsx52(FrameProvider, { children: /* @__PURE__ */ jsx52(
8752
+ /* @__PURE__ */ jsx53(DragDropContext, { disableAutoScroll: dnd == null ? void 0 : dnd.disableAutoScroll, children: /* @__PURE__ */ jsx53(CustomEditor, { children: children || /* @__PURE__ */ jsx53(FrameProvider, { children: /* @__PURE__ */ jsx53(
8518
8753
  "div",
8519
8754
  {
8520
8755
  className: getLayoutClassName({
8521
8756
  leftSideBarVisible,
8757
+ mounted,
8522
8758
  rightSideBarVisible: !hasDesktopFieldsPlugin && rightSideBarVisible,
8523
- navBarVisible
8759
+ navBarVisible,
8760
+ mobilePanelHeightToggle: mobilePanelHeightMode === "toggle",
8761
+ mobilePanelHeightMinContent: mobilePanelHeightMode === "min-content",
8762
+ mobilePanelCustomHeight: mobilePanelHeight !== null && leftSideBarVisible
8524
8763
  }),
8525
8764
  style: { height },
8526
- children: /* @__PURE__ */ jsxs23("div", { className: getLayoutClassName("inner"), children: [
8527
- navBarVisible && /* @__PURE__ */ jsxs23("header", { className: getLayoutClassName("header"), children: [
8528
- /* @__PURE__ */ jsx52("div", { className: getLayoutClassName("headerStart"), children: /* @__PURE__ */ jsx52(Nav, { items: pluginItems, orientation: "horizontal" }) }),
8529
- /* @__PURE__ */ jsx52("div", { className: getLayoutClassName("headerCenter"), children: chrome.showUrlBar && /* @__PURE__ */ jsx52(BrowserBar, {}) }),
8530
- /* @__PURE__ */ jsxs23("div", { className: getLayoutClassName("headerEnd"), children: [
8531
- chrome.showHistoryControls && /* @__PURE__ */ jsx52(HeaderHistory, {}),
8532
- /* @__PURE__ */ jsx52(HeaderPublish, {})
8533
- ] })
8534
- ] }),
8535
- leftSideBarVisible && /* @__PURE__ */ jsx52(Sidebar, { position: "left", children: Object.entries(pluginItems).map(
8536
- ([id, { mobileOnly, render: Render2 }]) => /* @__PURE__ */ jsx52(
8537
- PluginTab,
8538
- {
8539
- visible: currentPlugin === id,
8540
- mobileOnly,
8541
- children: /* @__PURE__ */ jsx52(Render2, {})
8542
- },
8543
- id
8544
- )
8545
- ) }),
8546
- /* @__PURE__ */ jsx52(Canvas, {}),
8547
- !hasDesktopFieldsPlugin && rightSideBarVisible && /* @__PURE__ */ jsx52(Sidebar, { position: "right", children: /* @__PURE__ */ jsx52(FieldSideBarBody, {}) })
8548
- ] })
8765
+ children: /* @__PURE__ */ jsxs23(
8766
+ "div",
8767
+ {
8768
+ className: getLayoutClassName("inner"),
8769
+ style: __spreadValues(__spreadValues({}, layoutOptions), mobilePanelStyle),
8770
+ children: [
8771
+ navBarVisible && /* @__PURE__ */ jsx53("div", { className: getLayoutClassName("header"), children: /* @__PURE__ */ jsx53(TopHeader, { pluginItems }) }),
8772
+ /* @__PURE__ */ jsxs23(
8773
+ "div",
8774
+ {
8775
+ ref: mobilePanelRef,
8776
+ className: getLayoutClassName("mobilePanel"),
8777
+ children: [
8778
+ /* @__PURE__ */ jsx53(
8779
+ "div",
8780
+ {
8781
+ className: getLayoutClassName("mobileDragHandle"),
8782
+ onTouchStart: (e) => handleMobileDragStart(e.touches[0].clientY),
8783
+ onMouseDown: (e) => handleMobileDragStart(e.clientY),
8784
+ children: /* @__PURE__ */ jsx53(
8785
+ "div",
8786
+ {
8787
+ className: getLayoutClassName("mobileDragHandlePill")
8788
+ }
8789
+ )
8790
+ }
8791
+ ),
8792
+ /* @__PURE__ */ jsx53(
8793
+ "div",
8794
+ {
8795
+ className: getLayoutClassName("mobilePanelContent"),
8796
+ children: Object.entries(pluginItems).map(
8797
+ ([id, { mobileOnly, render: Render2 }]) => /* @__PURE__ */ jsx53(
8798
+ PluginTab,
8799
+ {
8800
+ visible: currentPlugin === id,
8801
+ mobileOnly,
8802
+ children: /* @__PURE__ */ jsx53(Render2, {})
8803
+ },
8804
+ id
8805
+ )
8806
+ )
8807
+ }
8808
+ )
8809
+ ]
8810
+ }
8811
+ ),
8812
+ /* @__PURE__ */ jsx53(
8813
+ Sidebar,
8814
+ {
8815
+ position: "left",
8816
+ sidebarRef: leftSidebarRef,
8817
+ isVisible: leftSideBarVisible,
8818
+ onResize: setLeftWidth,
8819
+ onResizeEnd: handleLeftSidebarResizeEnd,
8820
+ children: Object.entries(pluginItems).map(
8821
+ ([id, { mobileOnly, render: Render2, label }]) => /* @__PURE__ */ jsx53(
8822
+ PluginTab,
8823
+ {
8824
+ visible: currentPlugin === id,
8825
+ mobileOnly,
8826
+ children: /* @__PURE__ */ jsx53(Render2, {})
8827
+ },
8828
+ id
8829
+ )
8830
+ )
8831
+ }
8832
+ ),
8833
+ /* @__PURE__ */ jsx53(
8834
+ Canvas,
8835
+ {
8836
+ theme,
8837
+ themeIcon,
8838
+ themeLabel,
8839
+ onToggleTheme: toggleTheme
8840
+ }
8841
+ ),
8842
+ !hasDesktopFieldsPlugin && /* @__PURE__ */ jsx53(
8843
+ Sidebar,
8844
+ {
8845
+ position: "right",
8846
+ sidebarRef: rightSidebarRef,
8847
+ isVisible: rightSideBarVisible,
8848
+ onResize: setRightWidth,
8849
+ onResizeEnd: handleRightSidebarResizeEnd,
8850
+ children: /* @__PURE__ */ jsx53(FieldSideBar, {})
8851
+ }
8852
+ )
8853
+ ]
8854
+ }
8855
+ )
8549
8856
  }
8550
8857
  ) }) }) }),
8551
- /* @__PURE__ */ jsx52("div", { id: "editor-portal-root", className: getClassName32("portal") })
8858
+ /* @__PURE__ */ jsx53("div", { id: "editor-portal-root", className: getClassName33("portal") })
8552
8859
  ]
8553
8860
  }
8554
- ) });
8861
+ );
8555
8862
  };
8556
8863
 
8557
8864
  // components/Editor/index.tsx
8558
- import { jsx as jsx53 } from "react/jsx-runtime";
8865
+ import { jsx as jsx54 } from "react/jsx-runtime";
8559
8866
  var CHROME_KEYS = [
8560
8867
  "showNavBar",
8561
8868
  "showThemeToggle",
@@ -8585,11 +8892,11 @@ var splitUiConfig = (ui) => {
8585
8892
  }
8586
8893
  return { runtime, chrome };
8587
8894
  };
8588
- var propsContext = createContext9({});
8895
+ var propsContext = createContext8({});
8589
8896
  function PropsProvider(props) {
8590
- return /* @__PURE__ */ jsx53(propsContext.Provider, { value: props, children: props.children });
8897
+ return /* @__PURE__ */ jsx54(propsContext.Provider, { value: props, children: props.children });
8591
8898
  }
8592
- var usePropsContext = () => useContext16(propsContext);
8899
+ var usePropsContext = () => useContext15(propsContext);
8593
8900
  var useChromeConfig = () => {
8594
8901
  const { ui } = usePropsContext();
8595
8902
  const { chrome } = splitUiConfig(ui);
@@ -8613,14 +8920,14 @@ function EditorProvider({ children }) {
8613
8920
  fullScreenCanvas,
8614
8921
  _experimentalVirtualization
8615
8922
  } = usePropsContext();
8616
- const iframe = useMemo23(
8923
+ const iframe = useMemo24(
8617
8924
  () => __spreadValues({
8618
8925
  enabled: true,
8619
8926
  waitForStyles: true
8620
8927
  }, _iframe),
8621
8928
  [_iframe]
8622
8929
  );
8623
- const [generatedAppState] = useState23(() => {
8930
+ const [generatedAppState] = useState24(() => {
8624
8931
  var _a, _b, _c, _d, _e, _f;
8625
8932
  const { runtime: initialUiRuntime } = splitUiConfig(initialUi);
8626
8933
  const initial = __spreadValues(__spreadValues({}, defaultAppState.ui), initialUiRuntime);
@@ -8673,7 +8980,7 @@ function EditorProvider({ children }) {
8673
8980
  return walkAppState(newAppState, config);
8674
8981
  });
8675
8982
  const { appendData = true } = _initialHistory || {};
8676
- const [blendedHistories] = useState23(
8983
+ const [blendedHistories] = useState24(
8677
8984
  [
8678
8985
  ...(_initialHistory == null ? void 0 : _initialHistory.histories) || [],
8679
8986
  ...appendData ? [{ state: generatedAppState }] : []
@@ -8687,7 +8994,7 @@ function EditorProvider({ children }) {
8687
8994
  });
8688
8995
  })
8689
8996
  );
8690
- const initialHistoryIndex = useMemo23(() => {
8997
+ const initialHistoryIndex = useMemo24(() => {
8691
8998
  if ((_initialHistory == null ? void 0 : _initialHistory.index) !== void 0 && (_initialHistory == null ? void 0 : _initialHistory.index) >= 0 && (_initialHistory == null ? void 0 : _initialHistory.index) < blendedHistories.length) {
8692
8999
  return _initialHistory == null ? void 0 : _initialHistory.index;
8693
9000
  }
@@ -8698,7 +9005,7 @@ function EditorProvider({ children }) {
8698
9005
  overrides,
8699
9006
  plugins
8700
9007
  });
8701
- const loadedFieldTransforms = useMemo23(() => {
9008
+ const loadedFieldTransforms = useMemo24(() => {
8702
9009
  const _plugins = plugins || [];
8703
9010
  const pluginFieldTransforms = _plugins.reduce(
8704
9011
  (acc, plugin) => __spreadValues(__spreadValues({}, acc), plugin.fieldTransforms),
@@ -8707,7 +9014,7 @@ function EditorProvider({ children }) {
8707
9014
  return __spreadValues(__spreadValues({}, pluginFieldTransforms), fieldTransforms);
8708
9015
  }, [fieldTransforms, plugins]);
8709
9016
  const instanceId = useSafeId();
8710
- const generateAppStore = useCallback22(
9017
+ const generateAppStore = useCallback25(
8711
9018
  (state) => {
8712
9019
  return {
8713
9020
  instanceId,
@@ -8739,15 +9046,15 @@ function EditorProvider({ children }) {
8739
9046
  loadedFieldTransforms
8740
9047
  ]
8741
9048
  );
8742
- const [appStore] = useState23(
9049
+ const [appStore] = useState24(
8743
9050
  () => createAppStore(generateAppStore(initialAppState))
8744
9051
  );
8745
- useEffect25(() => {
9052
+ useEffect26(() => {
8746
9053
  if (process.env.NODE_ENV !== "production") {
8747
9054
  window.__PUCK_INTERNAL_DO_NOT_USE = { appStore };
8748
9055
  }
8749
9056
  }, [appStore]);
8750
- useEffect25(() => {
9057
+ useEffect26(() => {
8751
9058
  const state = appStore.getState().state;
8752
9059
  appStore.setState(__spreadValues({}, generateAppStore(state)));
8753
9060
  }, [generateAppStore]);
@@ -8756,8 +9063,8 @@ function EditorProvider({ children }) {
8756
9063
  index: initialHistoryIndex,
8757
9064
  initialAppState
8758
9065
  });
8759
- const previousData = useRef16(null);
8760
- useEffect25(() => {
9066
+ const previousData = useRef19(null);
9067
+ useEffect26(() => {
8761
9068
  return appStore.subscribe(
8762
9069
  (s) => s.state.data,
8763
9070
  (data) => {
@@ -8771,16 +9078,16 @@ function EditorProvider({ children }) {
8771
9078
  }, [onChange, config]);
8772
9079
  useRegisterPermissionsSlice(appStore, permissions);
8773
9080
  const uEditorStore = useRegisterUseEditorStore(appStore);
8774
- useEffect25(() => {
9081
+ useEffect26(() => {
8775
9082
  const { resolveAndCommitData } = appStore.getState();
8776
9083
  setTimeout(() => {
8777
9084
  resolveAndCommitData();
8778
9085
  }, 0);
8779
9086
  }, []);
8780
- return /* @__PURE__ */ jsx53(appStoreContext.Provider, { value: appStore, children: /* @__PURE__ */ jsx53(UseEditorStoreContext.Provider, { value: uEditorStore, children }) });
9087
+ return /* @__PURE__ */ jsx54(appStoreContext.Provider, { value: appStore, children: /* @__PURE__ */ jsx54(UseEditorStoreContext.Provider, { value: uEditorStore, children }) });
8781
9088
  }
8782
9089
  function Editor3(props) {
8783
- return /* @__PURE__ */ jsx53(PropsProvider, __spreadProps(__spreadValues({}, props), { children: /* @__PURE__ */ jsx53(EditorProvider, __spreadProps(__spreadValues({}, props), { children: /* @__PURE__ */ jsx53(Layout, { children: props.children }) })) }));
9090
+ return /* @__PURE__ */ jsx54(PropsProvider, __spreadProps(__spreadValues({}, props), { children: /* @__PURE__ */ jsx54(EditorProvider, __spreadProps(__spreadValues({}, props), { children: /* @__PURE__ */ jsx54(Layout, { children: props.children }) })) }));
8784
9091
  }
8785
9092
  Editor3.Components = Components;
8786
9093
  Editor3.Fields = Fields;
@@ -8790,10 +9097,10 @@ Editor3.Preview = Preview2;
8790
9097
 
8791
9098
  // lib/use-stable-value.ts
8792
9099
  init_react_import();
8793
- import { useRef as useRef17 } from "react";
9100
+ import { useRef as useRef20 } from "react";
8794
9101
  import { deepEqual as deepEqual3 } from "fast-equals";
8795
9102
  var useStableValue = (value) => {
8796
- const ref = useRef17(value);
9103
+ const ref = useRef20(value);
8797
9104
  if (!deepEqual3(ref.current, value)) {
8798
9105
  ref.current = value;
8799
9106
  }
@@ -8802,11 +9109,11 @@ var useStableValue = (value) => {
8802
9109
 
8803
9110
  // components/App/context.ts
8804
9111
  init_react_import();
8805
- import { createContext as createContext10, useContext as useContext17, useMemo as useMemo24 } from "react";
9112
+ import { createContext as createContext9, useContext as useContext16, useMemo as useMemo25 } from "react";
8806
9113
  import { matchRoutes, useLocation, useNavigate } from "react-router";
8807
- var appConfigContext = createContext10(null);
9114
+ var appConfigContext = createContext9(null);
8808
9115
  var useAppConfigContext = () => {
8809
- const ctx = useContext17(appConfigContext);
9116
+ const ctx = useContext16(appConfigContext);
8810
9117
  if (!ctx) {
8811
9118
  throw new Error("useApp must be called inside an <AppProvider> or <App>");
8812
9119
  }
@@ -8825,7 +9132,7 @@ var useApp = () => {
8825
9132
  const currentPath = location.pathname || "/";
8826
9133
  const isEditing = cfg.editorPath !== null && (currentPath === cfg.editorPath || currentPath.startsWith(`${cfg.editorPath}/`));
8827
9134
  const matchRoute = isEditing ? stripPrefix(currentPath, cfg.editorPath) : currentPath;
8828
- const matched = useMemo24(() => {
9135
+ const matched = useMemo25(() => {
8829
9136
  const routeKeys = Object.keys(cfg.pages);
8830
9137
  if (routeKeys.length === 0) return null;
8831
9138
  const matches = matchRoutes(
@@ -8841,7 +9148,7 @@ var useApp = () => {
8841
9148
  data: cfg.pages[key]
8842
9149
  };
8843
9150
  }, [cfg.pages, matchRoute]);
8844
- const routes = useMemo24(() => Object.keys(cfg.pages), [cfg.pages]);
9151
+ const routes = useMemo25(() => Object.keys(cfg.pages), [cfg.pages]);
8845
9152
  const navigate = (route) => {
8846
9153
  const target = isEditing && cfg.editorPath ? `${cfg.editorPath}${route === "/" ? "" : route}` || "/" : route;
8847
9154
  rrNavigate(target || "/");
@@ -8858,14 +9165,14 @@ var useApp = () => {
8858
9165
 
8859
9166
  // components/App/AppProvider.tsx
8860
9167
  init_react_import();
8861
- import { useMemo as useMemo25 } from "react";
9168
+ import { useMemo as useMemo26 } from "react";
8862
9169
  import {
8863
9170
  BrowserRouter,
8864
9171
  HashRouter,
8865
9172
  MemoryRouter,
8866
9173
  StaticRouter
8867
9174
  } from "react-router";
8868
- import { jsx as jsx54 } from "react/jsx-runtime";
9175
+ import { jsx as jsx55 } from "react/jsx-runtime";
8869
9176
  var EDITOR_PATH = "/editor";
8870
9177
  var isServer = typeof window === "undefined";
8871
9178
  function AppProvider({
@@ -8878,7 +9185,7 @@ function AppProvider({
8878
9185
  }) {
8879
9186
  const stablePages = useStableValue(pages);
8880
9187
  const resolvedEditorPath = editorPath === null ? null : editorPath || EDITOR_PATH;
8881
- const ctxValue = useMemo25(
9188
+ const ctxValue = useMemo26(
8882
9189
  () => ({
8883
9190
  config,
8884
9191
  pages: stablePages,
@@ -8886,28 +9193,28 @@ function AppProvider({
8886
9193
  }),
8887
9194
  [config, stablePages, resolvedEditorPath]
8888
9195
  );
8889
- const inner = /* @__PURE__ */ jsx54(appConfigContext.Provider, { value: ctxValue, children });
9196
+ const inner = /* @__PURE__ */ jsx55(appConfigContext.Provider, { value: ctxValue, children });
8890
9197
  if (isServer) {
8891
- return /* @__PURE__ */ jsx54(StaticRouter, { location: currentPath != null ? currentPath : "/", children: inner });
9198
+ return /* @__PURE__ */ jsx55(StaticRouter, { location: currentPath != null ? currentPath : "/", children: inner });
8892
9199
  }
8893
9200
  if (router === "hash") {
8894
- return /* @__PURE__ */ jsx54(HashRouter, { children: inner });
9201
+ return /* @__PURE__ */ jsx55(HashRouter, { children: inner });
8895
9202
  }
8896
9203
  if (router === "memory") {
8897
- return /* @__PURE__ */ jsx54(MemoryRouter, { initialEntries: [currentPath != null ? currentPath : "/"], children: inner });
9204
+ return /* @__PURE__ */ jsx55(MemoryRouter, { initialEntries: [currentPath != null ? currentPath : "/"], children: inner });
8898
9205
  }
8899
- return /* @__PURE__ */ jsx54(BrowserRouter, { children: inner });
9206
+ return /* @__PURE__ */ jsx55(BrowserRouter, { children: inner });
8900
9207
  }
8901
9208
 
8902
9209
  // components/App/App.tsx
8903
9210
  init_react_import();
8904
9211
  import { Route, Routes } from "react-router";
8905
- import { Fragment as Fragment14, jsx as jsx55, jsxs as jsxs24 } from "react/jsx-runtime";
9212
+ import { Fragment as Fragment15, jsx as jsx56, jsxs as jsxs24 } from "react/jsx-runtime";
8906
9213
  var joinEditorPath = (editorPath, route) => {
8907
9214
  if (route === "/") return editorPath;
8908
9215
  return `${editorPath}${route}`;
8909
9216
  };
8910
- var DefaultNotFound = () => /* @__PURE__ */ jsx55(
9217
+ var DefaultNotFound = () => /* @__PURE__ */ jsx56(
8911
9218
  "div",
8912
9219
  {
8913
9220
  style: {
@@ -8918,8 +9225,8 @@ var DefaultNotFound = () => /* @__PURE__ */ jsx55(
8918
9225
  alignItems: "center"
8919
9226
  },
8920
9227
  children: /* @__PURE__ */ jsxs24("div", { children: [
8921
- /* @__PURE__ */ jsx55("h1", { children: "404" }),
8922
- /* @__PURE__ */ jsx55("p", { children: "No page matches this route." })
9228
+ /* @__PURE__ */ jsx56("h1", { children: "404" }),
9229
+ /* @__PURE__ */ jsx56("p", { children: "No page matches this route." })
8923
9230
  ] })
8924
9231
  }
8925
9232
  );
@@ -8930,7 +9237,7 @@ function RenderForKey({
8930
9237
  const { config, pages } = useApp();
8931
9238
  const data = pages[routeKey];
8932
9239
  if (!data) return null;
8933
- return /* @__PURE__ */ jsx55(
9240
+ return /* @__PURE__ */ jsx56(
8934
9241
  Render,
8935
9242
  {
8936
9243
  config,
@@ -8948,7 +9255,7 @@ function EditorForKey({
8948
9255
  const { config, pages, routes, navigate } = useApp();
8949
9256
  const data = pages[routeKey];
8950
9257
  if (!data) return null;
8951
- return /* @__PURE__ */ jsx55(
9258
+ return /* @__PURE__ */ jsx56(
8952
9259
  Editor3,
8953
9260
  {
8954
9261
  config,
@@ -8986,11 +9293,11 @@ function AppRender({ metadata, renderNotFound }) {
8986
9293
  if (isEditing) return null;
8987
9294
  const routeKeys = Object.keys(pages);
8988
9295
  return /* @__PURE__ */ jsxs24(Routes, { children: [
8989
- routeKeys.map((routeKey) => /* @__PURE__ */ jsx55(
9296
+ routeKeys.map((routeKey) => /* @__PURE__ */ jsx56(
8990
9297
  Route,
8991
9298
  {
8992
9299
  path: routeKey,
8993
- element: /* @__PURE__ */ jsx55(
9300
+ element: /* @__PURE__ */ jsx56(
8994
9301
  RenderForKey,
8995
9302
  {
8996
9303
  routeKey,
@@ -9000,11 +9307,11 @@ function AppRender({ metadata, renderNotFound }) {
9000
9307
  },
9001
9308
  `render:${routeKey}`
9002
9309
  )),
9003
- /* @__PURE__ */ jsx55(
9310
+ /* @__PURE__ */ jsx56(
9004
9311
  Route,
9005
9312
  {
9006
9313
  path: "*",
9007
- element: renderNotFound ? /* @__PURE__ */ jsx55(Fragment14, { children: renderNotFound() }) : /* @__PURE__ */ jsx55(DefaultNotFound, {})
9314
+ element: renderNotFound ? /* @__PURE__ */ jsx56(Fragment15, { children: renderNotFound() }) : /* @__PURE__ */ jsx56(DefaultNotFound, {})
9008
9315
  }
9009
9316
  )
9010
9317
  ] });
@@ -9015,11 +9322,11 @@ function AppEditor(props) {
9015
9322
  if (!isEditing || editorPath === null) return null;
9016
9323
  const routeKeys = Object.keys(pages);
9017
9324
  return /* @__PURE__ */ jsxs24(Routes, { children: [
9018
- routeKeys.map((routeKey) => /* @__PURE__ */ jsx55(
9325
+ routeKeys.map((routeKey) => /* @__PURE__ */ jsx56(
9019
9326
  Route,
9020
9327
  {
9021
9328
  path: joinEditorPath(editorPath, routeKey),
9022
- element: /* @__PURE__ */ jsx55(
9329
+ element: /* @__PURE__ */ jsx56(
9023
9330
  EditorForKey,
9024
9331
  {
9025
9332
  routeKey,
@@ -9030,26 +9337,26 @@ function AppEditor(props) {
9030
9337
  },
9031
9338
  `edit:${routeKey}`
9032
9339
  )),
9033
- /* @__PURE__ */ jsx55(
9340
+ /* @__PURE__ */ jsx56(
9034
9341
  Route,
9035
9342
  {
9036
9343
  path: "*",
9037
- element: renderNotFound ? /* @__PURE__ */ jsx55(Fragment14, { children: renderNotFound() }) : /* @__PURE__ */ jsx55(DefaultNotFound, {})
9344
+ element: renderNotFound ? /* @__PURE__ */ jsx56(Fragment15, { children: renderNotFound() }) : /* @__PURE__ */ jsx56(DefaultNotFound, {})
9038
9345
  }
9039
9346
  )
9040
9347
  ] });
9041
9348
  }
9042
9349
  function DefaultAppLayout(props) {
9043
9350
  const _a = props, { renderNotFound } = _a, editorProps = __objRest(_a, ["renderNotFound"]);
9044
- return /* @__PURE__ */ jsxs24(Fragment14, { children: [
9045
- /* @__PURE__ */ jsx55(
9351
+ return /* @__PURE__ */ jsxs24(Fragment15, { children: [
9352
+ /* @__PURE__ */ jsx56(
9046
9353
  AppRender,
9047
9354
  {
9048
9355
  metadata: editorProps.metadata,
9049
9356
  renderNotFound
9050
9357
  }
9051
9358
  ),
9052
- /* @__PURE__ */ jsx55(AppEditor, __spreadProps(__spreadValues({}, editorProps), { renderNotFound }))
9359
+ /* @__PURE__ */ jsx56(AppEditor, __spreadProps(__spreadValues({}, editorProps), { renderNotFound }))
9053
9360
  ] });
9054
9361
  }
9055
9362
  function App(props) {
@@ -9068,7 +9375,7 @@ function App(props) {
9068
9375
  "router",
9069
9376
  "children"
9070
9377
  ]);
9071
- return /* @__PURE__ */ jsx55(
9378
+ return /* @__PURE__ */ jsx56(
9072
9379
  AppProvider,
9073
9380
  {
9074
9381
  config,
@@ -9076,7 +9383,7 @@ function App(props) {
9076
9383
  currentPath,
9077
9384
  editorPath,
9078
9385
  router,
9079
- children: children != null ? children : /* @__PURE__ */ jsx55(DefaultAppLayout, __spreadValues({}, layoutProps))
9386
+ children: children != null ? children : /* @__PURE__ */ jsx56(DefaultAppLayout, __spreadValues({}, layoutProps))
9080
9387
  }
9081
9388
  );
9082
9389
  }
@@ -9114,23 +9421,6 @@ function pageMetadata(data) {
9114
9421
  return out;
9115
9422
  }
9116
9423
 
9117
- // plugins/blocks/index.tsx
9118
- init_react_import();
9119
-
9120
- // css-module:/Users/rami/Documents/apps/react-editor/packages/core/plugins/blocks/styles.module.css#css-module
9121
- init_react_import();
9122
- var styles_module_default28 = { "BlocksPlugin": "_BlocksPlugin_15ud0_1" };
9123
-
9124
- // plugins/blocks/index.tsx
9125
- import { jsx as jsx56 } from "react/jsx-runtime";
9126
- var getClassName33 = get_class_name_factory_default("BlocksPlugin", styles_module_default28);
9127
- var blocksPlugin = () => ({
9128
- name: "blocks",
9129
- label: "Blocks",
9130
- render: () => /* @__PURE__ */ jsx56("div", { className: getClassName33(), children: /* @__PURE__ */ jsx56(Components, {}) }),
9131
- icon: /* @__PURE__ */ jsx56(Plus, {})
9132
- });
9133
-
9134
9424
  // plugins/outline/index.tsx
9135
9425
  init_react_import();
9136
9426
 
@@ -9215,6 +9505,7 @@ export {
9215
9505
  createUseEditor,
9216
9506
  useEditor,
9217
9507
  useGetEditor,
9508
+ blocksPlugin,
9218
9509
  fieldsPlugin,
9219
9510
  usePropsContext,
9220
9511
  Editor3 as Editor,
@@ -9225,7 +9516,6 @@ export {
9225
9516
  App,
9226
9517
  useRouteParams,
9227
9518
  pageMetadata,
9228
- blocksPlugin,
9229
9519
  outlinePlugin,
9230
9520
  legacySideBarPlugin
9231
9521
  };