@orion-studios/payload-studio 0.6.0-beta.112 → 0.6.0-beta.114
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.
|
@@ -695,6 +695,51 @@ var syncModelBackgroundToBlock = (model) => {
|
|
|
695
695
|
})
|
|
696
696
|
});
|
|
697
697
|
};
|
|
698
|
+
var spacingLonghands = [
|
|
699
|
+
"margin-top",
|
|
700
|
+
"margin-bottom",
|
|
701
|
+
"margin-left",
|
|
702
|
+
"margin-right",
|
|
703
|
+
"padding-top",
|
|
704
|
+
"padding-bottom",
|
|
705
|
+
"padding-left",
|
|
706
|
+
"padding-right"
|
|
707
|
+
];
|
|
708
|
+
var hasSpacingStyle = (style, property) => Boolean(style[property] || style[property.replace(/-([a-z])/g, (_, char) => char.toUpperCase())]);
|
|
709
|
+
var hoistPreviewSpacingToModel = (view) => {
|
|
710
|
+
const element = view.el;
|
|
711
|
+
const preview = element?.querySelector?.(".xo-builder-preview");
|
|
712
|
+
if (!preview) {
|
|
713
|
+
return;
|
|
714
|
+
}
|
|
715
|
+
const model = view.model;
|
|
716
|
+
const style = model.getStyle?.() || {};
|
|
717
|
+
const computed = window.getComputedStyle(preview);
|
|
718
|
+
const nextStyle = {};
|
|
719
|
+
spacingLonghands.forEach((property) => {
|
|
720
|
+
const isPadding = property.startsWith("padding-");
|
|
721
|
+
if (hasSpacingStyle(style, property) || hasSpacingStyle(style, isPadding ? "padding" : "margin")) {
|
|
722
|
+
return;
|
|
723
|
+
}
|
|
724
|
+
const value = computed.getPropertyValue(property).trim();
|
|
725
|
+
if (value && (isPadding || value !== "0px")) {
|
|
726
|
+
nextStyle[property] = value;
|
|
727
|
+
}
|
|
728
|
+
});
|
|
729
|
+
if (Object.keys(nextStyle).length > 0) {
|
|
730
|
+
model.addStyle?.(nextStyle);
|
|
731
|
+
}
|
|
732
|
+
preview.style.margin = "0";
|
|
733
|
+
preview.style.marginTop = "0";
|
|
734
|
+
preview.style.marginRight = "0";
|
|
735
|
+
preview.style.marginBottom = "0";
|
|
736
|
+
preview.style.marginLeft = "0";
|
|
737
|
+
preview.style.padding = "0";
|
|
738
|
+
preview.style.paddingTop = "0";
|
|
739
|
+
preview.style.paddingRight = "0";
|
|
740
|
+
preview.style.paddingBottom = "0";
|
|
741
|
+
preview.style.paddingLeft = "0";
|
|
742
|
+
};
|
|
698
743
|
var previewForDefinition = (definition, props) => definition.editorPreview?.(props) || `<div class="orion-builder-v2-dynamic-placeholder"><strong>${definition.label}</strong></div>`;
|
|
699
744
|
var blockPreviewForDefinition = (type) => {
|
|
700
745
|
const normalizedType = type.replace(/[^a-z0-9-]/gi, "-");
|
|
@@ -1032,6 +1077,7 @@ var registerProjectDynamicComponents = (editor, adapter) => {
|
|
|
1032
1077
|
this.model.addAttributes?.({ "data-orion-background-color": backgroundColor });
|
|
1033
1078
|
}
|
|
1034
1079
|
this.model.components(previewForDefinition(definition, props));
|
|
1080
|
+
hoistPreviewSpacingToModel(this);
|
|
1035
1081
|
lockPreviewChildren(this.model);
|
|
1036
1082
|
queueMicrotask(() => bindEditablePreview(this, editor));
|
|
1037
1083
|
}
|
|
@@ -1511,6 +1557,37 @@ var readStylePanelColor = (property) => {
|
|
|
1511
1557
|
return swatchColor;
|
|
1512
1558
|
};
|
|
1513
1559
|
var readStylePanelRadio = (property) => (readStylePanelValue(property)?.querySelector("input:checked")?.value || "").trim();
|
|
1560
|
+
var writeStylePanelLength = (property, value) => {
|
|
1561
|
+
const control = readStylePanelValue(property);
|
|
1562
|
+
const input = control?.querySelector("input");
|
|
1563
|
+
if (!input) {
|
|
1564
|
+
return;
|
|
1565
|
+
}
|
|
1566
|
+
const match = value.trim().match(/^(-?\d*\.?\d+)([a-z%]*)$/i);
|
|
1567
|
+
if (!match) {
|
|
1568
|
+
return;
|
|
1569
|
+
}
|
|
1570
|
+
const [, amount, unit = "px"] = match;
|
|
1571
|
+
const unitSelect = control?.querySelector("select");
|
|
1572
|
+
input.value = amount;
|
|
1573
|
+
if (unitSelect) {
|
|
1574
|
+
unitSelect.value = unit || "px";
|
|
1575
|
+
}
|
|
1576
|
+
};
|
|
1577
|
+
var spacingProperties = [
|
|
1578
|
+
"margin-top",
|
|
1579
|
+
"margin-bottom",
|
|
1580
|
+
"margin-left",
|
|
1581
|
+
"margin-right",
|
|
1582
|
+
"padding-top",
|
|
1583
|
+
"padding-bottom",
|
|
1584
|
+
"padding-left",
|
|
1585
|
+
"padding-right"
|
|
1586
|
+
];
|
|
1587
|
+
var spacingTargetForComponent = (component) => {
|
|
1588
|
+
const element = component?.getEl?.();
|
|
1589
|
+
return element || null;
|
|
1590
|
+
};
|
|
1514
1591
|
var hasExplicitHorizontalAlign = (block) => {
|
|
1515
1592
|
const settings = readNestedRecord(block, "settings");
|
|
1516
1593
|
const typography = readNestedRecord(settings, "typography");
|
|
@@ -2264,6 +2341,16 @@ function GrapesPageEditor({
|
|
|
2264
2341
|
hydrateSelectedTypographyStyleFromOrionBlock(component);
|
|
2265
2342
|
rememberComponentSnapshot(component);
|
|
2266
2343
|
refreshSelectedState(component);
|
|
2344
|
+
window.requestAnimationFrame(() => {
|
|
2345
|
+
const element = spacingTargetForComponent(component);
|
|
2346
|
+
if (!element) {
|
|
2347
|
+
return;
|
|
2348
|
+
}
|
|
2349
|
+
const computed = window.getComputedStyle(element);
|
|
2350
|
+
spacingProperties.forEach((property) => {
|
|
2351
|
+
writeStylePanelLength(property, computed.getPropertyValue(property));
|
|
2352
|
+
});
|
|
2353
|
+
});
|
|
2267
2354
|
};
|
|
2268
2355
|
const applyQuickLayout = (layout) => {
|
|
2269
2356
|
const nextStyle = quickLayoutStyles[layout];
|
|
@@ -571,6 +571,51 @@ var syncModelBackgroundToBlock = (model) => {
|
|
|
571
571
|
})
|
|
572
572
|
});
|
|
573
573
|
};
|
|
574
|
+
var spacingLonghands = [
|
|
575
|
+
"margin-top",
|
|
576
|
+
"margin-bottom",
|
|
577
|
+
"margin-left",
|
|
578
|
+
"margin-right",
|
|
579
|
+
"padding-top",
|
|
580
|
+
"padding-bottom",
|
|
581
|
+
"padding-left",
|
|
582
|
+
"padding-right"
|
|
583
|
+
];
|
|
584
|
+
var hasSpacingStyle = (style, property) => Boolean(style[property] || style[property.replace(/-([a-z])/g, (_, char) => char.toUpperCase())]);
|
|
585
|
+
var hoistPreviewSpacingToModel = (view) => {
|
|
586
|
+
const element = view.el;
|
|
587
|
+
const preview = element?.querySelector?.(".xo-builder-preview");
|
|
588
|
+
if (!preview) {
|
|
589
|
+
return;
|
|
590
|
+
}
|
|
591
|
+
const model = view.model;
|
|
592
|
+
const style = model.getStyle?.() || {};
|
|
593
|
+
const computed = window.getComputedStyle(preview);
|
|
594
|
+
const nextStyle = {};
|
|
595
|
+
spacingLonghands.forEach((property) => {
|
|
596
|
+
const isPadding = property.startsWith("padding-");
|
|
597
|
+
if (hasSpacingStyle(style, property) || hasSpacingStyle(style, isPadding ? "padding" : "margin")) {
|
|
598
|
+
return;
|
|
599
|
+
}
|
|
600
|
+
const value = computed.getPropertyValue(property).trim();
|
|
601
|
+
if (value && (isPadding || value !== "0px")) {
|
|
602
|
+
nextStyle[property] = value;
|
|
603
|
+
}
|
|
604
|
+
});
|
|
605
|
+
if (Object.keys(nextStyle).length > 0) {
|
|
606
|
+
model.addStyle?.(nextStyle);
|
|
607
|
+
}
|
|
608
|
+
preview.style.margin = "0";
|
|
609
|
+
preview.style.marginTop = "0";
|
|
610
|
+
preview.style.marginRight = "0";
|
|
611
|
+
preview.style.marginBottom = "0";
|
|
612
|
+
preview.style.marginLeft = "0";
|
|
613
|
+
preview.style.padding = "0";
|
|
614
|
+
preview.style.paddingTop = "0";
|
|
615
|
+
preview.style.paddingRight = "0";
|
|
616
|
+
preview.style.paddingBottom = "0";
|
|
617
|
+
preview.style.paddingLeft = "0";
|
|
618
|
+
};
|
|
574
619
|
var previewForDefinition = (definition, props) => definition.editorPreview?.(props) || `<div class="orion-builder-v2-dynamic-placeholder"><strong>${definition.label}</strong></div>`;
|
|
575
620
|
var blockPreviewForDefinition = (type) => {
|
|
576
621
|
const normalizedType = type.replace(/[^a-z0-9-]/gi, "-");
|
|
@@ -908,6 +953,7 @@ var registerProjectDynamicComponents = (editor, adapter) => {
|
|
|
908
953
|
this.model.addAttributes?.({ "data-orion-background-color": backgroundColor });
|
|
909
954
|
}
|
|
910
955
|
this.model.components(previewForDefinition(definition, props));
|
|
956
|
+
hoistPreviewSpacingToModel(this);
|
|
911
957
|
lockPreviewChildren(this.model);
|
|
912
958
|
queueMicrotask(() => bindEditablePreview(this, editor));
|
|
913
959
|
}
|
|
@@ -1387,6 +1433,37 @@ var readStylePanelColor = (property) => {
|
|
|
1387
1433
|
return swatchColor;
|
|
1388
1434
|
};
|
|
1389
1435
|
var readStylePanelRadio = (property) => (readStylePanelValue(property)?.querySelector("input:checked")?.value || "").trim();
|
|
1436
|
+
var writeStylePanelLength = (property, value) => {
|
|
1437
|
+
const control = readStylePanelValue(property);
|
|
1438
|
+
const input = control?.querySelector("input");
|
|
1439
|
+
if (!input) {
|
|
1440
|
+
return;
|
|
1441
|
+
}
|
|
1442
|
+
const match = value.trim().match(/^(-?\d*\.?\d+)([a-z%]*)$/i);
|
|
1443
|
+
if (!match) {
|
|
1444
|
+
return;
|
|
1445
|
+
}
|
|
1446
|
+
const [, amount, unit = "px"] = match;
|
|
1447
|
+
const unitSelect = control?.querySelector("select");
|
|
1448
|
+
input.value = amount;
|
|
1449
|
+
if (unitSelect) {
|
|
1450
|
+
unitSelect.value = unit || "px";
|
|
1451
|
+
}
|
|
1452
|
+
};
|
|
1453
|
+
var spacingProperties = [
|
|
1454
|
+
"margin-top",
|
|
1455
|
+
"margin-bottom",
|
|
1456
|
+
"margin-left",
|
|
1457
|
+
"margin-right",
|
|
1458
|
+
"padding-top",
|
|
1459
|
+
"padding-bottom",
|
|
1460
|
+
"padding-left",
|
|
1461
|
+
"padding-right"
|
|
1462
|
+
];
|
|
1463
|
+
var spacingTargetForComponent = (component) => {
|
|
1464
|
+
const element = component?.getEl?.();
|
|
1465
|
+
return element || null;
|
|
1466
|
+
};
|
|
1390
1467
|
var hasExplicitHorizontalAlign = (block) => {
|
|
1391
1468
|
const settings = readNestedRecord(block, "settings");
|
|
1392
1469
|
const typography = readNestedRecord(settings, "typography");
|
|
@@ -2140,6 +2217,16 @@ function GrapesPageEditor({
|
|
|
2140
2217
|
hydrateSelectedTypographyStyleFromOrionBlock(component);
|
|
2141
2218
|
rememberComponentSnapshot(component);
|
|
2142
2219
|
refreshSelectedState(component);
|
|
2220
|
+
window.requestAnimationFrame(() => {
|
|
2221
|
+
const element = spacingTargetForComponent(component);
|
|
2222
|
+
if (!element) {
|
|
2223
|
+
return;
|
|
2224
|
+
}
|
|
2225
|
+
const computed = window.getComputedStyle(element);
|
|
2226
|
+
spacingProperties.forEach((property) => {
|
|
2227
|
+
writeStylePanelLength(property, computed.getPropertyValue(property));
|
|
2228
|
+
});
|
|
2229
|
+
});
|
|
2143
2230
|
};
|
|
2144
2231
|
const applyQuickLayout = (layout) => {
|
|
2145
2232
|
const nextStyle = quickLayoutStyles[layout];
|
package/dist/index.mjs
CHANGED
|
@@ -5,18 +5,18 @@ import {
|
|
|
5
5
|
admin_app_exports
|
|
6
6
|
} from "./chunk-RKTIFEUY.mjs";
|
|
7
7
|
import "./chunk-W2UOCJDX.mjs";
|
|
8
|
+
import {
|
|
9
|
+
blocks_exports
|
|
10
|
+
} from "./chunk-JQAHXYAM.mjs";
|
|
8
11
|
import {
|
|
9
12
|
nextjs_exports
|
|
10
13
|
} from "./chunk-ZADL33R6.mjs";
|
|
11
14
|
import "./chunk-ZTXJG4K5.mjs";
|
|
12
|
-
import {
|
|
13
|
-
blocks_exports
|
|
14
|
-
} from "./chunk-JQAHXYAM.mjs";
|
|
15
15
|
import {
|
|
16
16
|
studio_pages_exports
|
|
17
|
-
} from "./chunk-
|
|
18
|
-
import "./chunk-7ZMXZRBP.mjs";
|
|
17
|
+
} from "./chunk-NGLIA2OE.mjs";
|
|
19
18
|
import "./chunk-OQSEJXC4.mjs";
|
|
19
|
+
import "./chunk-7ZMXZRBP.mjs";
|
|
20
20
|
import {
|
|
21
21
|
studio_exports
|
|
22
22
|
} from "./chunk-ADIIWIYL.mjs";
|
|
@@ -7,14 +7,14 @@ import {
|
|
|
7
7
|
pageStudioModuleManifest,
|
|
8
8
|
resolveBuilderThemeTokens,
|
|
9
9
|
toEditorInitialDoc
|
|
10
|
-
} from "../chunk-
|
|
10
|
+
} from "../chunk-NGLIA2OE.mjs";
|
|
11
|
+
import "../chunk-OQSEJXC4.mjs";
|
|
11
12
|
import {
|
|
12
13
|
createDefaultStudioDocument,
|
|
13
14
|
defaultBuilderThemeTokens,
|
|
14
15
|
layoutToStudioDocument,
|
|
15
16
|
studioDocumentToLayout
|
|
16
17
|
} from "../chunk-7ZMXZRBP.mjs";
|
|
17
|
-
import "../chunk-OQSEJXC4.mjs";
|
|
18
18
|
import "../chunk-ADIIWIYL.mjs";
|
|
19
19
|
import "../chunk-6BWS3CLP.mjs";
|
|
20
20
|
export {
|
package/package.json
CHANGED
|
@@ -1,3 +1,6 @@
|
|
|
1
|
+
import {
|
|
2
|
+
sectionStyleDefaults
|
|
3
|
+
} from "./chunk-OQSEJXC4.mjs";
|
|
1
4
|
import {
|
|
2
5
|
createDefaultStudioDocument,
|
|
3
6
|
defaultBuilderThemeTokens,
|
|
@@ -5,9 +8,6 @@ import {
|
|
|
5
8
|
migrateBlockToSettingsV2,
|
|
6
9
|
studioDocumentToLayout
|
|
7
10
|
} from "./chunk-7ZMXZRBP.mjs";
|
|
8
|
-
import {
|
|
9
|
-
sectionStyleDefaults
|
|
10
|
-
} from "./chunk-OQSEJXC4.mjs";
|
|
11
11
|
import {
|
|
12
12
|
assertStudioDocumentV1,
|
|
13
13
|
compileStudioDocument,
|