@reacteditor/core 0.0.16 → 0.0.18

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 (34) hide show
  1. package/dist/{Editor-4LPVLYSU.css → Editor-IRCQF4VT.css} +10 -16
  2. package/dist/{Editor-J7XDD77B.mjs → Editor-ULH2S4LO.mjs} +7 -7
  3. package/dist/{Render-STFB5CNO.mjs → Render-IDDFFANP.mjs} +1 -1
  4. package/dist/{chunk-4L7H4JV4.mjs → chunk-AD67LVXW.mjs} +2 -2
  5. package/dist/{chunk-RGC274VM.mjs → chunk-DGIVBKSJ.mjs} +1 -1
  6. package/dist/{chunk-Y2EFNT5P.mjs → chunk-DQU3HIP4.mjs} +16 -6
  7. package/dist/{chunk-RQZQMS6E.mjs → chunk-HR67L662.mjs} +1 -1
  8. package/dist/{chunk-TG2KTWSB.mjs → chunk-IOAYKTDH.mjs} +1 -1
  9. package/dist/{chunk-JHURG5NN.mjs → chunk-LFJGTSUB.mjs} +14 -2
  10. package/dist/{chunk-5QKQ3LQJ.mjs → chunk-NABX5FH7.mjs} +4 -4
  11. package/dist/{chunk-Q667J2EG.mjs → chunk-UQHR5LFK.mjs} +130 -29
  12. package/dist/{chunk-3NSI5XES.mjs → chunk-WUEYD7ZN.mjs} +60 -47
  13. package/dist/{full-7ABPY2WA.css → full-B5V3G4IY.css} +10 -16
  14. package/dist/{full-T5SGODJ2.mjs → full-LIVYWOAF.mjs} +6 -6
  15. package/dist/{index-BZRpxcwy.d.mts → index-CUe2XTb6.d.mts} +28 -1
  16. package/dist/{index-B_21fGrq.d.ts → index-CYzc1n29.d.ts} +28 -1
  17. package/dist/index.css +10 -16
  18. package/dist/index.d.mts +35 -20
  19. package/dist/index.d.ts +35 -20
  20. package/dist/index.js +194 -59
  21. package/dist/index.mjs +9 -9
  22. package/dist/internal.d.mts +1 -1
  23. package/dist/internal.d.ts +1 -1
  24. package/dist/{loaded-ZQCRSG65.mjs → loaded-FZVSXAM7.mjs} +3 -3
  25. package/dist/{loaded-DUBT6SP5.mjs → loaded-MSWM6QEM.mjs} +3 -3
  26. package/dist/{loaded-6YKSFCCD.mjs → loaded-PYHJ6TB5.mjs} +3 -3
  27. package/dist/no-external.css +10 -16
  28. package/dist/no-external.d.mts +2 -2
  29. package/dist/no-external.d.ts +2 -2
  30. package/dist/no-external.js +194 -59
  31. package/dist/no-external.mjs +9 -9
  32. package/dist/rsc.js +16 -6
  33. package/dist/rsc.mjs +2 -2
  34. package/package.json +1 -1
package/dist/index.d.ts CHANGED
@@ -1,10 +1,10 @@
1
1
  import { D as Data, o as Field, p as FieldProps, C as Config, U as UserGenerics, O as OnAction, f as UiState, q as EditorChromeConfig, d as Plugin, e as Overrides, h as FieldTransforms, M as Metadata, I as IframeConfig, V as Viewports, a as Permissions, E as EditorAction, r as InitialHistory, b as ComponentData, l as DefaultComponentProps, m as DefaultRootFieldProps, c as ResolveDataTrigger, s as ItemSelector, t as PluginInternal } from './actions-BxLinRKD.js';
2
2
  export { u as Adaptor, A as AppState, v as ArrayField, w as ArrayState, x as AsFieldProps, B as BaseData, y as BaseField, z as CacheOpts, G as ColorField, g as ComponentConfig, J as ComponentConfigExtensions, K as ComponentConfigParams, L as ComponentDataMap, N as ComponentDataOptionalId, Q as ComponentMetadata, S as ConfigParams, j as Content, T as CustomField, X as CustomFieldRender, k as DefaultComponents, Y as DefaultRootProps, Z as DefaultRootRenderProps, _ as Direction, $ as DragAxis, a0 as EditorComponent, a1 as EditorContext, a2 as EditorMetadata, a3 as ExternalField, a4 as ExternalFieldWithAdaptor, a5 as ExtractConfigParams, a6 as ExtractField, a7 as FieldMetadata, a8 as FieldRenderFunctions, a9 as FieldTransformFn, aa as FieldTransformFnParams, F as Fields, H as History, ab as ItemWithId, ac as MappedItem, ad as NumberField, ae as ObjectField, af as OverrideKey, ag as RadioField, ah as RichText, i as RichtextField, ai as RootConfig, n as RootData, R as RootDataWithProps, aj as RootDataWithoutProps, ak as SelectField, al as Slot, am as SlotComponent, an as SlotField, ao as TextField, ap as TextareaField, aq as Viewport, ar as WithChildren, as as WithEditorProps, W as WithId, at as WithSlotProps, au as overrideKeys } from './actions-BxLinRKD.js';
