@reacteditor/core 0.0.8 → 0.0.10

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (37) hide show
  1. package/dist/{Editor-KXEVJBNG.mjs → Editor-3COFH5WN.mjs} +3 -3
  2. package/dist/{actions-2L-1hQ7r.d.mts → actions-B8_EA7vy.d.mts} +1 -1
  3. package/dist/{actions-2L-1hQ7r.d.ts → actions-B8_EA7vy.d.ts} +1 -1
  4. package/dist/{chunk-R5DQGUQS.mjs → chunk-3IP22OOD.mjs} +323 -47
  5. package/dist/{chunk-AJWRDM22.mjs → chunk-BZ4BQZJR.mjs} +4 -4
  6. package/dist/{chunk-TI3KC54Y.mjs → chunk-PUDWMFBH.mjs} +46 -0
  7. package/dist/{full-ZFZZ626B.mjs → full-QT5KXRDP.mjs} +2 -2
  8. package/dist/{index-BNsSzMCj.d.ts → index-BrHy0cc_.d.ts} +1 -1
  9. package/dist/{index-BXuSeNez.d.mts → index-JoD48fK_.d.mts} +1 -1
  10. package/dist/index.css +84 -84
  11. package/dist/index.d.mts +110 -17
  12. package/dist/index.d.ts +110 -17
  13. package/dist/index.js +1013 -684
  14. package/dist/index.mjs +27 -11
  15. package/dist/internal.d.mts +2 -2
  16. package/dist/internal.d.ts +2 -2
  17. package/dist/nextjs.d.mts +38 -0
  18. package/dist/nextjs.d.ts +38 -0
  19. package/dist/nextjs.js +65 -0
  20. package/dist/nextjs.mjs +30 -0
  21. package/dist/no-external.css +84 -84
  22. package/dist/no-external.d.mts +4 -4
  23. package/dist/no-external.d.ts +4 -4
  24. package/dist/no-external.js +1013 -684
  25. package/dist/no-external.mjs +27 -11
  26. package/dist/remix.d.mts +33 -0
  27. package/dist/remix.d.ts +33 -0
  28. package/dist/remix.js +65 -0
  29. package/dist/remix.mjs +30 -0
  30. package/dist/rsc.d.mts +2 -2
  31. package/dist/rsc.d.ts +2 -2
  32. package/dist/rsc.js +48 -0
  33. package/dist/rsc.mjs +5 -1
  34. package/dist/{walk-tree-4C3ODO3X.d.mts → walk-tree-BR2XIZ0W.d.mts} +33 -2
  35. package/dist/{walk-tree-C9GrSWsR.d.ts → walk-tree-DpUJ9kDx.d.ts} +33 -2
  36. package/package.json +14 -3
  37. package/dist/{chunk-U7VW3V3W.mjs → chunk-BUR5T7IX.mjs} +3 -3
@@ -4,12 +4,12 @@ import {
4
4
  import {
5
5
  EditorInner,
6
6
  LoadedRichTextMenu
7
- } from "./chunk-AJWRDM22.mjs";
7
+ } from "./chunk-BZ4BQZJR.mjs";
8
+ import "./chunk-BUR5T7IX.mjs";
9
+ import "./chunk-FT6UFK7G.mjs";
8
10
  import "./chunk-6QJ2HF4O.mjs";
9
- import "./chunk-U7VW3V3W.mjs";
10
11
  import "./chunk-OIFPBVSF.mjs";
11
12
  import "./chunk-AD7BMXAA.mjs";
