@contentful/experiences-visual-editor-react 0.0.1-dev-20240307T2018-aadea9e.0 → 0.0.1-dev-20240307T2139-e68f560.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.js +12 -49
- package/dist/index.js.map +1 -1
- package/dist/renderApp.js +12 -49
- package/dist/renderApp.js.map +1 -1
- package/package.json +4 -4
package/dist/index.js
CHANGED
|
@@ -26,16 +26,6 @@ const INCOMING_EVENTS$1 = {
|
|
|
26
26
|
SelectComponent: 'selectComponent',
|
|
27
27
|
HoverComponent: 'hoverComponent',
|
|
28
28
|
UpdatedEntity: 'updatedEntity',
|
|
29
|
-
/**
|
|
30
|
-
* @deprecated use `AssembliesAdded` instead. This will be removed in version 5.
|
|
31
|
-
* In the meanwhile, the experience builder will send the old and the new event to support multiple SDK versions.
|
|
32
|
-
*/
|
|
33
|
-
DesignComponentsAdded: 'designComponentsAdded',
|
|
34
|
-
/**
|
|
35
|
-
* @deprecated use `AssembliesRegistered` instead. This will be removed in version 5.
|
|
36
|
-
* In the meanwhile, the experience builder will send the old and the new event to support multiple SDK versions.
|
|
37
|
-
*/
|
|
38
|
-
DesignComponentsRegistered: 'designComponentsRegistered',
|
|
39
29
|
AssembliesAdded: 'assembliesAdded',
|
|
40
30
|
AssembliesRegistered: 'assembliesRegistered',
|
|
41
31
|
InitEditor: 'initEditor',
|
|
@@ -1487,16 +1477,6 @@ const INCOMING_EVENTS = {
|
|
|
1487
1477
|
SelectComponent: 'selectComponent',
|
|
1488
1478
|
HoverComponent: 'hoverComponent',
|
|
1489
1479
|
UpdatedEntity: 'updatedEntity',
|
|
1490
|
-
/**
|
|
1491
|
-
* @deprecated use `AssembliesAdded` instead. This will be removed in version 5.
|
|
1492
|
-
* In the meanwhile, the experience builder will send the old and the new event to support multiple SDK versions.
|
|
1493
|
-
*/
|
|
1494
|
-
DesignComponentsAdded: 'designComponentsAdded',
|
|
1495
|
-
/**
|
|
1496
|
-
* @deprecated use `AssembliesRegistered` instead. This will be removed in version 5.
|
|
1497
|
-
* In the meanwhile, the experience builder will send the old and the new event to support multiple SDK versions.
|
|
1498
|
-
*/
|
|
1499
|
-
DesignComponentsRegistered: 'designComponentsRegistered',
|
|
1500
1480
|
AssembliesAdded: 'assembliesAdded',
|
|
1501
1481
|
AssembliesRegistered: 'assembliesRegistered',
|
|
1502
1482
|
InitEditor: 'initEditor',
|
|
@@ -1551,15 +1531,6 @@ const ASSEMBLY_NODE_TYPE = 'assembly';
|
|
|
1551
1531
|
const ASSEMBLY_DEFAULT_CATEGORY = 'Assemblies';
|
|
1552
1532
|
const ASSEMBLY_BLOCK_NODE_TYPE = 'assemblyBlock';
|
|
1553
1533
|
const ASSEMBLY_NODE_TYPES = [ASSEMBLY_NODE_TYPE, ASSEMBLY_BLOCK_NODE_TYPE];
|
|
1554
|
-
/** @deprecated use `ASSEMBLY_NODE_TYPE` instead. This will be removed in version 5. */
|
|
1555
|
-
const DESIGN_COMPONENT_NODE_TYPE = 'designComponent';
|
|
1556
|
-
/** @deprecated use `ASSEMBLY_BLOCK_NODE_TYPE` instead. This will be removed in version 5. */
|
|
1557
|
-
const DESIGN_COMPONENT_BLOCK_NODE_TYPE = 'designComponentBlock';
|
|
1558
|
-
/** @deprecated use `ASSEMBLY_NODE_TYPES` instead. This will be removed in version 5. */
|
|
1559
|
-
const DESIGN_COMPONENT_NODE_TYPES = [
|
|
1560
|
-
DESIGN_COMPONENT_NODE_TYPE,
|
|
1561
|
-
DESIGN_COMPONENT_BLOCK_NODE_TYPE,
|
|
1562
|
-
];
|
|
1563
1534
|
const CF_STYLE_ATTRIBUTES = [
|
|
1564
1535
|
'cfHorizontalAlignment',
|
|
1565
1536
|
'cfVerticalAlignment',
|
|
@@ -2108,9 +2079,7 @@ const useComponentProps = ({ node, areEntitiesFetched, resolveDesignValue, rende
|
|
|
2108
2079
|
const entityStore = useEntityStore((state) => state.entityStore);
|
|
2109
2080
|
const props = useMemo(() => {
|
|
2110
2081
|
// Don't enrich the assembly wrapper node with props
|
|
2111
|
-
if (!definition ||
|
|
2112
|
-
node.type === DESIGN_COMPONENT_NODE_TYPE ||
|
|
2113
|
-
node.type === ASSEMBLY_NODE_TYPE) {
|
|
2082
|
+
if (!definition || node.type === ASSEMBLY_NODE_TYPE) {
|
|
2114
2083
|
return {};
|
|
2115
2084
|
}
|
|
2116
2085
|
return Object.entries(definition.variables).reduce((acc, [variableName, variableDefinition]) => {
|
|
@@ -2408,7 +2377,7 @@ const deserializeAssemblyNode = ({ node, nodeId, nodeLocation, parentId, assembl
|
|
|
2408
2377
|
};
|
|
2409
2378
|
};
|
|
2410
2379
|
const resolveAssembly = ({ node, entityStore, }) => {
|
|
2411
|
-
if (node.type !==
|
|
2380
|
+
if (node.type !== ASSEMBLY_NODE_TYPE) {
|
|
2412
2381
|
return node;
|
|
2413
2382
|
}
|
|
2414
2383
|
const componentId = node.data.blockId;
|
|
@@ -2453,8 +2422,7 @@ const useComponent = ({ node: rawNode, resolveDesignValue, renderDropzone, userI
|
|
|
2453
2422
|
const areEntitiesFetched = useEntityStore((state) => state.areEntitiesFetched);
|
|
2454
2423
|
const entityStore = useEntityStore((state) => state.entityStore);
|
|
2455
2424
|
const node = useMemo(() => {
|
|
2456
|
-
if (
|
|
2457
|
-
areEntitiesFetched) {
|
|
2425
|
+
if (rawNode.type === ASSEMBLY_NODE_TYPE && areEntitiesFetched) {
|
|
2458
2426
|
return resolveAssembly({
|
|
2459
2427
|
node: rawNode,
|
|
2460
2428
|
entityStore,
|
|
@@ -2464,8 +2432,7 @@ const useComponent = ({ node: rawNode, resolveDesignValue, renderDropzone, userI
|
|
|
2464
2432
|
}, [areEntitiesFetched, rawNode, entityStore]);
|
|
2465
2433
|
const componentRegistration = useMemo(() => {
|
|
2466
2434
|
const registration = componentRegistry.get(node.data.blockId);
|
|
2467
|
-
if (
|
|
2468
|
-
!registration) {
|
|
2435
|
+
if (node.type === ASSEMBLY_NODE_TYPE && !registration) {
|
|
2469
2436
|
return createAssemblyRegistration({
|
|
2470
2437
|
definitionId: node.data.blockId,
|
|
2471
2438
|
component: Assembly,
|
|
@@ -2489,7 +2456,7 @@ const useComponent = ({ node: rawNode, resolveDesignValue, renderDropzone, userI
|
|
|
2489
2456
|
const { editorMode, renderDropzone: _renderDropzone, ...otherComponentProps } = componentProps;
|
|
2490
2457
|
const elementToRender = builtInComponents.includes(node.data.blockId || '')
|
|
2491
2458
|
? (dragProps) => React.createElement(componentRegistration.component, { ...dragProps, ...componentProps })
|
|
2492
|
-
: node.type ===
|
|
2459
|
+
: node.type === ASSEMBLY_NODE_TYPE
|
|
2493
2460
|
? // Assembly.tsx requires renderDropzone and editorMode as well
|
|
2494
2461
|
() => React.createElement(componentRegistration.component, componentProps)
|
|
2495
2462
|
: () => React.createElement(componentRegistration.component, otherComponentProps);
|
|
@@ -2796,7 +2763,7 @@ function treeVisit(initialNode, onNode) {
|
|
|
2796
2763
|
}
|
|
2797
2764
|
|
|
2798
2765
|
const isAssemblyNode = (node) => {
|
|
2799
|
-
return node.type ===
|
|
2766
|
+
return node.type === ASSEMBLY_NODE_TYPE;
|
|
2800
2767
|
};
|
|
2801
2768
|
const useTreeStore = create((set, get) => ({
|
|
2802
2769
|
tree: {
|
|
@@ -3213,8 +3180,7 @@ function Dropzone({ node, zoneId, resolveDesignValue, className, WrapperComponen
|
|
|
3213
3180
|
const isRootZone = zoneId === ROOT_ID;
|
|
3214
3181
|
const isDestination = draggedDestinationId === zoneId;
|
|
3215
3182
|
const isEmptyCanvas = isRootZone && !content.length;
|
|
3216
|
-
const isAssembly =
|
|
3217
|
-
ASSEMBLY_NODE_TYPES.includes(node?.type || '');
|
|
3183
|
+
const isAssembly = ASSEMBLY_NODE_TYPES.includes(node?.type || '');
|
|
3218
3184
|
// To avoid a circular dependency, we create the recursive rendering function here and trickle it down
|
|
3219
3185
|
const renderDropzone = useCallback((node, props) => {
|
|
3220
3186
|
return (React.createElement(Dropzone, { zoneId: node.data.id, node: node, resolveDesignValue: resolveDesignValue, ...props }));
|
|
@@ -3476,8 +3442,7 @@ class MouseOverHandler {
|
|
|
3476
3442
|
};
|
|
3477
3443
|
}
|
|
3478
3444
|
getBoundingClientRect(element) {
|
|
3479
|
-
const isAssembly = element.getAttribute('data-cf-node-block-type') ===
|
|
3480
|
-
element.getAttribute('data-cf-node-block-type') === ASSEMBLY_NODE_TYPE;
|
|
3445
|
+
const isAssembly = element.getAttribute('data-cf-node-block-type') === ASSEMBLY_NODE_TYPE;
|
|
3481
3446
|
if (!isAssembly) {
|
|
3482
3447
|
return element.getBoundingClientRect();
|
|
3483
3448
|
}
|
|
@@ -3772,9 +3737,6 @@ function useEditorSubscriber() {
|
|
|
3772
3737
|
}
|
|
3773
3738
|
break;
|
|
3774
3739
|
}
|
|
3775
|
-
case INCOMING_EVENTS.DesignComponentsRegistered:
|
|
3776
|
-
// Event was deprecated and support will be discontinued with version 5
|
|
3777
|
-
break;
|
|
3778
3740
|
case INCOMING_EVENTS.AssembliesRegistered: {
|
|
3779
3741
|
const { assemblies } = payload;
|
|
3780
3742
|
assemblies.forEach((definition) => {
|
|
@@ -3785,9 +3747,6 @@ function useEditorSubscriber() {
|
|
|
3785
3747
|
});
|
|
3786
3748
|
break;
|
|
3787
3749
|
}
|
|
3788
|
-
case INCOMING_EVENTS.DesignComponentsAdded:
|
|
3789
|
-
// Event was deprecated and support will be discontinued with version 5
|
|
3790
|
-
break;
|
|
3791
3750
|
case INCOMING_EVENTS.AssembliesAdded: {
|
|
3792
3751
|
const { assembly, assemblyDefinition, } = payload;
|
|
3793
3752
|
entityStore.updateEntity(assembly);
|
|
@@ -3806,6 +3765,10 @@ function useEditorSubscriber() {
|
|
|
3806
3765
|
break;
|
|
3807
3766
|
}
|
|
3808
3767
|
case INCOMING_EVENTS.CanvasResized: {
|
|
3768
|
+
const { selectedNodeId } = payload;
|
|
3769
|
+
if (selectedNodeId) {
|
|
3770
|
+
sendSelectedComponentCoordinates(selectedNodeId);
|
|
3771
|
+
}
|
|
3809
3772
|
break;
|
|
3810
3773
|
}
|
|
3811
3774
|
case INCOMING_EVENTS.HoverComponent: {
|