@commercetools-demo/puck-content-manager 0.2.0 → 0.3.0
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/index.d.mts +7 -7
- package/dist/index.d.ts +7 -7
- package/dist/index.js +246 -408
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +264 -409
- package/dist/index.mjs.map +1 -1
- package/package.json +7 -4
package/dist/index.js
CHANGED
|
@@ -32,7 +32,7 @@ var index_exports = {};
|
|
|
32
32
|
__export(index_exports, {
|
|
33
33
|
ContentEditor: () => ContentEditor,
|
|
34
34
|
ContentManager: () => ContentManager,
|
|
35
|
-
|
|
35
|
+
ContentManagerList: () => ContentManagerList
|
|
36
36
|
});
|
|
37
37
|
module.exports = __toCommonJS(index_exports);
|
|
38
38
|
|
|
@@ -50,27 +50,8 @@ var import_loading_spinner = __toESM(require("@commercetools-uikit/loading-spinn
|
|
|
50
50
|
var import_text_input = __toESM(require("@commercetools-uikit/text-input"));
|
|
51
51
|
var import_label = __toESM(require("@commercetools-uikit/label"));
|
|
52
52
|
var import_icons = require("@commercetools-uikit/icons");
|
|
53
|
+
var import_stamp = __toESM(require("@commercetools-uikit/stamp"));
|
|
53
54
|
var import_jsx_runtime = require("react/jsx-runtime");
|
|
54
|
-
var StatusBadge = ({ variant }) => {
|
|
55
|
-
const styles = variant === "published" ? { background: "var(--color-success-95)", color: "var(--color-success-40)", border: "1px solid var(--color-success-85)" } : variant === "draft" ? { background: "var(--color-warning-95)", color: "var(--color-warning-40)", border: "1px solid var(--color-warning-85)" } : { background: "var(--color-neutral-95)", color: "var(--color-neutral-50)", border: "1px solid var(--color-neutral-85)" };
|
|
56
|
-
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
57
|
-
"span",
|
|
58
|
-
{
|
|
59
|
-
style: {
|
|
60
|
-
...styles,
|
|
61
|
-
display: "inline-flex",
|
|
62
|
-
alignItems: "center",
|
|
63
|
-
padding: "2px 8px",
|
|
64
|
-
borderRadius: "var(--border-radius-20)",
|
|
65
|
-
fontSize: "var(--font-size-10)",
|
|
66
|
-
fontWeight: "var(--font-weight-600)",
|
|
67
|
-
marginRight: "4px",
|
|
68
|
-
whiteSpace: "nowrap"
|
|
69
|
-
},
|
|
70
|
-
children: variant === "published" ? "Published" : variant === "draft" ? "Draft" : "No state"
|
|
71
|
-
}
|
|
72
|
-
);
|
|
73
|
-
};
|
|
74
55
|
var columns = [
|
|
75
56
|
{ key: "name", label: "Name" },
|
|
76
57
|
{ key: "contentType", label: "Content Type" },
|
|
@@ -216,7 +197,7 @@ var ContentList = ({ defaultContentType, onEdit }) => {
|
|
|
216
197
|
itemRenderer: (row, column) => {
|
|
217
198
|
switch (column.key) {
|
|
218
199
|
case "name":
|
|
219
|
-
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_text.default.Body, {
|
|
200
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_text.default.Body, { fontWeight: "bold", children: row.value.name });
|
|
220
201
|
case "contentType":
|
|
221
202
|
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
222
203
|
"code",
|
|
@@ -234,10 +215,10 @@ var ContentList = ({ defaultContentType, onEdit }) => {
|
|
|
234
215
|
case "status": {
|
|
235
216
|
const hasDraft = !!row.states.draft;
|
|
236
217
|
const hasPublished = !!row.states.published;
|
|
237
|
-
return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("span", { children: [
|
|
238
|
-
hasDraft && /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
239
|
-
hasPublished && /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
240
|
-
!hasDraft && !hasPublished && /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
218
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("span", { style: { display: "inline-flex", gap: "4px", flexWrap: "wrap" }, children: [
|
|
219
|
+
hasDraft && /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_stamp.default, { tone: "warning", label: "Draft", isCondensed: true }),
|
|
220
|
+
hasPublished && /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_stamp.default, { tone: "positive", label: "Published", isCondensed: true }),
|
|
221
|
+
!hasDraft && !hasPublished && /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_stamp.default, { tone: "secondary", label: "No state", isCondensed: true })
|
|
241
222
|
] });
|
|
242
223
|
}
|
|
243
224
|
case "updatedAt":
|
|
@@ -263,7 +244,7 @@ var ContentList = ({ defaultContentType, onEdit }) => {
|
|
|
263
244
|
)
|
|
264
245
|
] }) });
|
|
265
246
|
};
|
|
266
|
-
var
|
|
247
|
+
var ContentManagerList = ({
|
|
267
248
|
baseURL,
|
|
268
249
|
projectKey,
|
|
269
250
|
businessUnitKey,
|
|
@@ -287,113 +268,11 @@ var import_puck = require("@measured/puck");
|
|
|
287
268
|
var import_puck2 = require("@measured/puck/puck.css");
|
|
288
269
|
var import_puck_api2 = require("@commercetools-demo/puck-api");
|
|
289
270
|
var import_puck_editor = require("@commercetools-demo/puck-editor");
|
|
271
|
+
var import_puck_version_history = require("@commercetools-demo/puck-version-history");
|
|
272
|
+
var import_loading_spinner2 = __toESM(require("@commercetools-uikit/loading-spinner"));
|
|
273
|
+
var import_text2 = __toESM(require("@commercetools-uikit/text"));
|
|
274
|
+
var import_spacings2 = __toESM(require("@commercetools-uikit/spacings"));
|
|
290
275
|
var import_jsx_runtime2 = require("react/jsx-runtime");
|
|
291
|
-
var BADGE_STYLES = {
|
|
292
|
-
saving: { bg: "rgba(251, 191, 36, 0.12)", color: "var(--status-saving)", border: "rgba(251, 191, 36, 0.3)" },
|
|
293
|
-
unsaved: { bg: "rgba(100, 116, 139, 0.12)", color: "var(--text-muted)", border: "rgba(100, 116, 139, 0.3)" },
|
|
294
|
-
draft: { bg: "rgba(129, 140, 248, 0.12)", color: "var(--status-draft)", border: "rgba(129, 140, 248, 0.3)" },
|
|
295
|
-
published: { bg: "rgba(6, 214, 160, 0.12)", color: "var(--status-published)", border: "rgba(6, 214, 160, 0.3)" }
|
|
296
|
-
};
|
|
297
|
-
var StatusBadge2 = ({
|
|
298
|
-
label,
|
|
299
|
-
variant
|
|
300
|
-
}) => {
|
|
301
|
-
const bs = BADGE_STYLES[variant];
|
|
302
|
-
return /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
|
|
303
|
-
"span",
|
|
304
|
-
{
|
|
305
|
-
style: {
|
|
306
|
-
display: "inline-flex",
|
|
307
|
-
alignItems: "center",
|
|
308
|
-
padding: "2px 10px",
|
|
309
|
-
borderRadius: "12px",
|
|
310
|
-
fontSize: "12px",
|
|
311
|
-
fontWeight: 600,
|
|
312
|
-
background: bs.bg,
|
|
313
|
-
color: bs.color,
|
|
314
|
-
border: `1px solid ${bs.border}`
|
|
315
|
-
},
|
|
316
|
-
children: label
|
|
317
|
-
}
|
|
318
|
-
);
|
|
319
|
-
};
|
|
320
|
-
var ContentToolbar = ({
|
|
321
|
-
saving,
|
|
322
|
-
isDirty,
|
|
323
|
-
states,
|
|
324
|
-
onSave,
|
|
325
|
-
onPublish,
|
|
326
|
-
onRevert
|
|
327
|
-
}) => {
|
|
328
|
-
const hasDraft = Boolean(states.draft);
|
|
329
|
-
const hasPublished = Boolean(states.published);
|
|
330
|
-
return /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)("div", { style: { display: "flex", alignItems: "center", gap: "12px", flexWrap: "wrap" }, children: [
|
|
331
|
-
/* @__PURE__ */ (0, import_jsx_runtime2.jsxs)("div", { style: { display: "flex", alignItems: "center", gap: "6px" }, children: [
|
|
332
|
-
saving && /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(StatusBadge2, { label: "Saving\u2026", variant: "saving" }),
|
|
333
|
-
!saving && isDirty && /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(StatusBadge2, { label: "Unsaved", variant: "unsaved" }),
|
|
334
|
-
!saving && !isDirty && hasDraft && /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(StatusBadge2, { label: "Draft", variant: "draft" }),
|
|
335
|
-
hasPublished && /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(StatusBadge2, { label: "Published", variant: "published" })
|
|
336
|
-
] }),
|
|
337
|
-
hasDraft && hasPublished && /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
|
|
338
|
-
"button",
|
|
339
|
-
{
|
|
340
|
-
onClick: onRevert,
|
|
341
|
-
disabled: saving,
|
|
342
|
-
style: {
|
|
343
|
-
padding: "6px 14px",
|
|
344
|
-
borderRadius: "4px",
|
|
345
|
-
border: "1px solid var(--border-glow)",
|
|
346
|
-
background: "transparent",
|
|
347
|
-
color: "var(--text-muted)",
|
|
348
|
-
fontWeight: 500,
|
|
349
|
-
fontSize: "13px",
|
|
350
|
-
cursor: saving ? "not-allowed" : "pointer",
|
|
351
|
-
opacity: saving ? 0.5 : 1
|
|
352
|
-
},
|
|
353
|
-
children: "Revert to Published"
|
|
354
|
-
}
|
|
355
|
-
),
|
|
356
|
-
/* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
|
|
357
|
-
"button",
|
|
358
|
-
{
|
|
359
|
-
onClick: onSave,
|
|
360
|
-
disabled: !isDirty || saving,
|
|
361
|
-
style: {
|
|
362
|
-
padding: "6px 14px",
|
|
363
|
-
borderRadius: "4px",
|
|
364
|
-
border: "1px solid var(--border-glow)",
|
|
365
|
-
background: "transparent",
|
|
366
|
-
color: "var(--text-muted)",
|
|
367
|
-
fontWeight: 500,
|
|
368
|
-
fontSize: "13px",
|
|
369
|
-
cursor: !isDirty || saving ? "not-allowed" : "pointer",
|
|
370
|
-
opacity: !isDirty || saving ? 0.4 : 1
|
|
371
|
-
},
|
|
372
|
-
children: "Save"
|
|
373
|
-
}
|
|
374
|
-
),
|
|
375
|
-
/* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
|
|
376
|
-
"button",
|
|
377
|
-
{
|
|
378
|
-
onClick: onPublish,
|
|
379
|
-
disabled: saving,
|
|
380
|
-
style: {
|
|
381
|
-
padding: "6px 16px",
|
|
382
|
-
borderRadius: "4px",
|
|
383
|
-
border: "1px solid var(--accent-cyan)",
|
|
384
|
-
background: "rgba(0, 212, 255, 0.1)",
|
|
385
|
-
color: "var(--accent-cyan)",
|
|
386
|
-
fontWeight: 600,
|
|
387
|
-
fontSize: "13px",
|
|
388
|
-
cursor: saving ? "not-allowed" : "pointer",
|
|
389
|
-
opacity: saving ? 0.5 : 1,
|
|
390
|
-
boxShadow: "0 0 12px rgba(0, 212, 255, 0.15)"
|
|
391
|
-
},
|
|
392
|
-
children: hasPublished ? "Re-publish" : "Publish"
|
|
393
|
-
}
|
|
394
|
-
)
|
|
395
|
-
] });
|
|
396
|
-
};
|
|
397
276
|
var ContentEditorInner = ({
|
|
398
277
|
contentKey,
|
|
399
278
|
config,
|
|
@@ -404,16 +283,35 @@ var ContentEditorInner = ({
|
|
|
404
283
|
const {
|
|
405
284
|
content,
|
|
406
285
|
states,
|
|
286
|
+
versions,
|
|
407
287
|
saving,
|
|
408
288
|
loading,
|
|
409
289
|
error,
|
|
410
290
|
saveDraft,
|
|
411
291
|
publish,
|
|
412
|
-
revertToPublished
|
|
292
|
+
revertToPublished,
|
|
293
|
+
loadVersions
|
|
413
294
|
} = (0, import_puck_api2.usePuckContent)(contentKey);
|
|
414
295
|
const latestDataRef = (0, import_react2.useRef)(null);
|
|
415
296
|
const [hasUnsavedChanges, setHasUnsavedChanges] = (0, import_react2.useState)(false);
|
|
297
|
+
const [isApplyingVersion, setIsApplyingVersion] = (0, import_react2.useState)(false);
|
|
298
|
+
const currentData = states.draft?.data ?? content?.data ?? {
|
|
299
|
+
content: [],
|
|
300
|
+
root: { props: {} }
|
|
301
|
+
};
|
|
302
|
+
const versionHistory = (0, import_puck_version_history.useVersionHistoryPanel)({
|
|
303
|
+
versions,
|
|
304
|
+
loadVersions,
|
|
305
|
+
currentData
|
|
306
|
+
});
|
|
307
|
+
const diff = (0, import_puck_version_history.useVersionDiff)(
|
|
308
|
+
versionHistory.previewData,
|
|
309
|
+
currentData
|
|
310
|
+
);
|
|
311
|
+
const isPreviewingRef = (0, import_react2.useRef)(false);
|
|
312
|
+
isPreviewingRef.current = versionHistory.isPreviewingHistory;
|
|
416
313
|
const handleChange = (0, import_react2.useCallback)((data) => {
|
|
314
|
+
if (isPreviewingRef.current) return;
|
|
417
315
|
latestDataRef.current = data;
|
|
418
316
|
setHasUnsavedChanges(true);
|
|
419
317
|
}, []);
|
|
@@ -449,6 +347,21 @@ var ContentEditorInner = ({
|
|
|
449
347
|
onError?.(err);
|
|
450
348
|
}
|
|
451
349
|
}, [revertToPublished, onError]);
|
|
350
|
+
const handleApplyVersion = (0, import_react2.useCallback)(async () => {
|
|
351
|
+
const versionData = versionHistory.previewData;
|
|
352
|
+
if (!versionData) return;
|
|
353
|
+
setIsApplyingVersion(true);
|
|
354
|
+
try {
|
|
355
|
+
await saveDraft(versionData);
|
|
356
|
+
setHasUnsavedChanges(false);
|
|
357
|
+
onSave?.(versionData);
|
|
358
|
+
versionHistory.clearSelection();
|
|
359
|
+
} catch (err) {
|
|
360
|
+
onError?.(err);
|
|
361
|
+
} finally {
|
|
362
|
+
setIsApplyingVersion(false);
|
|
363
|
+
}
|
|
364
|
+
}, [versionHistory, saveDraft, onSave, onError]);
|
|
452
365
|
const contentConfig = (0, import_react2.useMemo)(() => {
|
|
453
366
|
const otherRootFields = Object.fromEntries(
|
|
454
367
|
Object.entries(config.root?.fields ?? {}).filter(([k]) => k !== "title")
|
|
@@ -471,69 +384,73 @@ var ContentEditorInner = ({
|
|
|
471
384
|
};
|
|
472
385
|
}, [config]);
|
|
473
386
|
if (loading) {
|
|
474
|
-
return /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
|
|
475
|
-
|
|
476
|
-
{
|
|
477
|
-
|
|
478
|
-
display: "flex",
|
|
479
|
-
alignItems: "center",
|
|
480
|
-
justifyContent: "center",
|
|
481
|
-
height: "100vh",
|
|
482
|
-
fontSize: "16px",
|
|
483
|
-
color: "var(--text-muted)"
|
|
484
|
-
},
|
|
485
|
-
children: "Loading editor\u2026"
|
|
486
|
-
}
|
|
487
|
-
);
|
|
387
|
+
return /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("div", { style: { display: "flex", alignItems: "center", justifyContent: "center", height: "100vh" }, children: /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)(import_spacings2.default.Stack, { scale: "m", alignItems: "center", children: [
|
|
388
|
+
/* @__PURE__ */ (0, import_jsx_runtime2.jsx)(import_loading_spinner2.default, {}),
|
|
389
|
+
/* @__PURE__ */ (0, import_jsx_runtime2.jsx)(import_text2.default.Body, { tone: "secondary", children: "Loading editor\u2026" })
|
|
390
|
+
] }) });
|
|
488
391
|
}
|
|
489
392
|
if (error) {
|
|
490
|
-
return /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)(
|
|
491
|
-
"
|
|
492
|
-
|
|
493
|
-
|
|
494
|
-
|
|
495
|
-
color: "var(--status-error)",
|
|
496
|
-
background: "rgba(248, 113, 113, 0.08)",
|
|
497
|
-
border: "1px solid rgba(248, 113, 113, 0.25)",
|
|
498
|
-
borderRadius: "8px",
|
|
499
|
-
margin: "16px"
|
|
500
|
-
},
|
|
501
|
-
children: [
|
|
502
|
-
/* @__PURE__ */ (0, import_jsx_runtime2.jsx)("strong", { children: "Error loading content:" }),
|
|
503
|
-
" ",
|
|
504
|
-
error
|
|
505
|
-
]
|
|
506
|
-
}
|
|
507
|
-
);
|
|
393
|
+
return /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("div", { style: { padding: "32px" }, children: /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)(import_text2.default.Body, { tone: "negative", children: [
|
|
394
|
+
/* @__PURE__ */ (0, import_jsx_runtime2.jsx)("strong", { children: "Error loading content:" }),
|
|
395
|
+
" ",
|
|
396
|
+
error
|
|
397
|
+
] }) });
|
|
508
398
|
}
|
|
509
|
-
const activeData =
|
|
510
|
-
|
|
511
|
-
|
|
512
|
-
|
|
513
|
-
return /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(import_puck_editor.ComponentSearchProvider, { children: /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
|
|
514
|
-
import_puck.Puck,
|
|
399
|
+
const activeData = versionHistory.previewData ?? currentData;
|
|
400
|
+
const toolbarStates = states;
|
|
401
|
+
return /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
|
|
402
|
+
import_puck_version_history.VersionHistoryProvider,
|
|
515
403
|
{
|
|
516
|
-
|
|
517
|
-
|
|
518
|
-
|
|
519
|
-
|
|
520
|
-
|
|
521
|
-
|
|
522
|
-
|
|
523
|
-
|
|
524
|
-
|
|
525
|
-
|
|
526
|
-
|
|
527
|
-
|
|
528
|
-
|
|
529
|
-
|
|
404
|
+
diff,
|
|
405
|
+
isPreviewingHistory: versionHistory.isPreviewingHistory,
|
|
406
|
+
versions,
|
|
407
|
+
isLoadingVersions: versionHistory.isLoadingVersions,
|
|
408
|
+
selectedVersionId: versionHistory.selectedVersionId,
|
|
409
|
+
isApplying: isApplyingVersion,
|
|
410
|
+
onVersionSelect: versionHistory.selectVersion,
|
|
411
|
+
onApply: () => void handleApplyVersion(),
|
|
412
|
+
onDiscard: versionHistory.clearSelection,
|
|
413
|
+
onLoadVersions: versionHistory.openPanel,
|
|
414
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(import_puck_editor.ComponentSearchProvider, { children: /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
|
|
415
|
+
import_puck.Puck,
|
|
416
|
+
{
|
|
417
|
+
config: contentConfig,
|
|
418
|
+
data: activeData,
|
|
419
|
+
onChange: handleChange,
|
|
420
|
+
onPublish: handlePublish,
|
|
421
|
+
overrides: {
|
|
422
|
+
headerActions: () => versionHistory.isPreviewingHistory ? /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)(import_spacings2.default.Inline, { scale: "s", alignItems: "center", children: [
|
|
423
|
+
/* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
|
|
424
|
+
import_puck_version_history.VersionPreviewBanner,
|
|
425
|
+
{
|
|
426
|
+
timestamp: versionHistory.selectedVersion.timestamp,
|
|
427
|
+
onApply: () => void handleApplyVersion(),
|
|
428
|
+
onDiscard: versionHistory.clearSelection,
|
|
429
|
+
isApplying: isApplyingVersion
|
|
430
|
+
}
|
|
431
|
+
),
|
|
432
|
+
/* @__PURE__ */ (0, import_jsx_runtime2.jsx)(import_puck_version_history.VersionHistoryButton, { disabled: isApplyingVersion })
|
|
433
|
+
] }) : /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
|
|
434
|
+
import_puck_editor.EditorToolbar,
|
|
435
|
+
{
|
|
436
|
+
saving,
|
|
437
|
+
isDirty: hasUnsavedChanges,
|
|
438
|
+
states: toolbarStates,
|
|
439
|
+
onSave: () => void handleSave(),
|
|
440
|
+
onPublish: () => void handlePublish(activeData),
|
|
441
|
+
onRevert: () => void handleRevert(),
|
|
442
|
+
showPublishButton: true
|
|
443
|
+
}
|
|
444
|
+
),
|
|
445
|
+
components: ({ children }) => /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(import_puck_editor.ComponentsPanel, { children }),
|
|
446
|
+
componentItem: ({ children, name }) => /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(import_puck_editor.ComponentItemFilter, { name, children }),
|
|
447
|
+
fields: ({ children, isLoading }) => /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(import_puck_version_history.VersionAwareFieldsPanel, { isLoading, children })
|
|
530
448
|
}
|
|
531
|
-
|
|
532
|
-
|
|
533
|
-
|
|
534
|
-
}
|
|
449
|
+
},
|
|
450
|
+
versionHistory.selectedVersionId ?? "current"
|
|
451
|
+
) })
|
|
535
452
|
}
|
|
536
|
-
)
|
|
453
|
+
);
|
|
537
454
|
};
|
|
538
455
|
var ContentEditor = ({
|
|
539
456
|
baseURL,
|
|
@@ -571,134 +488,24 @@ var import_react_router_dom = require("react-router-dom");
|
|
|
571
488
|
var import_puck3 = require("@measured/puck");
|
|
572
489
|
var import_puck4 = require("@measured/puck/puck.css");
|
|
573
490
|
var import_puck_editor2 = require("@commercetools-demo/puck-editor");
|
|
491
|
+
var import_puck_version_history2 = require("@commercetools-demo/puck-version-history");
|
|
574
492
|
var import_puck_api3 = require("@commercetools-demo/puck-api");
|
|
575
493
|
var import_data_table2 = __toESM(require("@commercetools-uikit/data-table"));
|
|
576
494
|
var import_primary_button2 = __toESM(require("@commercetools-uikit/primary-button"));
|
|
577
495
|
var import_secondary_button2 = __toESM(require("@commercetools-uikit/secondary-button"));
|
|
578
496
|
var import_flat_button2 = __toESM(require("@commercetools-uikit/flat-button"));
|
|
579
497
|
var import_card2 = __toESM(require("@commercetools-uikit/card"));
|
|
580
|
-
var
|
|
581
|
-
var
|
|
582
|
-
var
|
|
498
|
+
var import_spacings3 = __toESM(require("@commercetools-uikit/spacings"));
|
|
499
|
+
var import_text3 = __toESM(require("@commercetools-uikit/text"));
|
|
500
|
+
var import_loading_spinner3 = __toESM(require("@commercetools-uikit/loading-spinner"));
|
|
583
501
|
var import_text_input2 = __toESM(require("@commercetools-uikit/text-input"));
|
|
584
502
|
var import_label2 = __toESM(require("@commercetools-uikit/label"));
|
|
503
|
+
var import_stamp2 = __toESM(require("@commercetools-uikit/stamp"));
|
|
585
504
|
var import_icons2 = require("@commercetools-uikit/icons");
|
|
586
505
|
var import_jsx_runtime3 = require("react/jsx-runtime");
|
|
587
|
-
var
|
|
588
|
-
|
|
589
|
-
|
|
590
|
-
"span",
|
|
591
|
-
{
|
|
592
|
-
style: {
|
|
593
|
-
...styles,
|
|
594
|
-
display: "inline-flex",
|
|
595
|
-
alignItems: "center",
|
|
596
|
-
padding: "2px 8px",
|
|
597
|
-
borderRadius: "var(--border-radius-20)",
|
|
598
|
-
fontSize: "var(--font-size-10)",
|
|
599
|
-
fontWeight: "var(--font-weight-600)",
|
|
600
|
-
marginRight: "4px",
|
|
601
|
-
whiteSpace: "nowrap"
|
|
602
|
-
},
|
|
603
|
-
children: variant === "published" ? "Published" : variant === "draft" ? "Draft" : "No state"
|
|
604
|
-
}
|
|
605
|
-
);
|
|
606
|
-
};
|
|
607
|
-
var BADGE_STYLES2 = {
|
|
608
|
-
saving: { bg: "rgba(251, 191, 36, 0.12)", color: "var(--status-saving)", border: "rgba(251, 191, 36, 0.3)" },
|
|
609
|
-
unsaved: { bg: "rgba(100, 116, 139, 0.12)", color: "var(--text-muted)", border: "rgba(100, 116, 139, 0.3)" },
|
|
610
|
-
draft: { bg: "rgba(129, 140, 248, 0.12)", color: "var(--status-draft)", border: "rgba(129, 140, 248, 0.3)" },
|
|
611
|
-
published: { bg: "rgba(6, 214, 160, 0.12)", color: "var(--status-published)", border: "rgba(6, 214, 160, 0.3)" }
|
|
612
|
-
};
|
|
613
|
-
var EditorStatusBadge = ({ label, variant }) => {
|
|
614
|
-
const bs = BADGE_STYLES2[variant];
|
|
615
|
-
return /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
|
|
616
|
-
"span",
|
|
617
|
-
{
|
|
618
|
-
style: {
|
|
619
|
-
display: "inline-flex",
|
|
620
|
-
alignItems: "center",
|
|
621
|
-
padding: "2px 10px",
|
|
622
|
-
borderRadius: "12px",
|
|
623
|
-
fontSize: "12px",
|
|
624
|
-
fontWeight: 600,
|
|
625
|
-
background: bs.bg,
|
|
626
|
-
color: bs.color,
|
|
627
|
-
border: `1px solid ${bs.border}`
|
|
628
|
-
},
|
|
629
|
-
children: label
|
|
630
|
-
}
|
|
631
|
-
);
|
|
632
|
-
};
|
|
633
|
-
var ContentToolbar2 = ({ saving, isDirty, states, onSave, onPublish, onRevert }) => {
|
|
634
|
-
const hasDraft = Boolean(states.draft);
|
|
635
|
-
const hasPublished = Boolean(states.published);
|
|
636
|
-
return /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)("div", { style: { display: "flex", alignItems: "center", gap: "12px", flexWrap: "wrap" }, children: [
|
|
637
|
-
/* @__PURE__ */ (0, import_jsx_runtime3.jsxs)("div", { style: { display: "flex", alignItems: "center", gap: "6px" }, children: [
|
|
638
|
-
saving && /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(EditorStatusBadge, { label: "Saving\u2026", variant: "saving" }),
|
|
639
|
-
!saving && isDirty && /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(EditorStatusBadge, { label: "Unsaved", variant: "unsaved" }),
|
|
640
|
-
!saving && !isDirty && hasDraft && /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(EditorStatusBadge, { label: "Draft", variant: "draft" }),
|
|
641
|
-
hasPublished && /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(EditorStatusBadge, { label: "Published", variant: "published" })
|
|
642
|
-
] }),
|
|
643
|
-
hasDraft && hasPublished && /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
|
|
644
|
-
"button",
|
|
645
|
-
{
|
|
646
|
-
onClick: onRevert,
|
|
647
|
-
disabled: saving,
|
|
648
|
-
style: {
|
|
649
|
-
padding: "6px 14px",
|
|
650
|
-
borderRadius: "4px",
|
|
651
|
-
border: "1px solid var(--border-glow)",
|
|
652
|
-
background: "transparent",
|
|
653
|
-
color: "var(--text-muted)",
|
|
654
|
-
fontWeight: 500,
|
|
655
|
-
fontSize: "13px",
|
|
656
|
-
cursor: saving ? "not-allowed" : "pointer",
|
|
657
|
-
opacity: saving ? 0.5 : 1
|
|
658
|
-
},
|
|
659
|
-
children: "Revert to Published"
|
|
660
|
-
}
|
|
661
|
-
),
|
|
662
|
-
/* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
|
|
663
|
-
"button",
|
|
664
|
-
{
|
|
665
|
-
onClick: onSave,
|
|
666
|
-
disabled: !isDirty || saving,
|
|
667
|
-
style: {
|
|
668
|
-
padding: "6px 14px",
|
|
669
|
-
borderRadius: "4px",
|
|
670
|
-
border: "1px solid var(--border-glow)",
|
|
671
|
-
background: "transparent",
|
|
672
|
-
color: "var(--text-muted)",
|
|
673
|
-
fontWeight: 500,
|
|
674
|
-
fontSize: "13px",
|
|
675
|
-
cursor: !isDirty || saving ? "not-allowed" : "pointer",
|
|
676
|
-
opacity: !isDirty || saving ? 0.4 : 1
|
|
677
|
-
},
|
|
678
|
-
children: "Save"
|
|
679
|
-
}
|
|
680
|
-
),
|
|
681
|
-
/* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
|
|
682
|
-
"button",
|
|
683
|
-
{
|
|
684
|
-
onClick: onPublish,
|
|
685
|
-
disabled: saving,
|
|
686
|
-
style: {
|
|
687
|
-
padding: "6px 16px",
|
|
688
|
-
borderRadius: "4px",
|
|
689
|
-
border: "1px solid var(--accent-cyan)",
|
|
690
|
-
background: "rgba(0, 212, 255, 0.1)",
|
|
691
|
-
color: "var(--accent-cyan)",
|
|
692
|
-
fontWeight: 600,
|
|
693
|
-
fontSize: "13px",
|
|
694
|
-
cursor: saving ? "not-allowed" : "pointer",
|
|
695
|
-
opacity: saving ? 0.5 : 1,
|
|
696
|
-
boxShadow: "0 0 12px rgba(0, 212, 255, 0.15)"
|
|
697
|
-
},
|
|
698
|
-
children: hasPublished ? "Re-publish" : "Publish"
|
|
699
|
-
}
|
|
700
|
-
)
|
|
701
|
-
] });
|
|
506
|
+
var DEFAULT_CONFIG = {
|
|
507
|
+
...import_puck_editor2.defaultPuckConfig,
|
|
508
|
+
components: { ...import_puck_editor2.defaultPuckConfig.components }
|
|
702
509
|
};
|
|
703
510
|
var NAV_BAR_STYLE = {
|
|
704
511
|
position: "sticky",
|
|
@@ -768,11 +575,11 @@ var ContentListRoute = ({ defaultContentType, backButton }) => {
|
|
|
768
575
|
}
|
|
769
576
|
};
|
|
770
577
|
const rows = contents.map((c) => ({ ...c, id: c.key }));
|
|
771
|
-
return /* @__PURE__ */ (0, import_jsx_runtime3.jsx)("div", { style: { maxWidth: "1200px", margin: "0 auto", padding: "32px 24px" }, children: /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)(
|
|
772
|
-
/* @__PURE__ */ (0, import_jsx_runtime3.jsxs)(
|
|
773
|
-
/* @__PURE__ */ (0, import_jsx_runtime3.jsxs)(
|
|
578
|
+
return /* @__PURE__ */ (0, import_jsx_runtime3.jsx)("div", { style: { maxWidth: "1200px", margin: "0 auto", padding: "32px 24px" }, children: /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)(import_spacings3.default.Stack, { scale: "l", children: [
|
|
579
|
+
/* @__PURE__ */ (0, import_jsx_runtime3.jsxs)(import_spacings3.default.Inline, { justifyContent: "space-between", alignItems: "center", children: [
|
|
580
|
+
/* @__PURE__ */ (0, import_jsx_runtime3.jsxs)(import_spacings3.default.Inline, { scale: "m", alignItems: "center", children: [
|
|
774
581
|
backButton,
|
|
775
|
-
/* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
|
|
582
|
+
/* @__PURE__ */ (0, import_jsx_runtime3.jsx)(import_text3.default.Headline, { as: "h1", children: "Content Items" })
|
|
776
583
|
] }),
|
|
777
584
|
/* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
|
|
778
585
|
import_primary_button2.default,
|
|
@@ -783,11 +590,11 @@ var ContentListRoute = ({ defaultContentType, backButton }) => {
|
|
|
783
590
|
}
|
|
784
591
|
)
|
|
785
592
|
] }),
|
|
786
|
-
showCreate && /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(import_card2.default, { insetScale: "l", children: /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)(
|
|
787
|
-
/* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
|
|
788
|
-
createError && /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
|
|
789
|
-
/* @__PURE__ */ (0, import_jsx_runtime3.jsxs)(
|
|
790
|
-
/* @__PURE__ */ (0, import_jsx_runtime3.jsx)("div", { style: { flex: 1 }, children: /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)(
|
|
593
|
+
showCreate && /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(import_card2.default, { insetScale: "l", children: /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)(import_spacings3.default.Stack, { scale: "m", children: [
|
|
594
|
+
/* @__PURE__ */ (0, import_jsx_runtime3.jsx)(import_text3.default.Subheadline, { as: "h4", isBold: true, children: "Create Content Item" }),
|
|
595
|
+
createError && /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(import_text3.default.Body, { tone: "negative", children: createError }),
|
|
596
|
+
/* @__PURE__ */ (0, import_jsx_runtime3.jsxs)(import_spacings3.default.Inline, { scale: "m", children: [
|
|
597
|
+
/* @__PURE__ */ (0, import_jsx_runtime3.jsx)("div", { style: { flex: 1 }, children: /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)(import_spacings3.default.Stack, { scale: "xs", children: [
|
|
791
598
|
/* @__PURE__ */ (0, import_jsx_runtime3.jsx)(import_label2.default, { htmlFor: "create-content-name", children: "Name" }),
|
|
792
599
|
/* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
|
|
793
600
|
import_text_input2.default,
|
|
@@ -799,7 +606,7 @@ var ContentListRoute = ({ defaultContentType, backButton }) => {
|
|
|
799
606
|
}
|
|
800
607
|
)
|
|
801
608
|
] }) }),
|
|
802
|
-
/* @__PURE__ */ (0, import_jsx_runtime3.jsx)("div", { style: { flex: 1 }, children: /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)(
|
|
609
|
+
/* @__PURE__ */ (0, import_jsx_runtime3.jsx)("div", { style: { flex: 1 }, children: /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)(import_spacings3.default.Stack, { scale: "xs", children: [
|
|
803
610
|
/* @__PURE__ */ (0, import_jsx_runtime3.jsx)(import_label2.default, { htmlFor: "create-content-type", children: "Content Type" }),
|
|
804
611
|
/* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
|
|
805
612
|
import_text_input2.default,
|
|
@@ -812,7 +619,7 @@ var ContentListRoute = ({ defaultContentType, backButton }) => {
|
|
|
812
619
|
)
|
|
813
620
|
] }) })
|
|
814
621
|
] }),
|
|
815
|
-
/* @__PURE__ */ (0, import_jsx_runtime3.jsxs)(
|
|
622
|
+
/* @__PURE__ */ (0, import_jsx_runtime3.jsxs)(import_spacings3.default.Inline, { scale: "s", children: [
|
|
816
623
|
/* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
|
|
817
624
|
import_primary_button2.default,
|
|
818
625
|
{
|
|
@@ -824,7 +631,7 @@ var ContentListRoute = ({ defaultContentType, backButton }) => {
|
|
|
824
631
|
/* @__PURE__ */ (0, import_jsx_runtime3.jsx)(import_secondary_button2.default, { label: "Cancel", onClick: () => setShowCreate(false) })
|
|
825
632
|
] })
|
|
826
633
|
] }) }),
|
|
827
|
-
/* @__PURE__ */ (0, import_jsx_runtime3.jsxs)(
|
|
634
|
+
/* @__PURE__ */ (0, import_jsx_runtime3.jsxs)(import_spacings3.default.Inline, { scale: "s", alignItems: "center", children: [
|
|
828
635
|
/* @__PURE__ */ (0, import_jsx_runtime3.jsx)("div", { style: { flex: 1, maxWidth: "280px" }, children: /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
|
|
829
636
|
import_text_input2.default,
|
|
830
637
|
{
|
|
@@ -853,8 +660,8 @@ var ContentListRoute = ({ defaultContentType, backButton }) => {
|
|
|
853
660
|
),
|
|
854
661
|
/* @__PURE__ */ (0, import_jsx_runtime3.jsx)(import_flat_button2.default, { label: "Refresh", onClick: () => void refresh() })
|
|
855
662
|
] }),
|
|
856
|
-
error && /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
|
|
857
|
-
loading ? /* @__PURE__ */ (0, import_jsx_runtime3.jsx)("div", { style: { display: "flex", justifyContent: "center", padding: "48px" }, children: /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
|
|
663
|
+
error && /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(import_text3.default.Body, { tone: "negative", children: error }),
|
|
664
|
+
loading ? /* @__PURE__ */ (0, import_jsx_runtime3.jsx)("div", { style: { display: "flex", justifyContent: "center", padding: "48px" }, children: /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(import_loading_spinner3.default, {}) }) : contents.length === 0 ? /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(import_spacings3.default.Stack, { scale: "m", alignItems: "center", children: /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(import_text3.default.Body, { tone: "secondary", children: "No content items found." }) }) : /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
|
|
858
665
|
import_data_table2.default,
|
|
859
666
|
{
|
|
860
667
|
columns: COLUMNS,
|
|
@@ -862,7 +669,7 @@ var ContentListRoute = ({ defaultContentType, backButton }) => {
|
|
|
862
669
|
itemRenderer: (row, column) => {
|
|
863
670
|
switch (column.key) {
|
|
864
671
|
case "name":
|
|
865
|
-
return /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
|
|
672
|
+
return /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(import_text3.default.Body, { fontWeight: "bold", children: row.value.name });
|
|
866
673
|
case "contentType":
|
|
867
674
|
return /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
|
|
868
675
|
"code",
|
|
@@ -880,16 +687,16 @@ var ContentListRoute = ({ defaultContentType, backButton }) => {
|
|
|
880
687
|
case "status": {
|
|
881
688
|
const hasDraft = !!row.states.draft;
|
|
882
689
|
const hasPublished = !!row.states.published;
|
|
883
|
-
return /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)("span", { children: [
|
|
884
|
-
hasDraft && /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
|
|
885
|
-
hasPublished && /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
|
|
886
|
-
!hasDraft && !hasPublished && /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
|
|
690
|
+
return /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)("span", { style: { display: "inline-flex", gap: "4px", flexWrap: "wrap" }, children: [
|
|
691
|
+
hasDraft && /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(import_stamp2.default, { tone: "warning", label: "Draft", isCondensed: true }),
|
|
692
|
+
hasPublished && /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(import_stamp2.default, { tone: "positive", label: "Published", isCondensed: true }),
|
|
693
|
+
!hasDraft && !hasPublished && /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(import_stamp2.default, { tone: "secondary", label: "No state", isCondensed: true })
|
|
887
694
|
] });
|
|
888
695
|
}
|
|
889
696
|
case "updatedAt":
|
|
890
|
-
return /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
|
|
697
|
+
return /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(import_text3.default.Body, { tone: "secondary", children: new Date(row.value.updatedAt).toLocaleDateString() });
|
|
891
698
|
case "actions":
|
|
892
|
-
return /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)(
|
|
699
|
+
return /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)(import_spacings3.default.Inline, { scale: "s", alignItems: "center", children: [
|
|
893
700
|
/* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
|
|
894
701
|
import_primary_button2.default,
|
|
895
702
|
{
|
|
@@ -924,16 +731,29 @@ var ContentEditorRoute = ({ config, backButton }) => {
|
|
|
924
731
|
const {
|
|
925
732
|
content,
|
|
926
733
|
states,
|
|
734
|
+
versions,
|
|
927
735
|
saving,
|
|
928
736
|
loading,
|
|
929
737
|
error,
|
|
930
738
|
saveDraft,
|
|
931
739
|
publish,
|
|
932
|
-
revertToPublished
|
|
740
|
+
revertToPublished,
|
|
741
|
+
loadVersions
|
|
933
742
|
} = (0, import_puck_api3.usePuckContent)(contentKey);
|
|
934
743
|
const latestDataRef = (0, import_react3.useRef)(null);
|
|
935
744
|
const [hasUnsavedChanges, setHasUnsavedChanges] = (0, import_react3.useState)(false);
|
|
745
|
+
const [isApplyingVersion, setIsApplyingVersion] = (0, import_react3.useState)(false);
|
|
746
|
+
const currentData = states.draft?.data ?? content?.data ?? { content: [], root: { props: {} } };
|
|
747
|
+
const versionHistory = (0, import_puck_version_history2.useVersionHistoryPanel)({
|
|
748
|
+
versions,
|
|
749
|
+
loadVersions,
|
|
750
|
+
currentData
|
|
751
|
+
});
|
|
752
|
+
const diff = (0, import_puck_version_history2.useVersionDiff)(versionHistory.previewData, currentData);
|
|
753
|
+
const isPreviewingRef = (0, import_react3.useRef)(false);
|
|
754
|
+
isPreviewingRef.current = versionHistory.isPreviewingHistory;
|
|
936
755
|
const handleChange = (0, import_react3.useCallback)((data) => {
|
|
756
|
+
if (isPreviewingRef.current) return;
|
|
937
757
|
latestDataRef.current = data;
|
|
938
758
|
setHasUnsavedChanges(true);
|
|
939
759
|
}, []);
|
|
@@ -967,6 +787,20 @@ var ContentEditorRoute = ({ config, backButton }) => {
|
|
|
967
787
|
console.error("[ContentManagerRouter] revert error:", err);
|
|
968
788
|
}
|
|
969
789
|
}, [revertToPublished]);
|
|
790
|
+
const handleApplyVersion = (0, import_react3.useCallback)(async () => {
|
|
791
|
+
const versionData = versionHistory.previewData;
|
|
792
|
+
if (!versionData) return;
|
|
793
|
+
setIsApplyingVersion(true);
|
|
794
|
+
try {
|
|
795
|
+
await saveDraft(versionData);
|
|
796
|
+
setHasUnsavedChanges(false);
|
|
797
|
+
versionHistory.clearSelection();
|
|
798
|
+
} catch (err) {
|
|
799
|
+
console.error("[ContentManagerRouter] apply version error:", err);
|
|
800
|
+
} finally {
|
|
801
|
+
setIsApplyingVersion(false);
|
|
802
|
+
}
|
|
803
|
+
}, [versionHistory, saveDraft]);
|
|
970
804
|
const contentConfig = (0, import_react3.useMemo)(() => {
|
|
971
805
|
const otherRootFields = Object.fromEntries(
|
|
972
806
|
Object.entries(config.root?.fields ?? {}).filter(([k]) => k !== "title")
|
|
@@ -989,86 +823,90 @@ var ContentEditorRoute = ({ config, backButton }) => {
|
|
|
989
823
|
};
|
|
990
824
|
}, [config]);
|
|
991
825
|
if (loading) {
|
|
992
|
-
return /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
|
|
993
|
-
|
|
994
|
-
{
|
|
995
|
-
|
|
996
|
-
display: "flex",
|
|
997
|
-
alignItems: "center",
|
|
998
|
-
justifyContent: "center",
|
|
999
|
-
height: "100vh",
|
|
1000
|
-
fontSize: "16px",
|
|
1001
|
-
color: "var(--text-muted)"
|
|
1002
|
-
},
|
|
1003
|
-
children: "Loading editor\u2026"
|
|
1004
|
-
}
|
|
1005
|
-
);
|
|
826
|
+
return /* @__PURE__ */ (0, import_jsx_runtime3.jsx)("div", { style: { display: "flex", alignItems: "center", justifyContent: "center", height: "100vh" }, children: /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)(import_spacings3.default.Stack, { scale: "m", alignItems: "center", children: [
|
|
827
|
+
/* @__PURE__ */ (0, import_jsx_runtime3.jsx)(import_loading_spinner3.default, {}),
|
|
828
|
+
/* @__PURE__ */ (0, import_jsx_runtime3.jsx)(import_text3.default.Body, { tone: "secondary", children: "Loading editor\u2026" })
|
|
829
|
+
] }) });
|
|
1006
830
|
}
|
|
1007
831
|
if (error) {
|
|
1008
|
-
return /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)(
|
|
1009
|
-
"
|
|
1010
|
-
|
|
1011
|
-
|
|
1012
|
-
|
|
1013
|
-
color: "var(--status-error)",
|
|
1014
|
-
background: "rgba(248, 113, 113, 0.08)",
|
|
1015
|
-
border: "1px solid rgba(248, 113, 113, 0.25)",
|
|
1016
|
-
borderRadius: "8px",
|
|
1017
|
-
margin: "16px"
|
|
1018
|
-
},
|
|
1019
|
-
children: [
|
|
1020
|
-
/* @__PURE__ */ (0, import_jsx_runtime3.jsx)("strong", { children: "Error loading content:" }),
|
|
1021
|
-
" ",
|
|
1022
|
-
error
|
|
1023
|
-
]
|
|
1024
|
-
}
|
|
1025
|
-
);
|
|
832
|
+
return /* @__PURE__ */ (0, import_jsx_runtime3.jsx)("div", { style: { padding: "32px" }, children: /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)(import_text3.default.Body, { tone: "negative", children: [
|
|
833
|
+
/* @__PURE__ */ (0, import_jsx_runtime3.jsx)("strong", { children: "Error loading content:" }),
|
|
834
|
+
" ",
|
|
835
|
+
error
|
|
836
|
+
] }) });
|
|
1026
837
|
}
|
|
1027
|
-
const activeData =
|
|
1028
|
-
|
|
1029
|
-
|
|
1030
|
-
|
|
1031
|
-
|
|
1032
|
-
|
|
1033
|
-
|
|
1034
|
-
|
|
1035
|
-
|
|
1036
|
-
|
|
1037
|
-
|
|
1038
|
-
|
|
1039
|
-
|
|
1040
|
-
|
|
1041
|
-
|
|
1042
|
-
|
|
1043
|
-
|
|
1044
|
-
|
|
1045
|
-
|
|
1046
|
-
|
|
1047
|
-
|
|
1048
|
-
import_puck3.Puck,
|
|
1049
|
-
{
|
|
1050
|
-
config: contentConfig,
|
|
1051
|
-
data: activeData,
|
|
1052
|
-
onChange: handleChange,
|
|
1053
|
-
onPublish: handlePublish,
|
|
1054
|
-
overrides: {
|
|
1055
|
-
headerActions: () => /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
|
|
1056
|
-
ContentToolbar2,
|
|
838
|
+
const activeData = versionHistory.previewData ?? currentData;
|
|
839
|
+
const toolbarStates = states;
|
|
840
|
+
return /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
|
|
841
|
+
import_puck_version_history2.VersionHistoryProvider,
|
|
842
|
+
{
|
|
843
|
+
diff,
|
|
844
|
+
isPreviewingHistory: versionHistory.isPreviewingHistory,
|
|
845
|
+
versions,
|
|
846
|
+
isLoadingVersions: versionHistory.isLoadingVersions,
|
|
847
|
+
selectedVersionId: versionHistory.selectedVersionId,
|
|
848
|
+
isApplying: isApplyingVersion,
|
|
849
|
+
onVersionSelect: versionHistory.selectVersion,
|
|
850
|
+
onApply: () => void handleApplyVersion(),
|
|
851
|
+
onDiscard: versionHistory.clearSelection,
|
|
852
|
+
onLoadVersions: versionHistory.openPanel,
|
|
853
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)("div", { style: { display: "flex", flexDirection: "column", height: "100%" }, children: [
|
|
854
|
+
/* @__PURE__ */ (0, import_jsx_runtime3.jsxs)("div", { style: NAV_BAR_STYLE, children: [
|
|
855
|
+
backButton,
|
|
856
|
+
backButton && /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(import_text3.default.Body, { tone: "secondary", children: "/" }),
|
|
857
|
+
/* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
|
|
858
|
+
import_flat_button2.default,
|
|
1057
859
|
{
|
|
1058
|
-
|
|
1059
|
-
|
|
1060
|
-
|
|
1061
|
-
|
|
1062
|
-
onPublish: () => void handlePublish(activeData),
|
|
1063
|
-
onRevert: () => void handleRevert()
|
|
860
|
+
label: "Content Items",
|
|
861
|
+
icon: /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(import_icons2.AngleLeftIcon, {}),
|
|
862
|
+
iconPosition: "left",
|
|
863
|
+
onClick: () => history.push("/")
|
|
1064
864
|
}
|
|
1065
865
|
),
|
|
1066
|
-
|
|
1067
|
-
|
|
1068
|
-
}
|
|
1069
|
-
|
|
1070
|
-
|
|
1071
|
-
|
|
866
|
+
/* @__PURE__ */ (0, import_jsx_runtime3.jsx)(import_text3.default.Body, { tone: "secondary", children: "/" }),
|
|
867
|
+
/* @__PURE__ */ (0, import_jsx_runtime3.jsx)(import_text3.default.Body, { fontWeight: "bold", children: contentName })
|
|
868
|
+
] }),
|
|
869
|
+
/* @__PURE__ */ (0, import_jsx_runtime3.jsx)("div", { style: { flex: 1, overflow: "hidden" }, children: /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(import_puck_editor2.ComponentSearchProvider, { children: /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
|
|
870
|
+
import_puck3.Puck,
|
|
871
|
+
{
|
|
872
|
+
config: contentConfig,
|
|
873
|
+
data: activeData,
|
|
874
|
+
onChange: handleChange,
|
|
875
|
+
onPublish: handlePublish,
|
|
876
|
+
overrides: {
|
|
877
|
+
headerActions: () => versionHistory.isPreviewingHistory ? /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)(import_spacings3.default.Inline, { scale: "s", alignItems: "center", children: [
|
|
878
|
+
/* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
|
|
879
|
+
import_puck_version_history2.VersionPreviewBanner,
|
|
880
|
+
{
|
|
881
|
+
timestamp: versionHistory.selectedVersion.timestamp,
|
|
882
|
+
onApply: () => void handleApplyVersion(),
|
|
883
|
+
onDiscard: versionHistory.clearSelection,
|
|
884
|
+
isApplying: isApplyingVersion
|
|
885
|
+
}
|
|
886
|
+
),
|
|
887
|
+
/* @__PURE__ */ (0, import_jsx_runtime3.jsx)(import_puck_version_history2.VersionHistoryButton, { disabled: isApplyingVersion })
|
|
888
|
+
] }) : /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
|
|
889
|
+
import_puck_editor2.EditorToolbar,
|
|
890
|
+
{
|
|
891
|
+
saving,
|
|
892
|
+
isDirty: hasUnsavedChanges,
|
|
893
|
+
states: toolbarStates,
|
|
894
|
+
onSave: () => void handleSave(),
|
|
895
|
+
onPublish: () => void handlePublish(activeData),
|
|
896
|
+
onRevert: () => void handleRevert(),
|
|
897
|
+
showPublishButton: true
|
|
898
|
+
}
|
|
899
|
+
),
|
|
900
|
+
components: ({ children }) => /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(import_puck_editor2.ComponentsPanel, { children }),
|
|
901
|
+
componentItem: ({ children, name }) => /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(import_puck_editor2.ComponentItemFilter, { name, children }),
|
|
902
|
+
fields: ({ children, isLoading }) => /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(import_puck_version_history2.VersionAwareFieldsPanel, { isLoading, children })
|
|
903
|
+
}
|
|
904
|
+
},
|
|
905
|
+
versionHistory.selectedVersionId ?? "current"
|
|
906
|
+
) }) })
|
|
907
|
+
] })
|
|
908
|
+
}
|
|
909
|
+
);
|
|
1072
910
|
};
|
|
1073
911
|
var ContentManagerRouterInner = ({
|
|
1074
912
|
config,
|
|
@@ -1091,13 +929,13 @@ var ContentManagerRouterInner = ({
|
|
|
1091
929
|
}
|
|
1092
930
|
)
|
|
1093
931
|
] });
|
|
1094
|
-
var
|
|
932
|
+
var ContentManager = ({
|
|
1095
933
|
parentUrl,
|
|
1096
934
|
baseURL,
|
|
1097
935
|
projectKey,
|
|
1098
936
|
businessUnitKey,
|
|
1099
937
|
jwtToken,
|
|
1100
|
-
config,
|
|
938
|
+
config = DEFAULT_CONFIG,
|
|
1101
939
|
defaultContentType,
|
|
1102
940
|
backButton
|
|
1103
941
|
}) => /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
|
|
@@ -1121,6 +959,6 @@ var ContentManagerRouter = ({
|
|
|
1121
959
|
0 && (module.exports = {
|
|
1122
960
|
ContentEditor,
|
|
1123
961
|
ContentManager,
|
|
1124
|
-
|
|
962
|
+
ContentManagerList
|
|
1125
963
|
});
|
|
1126
964
|
//# sourceMappingURL=index.js.map
|