@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.
- package/dist/{Editor-4LPVLYSU.css → Editor-IRCQF4VT.css} +10 -16
- package/dist/{Editor-J7XDD77B.mjs → Editor-ULH2S4LO.mjs} +7 -7
- package/dist/{Render-STFB5CNO.mjs → Render-IDDFFANP.mjs} +1 -1
- package/dist/{chunk-4L7H4JV4.mjs → chunk-AD67LVXW.mjs} +2 -2
- package/dist/{chunk-RGC274VM.mjs → chunk-DGIVBKSJ.mjs} +1 -1
- package/dist/{chunk-Y2EFNT5P.mjs → chunk-DQU3HIP4.mjs} +16 -6
- package/dist/{chunk-RQZQMS6E.mjs → chunk-HR67L662.mjs} +1 -1
- package/dist/{chunk-TG2KTWSB.mjs → chunk-IOAYKTDH.mjs} +1 -1
- package/dist/{chunk-JHURG5NN.mjs → chunk-LFJGTSUB.mjs} +14 -2
- package/dist/{chunk-5QKQ3LQJ.mjs → chunk-NABX5FH7.mjs} +4 -4
- package/dist/{chunk-Q667J2EG.mjs → chunk-UQHR5LFK.mjs} +130 -29
- package/dist/{chunk-3NSI5XES.mjs → chunk-WUEYD7ZN.mjs} +60 -47
- package/dist/{full-7ABPY2WA.css → full-B5V3G4IY.css} +10 -16
- package/dist/{full-T5SGODJ2.mjs → full-LIVYWOAF.mjs} +6 -6
- package/dist/{index-BZRpxcwy.d.mts → index-CUe2XTb6.d.mts} +28 -1
- package/dist/{index-B_21fGrq.d.ts → index-CYzc1n29.d.ts} +28 -1
- package/dist/index.css +10 -16
- package/dist/index.d.mts +35 -20
- package/dist/index.d.ts +35 -20
- package/dist/index.js +194 -59
- package/dist/index.mjs +9 -9
- package/dist/internal.d.mts +1 -1
- package/dist/internal.d.ts +1 -1
- package/dist/{loaded-ZQCRSG65.mjs → loaded-FZVSXAM7.mjs} +3 -3
- package/dist/{loaded-DUBT6SP5.mjs → loaded-MSWM6QEM.mjs} +3 -3
- package/dist/{loaded-6YKSFCCD.mjs → loaded-PYHJ6TB5.mjs} +3 -3
- package/dist/no-external.css +10 -16
- package/dist/no-external.d.mts +2 -2
- package/dist/no-external.d.ts +2 -2
- package/dist/no-external.js +194 -59
- package/dist/no-external.mjs +9 -9
- package/dist/rsc.js +16 -6
- package/dist/rsc.mjs +2 -2
- package/package.json +1 -1
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
import {
|
|
2
2
|
EditorInner,
|
|
3
3
|
LoadedRichTextMenu
|
|
4
|
-
} from "./chunk-
|
|
4
|
+
} from "./chunk-NABX5FH7.mjs";
|
|
5
5
|
import {
|
|
6
6
|
ActionBar,
|
|
7
7
|
IconButton,
|
|
8
8
|
LoadedRichTextMenuInner,
|
|
9
9
|
Loader
|
|
10
|
-
} from "./chunk-
|
|
10
|
+
} from "./chunk-UQHR5LFK.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-
|
|
19
|
+
} from "./chunk-AD67LVXW.mjs";
|
|
20
20
|
import {
|
|
21
21
|
Check,
|
|
22
22
|
ChevronDown,
|
|
@@ -60,7 +60,7 @@ import {
|
|
|
60
60
|
useRegisterFieldsSlice,
|
|
61
61
|
useRegisterHistorySlice,
|
|
62
62
|
useRegisterPermissionsSlice
|
|
63
|
-
} from "./chunk-
|
|
63
|
+
} from "./chunk-LFJGTSUB.mjs";
|
|
64
64
|
import {
|
|
65
65
|
getItem,
|
|
66
66
|
insert,
|
|
@@ -74,7 +74,7 @@ import {
|
|
|
74
74
|
} from "./chunk-FTVOCMGV.mjs";
|
|
75
75
|
import {
|
|
76
76
|
get_class_name_factory_default
|
|
77
|
-
} from "./chunk-
|
|
77
|
+
} from "./chunk-DQU3HIP4.mjs";
|
|
78
78
|
import {
|
|
79
79
|
defaultSlots,
|
|
80
80
|
expandNode,
|
|
@@ -226,9 +226,8 @@ var Button = (_a) => {
|
|
|
226
226
|
href
|
|
227
227
|
}, dataAttrs), {
|
|
228
228
|
children: [
|
|
229
|
-
icon && /* @__PURE__ */ jsx("div", { className: getClassName("icon"), children: icon }),
|
|
230
|
-
children
|
|
231
|
-
loading && /* @__PURE__ */ jsx("div", { className: getClassName("spinner"), children: /* @__PURE__ */ jsx(Loader, { size: 14 }) })
|
|
229
|
+
loading ? /* @__PURE__ */ jsx("div", { className: getClassName("spinner"), children: /* @__PURE__ */ jsx(Loader, { size: 14 }) }) : icon && /* @__PURE__ */ jsx("div", { className: getClassName("icon"), children: icon }),
|
|
230
|
+
children
|
|
232
231
|
]
|
|
233
232
|
})
|
|
234
233
|
);
|
|
@@ -2146,7 +2145,7 @@ EditorFallback.displayName = "EditorFallback";
|
|
|
2146
2145
|
// components/AutoField/fields/RichtextField/index.tsx
|
|
2147
2146
|
import { Fragment as Fragment3, jsx as jsx20 } from "react/jsx-runtime";
|
|
2148
2147
|
var Editor = lazy(
|
|
2149
|
-
() => import("./Editor-
|
|
2148
|
+
() => import("./Editor-ULH2S4LO.mjs").then((m) => ({
|
|
2150
2149
|
default: m.Editor
|
|
2151
2150
|
}))
|
|
2152
2151
|
);
|
|
@@ -4698,12 +4697,12 @@ import {
|
|
|
4698
4697
|
} from "react";
|
|
4699
4698
|
import { jsx as jsx30 } from "react/jsx-runtime";
|
|
4700
4699
|
var Editor2 = lazy2(
|
|
4701
|
-
() => import("./Editor-
|
|
4700
|
+
() => import("./Editor-ULH2S4LO.mjs").then((m) => ({
|
|
4702
4701
|
default: m.Editor
|
|
4703
4702
|
}))
|
|
4704
4703
|
);
|
|
4705
4704
|
var RichTextRender = lazy2(
|
|
4706
|
-
() => import("./Render-
|
|
4705
|
+
() => import("./Render-IDDFFANP.mjs").then((m) => ({
|
|
4707
4706
|
default: m.RichTextRender
|
|
4708
4707
|
}))
|
|
4709
4708
|
);
|
|
@@ -5896,6 +5895,9 @@ var createEditorCommands = (appStore) => {
|
|
|
5896
5895
|
ui: { itemSelector: { index: sel.index, zone: sel.zone } }
|
|
5897
5896
|
});
|
|
5898
5897
|
};
|
|
5898
|
+
const publish = () => {
|
|
5899
|
+
void getState().publish();
|
|
5900
|
+
};
|
|
5899
5901
|
return {
|
|
5900
5902
|
insertComponent: insertComponent2,
|
|
5901
5903
|
removeComponent,
|
|
@@ -5905,7 +5907,8 @@ var createEditorCommands = (appStore) => {
|
|
|
5905
5907
|
updateProps,
|
|
5906
5908
|
updateRoot,
|
|
5907
5909
|
selectComponent,
|
|
5908
|
-
scrollToComponent
|
|
5910
|
+
scrollToComponent,
|
|
5911
|
+
publish
|
|
5909
5912
|
};
|
|
5910
5913
|
};
|
|
5911
5914
|
|
|
@@ -5924,6 +5927,8 @@ var generateUseEditor = (store, getState, commands) => {
|
|
|
5924
5927
|
const storeData = __spreadProps(__spreadValues({}, commands), {
|
|
5925
5928
|
appState: makeStatePublic(store.state),
|
|
5926
5929
|
config: store.config,
|
|
5930
|
+
route: store.route,
|
|
5931
|
+
isPublishing: store.isPublishing,
|
|
5927
5932
|
dispatch: store.dispatch,
|
|
5928
5933
|
getPermissions: store.permissions.getPermissions,
|
|
5929
5934
|
refreshPermissions: store.permissions.refreshPermissions,
|
|
@@ -5958,7 +5963,9 @@ var convertToPickedStore = (store) => {
|
|
|
5958
5963
|
dispatch: store.dispatch,
|
|
5959
5964
|
permissions: store.permissions,
|
|
5960
5965
|
history: store.history,
|
|
5961
|
-
selectedItem: store.selectedItem
|
|
5966
|
+
selectedItem: store.selectedItem,
|
|
5967
|
+
route: store.route,
|
|
5968
|
+
isPublishing: store.isPublishing
|
|
5962
5969
|
};
|
|
5963
5970
|
};
|
|
5964
5971
|
var useRegisterUseEditorStore = (appStore) => {
|
|
@@ -7634,18 +7641,19 @@ var DEVICE_VIEWPORTS = {
|
|
|
7634
7641
|
mobile: { width: 360, height: "auto", icon: "Smartphone", label: "Mobile" }
|
|
7635
7642
|
};
|
|
7636
7643
|
var UrlBar = () => {
|
|
7637
|
-
const { routes,
|
|
7644
|
+
const { routes, route, onRouteChange } = usePropsContext();
|
|
7638
7645
|
const chrome = useChromeConfig();
|
|
7639
|
-
const
|
|
7640
|
-
const
|
|
7641
|
-
const
|
|
7642
|
-
|
|
7643
|
-
|
|
7644
|
-
|
|
7646
|
+
const currentKey = route == null ? void 0 : route.key;
|
|
7647
|
+
const showRoutePicker = !!routes && currentKey !== void 0 && !!onRouteChange;
|
|
7648
|
+
const [inputValue, setInputValue] = useState20(currentKey != null ? currentKey : "");
|
|
7649
|
+
const lastSyncedPath = useRef13(currentKey);
|
|
7650
|
+
if (lastSyncedPath.current !== currentKey) {
|
|
7651
|
+
lastSyncedPath.current = currentKey;
|
|
7652
|
+
setInputValue(currentKey != null ? currentKey : "");
|
|
7645
7653
|
}
|
|
7646
7654
|
const submit = (raw) => {
|
|
7647
7655
|
const next = normalizeRoute(raw);
|
|
7648
|
-
if (!next || next ===
|
|
7656
|
+
if (!next || next === currentKey) return;
|
|
7649
7657
|
void (onRouteChange == null ? void 0 : onRouteChange(next));
|
|
7650
7658
|
};
|
|
7651
7659
|
if (!chrome.showUrlBar) return null;
|
|
@@ -7654,7 +7662,7 @@ var UrlBar = () => {
|
|
|
7654
7662
|
Combobox,
|
|
7655
7663
|
{
|
|
7656
7664
|
items: routes,
|
|
7657
|
-
value:
|
|
7665
|
+
value: currentKey,
|
|
7658
7666
|
onValueChange: (next) => {
|
|
7659
7667
|
if (typeof next === "string") submit(next);
|
|
7660
7668
|
},
|
|
@@ -8425,12 +8433,12 @@ var TopHeader = ({
|
|
|
8425
8433
|
pluginItems
|
|
8426
8434
|
}) => {
|
|
8427
8435
|
const appStore = useAppStoreApi();
|
|
8428
|
-
const { onPublish, currentRoute } = usePropsContext();
|
|
8429
8436
|
const chrome = useChromeConfig();
|
|
8430
8437
|
const back = useAppStore((s) => s.history.back);
|
|
8431
8438
|
const forward = useAppStore((s) => s.history.forward);
|
|
8432
8439
|
const hasFuture = useAppStore((s) => s.history.hasFuture());
|
|
8433
8440
|
const hasPast = useAppStore((s) => s.history.hasPast());
|
|
8441
|
+
const isPublishing = useAppStore((s) => s.isPublishing);
|
|
8434
8442
|
const CustomHeaderActions = useAppStore(
|
|
8435
8443
|
(s) => s.overrides.headerActions || DefaultOverride
|
|
8436
8444
|
);
|
|
@@ -8482,11 +8490,8 @@ var TopHeader = ({
|
|
|
8482
8490
|
/* @__PURE__ */ jsx53(CustomHeaderActions, { children: /* @__PURE__ */ jsx53(
|
|
8483
8491
|
Button,
|
|
8484
8492
|
{
|
|
8485
|
-
onClick: () =>
|
|
8486
|
-
|
|
8487
|
-
onPublish && onPublish(data, currentRoute);
|
|
8488
|
-
},
|
|
8489
|
-
children: "Publish"
|
|
8493
|
+
onClick: () => appStore.getState().publish(),
|
|
8494
|
+
children: isPublishing ? "Publishing\u2026" : "Publish"
|
|
8490
8495
|
}
|
|
8491
8496
|
) })
|
|
8492
8497
|
] })
|
|
@@ -8908,6 +8913,7 @@ function EditorProvider({ children }) {
|
|
|
8908
8913
|
data: initialData,
|
|
8909
8914
|
ui: initialUi,
|
|
8910
8915
|
onChange,
|
|
8916
|
+
onPublish,
|
|
8911
8917
|
permissions = {},
|
|
8912
8918
|
plugins,
|
|
8913
8919
|
overrides,
|
|
@@ -8918,7 +8924,8 @@ function EditorProvider({ children }) {
|
|
|
8918
8924
|
onAction,
|
|
8919
8925
|
fieldTransforms,
|
|
8920
8926
|
fullScreenCanvas,
|
|
8921
|
-
_experimentalVirtualization
|
|
8927
|
+
_experimentalVirtualization,
|
|
8928
|
+
route
|
|
8922
8929
|
} = usePropsContext();
|
|
8923
8930
|
const iframe = useMemo24(
|
|
8924
8931
|
() => __spreadValues({
|
|
@@ -9028,7 +9035,9 @@ function EditorProvider({ children }) {
|
|
|
9028
9035
|
_experimentalVirtualization: !!_experimentalVirtualization,
|
|
9029
9036
|
onAction,
|
|
9030
9037
|
metadata,
|
|
9031
|
-
fieldTransforms: loadedFieldTransforms
|
|
9038
|
+
fieldTransforms: loadedFieldTransforms,
|
|
9039
|
+
route: route != null ? route : null,
|
|
9040
|
+
onPublish
|
|
9032
9041
|
};
|
|
9033
9042
|
},
|
|
9034
9043
|
[
|
|
@@ -9043,7 +9052,9 @@ function EditorProvider({ children }) {
|
|
|
9043
9052
|
_experimentalVirtualization,
|
|
9044
9053
|
onAction,
|
|
9045
9054
|
metadata,
|
|
9046
|
-
loadedFieldTransforms
|
|
9055
|
+
loadedFieldTransforms,
|
|
9056
|
+
route,
|
|
9057
|
+
onPublish
|
|
9047
9058
|
]
|
|
9048
9059
|
);
|
|
9049
9060
|
const [appStore] = useState24(
|
|
@@ -9131,34 +9142,31 @@ var useApp = () => {
|
|
|
9131
9142
|
const rrNavigate = useNavigate();
|
|
9132
9143
|
const currentPath = location.pathname || "/";
|
|
9133
9144
|
const isEditing = cfg.editorPath !== null && (currentPath === cfg.editorPath || currentPath.startsWith(`${cfg.editorPath}/`));
|
|
9134
|
-
const
|
|
9135
|
-
const
|
|
9145
|
+
const pagePath = isEditing ? stripPrefix(currentPath, cfg.editorPath) : currentPath;
|
|
9146
|
+
const route = useMemo25(() => {
|
|
9136
9147
|
const routeKeys = Object.keys(cfg.pages);
|
|
9137
9148
|
if (routeKeys.length === 0) return null;
|
|
9138
9149
|
const matches = matchRoutes(
|
|
9139
9150
|
routeKeys.map((path) => ({ path })),
|
|
9140
|
-
|
|
9151
|
+
pagePath
|
|
9141
9152
|
);
|
|
9142
9153
|
if (!matches || matches.length === 0) return null;
|
|
9143
9154
|
const last = matches[matches.length - 1];
|
|
9144
|
-
const key = last.route.path;
|
|
9145
9155
|
return {
|
|
9146
|
-
|
|
9147
|
-
|
|
9148
|
-
|
|
9156
|
+
key: last.route.path,
|
|
9157
|
+
path: pagePath,
|
|
9158
|
+
params: last.params
|
|
9149
9159
|
};
|
|
9150
|
-
}, [cfg.pages,
|
|
9160
|
+
}, [cfg.pages, pagePath]);
|
|
9151
9161
|
const routes = useMemo25(() => Object.keys(cfg.pages), [cfg.pages]);
|
|
9152
|
-
const navigate = (
|
|
9153
|
-
const
|
|
9154
|
-
rrNavigate(
|
|
9162
|
+
const navigate = (target) => {
|
|
9163
|
+
const next = isEditing && cfg.editorPath ? `${cfg.editorPath}${target === "/" ? "" : target}` || "/" : target;
|
|
9164
|
+
rrNavigate(next || "/");
|
|
9155
9165
|
};
|
|
9156
9166
|
return __spreadProps(__spreadValues({}, cfg), {
|
|
9157
9167
|
routes,
|
|
9158
|
-
currentPath,
|
|
9159
9168
|
isEditing,
|
|
9160
|
-
|
|
9161
|
-
matched,
|
|
9169
|
+
route,
|
|
9162
9170
|
navigate
|
|
9163
9171
|
});
|
|
9164
9172
|
};
|
|
@@ -9252,9 +9260,14 @@ function EditorForKey({
|
|
|
9252
9260
|
editorProps,
|
|
9253
9261
|
children
|
|
9254
9262
|
}) {
|
|
9255
|
-
const { config, pages, routes, navigate } = useApp();
|
|
9263
|
+
const { config, pages, routes, navigate, route } = useApp();
|
|
9256
9264
|
const data = pages[routeKey];
|
|
9257
9265
|
if (!data) return null;
|
|
9266
|
+
const editorRoute = {
|
|
9267
|
+
key: routeKey,
|
|
9268
|
+
path: (route == null ? void 0 : route.key) === routeKey ? route.path : routeKey,
|
|
9269
|
+
params: (route == null ? void 0 : route.key) === routeKey ? route.params : {}
|
|
9270
|
+
};
|
|
9258
9271
|
return /* @__PURE__ */ jsx56(
|
|
9259
9272
|
Editor3,
|
|
9260
9273
|
{
|
|
@@ -9281,7 +9294,7 @@ function EditorForKey({
|
|
|
9281
9294
|
disableZoomControls: editorProps.disableZoomControls,
|
|
9282
9295
|
_experimentalVirtualization: editorProps._experimentalVirtualization,
|
|
9283
9296
|
routes,
|
|
9284
|
-
|
|
9297
|
+
route: editorRoute,
|
|
9285
9298
|
onRouteChange: (next) => navigate(next),
|
|
9286
9299
|
children
|
|
9287
9300
|
},
|
|
@@ -88,25 +88,19 @@
|
|
|
88
88
|
}
|
|
89
89
|
|
|
90
90
|
/* css-module:/Users/rami/Documents/apps/react-editor/packages/core/components/Loader/styles.module.css/#css-module-data */
|
|
91
|
-
@keyframes _loader-
|
|
92
|
-
|
|
93
|
-
transform: rotate(0deg)
|
|
91
|
+
@keyframes _loader-spin_6933g_1 {
|
|
92
|
+
from {
|
|
93
|
+
transform: rotate(0deg);
|
|
94
94
|
}
|
|
95
|
-
|
|
96
|
-
transform: rotate(
|
|
97
|
-
}
|
|
98
|
-
100% {
|
|
99
|
-
transform: rotate(360deg) scale(1);
|
|
95
|
+
to {
|
|
96
|
+
transform: rotate(360deg);
|
|
100
97
|
}
|
|
101
98
|
}
|
|
102
|
-
.
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
display: inline-block;
|
|
108
|
-
animation: _loader-animation_nacdm_1 1s 0s infinite linear;
|
|
109
|
-
animation-fill-mode: both;
|
|
99
|
+
._Loader_6933g_10 {
|
|
100
|
+
display: inline-flex;
|
|
101
|
+
align-items: center;
|
|
102
|
+
justify-content: center;
|
|
103
|
+
animation: _loader-spin_6933g_1 1s linear infinite;
|
|
110
104
|
}
|
|
111
105
|
|
|
112
106
|
/* css-module:/Users/rami/Documents/apps/react-editor/packages/core/components/ActionBar/styles.module.css/#css-module-data */
|
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
import {
|
|
2
2
|
LoadedRichTextMenuInner
|
|
3
|
-
} from "./chunk-
|
|
4
|
-
import "./chunk-
|
|
5
|
-
import "./chunk-
|
|
6
|
-
import "./chunk-
|
|
7
|
-
import "./chunk-
|
|
3
|
+
} from "./chunk-UQHR5LFK.mjs";
|
|
4
|
+
import "./chunk-HR67L662.mjs";
|
|
5
|
+
import "./chunk-DGIVBKSJ.mjs";
|
|
6
|
+
import "./chunk-IOAYKTDH.mjs";
|
|
7
|
+
import "./chunk-LFJGTSUB.mjs";
|
|
8
8
|
import "./chunk-M4JDRFYB.mjs";
|
|
9
9
|
import "./chunk-FTVOCMGV.mjs";
|
|
10
|
-
import "./chunk-
|
|
10
|
+
import "./chunk-DQU3HIP4.mjs";
|
|
11
11
|
import "./chunk-JIXMPJZA.mjs";
|
|
12
12
|
import {
|
|
13
13
|
__spreadValues,
|
|
@@ -69,6 +69,23 @@ type ZoomConfig = {
|
|
|
69
69
|
type ComponentState = Record<string, {
|
|
70
70
|
loadingCount: number;
|
|
71
71
|
}>;
|
|
72
|
+
/**
|
|
73
|
+
* Routing descriptor for the page currently loaded in the editor. Mirrored
|
|
74
|
+
* from `useApp().route` by `<App>` and exposed via `useEditor((s) => s.route)`.
|
|
75
|
+
*/
|
|
76
|
+
type EditorRoute = {
|
|
77
|
+
/** Route key/pattern, e.g. "/posts/:handle". */
|
|
78
|
+
key: string;
|
|
79
|
+
/** Canonical page URL (editorPath stripped), e.g. "/posts/abc". */
|
|
80
|
+
path: string;
|
|
81
|
+
/** Concrete URL params extracted from the URL. */
|
|
82
|
+
params: Record<string, string | undefined>;
|
|
83
|
+
};
|
|
84
|
+
/** Publish callback signature — receives current data + route descriptor. */
|
|
85
|
+
type OnPublish<UserData = unknown> = (payload: {
|
|
86
|
+
data: UserData;
|
|
87
|
+
route: EditorRoute | null;
|
|
88
|
+
}) => void | Promise<void>;
|
|
72
89
|
type AppStore<UserConfig extends Config = Config, G extends UserGenerics<UserConfig> = UserGenerics<UserConfig>> = {
|
|
73
90
|
instanceId: string;
|
|
74
91
|
state: G["UserAppState"];
|
|
@@ -113,6 +130,16 @@ type AppStore<UserConfig extends Config = Config, G extends UserGenerics<UserCon
|
|
|
113
130
|
id: string;
|
|
114
131
|
} | null;
|
|
115
132
|
scrollToComponent: (id: string) => void;
|
|
133
|
+
route: EditorRoute | null;
|
|
134
|
+
onPublish?: OnPublish<G["UserData"]>;
|
|
135
|
+
/** True while a `publish()` call is in flight. */
|
|
136
|
+
isPublishing: boolean;
|
|
137
|
+
/**
|
|
138
|
+
* Invoke the user's `onPublish` with the current data + route, awaiting
|
|
139
|
+
* the result. `isPublishing` flips true for the duration. No-op when
|
|
140
|
+
* `onPublish` isn't set.
|
|
141
|
+
*/
|
|
142
|
+
publish: () => Promise<void>;
|
|
116
143
|
};
|
|
117
144
|
|
|
118
|
-
export type { AppStore as A, GetPermissions as G, HistorySlice as H, RefreshPermissions as R };
|
|
145
|
+
export type { AppStore as A, EditorRoute as E, GetPermissions as G, HistorySlice as H, OnPublish as O, RefreshPermissions as R };
|
|
@@ -69,6 +69,23 @@ type ZoomConfig = {
|
|
|
69
69
|
type ComponentState = Record<string, {
|
|
70
70
|
loadingCount: number;
|
|
71
71
|
}>;
|
|
72
|
+
/**
|
|
73
|
+
* Routing descriptor for the page currently loaded in the editor. Mirrored
|
|
74
|
+
* from `useApp().route` by `<App>` and exposed via `useEditor((s) => s.route)`.
|
|
75
|
+
*/
|
|
76
|
+
type EditorRoute = {
|
|
77
|
+
/** Route key/pattern, e.g. "/posts/:handle". */
|
|
78
|
+
key: string;
|
|
79
|
+
/** Canonical page URL (editorPath stripped), e.g. "/posts/abc". */
|
|
80
|
+
path: string;
|
|
81
|
+
/** Concrete URL params extracted from the URL. */
|
|
82
|
+
params: Record<string, string | undefined>;
|
|
83
|
+
};
|
|
84
|
+
/** Publish callback signature — receives current data + route descriptor. */
|
|
85
|
+
type OnPublish<UserData = unknown> = (payload: {
|
|
86
|
+
data: UserData;
|
|
87
|
+
route: EditorRoute | null;
|
|
88
|
+
}) => void | Promise<void>;
|
|
72
89
|
type AppStore<UserConfig extends Config = Config, G extends UserGenerics<UserConfig> = UserGenerics<UserConfig>> = {
|
|
73
90
|
instanceId: string;
|
|
74
91
|
state: G["UserAppState"];
|
|
@@ -113,6 +130,16 @@ type AppStore<UserConfig extends Config = Config, G extends UserGenerics<UserCon
|
|
|
113
130
|
id: string;
|
|
114
131
|
} | null;
|
|
115
132
|
scrollToComponent: (id: string) => void;
|
|
133
|
+
route: EditorRoute | null;
|
|
134
|
+
onPublish?: OnPublish<G["UserData"]>;
|
|
135
|
+
/** True while a `publish()` call is in flight. */
|
|
136
|
+
isPublishing: boolean;
|
|
137
|
+
/**
|
|
138
|
+
* Invoke the user's `onPublish` with the current data + route, awaiting
|
|
139
|
+
* the result. `isPublishing` flips true for the duration. No-op when
|
|
140
|
+
* `onPublish` isn't set.
|
|
141
|
+
*/
|
|
142
|
+
publish: () => Promise<void>;
|
|
116
143
|
};
|
|
117
144
|
|
|
118
|
-
export type { AppStore as A, GetPermissions as G, HistorySlice as H, RefreshPermissions as R };
|
|
145
|
+
export type { AppStore as A, EditorRoute as E, GetPermissions as G, HistorySlice as H, OnPublish as O, RefreshPermissions as R };
|
package/dist/index.css
CHANGED
|
@@ -706,25 +706,19 @@ textarea._Input-input_zwh6e_27 {
|
|
|
706
706
|
}
|
|
707
707
|
|
|
708
708
|
/* css-module:/Users/rami/Documents/apps/react-editor/packages/core/components/Loader/styles.module.css/#css-module-data */
|
|
709
|
-
@keyframes _loader-
|
|
710
|
-
|
|
711
|
-
transform: rotate(0deg)
|
|
709
|
+
@keyframes _loader-spin_6933g_1 {
|
|
710
|
+
from {
|
|
711
|
+
transform: rotate(0deg);
|
|
712
712
|
}
|
|
713
|
-
|
|
714
|
-
transform: rotate(
|
|
715
|
-
}
|
|
716
|
-
100% {
|
|
717
|
-
transform: rotate(360deg) scale(1);
|
|
713
|
+
to {
|
|
714
|
+
transform: rotate(360deg);
|
|
718
715
|
}
|
|
719
716
|
}
|
|
720
|
-
.
|
|
721
|
-
|
|
722
|
-
|
|
723
|
-
|
|
724
|
-
|
|
725
|
-
display: inline-block;
|
|
726
|
-
animation: _loader-animation_nacdm_1 1s 0s infinite linear;
|
|
727
|
-
animation-fill-mode: both;
|
|
717
|
+
._Loader_6933g_10 {
|
|
718
|
+
display: inline-flex;
|
|
719
|
+
align-items: center;
|
|
720
|
+
justify-content: center;
|
|
721
|
+
animation: _loader-spin_6933g_1 1s linear infinite;
|
|
728
722
|
}
|
|
729
723
|
|
|
730
724
|
/* css-module:/Users/rami/Documents/apps/react-editor/packages/core/components/DragIcon/styles.module.css/#css-module-data */
|
package/dist/index.d.mts
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.mjs';
|
|
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.mjs';
|
|
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-BvYigWFL.mjs';
|
|
4
|
+
import { O as OnPublish, E as EditorRoute, A as AppStore, G as GetPermissions, R as RefreshPermissions, H as HistorySlice } from './index-CUe2XTb6.mjs';
|
|
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-BZRpxcwy.mjs';
|
|
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
|
|
38
|
-
* - `onPublish(data,
|
|
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
|
-
|
|
97
|
-
|
|
98
|
-
|
|
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
|
-
/**
|
|
115
|
-
currentPath: string;
|
|
116
|
-
/** True when currentPath starts with editorPath. */
|
|
119
|
+
/** True when the live URL is under `editorPath`. */
|
|
117
120
|
isEditing: boolean;
|
|
118
|
-
/**
|
|
119
|
-
|
|
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
|
|
153
|
-
onPublish?:
|
|
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?:
|
|
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
|
-
|
|
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
|
|
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 };
|