3
3
  export { G as GetRoutePropsOptions, g as getRouteProps, m as migrate, r as resolveAllData, a as resolveRouteFromString, t as transformProps, w as walkTree } from './walk-tree-Clklc1Ql.js';
4
+ import { O as OnPublish, E as EditorRoute, A as AppStore, G as GetPermissions, R as RefreshPermissions, H as HistorySlice } from './index-CYzc1n29.js';
4
5
  import * as react_jsx_runtime from 'react/jsx-runtime';
5
6
  import * as react from 'react';
6
7
  import react__default, { ReactNode, SyntheticEvent, ReactElement, CSSProperties } from 'react';
7
- import { A as AppStore, G as GetPermissions, R as RefreshPermissions, H as HistorySlice } from './index-B_21fGrq.js';
8
8
  import '@tiptap/react';
9
9
  import '@tiptap/extension-blockquote';
10
10
  import '@tiptap/extension-bold';
@@ -34,8 +34,8 @@ type GlobalsMap = NonNullable<Data["globals"]>;
34
34
  * the picker entry in `<Editor routes>`. The same string flows through:
35
35
  * - `pages={{ [routeKey]: pageData }}` declares the schema
36
36
  * - `<Editor routes={[routeKey, ...]}>` powers the page picker
37
- * - `<Editor currentPath={routeKey}>` marks the selected page
38
- * - `onPublish(data, routeKey)` returns it for persistence
37
+ * - `<Editor route={{ key: routeKey, path, params }}>` marks the selected page
38
+ * - `onPublish({ data, route })` returns the descriptor for persistence
39
39
  *
40
40
  * Patterns follow path-to-regexp v8 / Express 5 syntax: "/", "/about",
41
41
  * "/products/:handle", "/docs/*splat".
@@ -93,13 +93,18 @@ declare function AutoField<ValueType = any, FieldType extends FieldNoLabel<Value
93
93
 
94
94
  /** A route key — the literal pattern used in `pages`. */
95
95
  type RouteKey = string;
