@contentful/experiences-visual-editor-react 0.0.1-alpha.3 → 0.0.1-alpha.5
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.js +30 -10
- package/dist/index.js.map +1 -1
- package/dist/renderApp.js +30 -10
- package/dist/renderApp.js.map +1 -1
- package/package.json +4 -4
package/dist/index.js
CHANGED
|
@@ -16,7 +16,7 @@ styleInject(css_248z$7);
|
|
|
16
16
|
|
|
17
17
|
const INCOMING_EVENTS$1 = {
|
|
18
18
|
RequestEditorMode: 'requestEditorMode',
|
|
19
|
-
|
|
19
|
+
ExperienceUpdated: 'componentTreeUpdated',
|
|
20
20
|
ComponentDraggingChanged: 'componentDraggingChanged',
|
|
21
21
|
ComponentDragCanceled: 'componentDragCanceled',
|
|
22
22
|
ComponentDragStarted: 'componentDragStarted',
|
|
@@ -520,7 +520,7 @@ const builtInStyles = {
|
|
|
520
520
|
type: 'Text',
|
|
521
521
|
group: 'style',
|
|
522
522
|
description: 'The border of the section',
|
|
523
|
-
defaultValue: '
|
|
523
|
+
defaultValue: '0px solid rgba(0, 0, 0, 0)',
|
|
524
524
|
},
|
|
525
525
|
cfGap: {
|
|
526
526
|
displayName: 'Gap',
|
|
@@ -1187,6 +1187,13 @@ class EntityStoreBase {
|
|
|
1187
1187
|
}
|
|
1188
1188
|
return this.entryMap.get(id);
|
|
1189
1189
|
}
|
|
1190
|
+
toJSON() {
|
|
1191
|
+
return {
|
|
1192
|
+
entryMap: Object.fromEntries(this.entryMap),
|
|
1193
|
+
assetMap: Object.fromEntries(this.assetMap),
|
|
1194
|
+
locale: this.locale,
|
|
1195
|
+
};
|
|
1196
|
+
}
|
|
1190
1197
|
}
|
|
1191
1198
|
|
|
1192
1199
|
/**
|
|
@@ -1435,7 +1442,7 @@ function gatherDeepReferencesFromTree(startingNode, dataSource) {
|
|
|
1435
1442
|
return deepReferences;
|
|
1436
1443
|
}
|
|
1437
1444
|
|
|
1438
|
-
var css_248z$6 = ".styles-module_DraggableComponent__m5-dA {\n pointer-events: all;\n position: relative;\n transition: outline 0.2s;\n cursor: grab;\n outline-offset: -2px;\n outline: 2px solid transparent;\n
|
|
1445
|
+
var css_248z$6 = ".styles-module_DraggableComponent__m5-dA {\n pointer-events: all;\n position: relative;\n transition: outline 0.2s;\n cursor: grab;\n box-sizing: border-box;\n display: flex;\n}\n\n.styles-module_DraggableComponent__m5-dA:before {\n content: \"\";\n position: absolute;\n top: 0;\n right: 0;\n bottom: 0;\n left: 0;\n outline-offset: -2px;\n outline: 2px solid transparent;\n z-index: 1;\n}\n\n.styles-module_DraggableClone__X8zTA:before {\n outline: 2px solid var(--exp-builder-blue500);\n}\n\n.styles-module_DraggableComponent__m5-dA > * {\n pointer-events: none;\n}\n\n.styles-module_isDragging__WHjPU {\n overflow: hidden;\n}\n\n.styles-module_isDragging__WHjPU * {\n pointer-events: none !important;\n}\n\n.styles-module_isSelected__BzICQ:before {\n outline: 2px solid transparent !important;\n}\n\n.styles-module_overlay__r4th9 {\n position: absolute;\n display: flex;\n align-items: center;\n min-width: max-content;\n height: 24px;\n z-index: 1;\n font-family: var(--exp-builder-font-stack-primary);\n font-size: 14px;\n font-weight: 500;\n background-color: var(--exp-builder-gray500);\n color: var(--exp-builder-color-white);\n border-radius: 0 0 2px 0;\n padding: 4px 12px 4px 12px;\n transition: opacity 0.2s;\n opacity: 0;\n text-wrap: nowrap;\n}\n\n.styles-module_overlayContainer__eiX-5 {\n opacity: 0;\n}\n\n.styles-module_overlayAssembly__tOzZU {\n background-color: var(--exp-builder-purple600);\n}\n\n.styles-module_userIsDragging__lqbjG > .styles-module_overlay__r4th9,\n.styles-module_userIsDragging__lqbjG > .styles-module_overlayContainer__eiX-5 {\n opacity: 0 !important;\n}\n\n.styles-module_userIsDragging__lqbjG:before {\n outline: 2px solid transparent !important;\n}\n\n.styles-module_DraggableComponent__m5-dA:hover:not(:has(div[data-rfd-draggable-id]:hover)) > .styles-module_overlay__r4th9 {\n opacity: 1;\n}\n\n.styles-module_DraggableComponent__m5-dA:hover:before,\n.styles-module_DraggableComponent__m5-dA:hover div[data-rfd-draggable-id]:before {\n outline: 2px dashed var(--exp-builder-gray500);\n}\n\n.styles-module_DraggableComponent__m5-dA:hover:not(:has(div[data-rfd-draggable-id]:hover)):before {\n outline: 2px solid var(--exp-builder-gray500);\n}\n\n.styles-module_isAssemblyBlock__Y3Avk:hover:before,\n.styles-module_isAssemblyBlock__Y3Avk:hover div[data-rfd-draggable-id]:before,\n.styles-module_DraggableComponent__m5-dA:hover div[data-rfd-draggable-id][data-cf-node-block-type^='assembly']:before {\n outline: 2px dashed var(--exp-builder-purple600);\n}\n\n.styles-module_isAssemblyBlock__Y3Avk:hover:not(:has(div[data-rfd-draggable-id]:hover)):before {\n outline: 2px solid var(--exp-builder-purple600);\n}\n";
|
|
1439
1446
|
var styles$3 = {"DraggableComponent":"styles-module_DraggableComponent__m5-dA","DraggableClone":"styles-module_DraggableClone__X8zTA","isDragging":"styles-module_isDragging__WHjPU","isSelected":"styles-module_isSelected__BzICQ","overlay":"styles-module_overlay__r4th9","overlayContainer":"styles-module_overlayContainer__eiX-5","overlayAssembly":"styles-module_overlayAssembly__tOzZU","userIsDragging":"styles-module_userIsDragging__lqbjG","isAssemblyBlock":"styles-module_isAssemblyBlock__Y3Avk"};
|
|
1440
1447
|
styleInject(css_248z$6);
|
|
1441
1448
|
|
|
@@ -1467,7 +1474,7 @@ const OUTGOING_EVENTS = {
|
|
|
1467
1474
|
};
|
|
1468
1475
|
const INCOMING_EVENTS = {
|
|
1469
1476
|
RequestEditorMode: 'requestEditorMode',
|
|
1470
|
-
|
|
1477
|
+
ExperienceUpdated: 'componentTreeUpdated',
|
|
1471
1478
|
ComponentDraggingChanged: 'componentDraggingChanged',
|
|
1472
1479
|
ComponentDragCanceled: 'componentDragCanceled',
|
|
1473
1480
|
ComponentDragStarted: 'componentDragStarted',
|
|
@@ -2009,9 +2016,11 @@ const useSelectedInstanceCoordinates = ({ node }) => {
|
|
|
2009
2016
|
if (selectedNodeId !== node.data.id) {
|
|
2010
2017
|
return;
|
|
2011
2018
|
}
|
|
2019
|
+
// Allows the drop animation to finish before
|
|
2020
|
+
// calculating the components coordinates
|
|
2012
2021
|
setTimeout(() => {
|
|
2013
2022
|
sendSelectedComponentCoordinates(node.data.id);
|
|
2014
|
-
},
|
|
2023
|
+
}, 10);
|
|
2015
2024
|
}, [node, selectedNodeId]);
|
|
2016
2025
|
const selectedElement = node.data.id
|
|
2017
2026
|
? document.querySelector(`[data-cf-node-id="${selectedNodeId}"]`)
|
|
@@ -2388,7 +2397,9 @@ const resolveAssembly = ({ node, entityStore, }) => {
|
|
|
2388
2397
|
});
|
|
2389
2398
|
return node;
|
|
2390
2399
|
}
|
|
2391
|
-
const componentFields = entityStore?.getValue(assembly, [
|
|
2400
|
+
const componentFields = entityStore?.getValue(assembly, [
|
|
2401
|
+
'fields',
|
|
2402
|
+
]);
|
|
2392
2403
|
if (!componentFields) {
|
|
2393
2404
|
console.warn(`Entry for assembly with ID '${componentId}' not found`, { entityStore });
|
|
2394
2405
|
return node;
|
|
@@ -2502,7 +2513,7 @@ const DraggableChildComponent = (props) => {
|
|
|
2502
2513
|
})));
|
|
2503
2514
|
};
|
|
2504
2515
|
|
|
2505
|
-
var css_248z$2 = ".styles-module_container__te-1H {\n margin-left: auto;\n margin-right: auto;\n position: relative;\n height: 100%;\n
|
|
2516
|
+
var css_248z$2 = ".styles-module_container__te-1H {\n margin-left: auto;\n margin-right: auto;\n position: relative;\n height: 100%;\n width: 100%;\n background-color: transparent;\n transition: background-color 0.2s;\n pointer-events: all;\n}\n\n.styles-module_container__te-1H:not(.styles-module_isRoot__5cn-i):before {\n content: \"\";\n position: absolute;\n top: 0;\n right: 0;\n bottom: 0;\n left: 0;\n outline-offset: -1px;\n outline: 2px solid transparent;\n z-index: 1;\n transition: outline 0.2s;\n}\n\n.styles-module_isRoot__5cn-i,\n.styles-module_isEmptyCanvas__0XHZR {\n flex: 1;\n}\n\n.styles-module_isEmptyZone__zVpnZ {\n min-height: 80px;\n}\n\n.styles-module_isDragging__Gm8v5:not(.styles-module_isRoot__5cn-i):before {\n outline: 2px dashed var(--exp-builder-gray300);\n}\n\n.styles-module_isDestination__5sCQx:not(.styles-module_isRoot__5cn-i):before {\n transition: outline 0.2s, background-color 0.2s;\n outline: 2px dashed var(--exp-builder-blue400);\n background-color: rgba(var(--exp-builder-blue100-rgb), 0.5);\n z-index: 2;\n}\n\n.styles-module_hitbox__YQ-1Z {\n position: fixed;\n pointer-events: all !important;\n}\n";
|
|
2506
2517
|
var styles$2 = {"container":"styles-module_container__te-1H","isRoot":"styles-module_isRoot__5cn-i","isEmptyCanvas":"styles-module_isEmptyCanvas__0XHZR","isEmptyZone":"styles-module_isEmptyZone__zVpnZ","isDragging":"styles-module_isDragging__Gm8v5","isDestination":"styles-module_isDestination__5sCQx","hitbox":"styles-module_hitbox__YQ-1Z"};
|
|
2507
2518
|
styleInject(css_248z$2);
|
|
2508
2519
|
|
|
@@ -3067,7 +3078,7 @@ const EmptyContainer = ({ isDragging }) => {
|
|
|
3067
3078
|
React.createElement("rect", { width: "11.676", height: "11.676", x: "18.011", y: "18.625", rx: "1.621", transform: "rotate(45 18.01 18.625)" }),
|
|
3068
3079
|
React.createElement("rect", { width: "11.676", height: "11.676", x: "30.557", y: "10.131", rx: "1.621", transform: "rotate(60 30.557 10.13)" }),
|
|
3069
3080
|
React.createElement("path", { fill: "#fff", stroke: "#fff", strokeWidth: ".243", d: "M31.113 17.038a.463.463 0 0 0-.683-.517l-1.763 1.032-1.033-1.763a.464.464 0 0 0-.8.469l1.034 1.763-1.763 1.033a.463.463 0 1 0 .468.8l1.763-1.033 1.033 1.763a.463.463 0 1 0 .8-.469l-1.033-1.763 1.763-1.033a.463.463 0 0 0 .214-.282Z" })),
|
|
3070
|
-
React.createElement("span", { className: styles$1.label }, "Add
|
|
3081
|
+
React.createElement("span", { className: styles$1.label }, "Add components to begin")));
|
|
3071
3082
|
};
|
|
3072
3083
|
|
|
3073
3084
|
const getZoneParents = (zoneId) => {
|
|
@@ -3694,7 +3705,7 @@ function useEditorSubscriber() {
|
|
|
3694
3705
|
console.debug(`[experiences-sdk-react::onMessage] Received message [${eventData.eventType}]`, eventData);
|
|
3695
3706
|
const { payload } = eventData;
|
|
3696
3707
|
switch (eventData.eventType) {
|
|
3697
|
-
case INCOMING_EVENTS.
|
|
3708
|
+
case INCOMING_EVENTS.ExperienceUpdated: {
|
|
3698
3709
|
const { tree, locale, changedNode, changedValueType, assemblies, } = payload;
|
|
3699
3710
|
// Make sure to first store the assemblies before setting the tree and thus triggering a rerender
|
|
3700
3711
|
if (assemblies) {
|
|
@@ -4150,10 +4161,19 @@ const RootRenderer = ({ onChange }) => {
|
|
|
4150
4161
|
document.removeEventListener('click', handleClickOutside);
|
|
4151
4162
|
};
|
|
4152
4163
|
}, []);
|
|
4153
|
-
const handleClickOutside = () => {
|
|
4164
|
+
const handleClickOutside = (e) => {
|
|
4165
|
+
const element = e.target;
|
|
4166
|
+
const isRoot = element.getAttribute('data-ctfl-zone-id') === ROOT_ID;
|
|
4167
|
+
const clickedOnCanvas = element.closest(`[data-ctfl-root]`);
|
|
4168
|
+
if (clickedOnCanvas && !isRoot) {
|
|
4169
|
+
return;
|
|
4170
|
+
}
|
|
4154
4171
|
sendMessage(OUTGOING_EVENTS.OutsideCanvasClick, {
|
|
4155
4172
|
outsideCanvasClick: true,
|
|
4156
4173
|
});
|
|
4174
|
+
sendMessage(OUTGOING_EVENTS.ComponentSelected, {
|
|
4175
|
+
selectedId: '',
|
|
4176
|
+
});
|
|
4157
4177
|
};
|
|
4158
4178
|
const handleResizeCanvas = useCallback(() => {
|
|
4159
4179
|
const parentElement = containerRef.current?.parentElement;
|