@orion-studios/payload-studio 0.5.0-beta.15 → 0.5.0-beta.17
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/studio-pages/client.mjs +35 -2
- package/package.json +1 -1
- package/dist/OrionBlocksFieldImpl-QX5GTMQZ.mjs +0 -904
- package/dist/admin/client.js +0 -3176
- package/dist/admin/client.mjs +0 -1994
- package/dist/admin/index.js +0 -303
- package/dist/admin/index.mjs +0 -13
- package/dist/admin-app/client.js +0 -136
- package/dist/admin-app/client.mjs +0 -110
- package/dist/admin-app/index.js +0 -82
- package/dist/admin-app/index.mjs +0 -13
- package/dist/admin-app/styles.css +0 -122
- package/dist/admin.css +0 -443
- package/dist/blocks/index.js +0 -1197
- package/dist/blocks/index.mjs +0 -42
- package/dist/chunk-6BWS3CLP.mjs +0 -16
- package/dist/chunk-AAOHJDNS.mjs +0 -67
- package/dist/chunk-ETRRXURT.mjs +0 -141
- package/dist/chunk-J7W5EE3B.mjs +0 -278
- package/dist/chunk-L36VUYHE.mjs +0 -1048
- package/dist/chunk-N67KVM2S.mjs +0 -156
- package/dist/chunk-NIRXZKDV.mjs +0 -304
- package/dist/chunk-PGLMIFRY.mjs +0 -209
- package/dist/chunk-ZLLNO5FM.mjs +0 -229
- package/dist/index.js +0 -2176
- package/dist/index.mjs +0 -28
- package/dist/nextjs/index.js +0 -244
- package/dist/nextjs/index.mjs +0 -15
- package/dist/studio/index.js +0 -171
- package/dist/studio/index.mjs +0 -17
- package/dist/studio-pages/builder.css +0 -502
- package/dist/studio-pages/client.js +0 -3873
|
@@ -773,6 +773,19 @@ function getRelationID(value) {
|
|
|
773
773
|
}
|
|
774
774
|
return null;
|
|
775
775
|
}
|
|
776
|
+
function getMediaURL(value) {
|
|
777
|
+
if (!value || typeof value !== "object") {
|
|
778
|
+
return "";
|
|
779
|
+
}
|
|
780
|
+
const typed = value;
|
|
781
|
+
if (typeof typed.url === "string" && typed.url.trim().length > 0) {
|
|
782
|
+
return typed.url.trim();
|
|
783
|
+
}
|
|
784
|
+
if (typeof typed.filename === "string" && typed.filename.trim().length > 0) {
|
|
785
|
+
return `/api/media/file/${encodeURIComponent(typed.filename)}`;
|
|
786
|
+
}
|
|
787
|
+
return "";
|
|
788
|
+
}
|
|
776
789
|
function extractUploadedMedia(value) {
|
|
777
790
|
const candidate = value && typeof value === "object" && "doc" in value ? value.doc : value;
|
|
778
791
|
if (!candidate || typeof candidate !== "object") {
|
|
@@ -1438,6 +1451,25 @@ function BuilderPageEditor({ initialDoc, pageID }) {
|
|
|
1438
1451
|
setUploadingTarget(null);
|
|
1439
1452
|
}
|
|
1440
1453
|
};
|
|
1454
|
+
const withHeroMediaFallbacks = (sourceLayout) => sourceLayout.map((block) => {
|
|
1455
|
+
if (!block || typeof block !== "object") {
|
|
1456
|
+
return block;
|
|
1457
|
+
}
|
|
1458
|
+
const nextBlock = { ...block };
|
|
1459
|
+
const blockType = normalizeText(nextBlock.blockType);
|
|
1460
|
+
if (blockType !== "hero") {
|
|
1461
|
+
return nextBlock;
|
|
1462
|
+
}
|
|
1463
|
+
const existingBackgroundImageURL = normalizeText(nextBlock.backgroundImageURL).trim();
|
|
1464
|
+
if (existingBackgroundImageURL.length > 0) {
|
|
1465
|
+
return nextBlock;
|
|
1466
|
+
}
|
|
1467
|
+
const mediaURL = getMediaURL(nextBlock.media);
|
|
1468
|
+
if (mediaURL.length > 0) {
|
|
1469
|
+
nextBlock.backgroundImageURL = mediaURL;
|
|
1470
|
+
}
|
|
1471
|
+
return nextBlock;
|
|
1472
|
+
});
|
|
1441
1473
|
const toPersistedLayout = (sourceLayout) => sourceLayout.map((block) => {
|
|
1442
1474
|
if (!block || typeof block !== "object") {
|
|
1443
1475
|
return block;
|
|
@@ -1601,13 +1633,14 @@ function BuilderPageEditor({ initialDoc, pageID }) {
|
|
|
1601
1633
|
setSaveError("");
|
|
1602
1634
|
setSaveMessage("");
|
|
1603
1635
|
try {
|
|
1604
|
-
const
|
|
1636
|
+
const normalizedLayout = withHeroMediaFallbacks(layout);
|
|
1637
|
+
const persistedLayout = toPersistedLayout(normalizedLayout);
|
|
1605
1638
|
const response = await fetch(`/api/pages/${pageID}`, {
|
|
1606
1639
|
body: JSON.stringify({
|
|
1607
1640
|
_status: status,
|
|
1608
1641
|
layout: persistedLayout,
|
|
1609
1642
|
studioDocument: layoutToStudioDocument(
|
|
1610
|
-
|
|
1643
|
+
normalizedLayout,
|
|
1611
1644
|
title,
|
|
1612
1645
|
{
|
|
1613
1646
|
pageWidthDefault: pageDefaults.pageWidthDefault
|