96
- type AppMatched<Data = unknown> = {
97
- /** The route key stringstable persistence identifier. */
98
- route: RouteKey;
96
+ /**
97
+ * Routing descriptor for the current page. Pure routing info no page data
98
+ * (use `pages[route.key]` for the static initial, or `useEditor((s) => s.appState.data)`
99
+ * for the live editor data).
100
+ */
101
+ type AppRoute = {
102
+ /** Route key/pattern, e.g. "/posts/:handle". */
103
+ key: RouteKey;
104
+ /** Canonical page URL with `editorPath` stripped, e.g. "/posts/abc". */
105
+ path: string;
99
106
  /** Concrete params extracted from the URL (e.g. { handle: "abc" }). */
100
107
  params: Readonly<Record<string, string | undefined>>;
101
- /** The page's data. */
102
- data: Data;
103
108
  };
104
109
  type AppConfigContext<UserConfig extends Config = Config, G extends UserGenerics<UserConfig> = UserGenerics<UserConfig>> = {
105
110
  config: UserConfig;
@@ -111,14 +116,10 @@ declare const appConfigContext: react.Context<AppConfigContext<Config, UserGener
111
116
  type AppContextValue<UserConfig extends Config = Config, G extends UserGenerics<UserConfig> = UserGenerics<UserConfig>> = AppConfigContext<UserConfig, G> & {
112
117
  /** All page route keys, in declaration order. */
113
118
  routes: RouteKey[];
114
- /** Resolved current pathname from React Router. */
115
- currentPath: string;
116
- /** True when currentPath starts with editorPath. */
119
+ /** True when the live URL is under `editorPath`. */
117
120
  isEditing: boolean;
118
- /** The URL relative to editorPath when isEditing what pages are matched against. */
119
- matchRoute: string;
120
- /** Result of matching matchRoute against pages. Null = 404. */
121
- matched: AppMatched<Partial<G["UserData"] | Data>> | null;
121
+ /** Resolved routing descriptor for the current page. Null = 404. */
122
+ route: AppRoute | null;
122
123
  /** Navigate to a route key. Wraps with editorPath when editing. */
123
124
  navigate: (route: RouteKey) => void;
124
125
  };
@@ -149,8 +150,8 @@ declare function AppProvider<UserConfig extends Config = Config, G extends UserG
149
150
 
150
151
  /** Editor pass-through props shared by <App> (default layout) and <App.Editor>. */
151
152
  type EditorPassthroughProps<UserConfig extends Config = Config, G extends UserGenerics<UserConfig> = UserGenerics<UserConfig>> = {
152
- /** Called when the editor publishes. `route` is the schema route key. */
153
- onPublish?: (data: G["UserData"], route?: string) => void;
153
+ /** Called when the editor publishes receives `{ data, route }`. */
154
+ onPublish?: OnPublish<G["UserData"]>;
154
155
  onChange?: (data: G["UserData"]) => void;
155
156
  onAction?: OnAction<G["UserData"]>;
156
157
  ui?: Partial<UiState> & Partial<EditorChromeConfig>;
@@ -296,7 +297,7 @@ type EditorProps<UserConfig extends Config = Config, G extends UserGenerics<User
296
297
  */
297
298
  ui?: Partial<UiState> & Partial<EditorChromeConfig>;
298
299
  onChange?: (data: G["UserData"]) => void;
299
- onPublish?: (data: G["UserData"], route?: string) => void;
300
+ onPublish?: OnPublish<G["UserData"]>;
300
301
  onAction?: OnAction<G["UserData"]>;
301
302
  permissions?: Partial<Permissions>;
302
303
  plugins?: Plugin<UserConfig>[];
@@ -315,7 +316,12 @@ type EditorProps<UserConfig extends Config = Config, G extends UserGenerics<User
315
316
  headerPath?: string;
316
317
  title?: ReactNode;
317
318
  routes?: Route[];
318
- currentRoute?: string;
319
+ /**
320
+ * Routing descriptor for the page being edited. Mirrored into the editor
321
+ * store and exposed via `useEditor((s) => s.route)`. Set by `<App>` from
322
+ * `useApp().route`; usually omitted when mounting `<Editor>` standalone.
323
+ */
324
+ route?: EditorRoute;
319
325
  onRouteChange?: (path: string) => void | Promise<void>;
320
326
  viewports?: Viewports;
321
327
  iframe?: IframeConfig;
@@ -501,11 +507,20 @@ type EditorCommands = {
501
507
  updateRoot: (updater: Partial<DefaultRootFieldProps> | ((prev: DefaultRootFieldProps) => Partial<DefaultRootFieldProps>)) => void;
502
508
  selectComponent: (id: string | null) => void;
503
509
  scrollToComponent: (id: string) => void;
510
+ /**
511
+ * Invoke the user's `onPublish` callback with the current editor data and
512
+ * route descriptor. No-op when `onPublish` isn't set on the Editor.
513
+ */
514
+ publish: () => void;
504
515
  };
505
516
 
506
517
  type UseEditorData<UserConfig extends Config = Config, G extends UserGenerics<UserConfig> = UserGenerics<UserConfig>> = EditorCommands & {
507
518
  appState: G["UserPublicAppState"];
508
519
  config: UserConfig;
520
+ /** Routing descriptor for the page being edited. Null when standalone or 404. */
521
+ route: EditorRoute | null;
522
+ /** True while a `publish()` call is in flight. */
523
+ isPublishing: boolean;
509
524
  dispatch: AppStore["dispatch"];
510
525
  getPermissions: GetPermissions<UserConfig>;
511
526
  refreshPermissions: RefreshPermissions<UserConfig>;
@@ -557,4 +572,4 @@ declare const outlinePlugin: () => Plugin;
557
572
 
558
573
  declare const legacySideBarPlugin: () => Plugin;
559
574
 
560
- export { Action, ActionBar, App, type AppContextValue, type AppEditorProps, type AppMatched, type AppProps, AppProvider, type AppProviderProps, type AppRenderProps, type AppRouterVariant, AutoField, Button, ComponentData, ComponentList, Config, Data, DefaultComponentProps, DefaultRootFieldProps, Drawer, Editor, EditorAction, type EditorApi, EditorChromeConfig, type EditorCommands, Field, FieldLabel, FieldProps, FieldTransforms, type GlobalsMap, Group, IconButton, IframeConfig, InitialHistory, type InsertComponentArgs, Label, Metadata, type MoveDestination, OnAction, Overrides, type PageMetadata, type Parent, Permissions, Plugin, Render, ResolveDataTrigger, RichTextMenu, type Route, type RouteKey, Separator, UiState, type UseEditorData, UserGenerics, Viewports, appConfigContext, blocksPlugin, createUseEditor, fieldsPlugin, legacySideBarPlugin, outlinePlugin, pageMetadata, registerOverlayPortal, renderContext, setDeep, useApp, useEditor, useGetEditor, usePropsContext, useRouteParams, useStableValue };
575
+ export { Action, ActionBar, App, type AppContextValue, type AppEditorProps, type AppProps, AppProvider, type AppProviderProps, type AppRenderProps, type AppRoute, type AppRouterVariant, AutoField, Button, ComponentData, ComponentList, Config, Data, DefaultComponentProps, DefaultRootFieldProps, Drawer, Editor, EditorAction, type EditorApi, EditorChromeConfig, type EditorCommands, EditorRoute, Field, FieldLabel, FieldProps, FieldTransforms, type GlobalsMap, Group, IconButton, IframeConfig, InitialHistory, type InsertComponentArgs, Label, Metadata, type MoveDestination, OnAction, OnPublish, Overrides, type PageMetadata, type Parent, Permissions, Plugin, Render, ResolveDataTrigger, RichTextMenu, type Route, type RouteKey, Separator, UiState, type UseEditorData, UserGenerics, Viewports, appConfigContext, blocksPlugin, createUseEditor, fieldsPlugin, legacySideBarPlugin, outlinePlugin, pageMetadata, registerOverlayPortal, renderContext, setDeep, useApp, useEditor, useGetEditor, usePropsContext, useRouteParams, useStableValue };
package/dist/index.js CHANGED
@@ -160,19 +160,29 @@ var init_get_class_name_factory = __esm({
160
160
  "use strict";
161
161
  init_react_import();
162
162
  import_classnames = __toESM(require_classnames());
163
- getClassNameFactory = (rootClass, styles2, config = { baseClass: "" }) => (options = {}) => {
163
+ getClassNameFactory = (rootClass, styles2, config = { baseClass: "" }) => (options = {}, modifiers) => {
164
164
  if (typeof options === "string") {
165
165
  const descendant = options;
166
- const style = styles2[`${rootClass}-${descendant}`];
166
+ const baseKey = `${rootClass}-${descendant}`;
167
+ const style = styles2[baseKey];
168
+ if (modifiers) {
169
+ const prefixedModifiers = {};
170
+ for (let modifier in modifiers) {
171
+ prefixedModifiers[styles2[`${baseKey}--${modifier}`]] = modifiers[modifier];
172
+ }
173
+ return config.baseClass + (0, import_classnames.default)(__spreadValues({
174
+ [style]: !!style
175
+ }, prefixedModifiers));
176
+ }
167
177
  if (style) {
168
- return config.baseClass + styles2[`${rootClass}-${descendant}`] || "";
178
+ return config.baseClass + style;
169
179
  }
170
180
  return "";
171
181
  } else if (typeof options === "object") {
172
- const modifiers = options;
182
+ const modifiers2 = options;
173
183
  const prefixedModifiers = {};
174
- for (let modifier in modifiers) {
175
- prefixedModifiers[styles2[`${rootClass}--${modifier}`]] = modifiers[modifier];
184
+ for (let modifier in modifiers2) {
185
+ prefixedModifiers[styles2[`${rootClass}--${modifier}`]] = modifiers2[modifier];
176
186
  }
177
187
  const c = styles2[rootClass];
178
188
  return config.baseClass + (0, import_classnames.default)(__spreadValues({
@@ -3245,7 +3255,19 @@ var init_store = __esm({
3245
3255
  metadata: {},
3246
3256
  fieldTransforms: {},
3247
3257
  scrollToComponent: () => {
3248
- }
3258
+ },
3259
+ route: null,
3260
+ isPublishing: false,
3261
+ publish: () => __async(null, null, function* () {
3262
+ const { onPublish, state, route } = get();
3263
+ if (!onPublish) return;
3264
+ set({ isPublishing: true });
3265
+ try {
3266
+ yield onPublish({ data: state.data, route });
3267
+ } finally {
3268
+ set({ isPublishing: false });
3269
+ }
3270
+ })
3249
3271
  }, initialAppStore), {
3250
3272
  fields: createFieldsSlice(set, get),
3251
3273
  history: createHistorySlice(set, get),
@@ -3590,12 +3612,12 @@ var init_styles_module2 = __esm({
3590
3612
  "use strict";
3591
3613
  init_react_import();
3592
3614
  init_css_module_data3();
3593
- styles_module_default4 = { "Loader": "_Loader_nacdm_13", "loader-animation": "_loader-animation_nacdm_1" };
3615
+ styles_module_default4 = { "Loader": "_Loader_6933g_10", "loader-spin": "_loader-spin_6933g_1" };
3594
3616
  }
3595
3617
  });
3596
3618
 
3597
3619
  // components/Loader/index.tsx
3598
- var import_jsx_runtime3, getClassName2, Loader;
3620
+ var import_jsx_runtime3, getClassName2, LoaderIcon, Loader;
3599
3621
  var init_Loader = __esm({
3600
3622
  "components/Loader/index.tsx"() {
3601
3623
  "use strict";
@@ -3604,25 +3626,125 @@ var init_Loader = __esm({
3604
3626
  init_styles_module2();
3605
3627
  import_jsx_runtime3 = require("react/jsx-runtime");
3606
3628
  getClassName2 = get_class_name_factory_default("Loader", styles_module_default4);
3629
+ LoaderIcon = ({ size = 16 }) => /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)(
3630
+ "svg",
3631
+ {
3632
+ height: size,
3633
+ strokeLinejoin: "round",
3634
+ style: { color: "currentcolor" },
3635
+ viewBox: "0 0 16 16",
3636
+ width: size,
3637
+ "aria-hidden": "true",
3638
+ children: [
3639
+ /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)("g", { clipPath: "url(#editor-loader-clip)", children: [
3640
+ /* @__PURE__ */ (0, import_jsx_runtime3.jsx)("path", { d: "M8 0V4", stroke: "currentColor", strokeWidth: "1.5" }),
3641
+ /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
3642
+ "path",
3643
+ {
3644
+ d: "M8 16V12",
3645
+ opacity: "0.5",
3646
+ stroke: "currentColor",
3647
+ strokeWidth: "1.5"
3648
+ }
3649
+ ),
3650
+ /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
3651
+ "path",
3652
+ {
3653
+ d: "M3.29773 1.52783L5.64887 4.7639",
3654
+ opacity: "0.9",
3655
+ stroke: "currentColor",
3656
+ strokeWidth: "1.5"
3657
+ }
3658
+ ),
3659
+ /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
3660
+ "path",
3661
+ {
3662
+ d: "M12.7023 1.52783L10.3511 4.7639",
3663
+ opacity: "0.1",
3664
+ stroke: "currentColor",
3665
+ strokeWidth: "1.5"
3666
+ }
3667
+ ),
3668
+ /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
3669
+ "path",
3670
+ {
3671
+ d: "M12.7023 14.472L10.3511 11.236",
3672
+ opacity: "0.4",
3673
+ stroke: "currentColor",
3674
+ strokeWidth: "1.5"
3675
+ }
3676
+ ),
3677
+ /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
3678
+ "path",
3679
+ {
3680
+ d: "M3.29773 14.472L5.64887 11.236",
3681
+ opacity: "0.6",
3682
+ stroke: "currentColor",
3683
+ strokeWidth: "1.5"
3684
+ }
3685
+ ),
3686
+ /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
3687
+ "path",
3688
+ {
3689
+ d: "M15.6085 5.52783L11.8043 6.7639",
3690
+ opacity: "0.2",
3691
+ stroke: "currentColor",
3692
+ strokeWidth: "1.5"
3693
+ }
3694
+ ),
3695
+ /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
3696
+ "path",
3697
+ {
3698
+ d: "M0.391602 10.472L4.19583 9.23598",
3699
+ opacity: "0.7",
3700
+ stroke: "currentColor",
3701
+ strokeWidth: "1.5"
3702
+ }
3703
+ ),
3704
+ /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
3705
+ "path",
3706
+ {
3707
+ d: "M15.6085 10.4722L11.8043 9.2361",
3708
+ opacity: "0.3",
3709
+ stroke: "currentColor",
3710
+ strokeWidth: "1.5"
3711
+ }
3712
+ ),
3713
+ /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
3714
+ "path",
3715
+ {
3716
+ d: "M0.391602 5.52783L4.19583 6.7639",
3717
+ opacity: "0.8",
3718
+ stroke: "currentColor",
3719
+ strokeWidth: "1.5"
3720
+ }
3721
+ )
3722
+ ] }),
3723
+ /* @__PURE__ */ (0, import_jsx_runtime3.jsx)("defs", { children: /* @__PURE__ */ (0, import_jsx_runtime3.jsx)("clipPath", { id: "editor-loader-clip", children: /* @__PURE__ */ (0, import_jsx_runtime3.jsx)("rect", { fill: "white", height: "16", width: "16" }) }) })
3724
+ ]
3725
+ }
3726
+ );
3607
3727
  Loader = (_a) => {
3608
3728
  var _b = _a, {
3609
3729
  color,
3610
- size = 16
3730
+ size = 16,
3731
+ className,
3732
+ style
3611
3733
  } = _b, props = __objRest(_b, [
3612
3734
  "color",
3613
- "size"
3735
+ "size",
3736
+ "className",
3737
+ "style"
3614
3738
  ]);
3615
3739
  return /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
3616
- "span",
3617
- __spreadValues({
3618
- className: getClassName2(),
3619
- style: {
3620
- width: size,
3621
- height: size,
3622
- color
3623
- },
3740
+ "div",
3741
+ __spreadProps(__spreadValues({
3742
+ className: [getClassName2(), className].filter(Boolean).join(" "),
3743
+ style: __spreadValues({ color }, style),
3624
3744
  "aria-label": "loading"
3625
- }, props)
3745
+ }, props), {
3746
+ children: /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(LoaderIcon, { size })
3747
+ })
3626
3748
  );
3627
3749
  };
3628
3750
  }
@@ -6946,9 +7068,8 @@ var Button = (_a) => {
6946
7068
  href
6947
7069
  }, dataAttrs), {
6948
7070
  children: [
6949
- icon && /* @__PURE__ */ (0, import_jsx_runtime14.jsx)("div", { className: getClassName10("icon"), children: icon }),
6950
- children,
6951
- loading && /* @__PURE__ */ (0, import_jsx_runtime14.jsx)("div", { className: getClassName10("spinner"), children: /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(Loader, { size: 14 }) })
7071
+ loading ? /* @__PURE__ */ (0, import_jsx_runtime14.jsx)("div", { className: getClassName10("spinner"), children: /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(Loader, { size: 14 }) }) : icon && /* @__PURE__ */ (0, import_jsx_runtime14.jsx)("div", { className: getClassName10("icon"), children: icon }),
7072
+ children
6952
7073
  ]
6953
7074
  })
6954
7075
  );
@@ -12797,6 +12918,9 @@ var createEditorCommands = (appStore) => {
12797
12918
  ui: { itemSelector: { index: sel.index, zone: sel.zone } }
12798
12919
  });
