@contentful/experiences-visual-editor-react 3.4.1-dev-20250901T1444-72c17a2.0 → 3.5.0-beta.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 +41 -27
- package/dist/index.js.map +1 -1
- package/dist/renderApp.js +41 -27
- package/dist/renderApp.js.map +1 -1
- package/package.json +4 -4
package/dist/index.js
CHANGED
|
@@ -8,8 +8,8 @@ import { create, useStore } from 'zustand';
|
|
|
8
8
|
import { produce } from 'immer';
|
|
9
9
|
import '@contentful/rich-text-react-renderer';
|
|
10
10
|
|
|
11
|
-
var css_248z$
|
|
12
|
-
styleInject(css_248z$
|
|
11
|
+
var css_248z$a = "html,\nbody {\n margin: 0;\n padding: 0;\n}\n\n/*\n * All of these variables are tokens from Forma-36 and should not be adjusted as these\n * are global variables that may affect multiple places.\n * As our customers may use other design libraries, we try to avoid overlapping global\n * variables by always using the prefix `--exp-builder-` inside this SDK.\n */\n\n:root {\n /* Color tokens from Forma 36: https://f36.contentful.com/tokens/color-system */\n --exp-builder-blue100: #e8f5ff;\n --exp-builder-blue200: #ceecff;\n --exp-builder-blue300: #98cbff;\n --exp-builder-blue400: #40a0ff;\n --exp-builder-blue500: #036fe3;\n --exp-builder-blue600: #0059c8;\n --exp-builder-blue700: #0041ab;\n --exp-builder-blue800: #003298;\n --exp-builder-blue900: #002a8e;\n --exp-builder-gray100: #f7f9fa;\n --exp-builder-gray200: #e7ebee;\n --exp-builder-gray300: #cfd9e0;\n --exp-builder-gray400: #aec1cc;\n --exp-builder-gray500: #67728a;\n --exp-builder-gray600: #5a657c;\n --exp-builder-gray700: #414d63;\n --exp-builder-gray800: #1b273a;\n --exp-builder-gray900: #111b2b;\n --exp-builder-purple600: #6c3ecf;\n --exp-builder-red200: #ffe0e0;\n --exp-builder-red800: #7f0010;\n --exp-builder-color-white: #ffffff;\n --exp-builder-glow-primary: 0px 0px 0px 3px #e8f5ff;\n\n /* RGB colors for applying opacity */\n --exp-builder-blue100-rgb: 232, 245, 255;\n --exp-builder-blue300-rgb: 152, 203, 255;\n\n /* Spacing tokens from Forma 36: https://f36.contentful.com/tokens/spacing */\n --exp-builder-spacing-s: 0.75rem;\n --exp-builder-spacing-2xs: 0.25rem;\n\n /* Typography tokens from Forma 36: https://f36.contentful.com/tokens/typography */\n --exp-builder-font-size-l: 1rem;\n --exp-builder-font-size-m: 0.875rem;\n --exp-builder-font-stack-primary: -apple-system, BlinkMacSystemFont, Segoe UI, Helvetica, Arial,\n sans-serif, Apple Color Emoji, Segoe UI Emoji, Segoe UI Symbol;\n --exp-builder-line-height-condensed: 1.25;\n}\n";
|
|
12
|
+
styleInject(css_248z$a);
|
|
13
13
|
|
|
14
14
|
/** @deprecated will be removed when dropping backward compatibility for old DND */
|
|
15
15
|
const INCOMING_EVENTS$1 = {
|
|
@@ -763,6 +763,7 @@ const BreakpointSchema$1 = z
|
|
|
763
763
|
const BaseComponentTreeNodeSchema$1 = z.object({
|
|
764
764
|
id: ComponentTreeNodeIdSchema$1.optional(),
|
|
765
765
|
definitionId: DefinitionPropertyKeySchema$1,
|
|
766
|
+
prebindingId: z.string().optional(),
|
|
766
767
|
displayName: z.string().optional(),
|
|
767
768
|
slotId: z.string().optional(),
|
|
768
769
|
variables: z.record(propertyKeySchema$1, ComponentPropertyValueSchema$1),
|
|
@@ -3172,10 +3173,6 @@ const cloneDeepAsPOJO = (obj) => {
|
|
|
3172
3173
|
return JSON.parse(JSON.stringify(obj));
|
|
3173
3174
|
};
|
|
3174
3175
|
|
|
3175
|
-
var css_248z$a = ".RootRenderer-module_rootContainer__9UawM {\n position: relative;\n display: flex;\n flex-direction: column;\n}\n\nbody {\n margin: 0;\n}\n\nhtml {\n -ms-overflow-style: none; /* Internet Explorer 10+ */\n scrollbar-width: none; /* Firefox */\n}\n\nhtml::-webkit-scrollbar {\n display: none;\n}\n";
|
|
3176
|
-
var styles$2 = {"rootContainer":"RootRenderer-module_rootContainer__9UawM"};
|
|
3177
|
-
styleInject(css_248z$a);
|
|
3178
|
-
|
|
3179
3176
|
// TODO: In order to support integrations without React, we should extract this heavy logic into simple
|
|
3180
3177
|
// functions that we can reuse in other frameworks.
|
|
3181
3178
|
/*
|
|
@@ -3581,6 +3578,7 @@ const BreakpointSchema = z
|
|
|
3581
3578
|
const BaseComponentTreeNodeSchema = z.object({
|
|
3582
3579
|
id: ComponentTreeNodeIdSchema.optional(),
|
|
3583
3580
|
definitionId: DefinitionPropertyKeySchema,
|
|
3581
|
+
prebindingId: z.string().optional(),
|
|
3584
3582
|
displayName: z.string().optional(),
|
|
3585
3583
|
slotId: z.string().optional(),
|
|
3586
3584
|
variables: z.record(propertyKeySchema, ComponentPropertyValueSchema),
|
|
@@ -4326,8 +4324,8 @@ var VisualEditorMode;
|
|
|
4326
4324
|
VisualEditorMode["InjectScript"] = "injectScript";
|
|
4327
4325
|
})(VisualEditorMode || (VisualEditorMode = {}));
|
|
4328
4326
|
|
|
4329
|
-
var css_248z$2 = ".contentful-container{display:flex;pointer-events:all;position:relative}.contentful-container::-webkit-scrollbar{display:none}.cf-container-wrapper{position:relative;width:100%}.contentful-container:after{align-items:center;bottom:0;color:var(--exp-builder-gray400);content:\"\";display:block;display:flex;font-family:var(--exp-builder-font-stack-primary);font-size:12px;justify-content:center;left:0;overflow-x:clip;pointer-events:none;position:absolute;right:0;top:0;z-index:1}.contentful-section-label:after{content:\"Section\"}.contentful-container-label:after{content:\"Container\"}.contentful-container-link,.contentful-container-link:active,.contentful-container-link:focus-visible,.contentful-container-link:hover,.contentful-container-link:read-write,.contentful-container-link:visited{color:inherit;outline:unset;text-decoration:unset}";
|
|
4330
|
-
styleInject(css_248z$2);
|
|
4327
|
+
var css_248z$2$1 = ".contentful-container{display:flex;pointer-events:all;position:relative}.contentful-container::-webkit-scrollbar{display:none}.cf-container-wrapper{position:relative;width:100%}.contentful-container:after{align-items:center;bottom:0;color:var(--exp-builder-gray400);content:\"\";display:block;display:flex;font-family:var(--exp-builder-font-stack-primary);font-size:12px;justify-content:center;left:0;overflow-x:clip;pointer-events:none;position:absolute;right:0;top:0;z-index:1}.contentful-section-label:after{content:\"Section\"}.contentful-container-label:after{content:\"Container\"}.contentful-container-link,.contentful-container-link:active,.contentful-container-link:focus-visible,.contentful-container-link:hover,.contentful-container-link:read-write,.contentful-container-link:visited{color:inherit;outline:unset;text-decoration:unset}";
|
|
4328
|
+
styleInject(css_248z$2$1);
|
|
4331
4329
|
|
|
4332
4330
|
const Flex = forwardRef(({ id, children, onMouseEnter, onMouseUp, onMouseLeave, onMouseDown, onClick, flex, flexBasis, flexShrink, flexDirection, gap, justifyContent, justifyItems, justifySelf, alignItems, alignSelf, alignContent, order, flexWrap, flexGrow, className, cssStyles, ...props }, ref) => {
|
|
4333
4331
|
return (React.createElement("div", { id: id, ref: ref, style: {
|
|
@@ -4660,9 +4658,9 @@ const MissingComponentPlaceholder = ({ blockId }) => {
|
|
|
4660
4658
|
"'"));
|
|
4661
4659
|
};
|
|
4662
4660
|
|
|
4663
|
-
var css_248z$
|
|
4661
|
+
var css_248z$2 = ".EditorBlock-module_emptySlot__za-Bi {\n min-height: 80px;\n min-width: 80px;\n}\n";
|
|
4664
4662
|
var styles$1 = {"emptySlot":"EditorBlock-module_emptySlot__za-Bi"};
|
|
4665
|
-
styleInject(css_248z$
|
|
4663
|
+
styleInject(css_248z$2);
|
|
4666
4664
|
|
|
4667
4665
|
const useComponentRegistration = (node) => {
|
|
4668
4666
|
return useMemo(() => {
|
|
@@ -4919,6 +4917,31 @@ const useComponentProps = ({ node, entityStore, areEntitiesFetched, resolveDesig
|
|
|
4919
4917
|
styles: componentStyles,
|
|
4920
4918
|
nodeId: node.data.id,
|
|
4921
4919
|
});
|
|
4920
|
+
// Allows custom components to render differently in the editor. This needs to be activated
|
|
4921
|
+
// through registry options as the component has to be aware of this prop to not cause any React warnings.
|
|
4922
|
+
const editorProps = useMemo(() => {
|
|
4923
|
+
const editorProps = {};
|
|
4924
|
+
if (options?.enableEditorProperties?.isEditorMode) {
|
|
4925
|
+
editorProps.isEditorMode = true;
|
|
4926
|
+
}
|
|
4927
|
+
if (options?.enableEditorProperties?.isEmpty) {
|
|
4928
|
+
editorProps.isEmpty = node.children.length === 0;
|
|
4929
|
+
}
|
|
4930
|
+
if (options?.enableEditorProperties?.nodeBlockId) {
|
|
4931
|
+
editorProps.nodeBlockId = node.data.blockId;
|
|
4932
|
+
}
|
|
4933
|
+
if (options?.enableCustomEditorView) {
|
|
4934
|
+
editorProps.isInExpEditorMode = true;
|
|
4935
|
+
}
|
|
4936
|
+
return editorProps;
|
|
4937
|
+
}, [
|
|
4938
|
+
node.children.length,
|
|
4939
|
+
node.data.blockId,
|
|
4940
|
+
options?.enableEditorProperties?.isEditorMode,
|
|
4941
|
+
options?.enableEditorProperties?.isEmpty,
|
|
4942
|
+
options?.enableEditorProperties?.nodeBlockId,
|
|
4943
|
+
options?.enableCustomEditorView,
|
|
4944
|
+
]);
|
|
4922
4945
|
const componentProps = useMemo(() => {
|
|
4923
4946
|
const sharedProps = {
|
|
4924
4947
|
'data-cf-node-id': node.data.id,
|
|
@@ -4928,21 +4951,10 @@ const useComponentProps = ({ node, entityStore, areEntitiesFetched, resolveDesig
|
|
|
4928
4951
|
};
|
|
4929
4952
|
return {
|
|
4930
4953
|
...sharedProps,
|
|
4931
|
-
|
|
4932
|
-
// through options as the component has to be aware of this prop to not cause any React warnings.
|
|
4933
|
-
...(options?.enableCustomEditorView ? { isInExpEditorMode: true } : {}),
|
|
4934
|
-
...(options?.editorProperties?.isEditorMode ? { isEditorMode: true } : {}),
|
|
4935
|
-
...(options?.editorProperties?.node ? { node } : {}),
|
|
4954
|
+
...editorProps,
|
|
4936
4955
|
...sanitizeNodeProps(props),
|
|
4937
4956
|
};
|
|
4938
|
-
}, [
|
|
4939
|
-
cfCsrClassName,
|
|
4940
|
-
node,
|
|
4941
|
-
options?.editorProperties?.isEditorMode,
|
|
4942
|
-
options?.editorProperties?.node,
|
|
4943
|
-
options?.enableCustomEditorView,
|
|
4944
|
-
props,
|
|
4945
|
-
]);
|
|
4957
|
+
}, [cfCsrClassName, editorProps, node, props]);
|
|
4946
4958
|
return { componentProps };
|
|
4947
4959
|
};
|
|
4948
4960
|
|
|
@@ -4987,9 +4999,9 @@ const RegistrationComponent = ({ node, resolveDesignValue, componentRegistration
|
|
|
4987
4999
|
return React.createElement(ImportedComponentErrorBoundary, { componentId: node.data.blockId }, React.createElement(componentRegistration.component, { ...componentProps, ...slotNodes }, children));
|
|
4988
5000
|
};
|
|
4989
5001
|
|
|
4990
|
-
var css_248z = ".EmptyCanvasMessage-module_empty-canvas-container__7K-0l {\n height: 200px;\n display: flex;\n width: 100%;\n align-items: center;\n justify-content: center;\n flex-direction: row;\n transition: all 0.2s;\n color: var(--exp-builder-gray400);\n font-size: var(--exp-builder-font-size-l);\n font-family: var(--exp-builder-font-stack-primary);\n outline: 2px dashed var(--exp-builder-gray400);\n outline-offset: -2px;\n}\n\n.EmptyCanvasMessage-module_empty-canvas-icon__EztFr rect {\n fill: var(--exp-builder-gray400);\n}\n\n.EmptyCanvasMessage-module_empty-canvas-label__cbIrR {\n margin-left: var(--exp-builder-spacing-s);\n}\n";
|
|
5002
|
+
var css_248z$1 = ".EmptyCanvasMessage-module_empty-canvas-container__7K-0l {\n height: 200px;\n display: flex;\n width: 100%;\n align-items: center;\n justify-content: center;\n flex-direction: row;\n transition: all 0.2s;\n color: var(--exp-builder-gray400);\n font-size: var(--exp-builder-font-size-l);\n font-family: var(--exp-builder-font-stack-primary);\n outline: 2px dashed var(--exp-builder-gray400);\n outline-offset: -2px;\n}\n\n.EmptyCanvasMessage-module_empty-canvas-icon__EztFr rect {\n fill: var(--exp-builder-gray400);\n}\n\n.EmptyCanvasMessage-module_empty-canvas-label__cbIrR {\n margin-left: var(--exp-builder-spacing-s);\n}\n";
|
|
4991
5003
|
var styles = {"empty-canvas-container":"EmptyCanvasMessage-module_empty-canvas-container__7K-0l","empty-canvas-icon":"EmptyCanvasMessage-module_empty-canvas-icon__EztFr","empty-canvas-label":"EmptyCanvasMessage-module_empty-canvas-label__cbIrR"};
|
|
4992
|
-
styleInject(css_248z);
|
|
5004
|
+
styleInject(css_248z$1);
|
|
4993
5005
|
|
|
4994
5006
|
const EmptyCanvasMessage = () => {
|
|
4995
5007
|
return (React.createElement("div", { className: styles['empty-canvas-container'], "data-type": "empty-container" },
|
|
@@ -5182,6 +5194,9 @@ function findAllImages() {
|
|
|
5182
5194
|
return Array.from(document.querySelectorAll('img'));
|
|
5183
5195
|
}
|
|
5184
5196
|
|
|
5197
|
+
var css_248z = "body {\n margin: 0;\n}\n\nhtml {\n -ms-overflow-style: none; /* Internet Explorer 10+ */\n scrollbar-width: none; /* Firefox */\n}\n\nhtml::-webkit-scrollbar {\n display: none;\n}\n";
|
|
5198
|
+
styleInject(css_248z);
|
|
5199
|
+
|
|
5185
5200
|
const RootRenderer = ({ inMemoryEntitiesStore, canvasMode }) => {
|
|
5186
5201
|
useEditorSubscriber(inMemoryEntitiesStore);
|
|
5187
5202
|
const tree = useTreeStore((state) => state.tree);
|
|
@@ -5194,8 +5209,7 @@ const RootRenderer = ({ inMemoryEntitiesStore, canvasMode }) => {
|
|
|
5194
5209
|
const wrappingPatternIds = rootBlockId !== ROOT_ID ? new Set([rootBlockId]) : new Set();
|
|
5195
5210
|
const entityStore = inMemoryEntitiesStore((state) => state.entityStore);
|
|
5196
5211
|
const areEntitiesFetched = inMemoryEntitiesStore((state) => state.areEntitiesFetched);
|
|
5197
|
-
return (React.createElement(React.Fragment, null,
|
|
5198
|
-
React.createElement("div", { "data-ctfl-root": true, className: styles$2.rootContainer }, !tree.root.children.length ? (React.createElement(EmptyCanvasMessage, null)) : (tree.root.children.map((topLevelChildNode) => (React.createElement(EditorBlock, { key: topLevelChildNode.data.id, node: topLevelChildNode, resolveDesignValue: resolveDesignValue, wrappingPatternIds: wrappingPatternIds, entityStore: entityStore, areEntitiesFetched: areEntitiesFetched })))))));
|
|
5212
|
+
return (React.createElement(React.Fragment, null, !tree.root.children.length ? (React.createElement(EmptyCanvasMessage, null)) : (tree.root.children.map((topLevelChildNode) => (React.createElement(EditorBlock, { key: topLevelChildNode.data.id, node: topLevelChildNode, resolveDesignValue: resolveDesignValue, wrappingPatternIds: wrappingPatternIds, entityStore: entityStore, areEntitiesFetched: areEntitiesFetched }))))));
|
|
5199
5213
|
};
|
|
5200
5214
|
|
|
5201
5215
|
const useInitializeEditor = (inMemoryEntitiesStore) => {
|