12
- import "./chunk-FT6UFK7G.mjs";
13
13
  import {
14
14
  useAppStore,
15
15
  useAppStoreApi
@@ -856,4 +856,4 @@ type EditorAction = {
856
856
  recordHistory?: boolean;
857
857
  } & (ReorderAction | InsertAction | MoveAction | ReplaceAction | ReplaceRootAction | RemoveAction | DuplicateAction | SetAction | SetDataAction | SetUiAction | RegisterZoneAction | UnregisterZoneAction);
858
858
 
859
- export { type EditorComponent as $, type AppState as A, type BaseData as B, type Config as C, type Data as D, type EditorAction as E, type Fields as F, type ComponentConfigExtensions as G, type History as H, type IframeConfig as I, type ComponentConfigParams as J, type ComponentDataMap as K, type ComponentDataOptionalId as L, type Metadata as M, type ComponentMetadata as N, type OnAction as O, type PrivateAppState as P, type ConfigParams as Q, type RootData as R, type CustomField as S, type CustomFieldRender as T, type UserGenerics as U, type Viewports as V, type WithId as W, type DefaultRootProps as X, type DefaultRootRenderProps as Y, type Direction as Z, type DragAxis as _, type Content as a, type EditorContext as a0, type EditorMetadata as a1, type ExternalField as a2, type ExternalFieldWithAdaptor as a3, type ExtractConfigParams as a4, type ExtractField as a5, type FieldMetadata as a6, type FieldRenderFunctions as a7, type FieldTransformFn as a8, type FieldTransformFnParams as a9, type ItemWithId as aa, type MappedItem as ab, type NumberField as ac, type ObjectField as ad, type OverrideKey as ae, type RadioField as af, type RichText as ag, type RootConfig as ah, type RootDataWithoutProps as ai, type SelectField as aj, type Slot as ak, type SlotComponent as al, type SlotField as am, type TextField as an, type TextareaField as ao, type Viewport as ap, type WithChildren as aq, type WithEditorProps as ar, type WithSlotProps as as, overrideKeys as at, type ComponentData as b, type DefaultComponents as c, type DefaultComponentProps as d, type DefaultRootFieldProps as e, type Permissions as f, type RootDataWithProps as g, type ResolveDataTrigger as h, type Plugin as i, type Overrides as j, type UiState as k, type ComponentConfig as l, type FieldTransforms as m, type RichtextField as n, type Field as o, type FieldProps as p, type InitialHistory as q, type ItemSelector as r, type PluginInternal as s, type Adaptor as t, type ArrayField as u, type ArrayState as v, type AsFieldProps as w, type BaseField as x, type CacheOpts as y, type ColorField as z };
859
+ export { type EditorComponent as $, type AppState as A, type BaseData as B, type Config as C, type Data as D, type EditorAction as E, type Fields as F, type ComponentConfigExtensions as G, type History as H, type IframeConfig as I, type ComponentConfigParams as J, type ComponentDataMap as K, type ComponentDataOptionalId as L, type Metadata as M, type ComponentMetadata as N, type OnAction as O, type PrivateAppState as P, type ConfigParams as Q, type RootDataWithProps as R, type CustomField as S, type CustomFieldRender as T, type UserGenerics as U, type Viewports as V, type WithId as W, type DefaultRootProps as X, type DefaultRootRenderProps as Y, type Direction as Z, type DragAxis as _, type Permissions as a, type EditorContext as a0, type EditorMetadata as a1, type ExternalField as a2, type ExternalFieldWithAdaptor as a3, type ExtractConfigParams as a4, type ExtractField as a5, type FieldMetadata as a6, type FieldRenderFunctions as a7, type FieldTransformFn as a8, type FieldTransformFnParams as a9, type ItemWithId as aa, type MappedItem as ab, type NumberField as ac, type ObjectField as ad, type OverrideKey as ae, type RadioField as af, type RichText as ag, type RootConfig as ah, type RootDataWithoutProps as ai, type SelectField as aj, type Slot as ak, type SlotComponent as al, type SlotField as am, type TextField as an, type TextareaField as ao, type Viewport as ap, type WithChildren as aq, type WithEditorProps as ar, type WithSlotProps as as, overrideKeys as at, type ComponentData as b, type ResolveDataTrigger as c, type Plugin as d, type Overrides as e, type UiState as f, type ComponentConfig as g, type FieldTransforms as h, type RichtextField as i, type Content as j, type DefaultComponents as k, type DefaultComponentProps as l, type DefaultRootFieldProps as m, type RootData as n, type Field as o, type FieldProps as p, type InitialHistory as q, type ItemSelector as r, type PluginInternal as s, type Adaptor as t, type ArrayField as u, type ArrayState as v, type AsFieldProps as w, type BaseField as x, type CacheOpts as y, type ColorField as z };
@@ -856,4 +856,4 @@ type EditorAction = {
856
856
  recordHistory?: boolean;
857
857
  } & (ReorderAction | InsertAction | MoveAction | ReplaceAction | ReplaceRootAction | RemoveAction | DuplicateAction | SetAction | SetDataAction | SetUiAction | RegisterZoneAction | UnregisterZoneAction);
858
858
 
859
- export { type EditorComponent as $, type AppState as A, type BaseData as B, type Config as C, type Data as D, type EditorAction as E, type Fields as F, type ComponentConfigExtensions as G, type History as H, type IframeConfig as I, type ComponentConfigParams as J, type ComponentDataMap as K, type ComponentDataOptionalId as L, type Metadata as M, type ComponentMetadata as N, type OnAction as O, type PrivateAppState as P, type ConfigParams as Q, type RootData as R, type CustomField as S, type CustomFieldRender as T, type UserGenerics as U, type Viewports as V, type WithId as W, type DefaultRootProps as X, type DefaultRootRenderProps as Y, type Direction as Z, type DragAxis as _, type Content as a, type EditorContext as a0, type EditorMetadata as a1, type ExternalField as a2, type ExternalFieldWithAdaptor as a3, type ExtractConfigParams as a4, type ExtractField as a5, type FieldMetadata as a6, type FieldRenderFunctions as a7, type FieldTransformFn as a8, type FieldTransformFnParams as a9, type ItemWithId as aa, type MappedItem as ab, type NumberField as ac, type ObjectField as ad, type OverrideKey as ae, type RadioField as af, type RichText as ag, type RootConfig as ah, type RootDataWithoutProps as ai, type SelectField as aj, type Slot as ak, type SlotComponent as al, type SlotField as am, type TextField as an, type TextareaField as ao, type Viewport as ap, type WithChildren as aq, type WithEditorProps as ar, type WithSlotProps as as, overrideKeys as at, type ComponentData as b, type DefaultComponents as c, type DefaultComponentProps as d, type DefaultRootFieldProps as e, type Permissions as f, type RootDataWithProps as g, type ResolveDataTrigger as h, type Plugin as i, type Overrides as j, type UiState as k, type ComponentConfig as l, type FieldTransforms as m, type RichtextField as n, type Field as o, type FieldProps as p, type InitialHistory as q, type ItemSelector as r, type PluginInternal as s, type Adaptor as t, type ArrayField as u, type ArrayState as v, type AsFieldProps as w, type BaseField as x, type CacheOpts as y, type ColorField as z };
859
+ export { type EditorComponent as $, type AppState as A, type BaseData as B, type Config as C, type Data as D, type EditorAction as E, type Fields as F, type ComponentConfigExtensions as G, type History as H, type IframeConfig as I, type ComponentConfigParams as J, type ComponentDataMap as K, type ComponentDataOptionalId as L, type Metadata as M, type ComponentMetadata as N, type OnAction as O, type PrivateAppState as P, type ConfigParams as Q, type RootDataWithProps as R, type CustomField as S, type CustomFieldRender as T, type UserGenerics as U, type Viewports as V, type WithId as W, type DefaultRootProps as X, type DefaultRootRenderProps as Y, type Direction as Z, type DragAxis as _, type Permissions as a, type EditorContext as a0, type EditorMetadata as a1, type ExternalField as a2, type ExternalFieldWithAdaptor as a3, type ExtractConfigParams as a4, type ExtractField as a5, type FieldMetadata as a6, type FieldRenderFunctions as a7, type FieldTransformFn as a8, type FieldTransformFnParams as a9, type ItemWithId as aa, type MappedItem as ab, type NumberField as ac, type ObjectField as ad, type OverrideKey as ae, type RadioField as af, type RichText as ag, type RootConfig as ah, type RootDataWithoutProps as ai, type SelectField as aj, type Slot as ak, type SlotComponent as al, type SlotField as am, type TextField as an, type TextareaField as ao, type Viewport as ap, type WithChildren as aq, type WithEditorProps as ar, type WithSlotProps as as, overrideKeys as at, type ComponentData as b, type ResolveDataTrigger as c, type Plugin as d, type Overrides as e, type UiState as f, type ComponentConfig as g, type FieldTransforms as h, type RichtextField as i, type Content as j, type DefaultComponents as k, type DefaultComponentProps as l, type DefaultRootFieldProps as m, type RootData as n, type Field as o, type FieldProps as p, type InitialHistory as q, type ItemSelector as r, type PluginInternal as s, type Adaptor as t, type ArrayField as u, type ArrayState as v, type AsFieldProps as w, type BaseField as x, type CacheOpts as y, type ColorField as z };
@@ -1,7 +1,13 @@
1
1
  import {
2
2
  EditorInner,
3
3
  LoadedRichTextMenu
4
- } from "./chunk-AJWRDM22.mjs";
4
+ } from "./chunk-BZ4BQZJR.mjs";
5
+ import {
6
+ ActionBar,
7
+ IconButton,
8
+ LoadedRichTextMenuInner,
9
+ Loader
10
+ } from "./chunk-BUR5T7IX.mjs";
5
11
  import {
6
12
  RichTextRenderFallback,
7
13
  SlotRender,
@@ -10,13 +16,7 @@ import {
10
16
  getSlotTransform,
11
17
  useRichtextProps,
12
18
  useSlots
13
- } from "./chunk-TI3KC54Y.mjs";
14
- import {
15
- ActionBar,
16
- IconButton,
17
- LoadedRichTextMenuInner,
18
- Loader
19
- } from "./chunk-U7VW3V3W.mjs";
19
+ } from "./chunk-PUDWMFBH.mjs";
20
20
  import {
21
21
  Check,
22
22
  ChevronDown,
@@ -2146,7 +2146,7 @@ EditorFallback.displayName = "EditorFallback";
2146
2146
  // components/AutoField/fields/RichtextField/index.tsx
2147
2147
  import { Fragment as Fragment3, jsx as jsx20 } from "react/jsx-runtime";
2148
2148
  var Editor = lazy(
2149
- () => import("./Editor-KXEVJBNG.mjs").then((m) => ({
2149
+ () => import("./Editor-3COFH5WN.mjs").then((m) => ({
2150
2150
  default: m.Editor
2151
2151
  }))
2152
2152
  );
@@ -3698,23 +3698,25 @@ var DragDropContextClient = ({
3698
3698
  },
3699
3699
  scrollToComponent: (id) => {
3700
3700
  const virtualizers = Array.from(rootVirtualizers.values());
3701
- if (virtualizers.length > 0) {
3702
- for (const handle of virtualizers) {
3703
- const index = handle.resolveIndex(id);
3704
- if (index < 0) {
3705
- continue;
3701
+ const scroll = () => {
3702
+ if (virtualizers.length > 0) {
3703
+ for (const handle of virtualizers) {
3704
+ const index = handle.resolveIndex(id);
3705
+ if (index < 0) continue;
3706
+ handle.virtualizer.scrollToIndex(index, {
3707
+ behavior: "smooth",
3708
+ align: "center"
3709
+ });
3706
3710
  }
3707
- handle.virtualizer.scrollToIndex(index, {
3708
- behavior: "auto",
3709
- // We avoid smooth scroll as this triggers virtualizer renders
3710
- align: "auto"
3711
- });
3711
+ return;
3712
3712
  }
3713
- } else {
3714
3713
  const frame = getFrame();
3715
- const el = frame == null ? void 0 : frame.querySelector(`[data-editor-component="${id}"]`);
3716
- el == null ? void 0 : el.scrollIntoView({ behavior: "smooth" });
3717
- }
3714
+ const el = frame == null ? void 0 : frame.querySelector(
3715
+ `[data-editor-component="${id}"]`
3716
+ );
3717
+ el == null ? void 0 : el.scrollIntoView({ behavior: "smooth", block: "center" });
3718
+ };
3719
+ requestAnimationFrame(() => requestAnimationFrame(scroll));
3718
3720
  }
3719
3721
  }));
3720
3722
  });
@@ -4696,7 +4698,7 @@ import {
4696
4698
  } from "react";
4697
4699
  import { jsx as jsx30 } from "react/jsx-runtime";
4698
4700
  var Editor2 = lazy2(
4699
- () => import("./Editor-KXEVJBNG.mjs").then((m) => ({
4701
+ () => import("./Editor-3COFH5WN.mjs").then((m) => ({
4700
4702
  default: m.Editor
4701
4703
  }))
4702
4704
  );
@@ -7660,7 +7662,7 @@ var DEVICE_VIEWPORTS = {
7660
7662
  var BrowserBar = ({
7661
7663
  onViewportChange
7662
7664
  }) => {
7663
- const { routes, currentPath, onRouteChange } = usePropsContext();
7665
+ const { routes, currentRoute, onRouteChange } = usePropsContext();
7664
7666
  const viewports = useAppStore((s) => s.state.ui.viewports);
7665
7667
  const dispatch = useAppStore((s) => s.dispatch);
7666
7668
  const leftSideBarVisible = useAppStore((s) => s.state.ui.leftSideBarVisible);
@@ -7686,24 +7688,24 @@ var BrowserBar = ({
7686
7688
  const setDevice = (device) => {
7687
7689
  onViewportChange == null ? void 0 : onViewportChange(DEVICE_VIEWPORTS[device]);
7688
7690
  };
7689
- const showRoutePicker = !!routes && currentPath !== void 0 && !!onRouteChange;
7690
- const [inputValue, setInputValue] = useState20(currentPath != null ? currentPath : "");
7691
- const lastSyncedPath = useRef13(currentPath);
7692
- if (lastSyncedPath.current !== currentPath) {
7693
- lastSyncedPath.current = currentPath;
7694
- setInputValue(currentPath != null ? currentPath : "");
7691
+ const showRoutePicker = !!routes && currentRoute !== void 0 && !!onRouteChange;
7692
+ const [inputValue, setInputValue] = useState20(currentRoute != null ? currentRoute : "");
7693
+ const lastSyncedPath = useRef13(currentRoute);
7694
+ if (lastSyncedPath.current !== currentRoute) {
7695
+ lastSyncedPath.current = currentRoute;
7696
+ setInputValue(currentRoute != null ? currentRoute : "");
7695
7697
  }
7696
7698
  const submit = (raw) => {
7697
7699
  const next = normalizeRoute(raw);
7698
- if (!next || next === currentPath) return;
7700
+ if (!next || next === currentRoute) return;
7699
7701
  void (onRouteChange == null ? void 0 : onRouteChange(next));
7700
7702
  };
7701
7703
  return /* @__PURE__ */ jsxs20("div", { className: getClassName30(), children: [
7702
7704
  showRoutePicker ? /* @__PURE__ */ jsxs20(
7703
7705
  Combobox,
7704
7706
  {
7705
- items: routes.map((r) => r.path),
7706
- value: currentPath,
7707
+ items: routes,
7708
+ value: currentRoute,
7707
7709
  onValueChange: (next) => {
7708
7710
  if (typeof next === "string") submit(next);
7709
7711
  },
@@ -7736,13 +7738,7 @@ var BrowserBar = ({
7736
7738
  ),
7737
7739
  /* @__PURE__ */ jsxs20(ComboboxContent, { children: [
7738
7740
  /* @__PURE__ */ jsx49(ComboboxEmpty, { children: "Press Enter to go to this path" }),
7739
- /* @__PURE__ */ jsx49(ComboboxList, { children: (path) => {
7740
- const route = routes.find((r) => r.path === path);
7741
- return /* @__PURE__ */ jsxs20(ComboboxItem, { value: path, children: [
7742
- /* @__PURE__ */ jsx49("span", { className: getClassName30("itemPath"), children: path }),
7743
- (route == null ? void 0 : route.title) ? /* @__PURE__ */ jsx49("span", { className: getClassName30("itemTitle"), children: route.title }) : null
7744
- ] }, path);
7745
- } })
7741
+ /* @__PURE__ */ jsx49(ComboboxList, { children: (path) => /* @__PURE__ */ jsx49(ComboboxItem, { value: path, children: /* @__PURE__ */ jsx49("span", { className: getClassName30("itemPath"), children: path }) }, path) })
7746
7742
  ] })
7747
7743
  ]
7748
7744
  }
@@ -8454,7 +8450,7 @@ var getLayoutClassName = get_class_name_factory_default("EditorLayout", styles_m
8454
8450
  var getPluginTabClassName = get_class_name_factory_default("EditorPluginTab", styles_module_default23);
8455
8451
  var FieldSideBarToolbar = () => {
8456
8452
  const appStore = useAppStoreApi();
8457
- const { onPublish } = usePropsContext();
8453
+ const { onPublish, currentRoute } = usePropsContext();
8458
8454
  const back = useAppStore((s) => s.history.back);
8459
8455
  const forward = useAppStore((s) => s.history.forward);
8460
8456
  const hasFuture = useAppStore((s) => s.history.hasFuture());
@@ -8490,7 +8486,7 @@ var FieldSideBarToolbar = () => {
8490
8486
  {
8491
8487
  onClick: () => {
8492
8488
  const data = appStore.getState().state.data;
8493
- onPublish && onPublish(data);
8489
+ onPublish && onPublish(data, currentRoute);
8494
8490
  },
8495
8491
  children: "Publish"
8496
8492
  }
@@ -9071,6 +9067,280 @@ Editor3.Layout = Layout;
9071
9067
  Editor3.Outline = Outline;
9072
9068
  Editor3.Preview = Preview2;
9073
9069
 
9070
+ // lib/use-stable-value.ts
9071
+ init_react_import();
9072
+ import { useRef as useRef20 } from "react";
9073
+ import { deepEqual as deepEqual3 } from "fast-equals";
9074
+ var useStableValue = (value) => {
9075
+ const ref = useRef20(value);
9076
+ if (!deepEqual3(ref.current, value)) {
9077
+ ref.current = value;
9078
+ }
9079
+ return ref.current;
9080
+ };
9081
+
9082
+ // components/App/context.ts
9083
+ init_react_import();
9084
+ import { createContext as createContext9, useContext as useContext16, useMemo as useMemo25 } from "react";
9085
+ import { matchRoutes, useLocation, useNavigate } from "react-router";
9086
+ var appConfigContext = createContext9(null);
9087
+ var useAppConfigContext = () => {
9088
+ const ctx = useContext16(appConfigContext);
9089
+ if (!ctx) {
9090
+ throw new Error("useApp must be called inside an <AppProvider> or <App>");
9091
+ }
9092
+ return ctx;
9093
+ };
9094
+ var stripPrefix = (path, prefix) => {
9095
+ if (path === prefix) return "/";
9096
+ if (!path.startsWith(`${prefix}/`)) return path;
9097
+ const rest = path.slice(prefix.length);
9098
+ return rest.startsWith("/") ? rest : `/${rest}`;
9099
+ };
9100
+ var useApp = () => {
9101
+ const cfg = useAppConfigContext();
9102
+ const location = useLocation();
9103
+ const rrNavigate = useNavigate();
9104
+ const currentPath = location.pathname || "/";
9105
+ const isEditing = cfg.editorPath !== null && (currentPath === cfg.editorPath || currentPath.startsWith(`${cfg.editorPath}/`));
9106
+ const matchRoute = isEditing ? stripPrefix(currentPath, cfg.editorPath) : currentPath;
9107
+ const matched = useMemo25(() => {
9108
+ const routeKeys = Object.keys(cfg.pages);
9109
+ if (routeKeys.length === 0) return null;
9110
+ const matches = matchRoutes(
9111
+ routeKeys.map((path) => ({ path })),
9112
+ matchRoute
9113
+ );
9114
+ if (!matches || matches.length === 0) return null;
9115
+ const last = matches[matches.length - 1];
9116
+ const key = last.route.path;
9117
+ return {
9118
+ route: key,
9119
+ params: last.params,
9120
+ data: cfg.pages[key]
9121
+ };
9122
+ }, [cfg.pages, matchRoute]);
9123
+ const routes = useMemo25(() => Object.keys(cfg.pages), [cfg.pages]);
9124
+ const navigate = (route) => {
9125
+ const target = isEditing && cfg.editorPath ? `${cfg.editorPath}${route === "/" ? "" : route}` || "/" : route;
9126
+ rrNavigate(target || "/");
9127
+ };
9128
+ return __spreadProps(__spreadValues({}, cfg), {
9129
+ routes,
9130
+ currentPath,
9131
+ isEditing,
9132
+ matchRoute,
9133
+ matched,
9134
+ navigate
9135
+ });
9136
+ };
9137
+
9138
+ // components/App/AppProvider.tsx
9139
+ init_react_import();
9140
+ import { useMemo as useMemo26 } from "react";
9141
+ import {
9142
+ BrowserRouter,
9143
+ HashRouter,
9144
+ MemoryRouter,
9145
+ StaticRouter
9146
+ } from "react-router";
9147
+ import { jsx as jsx57 } from "react/jsx-runtime";
9148
+ var EDITOR_PATH = "/editor";
9149
+ var isServer = typeof window === "undefined";
9150
+ function AppProvider({
9151
+ config,
9152
+ pages,
9153
+ editorPath = EDITOR_PATH,
9154
+ router = "browser",
9155
+ currentPath,
9156
+ children
9157
+ }) {
9158
+ const stablePages = useStableValue(pages);
9159
+ const resolvedEditorPath = editorPath === null ? null : editorPath || EDITOR_PATH;
9160
+ const ctxValue = useMemo26(
9161
+ () => ({
9162
+ config,
9163
+ pages: stablePages,
9164
+ editorPath: resolvedEditorPath
9165
+ }),
9166
+ [config, stablePages, resolvedEditorPath]
9167
+ );
9168
+ const inner = /* @__PURE__ */ jsx57(appConfigContext.Provider, { value: ctxValue, children });
9169
+ if (isServer) {
9170
+ return /* @__PURE__ */ jsx57(StaticRouter, { location: currentPath != null ? currentPath : "/", children: inner });
9171
+ }
9172
+ if (router === "hash") {
9173
+ return /* @__PURE__ */ jsx57(HashRouter, { children: inner });
9174
+ }
9175
+ if (router === "memory") {
9176
+ return /* @__PURE__ */ jsx57(MemoryRouter, { initialEntries: [currentPath != null ? currentPath : "/"], children: inner });
9177
+ }
9178
+ return /* @__PURE__ */ jsx57(BrowserRouter, { children: inner });
9179
+ }
9180
+
9181
+ // components/App/App.tsx
9182
+ init_react_import();
9183
+ import { Route, Routes } from "react-router";
9184
+ import { Fragment as Fragment16, jsx as jsx58, jsxs as jsxs25 } from "react/jsx-runtime";
9185
+ var joinEditorPath = (editorPath, route) => {
9186
+ if (route === "/") return editorPath;
9187
+ return `${editorPath}${route}`;
9188
+ };
9189
+ var DefaultNotFound = () => /* @__PURE__ */ jsx58(
9190
+ "div",
9191
+ {
9192
+ style: {
9193
+ display: "flex",
9194
+ height: "100vh",
9195
+ textAlign: "center",
9196
+ justifyContent: "center",
9197
+ alignItems: "center"
9198
+ },
9199
+ children: /* @__PURE__ */ jsxs25("div", { children: [
9200
+ /* @__PURE__ */ jsx58("h1", { children: "404" }),
9201
+ /* @__PURE__ */ jsx58("p", { children: "No page matches this route." })
9202
+ ] })
9203
+ }
9204
+ );
9205
+ function RenderRoute({
9206
+ routeKey,
9207
+ metadata
9208
+ }) {
9209
+ const { config, pages } = useApp();
9210
+ const data = pages[routeKey];
9211
+ if (!data) return null;
9212
+ return /* @__PURE__ */ jsx58(
9213
+ Render,
9214
+ {
9215
+ config,
9216
+ data,
9217
+ metadata
9218
+ },
9219
+ routeKey
9220
+ );
9221
+ }
9222
+ function EditorRouteRender({
9223
+ routeKey,
9224
+ layoutProps
9225
+ }) {
9226
+ const {
9227
+ onPublish,
9228
+ onChange,
9229
+ plugins,
9230
+ overrides,
9231
+ fieldTransforms,
9232
+ metadata,
9233
+ iframe,
9234
+ viewports,
9235
+ permissions
9236
+ } = layoutProps;
9237
+ const { config, pages, routes, navigate } = useApp();
9238
+ const data = pages[routeKey];
9239
+ if (!data) return null;
9240
+ return /* @__PURE__ */ jsx58(
9241
+ Editor3,
9242
+ {
9243
+ config,
9244
+ data,
9245
+ plugins,
9246
+ overrides,
9247
+ fieldTransforms,
9248
+ metadata,
9249
+ iframe,
9250
+ viewports,
9251
+ permissions,
9252
+ onChange,
9253
+ onPublish,
9254
+ routes,
9255
+ currentRoute: routeKey,
9256
+ onRouteChange: (next) => navigate(next)
9257
+ },
9258
+ routeKey
9259
+ );
9260
+ }
9261
+ function NotFoundRoute({
9262
+ renderNotFound
9263
+ }) {
9264
+ return renderNotFound ? /* @__PURE__ */ jsx58(Fragment16, { children: renderNotFound() }) : /* @__PURE__ */ jsx58(DefaultNotFound, {});
9265
+ }
9266
+ function AppLayout(layoutProps) {
9267
+ const { pages, editorPath } = useApp();
9268
+ const renderRoutes = Object.keys(pages);
9269
+ return /* @__PURE__ */ jsxs25(Routes, { children: [
9270
+ renderRoutes.map((routeKey) => /* @__PURE__ */ jsx58(
9271
+ Route,
9272
+ {
9273
+ path: routeKey,
9274
+ element: /* @__PURE__ */ jsx58(
9275
+ RenderRoute,
9276
+ {
9277
+ routeKey,
9278
+ metadata: layoutProps.metadata
9279
+ }
9280
+ )
9281
+ },
9282
+ `render:${routeKey}`
9283
+ )),
9284
+ editorPath !== null && renderRoutes.map((routeKey) => /* @__PURE__ */ jsx58(
9285
+ Route,
9286
+ {
9287
+ path: joinEditorPath(editorPath, routeKey),
9288
+ element: /* @__PURE__ */ jsx58(
9289
+ EditorRouteRender,
9290
+ {
9291
+ routeKey,
9292
+ layoutProps
9293
+ }
9294
+ )
9295
+ },
9296
+ `edit:${routeKey}`
9297
+ )),
9298
+ /* @__PURE__ */ jsx58(
9299
+ Route,
9300
+ {
9301
+ path: "*",
9302
+ element: /* @__PURE__ */ jsx58(NotFoundRoute, { renderNotFound: layoutProps.renderNotFound })
9303
+ }
9304
+ )
9305
+ ] });
9306
+ }
9307
+ function App(props) {
9308
+ const _a = props, {
9309
+ config,
9310
+ pages,
9311
+ currentPath,
9312
+ editorPath,
9313
+ router,
9314
+ children
9315
+ } = _a, layoutProps = __objRest(_a, [
9316
+ "config",
9317
+ "pages",
9318
+ "currentPath",
9319
+ "editorPath",
9320
+ "router",
9321
+ "children"
9322
+ ]);
9323
+ return /* @__PURE__ */ jsx58(
9324
+ AppProvider,
9325
+ {
9326
+ config,
9327
+ pages,
9328
+ currentPath,
9329
+ editorPath,
9330
+ router,
9331
+ children: children != null ? children : /* @__PURE__ */ jsx58(AppLayout, __spreadValues({}, layoutProps))
9332
+ }
9333
+ );
9334
+ }
9335
+
9336
+ // components/App/use-route-params.ts
9337
+ init_react_import();
9338
+ import { useParams } from "react-router";
9339
+ var useRouteParams = useParams;
9340
+
9341
+ // components/App/index.ts
9342
+ init_react_import();
9343
+
9074
9344
  // lib/page-metadata.ts
9075
9345
  init_react_import();
9076
9346
  function pageMetadata(data) {
@@ -9096,12 +9366,12 @@ function pageMetadata(data) {
9096
9366
 
9097
9367
  // plugins/legacy-side-bar/index.tsx
9098
9368
  init_react_import();
9099
- import { jsx as jsx57, jsxs as jsxs25 } from "react/jsx-runtime";
9369
+ import { jsx as jsx59, jsxs as jsxs26 } from "react/jsx-runtime";
9100
9370
  var legacySideBarPlugin = () => ({
9101
9371
  name: "legacy-side-bar",
9102
- render: () => /* @__PURE__ */ jsxs25("div", { style: { overflowY: "auto" }, children: [
9103
- /* @__PURE__ */ jsx57(SidebarSection, { title: "Components", noBorderTop: true, children: /* @__PURE__ */ jsx57(Components, {}) }),
9104
- /* @__PURE__ */ jsx57(SidebarSection, { title: "Outline", children: /* @__PURE__ */ jsx57(Outline, {}) })
9372
+ render: () => /* @__PURE__ */ jsxs26("div", { style: { overflowY: "auto" }, children: [
9373
+ /* @__PURE__ */ jsx59(SidebarSection, { title: "Components", noBorderTop: true, children: /* @__PURE__ */ jsx59(Components, {}) }),
9374
+ /* @__PURE__ */ jsx59(SidebarSection, { title: "Outline", children: /* @__PURE__ */ jsx59(Outline, {}) })
9105
9375
  ] })
9106
9376
  });
9107
9377
 
@@ -9166,6 +9436,12 @@ export {
9166
9436
  fieldsPlugin,
9167
9437
  usePropsContext,
9168
9438
  Editor3 as Editor,
9439
+ useStableValue,
9440
+ appConfigContext,
9441
+ useApp,
9442
+ AppProvider,
9443
+ App,
9444
+ useRouteParams,
9169
9445
  pageMetadata,
9170
9446
  legacySideBarPlugin
9171
9447
  };
@@ -1,9 +1,9 @@
1
+ import {
2
+ LoadedRichTextMenuInner
3
+ } from "./chunk-BUR5T7IX.mjs";
1
4
  import {
2
5
  styles_module_default
3
6
  } from "./chunk-6QJ2HF4O.mjs";
4
- import {
5
- LoadedRichTextMenuInner
6
- } from "./chunk-U7VW3V3W.mjs";
7
7
  import {
8
8
  useAppStore,
9
9
  useAppStoreApi
@@ -100,7 +100,7 @@ init_react_import();
100
100
  import { lazy, Suspense } from "react";
101
101
  import { jsx as jsx2 } from "react/jsx-runtime";
102
102
  var LoadedRichTextMenuFull = lazy(
103
- () => import("./full-ZFZZ626B.mjs").then((m) => ({
103
+ () => import("./full-QT5KXRDP.mjs").then((m) => ({
104
104
  default: m.LoadedRichTextMenuFull
105
105
  }))
106
106
  );
@@ -24,6 +24,50 @@ import {
24
24
  init_react_import
25
25
  } from "./chunk-M6W7YEVX.mjs";
26
26
 
27
+ // lib/get-route-props.ts
28
+ init_react_import();
29
+ import { matchRoutes } from "react-router";
30
+ var DEFAULT_EDITOR_PATH = "/editor";
31
+ var stripEditorPrefix = (currentRoute, editorPath) => {
32
+ if (!editorPath) return currentRoute;
33
+ if (currentRoute === editorPath) return "/";
34
+ if (!currentRoute.startsWith(`${editorPath}/`)) return currentRoute;
35
+ const rest = currentRoute.slice(editorPath.length);
36
+ return rest.startsWith("/") ? rest : `/${rest}`;
37
+ };
38
+ var findMatch = (pages, pathname) => {
39
+ const keys = Object.keys(pages);
40
+ if (keys.length === 0) return null;
41
+ const matches = matchRoutes(
42
+ keys.map((path) => ({ path })),
43
+ pathname
44
+ );
45
+ if (!matches || matches.length === 0) return null;
46
+ const last = matches[matches.length - 1];
47
+ const key = last.route.path;
48
+ return { route: key, params: last.params, data: pages[key] };
49
+ };
50
+ var getRouteProps = (pages, currentRoute, options = {}) => {
51
+ var _a, _b;
52
+ const editorPath = options.editorPath === void 0 ? DEFAULT_EDITOR_PATH : options.editorPath;
53
+ const matchRoute = stripEditorPrefix(currentRoute || "/", editorPath);
54
+ const match = findMatch(pages, matchRoute);
55
+ if (!match) return null;
56
+ const props = (_b = (_a = match.data) == null ? void 0 : _a.root) == null ? void 0 : _b.props;
57
+ return props != null ? props : null;
58
+ };
59
+ var resolveRouteFromString = (pages, currentRoute, options = {}) => {
60
+ const editorPath = options.editorPath === void 0 ? DEFAULT_EDITOR_PATH : options.editorPath;
61
+ const matchRoute = stripEditorPrefix(currentRoute || "/", editorPath);
62
+ const match = findMatch(pages, matchRoute);
63
+ if (!match) return null;
64
+ return {
65
+ route: match.route,
66
+ data: match.data,
67
+ params: match.params
68
+ };
69
+ };
70
+
27
71
  // lib/migrate.ts
28
72
  init_react_import();
29
73
  var migrations = [
@@ -470,6 +514,8 @@ export {
470
514
  useRichtextProps,
471
515
  SlotRenderPure,
472
516
  SlotRender,
517
+ getRouteProps,
518
+ resolveRouteFromString,
473
519
  migrate,
474
520
  transformProps,
475
521
  resolveAllData
@@ -1,9 +1,9 @@
1
1
  import {
2
2
  LoadedRichTextMenuInner
3
- } from "./chunk-U7VW3V3W.mjs";
3
+ } from "./chunk-BUR5T7IX.mjs";
4
+ import "./chunk-FT6UFK7G.mjs";
4
5
  import "./chunk-OIFPBVSF.mjs";
5
6
  import "./chunk-AD7BMXAA.mjs";
6
- import "./chunk-FT6UFK7G.mjs";
7
7
  import "./chunk-LRFRIIKG.mjs";
8
8
  import "./chunk-M4JDRFYB.mjs";
9
9
  import "./chunk-IIRJMJFU.mjs";
@@ -1,4 +1,4 @@
1
- import { H as History, f as Permissions, b as ComponentData, C as Config, U as UserGenerics, F as Fields, E as EditorAction, g as RootDataWithProps, h as ResolveDataTrigger, i as Plugin, j as Overrides, V as Viewports, I as IframeConfig, k as UiState, l as ComponentConfig, A as AppState, M as Metadata, m as FieldTransforms, n as RichtextField } from './actions-2L-1hQ7r.js';
1
+ import { H as History, a as Permissions, b as ComponentData, C as Config, U as UserGenerics, F as Fields, E as EditorAction, R as RootDataWithProps, c as ResolveDataTrigger, d as Plugin, e as Overrides, V as Viewports, I as IframeConfig, f as UiState, g as ComponentConfig, A as AppState, M as Metadata, h as FieldTransforms, i as RichtextField } from './actions-B8_EA7vy.js';
2
2
  import { Editor } from '@tiptap/react';
3
3
 
4
4
  type HistorySlice<D = any> = {
@@ -1,4 +1,4 @@
1
- import { H as History, f as Permissions, b as ComponentData, C as Config, U as UserGenerics, F as Fields, E as EditorAction, g as RootDataWithProps, h as ResolveDataTrigger, i as Plugin, j as Overrides, V as Viewports, I as IframeConfig, k as UiState, l as ComponentConfig, A as AppState, M as Metadata, m as FieldTransforms, n as RichtextField } from './actions-2L-1hQ7r.mjs';
1
+ import { H as History, a as Permissions, b as ComponentData, C as Config, U as UserGenerics, F as Fields, E as EditorAction, R as RootDataWithProps, c as ResolveDataTrigger, d as Plugin, e as Overrides, V as Viewports, I as IframeConfig, f as UiState, g as ComponentConfig, A as AppState, M as Metadata, h as FieldTransforms, i as RichtextField } from './actions-B8_EA7vy.mjs';
2
2
  import { Editor } from '@tiptap/react';
3
3
 
4
4
  type HistorySlice<D = any> = {