12799
12920
  };
12921
+ const publish = () => {
12922
+ void getState().publish();
12923
+ };
12800
12924
  return {
12801
12925
  insertComponent: insertComponent2,
12802
12926
  removeComponent,
@@ -12806,7 +12930,8 @@ var createEditorCommands = (appStore) => {
12806
12930
  updateProps,
12807
12931
  updateRoot,
12808
12932
  selectComponent,
12809
- scrollToComponent
12933
+ scrollToComponent,
12934
+ publish
12810
12935
  };
12811
12936
  };
12812
12937
 
@@ -12825,6 +12950,8 @@ var generateUseEditor = (store, getState, commands) => {
12825
12950
  const storeData = __spreadProps(__spreadValues({}, commands), {
12826
12951
  appState: makeStatePublic(store.state),
12827
12952
  config: store.config,
12953
+ route: store.route,
12954
+ isPublishing: store.isPublishing,
12828
12955
  dispatch: store.dispatch,
12829
12956
  getPermissions: store.permissions.getPermissions,
12830
12957
  refreshPermissions: store.permissions.refreshPermissions,
@@ -12859,7 +12986,9 @@ var convertToPickedStore = (store) => {
12859
12986
  dispatch: store.dispatch,
12860
12987
  permissions: store.permissions,
12861
12988
  history: store.history,
12862
- selectedItem: store.selectedItem
12989
+ selectedItem: store.selectedItem,
12990
+ route: store.route,
12991
+ isPublishing: store.isPublishing
12863
12992
  };
12864
12993
  };
12865
12994
  var useRegisterUseEditorStore = (appStore) => {
@@ -13301,18 +13430,19 @@ var DEVICE_VIEWPORTS = {
13301
13430
  mobile: { width: 360, height: "auto", icon: "Smartphone", label: "Mobile" }
13302
13431
  };
13303
13432
  var UrlBar = () => {
13304
- const { routes, currentRoute, onRouteChange } = usePropsContext();
13433
+ const { routes, route, onRouteChange } = usePropsContext();
13305
13434
  const chrome = useChromeConfig();
13306
- const showRoutePicker = !!routes && currentRoute !== void 0 && !!onRouteChange;
13307
- const [inputValue, setInputValue] = (0, import_react87.useState)(currentRoute != null ? currentRoute : "");
13308
- const lastSyncedPath = (0, import_react87.useRef)(currentRoute);
13309
- if (lastSyncedPath.current !== currentRoute) {
13310
- lastSyncedPath.current = currentRoute;
13311
- setInputValue(currentRoute != null ? currentRoute : "");
13435
+ const currentKey = route == null ? void 0 : route.key;
13436
+ const showRoutePicker = !!routes && currentKey !== void 0 && !!onRouteChange;
13437
+ const [inputValue, setInputValue] = (0, import_react87.useState)(currentKey != null ? currentKey : "");
13438
+ const lastSyncedPath = (0, import_react87.useRef)(currentKey);
13439
+ if (lastSyncedPath.current !== currentKey) {
13440
+ lastSyncedPath.current = currentKey;
13441
+ setInputValue(currentKey != null ? currentKey : "");
13312
13442
  }
13313
13443
  const submit = (raw) => {
13314
13444
  const next = normalizeRoute(raw);
13315
- if (!next || next === currentRoute) return;
13445
+ if (!next || next === currentKey) return;
13316
13446
  void (onRouteChange == null ? void 0 : onRouteChange(next));
13317
13447
  };
13318
13448
  if (!chrome.showUrlBar) return null;
@@ -13321,7 +13451,7 @@ var UrlBar = () => {
13321
13451
  Combobox,
13322
13452
  {
13323
13453
  items: routes,
13324
- value: currentRoute,
13454
+ value: currentKey,
13325
13455
  onValueChange: (next) => {
13326
13456
  if (typeof next === "string") submit(next);
13327
13457
  },
@@ -14155,12 +14285,12 @@ var TopHeader = ({
14155
14285
  pluginItems
14156
14286
  }) => {
14157
14287
  const appStore = useAppStoreApi();
14158
- const { onPublish, currentRoute } = usePropsContext();
14159
14288
  const chrome = useChromeConfig();
14160
14289
  const back = useAppStore((s) => s.history.back);
14161
14290
  const forward = useAppStore((s) => s.history.forward);
14162
14291
  const hasFuture = useAppStore((s) => s.history.hasFuture());
14163
14292
  const hasPast = useAppStore((s) => s.history.hasPast());
14293
+ const isPublishing = useAppStore((s) => s.isPublishing);
14164
14294
  const CustomHeaderActions = useAppStore(
14165
14295
  (s) => s.overrides.headerActions || DefaultOverride
14166
14296
  );
@@ -14212,11 +14342,8 @@ var TopHeader = ({
14212
14342
  /* @__PURE__ */ (0, import_jsx_runtime91.jsx)(CustomHeaderActions, { children: /* @__PURE__ */ (0, import_jsx_runtime91.jsx)(
14213
14343
  Button,
14214
14344
  {
14215
- onClick: () => {
14216
- const data = appStore.getState().state.data;
14217
- onPublish && onPublish(data, currentRoute);
14218
- },
14219
- children: "Publish"
14345
+ onClick: () => appStore.getState().publish(),
14346
+ children: isPublishing ? "Publishing\u2026" : "Publish"
14220
14347
  }
14221
14348
  ) })
14222
14349
  ] })
@@ -14638,6 +14765,7 @@ function EditorProvider({ children }) {
14638
14765
  data: initialData,
14639
14766
  ui: initialUi,
14640
14767
  onChange,
14768
+ onPublish,
14641
14769
  permissions = {},
14642
14770
  plugins,
14643
14771
  overrides,
@@ -14648,7 +14776,8 @@ function EditorProvider({ children }) {
14648
14776
  onAction,
14649
14777
  fieldTransforms,
14650
14778
  fullScreenCanvas,
14651
- _experimentalVirtualization
14779
+ _experimentalVirtualization,
14780
+ route
14652
14781
  } = usePropsContext();
14653
14782
  const iframe = (0, import_react95.useMemo)(
14654
14783
  () => __spreadValues({
@@ -14758,7 +14887,9 @@ function EditorProvider({ children }) {
14758
14887
  _experimentalVirtualization: !!_experimentalVirtualization,
14759
14888
  onAction,
14760
14889
  metadata,
14761
- fieldTransforms: loadedFieldTransforms
14890
+ fieldTransforms: loadedFieldTransforms,
14891
+ route: route != null ? route : null,
14892
+ onPublish
14762
14893
  };
14763
14894
  },
14764
14895
  [
@@ -14773,7 +14904,9 @@ function EditorProvider({ children }) {
14773
14904
  _experimentalVirtualization,
14774
14905
  onAction,
14775
14906
  metadata,
14776
- loadedFieldTransforms
14907
+ loadedFieldTransforms,
14908
+ route,
14909
+ onPublish
14777
14910
  ]
14778
14911
  );
14779
14912
  const [appStore] = (0, import_react95.useState)(
@@ -14866,34 +14999,31 @@ var useApp = () => {
14866
14999
  const rrNavigate = (0, import_react_router.useNavigate)();
14867
15000
  const currentPath = location.pathname || "/";
14868
15001
  const isEditing = cfg.editorPath !== null && (currentPath === cfg.editorPath || currentPath.startsWith(`${cfg.editorPath}/`));
14869
- const matchRoute = isEditing ? stripPrefix(currentPath, cfg.editorPath) : currentPath;
14870
- const matched = (0, import_react97.useMemo)(() => {
15002
+ const pagePath = isEditing ? stripPrefix(currentPath, cfg.editorPath) : currentPath;
15003
+ const route = (0, import_react97.useMemo)(() => {
14871
15004
  const routeKeys = Object.keys(cfg.pages);
14872
15005
  if (routeKeys.length === 0) return null;
14873
15006
  const matches = (0, import_react_router.matchRoutes)(
14874
15007
  routeKeys.map((path) => ({ path })),
14875
- matchRoute
15008
+ pagePath
14876
15009
  );
14877
15010
  if (!matches || matches.length === 0) return null;
14878
15011
  const last = matches[matches.length - 1];
14879
- const key = last.route.path;
14880
15012
  return {
14881
- route: key,
14882
- params: last.params,
14883
- data: cfg.pages[key]
15013
+ key: last.route.path,
15014
+ path: pagePath,
15015
+ params: last.params
14884
15016
  };
14885
- }, [cfg.pages, matchRoute]);
15017
+ }, [cfg.pages, pagePath]);
14886
15018
  const routes = (0, import_react97.useMemo)(() => Object.keys(cfg.pages), [cfg.pages]);
14887
- const navigate = (route) => {
14888
- const target = isEditing && cfg.editorPath ? `${cfg.editorPath}${route === "/" ? "" : route}` || "/" : route;
14889
- rrNavigate(target || "/");
15019
+ const navigate = (target) => {
15020
+ const next = isEditing && cfg.editorPath ? `${cfg.editorPath}${target === "/" ? "" : target}` || "/" : target;
15021
+ rrNavigate(next || "/");
14890
15022
  };
14891
15023
  return __spreadProps(__spreadValues({}, cfg), {
14892
15024
  routes,
14893
- currentPath,
14894
15025
  isEditing,
14895
- matchRoute,
14896
- matched,
15026
+ route,
14897
15027
  navigate
14898
15028
  });
14899
15029
  };
@@ -14977,9 +15107,14 @@ function EditorForKey({
14977
15107
  editorProps,
14978
15108
  children
14979
15109
  }) {
14980
- const { config, pages, routes, navigate } = useApp();
15110
+ const { config, pages, routes, navigate, route } = useApp();
14981
15111
  const data = pages[routeKey];
14982
15112
  if (!data) return null;
15113
+ const editorRoute = {
15114
+ key: routeKey,
15115
+ path: (route == null ? void 0 : route.key) === routeKey ? route.path : routeKey,
15116
+ params: (route == null ? void 0 : route.key) === routeKey ? route.params : {}
15117
+ };
14983
15118
  return /* @__PURE__ */ (0, import_jsx_runtime94.jsx)(
14984
15119
  Editor4,
14985
15120
  {
@@ -15006,7 +15141,7 @@ function EditorForKey({
15006
15141
  disableZoomControls: editorProps.disableZoomControls,
15007
15142
  _experimentalVirtualization: editorProps._experimentalVirtualization,
15008
15143
  routes,
15009
- currentRoute: routeKey,
15144
+ route: editorRoute,
15010
15145
  onRouteChange: (next) => navigate(next),
15011
15146
  children
15012
15147
  },
package/dist/index.mjs CHANGED
@@ -25,8 +25,8 @@ import {
25
25
  usePropsContext,
26
26
  useRouteParams,
27
27
  useStableValue
28
- } from "./chunk-3NSI5XES.mjs";
29
- import "./chunk-5QKQ3LQJ.mjs";
28
+ } from "./chunk-WUEYD7ZN.mjs";
29
+ import "./chunk-NABX5FH7.mjs";
30
30
  import {
31
31
  Action,
32
32
  ActionBar,
@@ -35,22 +35,22 @@ import {
35
35
  Label,
36
36
  RichTextMenu,
37
37
  Separator
38
- } from "./chunk-Q667J2EG.mjs";
39
- import "./chunk-RQZQMS6E.mjs";
38
+ } from "./chunk-UQHR5LFK.mjs";
39
+ import "./chunk-HR67L662.mjs";
40
40
  import {
41
41
  getRouteProps,
42
42
  migrate,
43
43
  resolveAllData,
44
44
  resolveRouteFromString,
45
45
  transformProps
46
- } from "./chunk-4L7H4JV4.mjs";
46
+ } from "./chunk-AD67LVXW.mjs";
47
47
  import "./chunk-6QJ2HF4O.mjs";
48
- import "./chunk-RGC274VM.mjs";
49
- import "./chunk-TG2KTWSB.mjs";
50
- import "./chunk-JHURG5NN.mjs";
48
+ import "./chunk-DGIVBKSJ.mjs";
49
+ import "./chunk-IOAYKTDH.mjs";
50
+ import "./chunk-LFJGTSUB.mjs";
51
51
  import "./chunk-M4JDRFYB.mjs";
52
52
  import "./chunk-FTVOCMGV.mjs";
53
- import "./chunk-Y2EFNT5P.mjs";
53
+ import "./chunk-DQU3HIP4.mjs";
54
54
  import {
55
55
  walkTree
56
56
  } from "./chunk-JIXMPJZA.mjs";
@@ -1,6 +1,6 @@
1
1
  import { Reducer } from 'react';
2
2
  import { D as Data, A as AppState, O as OnAction, P as PrivateAppState, E as EditorAction } from './actions-BxLinRKD.mjs';
3
- import { A as AppStore } from './index-BZRpxcwy.mjs';
3
+ import { A as AppStore } from './index-CUe2XTb6.mjs';
4
4
  import '@tiptap/react';
5
5
  import '@tiptap/extension-blockquote';
6
6
  import '@tiptap/extension-bold';
@@ -1,6 +1,6 @@
1
1
  import { Reducer } from 'react';
2
2
  import { D as Data, A as AppState, O as OnAction, P as PrivateAppState, E as EditorAction } from './actions-BxLinRKD.js';
3
- import { A as AppStore } from './index-B_21fGrq.js';
3
+ import { A as AppStore } from './index-CYzc1n29.js';
4
4
  import '@tiptap/react';
5
5
  import '@tiptap/extension-blockquote';
6
6
  import '@tiptap/extension-bold';
@@ -1,14 +1,14 @@
1
1
  import {
2
2
  useAlignOptions
3
- } from "./chunk-RGC274VM.mjs";
3
+ } from "./chunk-DGIVBKSJ.mjs";
4
4
  import {
5
5
  AlignLeft,
6
6
  SelectControl,
7
7
  useControlContext
8
- } from "./chunk-JHURG5NN.mjs";
8
+ } from "./chunk-LFJGTSUB.mjs";
9
9
  import "./chunk-M4JDRFYB.mjs";
10
10
  import "./chunk-FTVOCMGV.mjs";
11
- import "./chunk-Y2EFNT5P.mjs";
11
+ import "./chunk-DQU3HIP4.mjs";
12
12
  import "./chunk-JIXMPJZA.mjs";
13
13
  import {
14
14
  init_react_import
@@ -1,14 +1,14 @@
1
1
  import {
2
2
  useListOptions
3
- } from "./chunk-RQZQMS6E.mjs";
3
+ } from "./chunk-HR67L662.mjs";
4
4
  import {
5
5
  List,
6
6
  SelectControl,
7
7
  useControlContext
8
- } from "./chunk-JHURG5NN.mjs";
8
+ } from "./chunk-LFJGTSUB.mjs";
9
9
  import "./chunk-M4JDRFYB.mjs";
10
10
  import "./chunk-FTVOCMGV.mjs";
11
- import "./chunk-Y2EFNT5P.mjs";
11
+ import "./chunk-DQU3HIP4.mjs";
12
12
  import "./chunk-JIXMPJZA.mjs";
13
13
  import {
14
14
  init_react_import