@contentful/experiences-core 1.39.0-alpha-20250528T1342-e28bc3d.0 → 1.39.0-dev-20250528T1423-593ccdb.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/constants.d.ts +6 -15
- package/dist/constants.js +6 -15
- package/dist/constants.js.map +1 -1
- package/dist/exports.d.ts +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.js +157 -120
- package/dist/index.js.map +1 -1
- package/dist/types.d.ts +23 -19
- package/dist/utils/utils.d.ts +22 -2
- package/package.json +3 -3
package/dist/constants.d.ts
CHANGED
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
/** @deprecated will be removed when dropping backward compatibility for old DND */
|
|
2
1
|
declare const SCROLL_STATES: {
|
|
3
2
|
readonly Start: "scrollStart";
|
|
4
3
|
readonly IsScrolling: "isScrolling";
|
|
@@ -8,19 +7,20 @@ declare const OUTGOING_EVENTS: {
|
|
|
8
7
|
readonly Connected: "connected";
|
|
9
8
|
readonly DesignTokens: "registerDesignTokens";
|
|
10
9
|
readonly RegisteredBreakpoints: "registeredBreakpoints";
|
|
11
|
-
/** @deprecated will be removed when dropping backward compatibility for old DND */
|
|
12
10
|
readonly MouseMove: "mouseMove";
|
|
13
|
-
|
|
11
|
+
readonly NewHoveredElement: "newHoveredElement";
|
|
14
12
|
readonly ComponentSelected: "componentSelected";
|
|
15
13
|
readonly RegisteredComponents: "registeredComponents";
|
|
16
14
|
readonly RequestComponentTreeUpdate: "requestComponentTreeUpdate";
|
|
15
|
+
readonly ComponentDragCanceled: "componentDragCanceled";
|
|
16
|
+
readonly ComponentDropped: "componentDropped";
|
|
17
|
+
readonly ComponentMoved: "componentMoved";
|
|
17
18
|
readonly CanvasReload: "canvasReload";
|
|
18
|
-
/** @deprecated will be removed when dropping backward compatibility for old DND */
|
|
19
19
|
readonly UpdateSelectedComponentCoordinates: "updateSelectedComponentCoordinates";
|
|
20
|
-
/** @deprecated will be removed when dropping backward compatibility for old DND */
|
|
21
20
|
readonly CanvasScroll: "canvasScrolling";
|
|
22
21
|
readonly CanvasError: "canvasError";
|
|
23
|
-
|
|
22
|
+
readonly ComponentMoveStarted: "componentMoveStarted";
|
|
23
|
+
readonly ComponentMoveEnded: "componentMoveEnded";
|
|
24
24
|
readonly OutsideCanvasClick: "outsideCanvasClick";
|
|
25
25
|
readonly SDKFeatures: "sdkFeatures";
|
|
26
26
|
readonly RequestEntities: "REQUEST_ENTITIES";
|
|
@@ -29,26 +29,17 @@ declare const INCOMING_EVENTS: {
|
|
|
29
29
|
readonly RequestEditorMode: "requestEditorMode";
|
|
30
30
|
readonly RequestReadOnlyMode: "requestReadOnlyMode";
|
|
31
31
|
readonly ExperienceUpdated: "componentTreeUpdated";
|
|
32
|
-
/** @deprecated will be removed when dropping backward compatibility for old DND */
|
|
33
32
|
readonly ComponentDraggingChanged: "componentDraggingChanged";
|
|
34
|
-
/** @deprecated will be removed when dropping backward compatibility for old DND */
|
|
35
33
|
readonly ComponentDragCanceled: "componentDragCanceled";
|
|
36
|
-
/** @deprecated will be removed when dropping backward compatibility for old DND */
|
|
37
34
|
readonly ComponentDragStarted: "componentDragStarted";
|
|
38
|
-
/** @deprecated will be removed when dropping backward compatibility for old DND */
|
|
39
35
|
readonly ComponentDragEnded: "componentDragEnded";
|
|
40
|
-
/** @deprecated will be removed when dropping backward compatibility for old DND */
|
|
41
36
|
readonly ComponentMoveEnded: "componentMoveEnded";
|
|
42
|
-
/** @deprecated will be removed when dropping backward compatibility for old DND */
|
|
43
37
|
readonly CanvasResized: "canvasResized";
|
|
44
|
-
/** @deprecated will be removed when dropping backward compatibility for old DND */
|
|
45
38
|
readonly SelectComponent: "selectComponent";
|
|
46
|
-
/** @deprecated will be removed when dropping backward compatibility for old DND */
|
|
47
39
|
readonly HoverComponent: "hoverComponent";
|
|
48
40
|
readonly UpdatedEntity: "updatedEntity";
|
|
49
41
|
readonly AssembliesAdded: "assembliesAdded";
|
|
50
42
|
readonly AssembliesRegistered: "assembliesRegistered";
|
|
51
|
-
/** @deprecated will be removed when dropping backward compatibility for old DND */
|
|
52
43
|
readonly MouseMove: "mouseMove";
|
|
53
44
|
readonly RequestedEntities: "REQUESTED_ENTITIES";
|
|
54
45
|
};
|
package/dist/constants.js
CHANGED
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
/** @deprecated will be removed when dropping backward compatibility for old DND */
|
|
2
1
|
const SCROLL_STATES = {
|
|
3
2
|
Start: 'scrollStart',
|
|
4
3
|
IsScrolling: 'isScrolling',
|
|
@@ -8,19 +7,20 @@ const OUTGOING_EVENTS = {
|
|
|
8
7
|
Connected: 'connected',
|
|
9
8
|
DesignTokens: 'registerDesignTokens',
|
|
10
9
|
RegisteredBreakpoints: 'registeredBreakpoints',
|
|
11
|
-
/** @deprecated will be removed when dropping backward compatibility for old DND */
|
|
12
10
|
MouseMove: 'mouseMove',
|
|
13
|
-
|
|
11
|
+
NewHoveredElement: 'newHoveredElement',
|
|
14
12
|
ComponentSelected: 'componentSelected',
|
|
15
13
|
RegisteredComponents: 'registeredComponents',
|
|
16
14
|
RequestComponentTreeUpdate: 'requestComponentTreeUpdate',
|
|
15
|
+
ComponentDragCanceled: 'componentDragCanceled',
|
|
16
|
+
ComponentDropped: 'componentDropped',
|
|
17
|
+
ComponentMoved: 'componentMoved',
|
|
17
18
|
CanvasReload: 'canvasReload',
|
|
18
|
-
/** @deprecated will be removed when dropping backward compatibility for old DND */
|
|
19
19
|
UpdateSelectedComponentCoordinates: 'updateSelectedComponentCoordinates',
|
|
20
|
-
/** @deprecated will be removed when dropping backward compatibility for old DND */
|
|
21
20
|
CanvasScroll: 'canvasScrolling',
|
|
22
21
|
CanvasError: 'canvasError',
|
|
23
|
-
|
|
22
|
+
ComponentMoveStarted: 'componentMoveStarted',
|
|
23
|
+
ComponentMoveEnded: 'componentMoveEnded',
|
|
24
24
|
OutsideCanvasClick: 'outsideCanvasClick',
|
|
25
25
|
SDKFeatures: 'sdkFeatures',
|
|
26
26
|
RequestEntities: 'REQUEST_ENTITIES',
|
|
@@ -29,26 +29,17 @@ const INCOMING_EVENTS = {
|
|
|
29
29
|
RequestEditorMode: 'requestEditorMode',
|
|
30
30
|
RequestReadOnlyMode: 'requestReadOnlyMode',
|
|
31
31
|
ExperienceUpdated: 'componentTreeUpdated',
|
|
32
|
-
/** @deprecated will be removed when dropping backward compatibility for old DND */
|
|
33
32
|
ComponentDraggingChanged: 'componentDraggingChanged',
|
|
34
|
-
/** @deprecated will be removed when dropping backward compatibility for old DND */
|
|
35
33
|
ComponentDragCanceled: 'componentDragCanceled',
|
|
36
|
-
/** @deprecated will be removed when dropping backward compatibility for old DND */
|
|
37
34
|
ComponentDragStarted: 'componentDragStarted',
|
|
38
|
-
/** @deprecated will be removed when dropping backward compatibility for old DND */
|
|
39
35
|
ComponentDragEnded: 'componentDragEnded',
|
|
40
|
-
/** @deprecated will be removed when dropping backward compatibility for old DND */
|
|
41
36
|
ComponentMoveEnded: 'componentMoveEnded',
|
|
42
|
-
/** @deprecated will be removed when dropping backward compatibility for old DND */
|
|
43
37
|
CanvasResized: 'canvasResized',
|
|
44
|
-
/** @deprecated will be removed when dropping backward compatibility for old DND */
|
|
45
38
|
SelectComponent: 'selectComponent',
|
|
46
|
-
/** @deprecated will be removed when dropping backward compatibility for old DND */
|
|
47
39
|
HoverComponent: 'hoverComponent',
|
|
48
40
|
UpdatedEntity: 'updatedEntity',
|
|
49
41
|
AssembliesAdded: 'assembliesAdded',
|
|
50
42
|
AssembliesRegistered: 'assembliesRegistered',
|
|
51
|
-
/** @deprecated will be removed when dropping backward compatibility for old DND */
|
|
52
43
|
MouseMove: 'mouseMove',
|
|
53
44
|
RequestedEntities: 'REQUESTED_ENTITIES',
|
|
54
45
|
};
|
package/dist/constants.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"constants.js","sources":["../src/constants.ts"],"sourcesContent":["
|
|
1
|
+
{"version":3,"file":"constants.js","sources":["../src/constants.ts"],"sourcesContent":["export const SCROLL_STATES = {\n Start: 'scrollStart',\n IsScrolling: 'isScrolling',\n End: 'scrollEnd',\n} as const;\n\nexport const OUTGOING_EVENTS = {\n Connected: 'connected',\n DesignTokens: 'registerDesignTokens',\n RegisteredBreakpoints: 'registeredBreakpoints',\n MouseMove: 'mouseMove',\n NewHoveredElement: 'newHoveredElement',\n ComponentSelected: 'componentSelected',\n RegisteredComponents: 'registeredComponents',\n RequestComponentTreeUpdate: 'requestComponentTreeUpdate',\n ComponentDragCanceled: 'componentDragCanceled',\n ComponentDropped: 'componentDropped',\n ComponentMoved: 'componentMoved',\n CanvasReload: 'canvasReload',\n UpdateSelectedComponentCoordinates: 'updateSelectedComponentCoordinates',\n CanvasScroll: 'canvasScrolling',\n CanvasError: 'canvasError',\n ComponentMoveStarted: 'componentMoveStarted',\n ComponentMoveEnded: 'componentMoveEnded',\n OutsideCanvasClick: 'outsideCanvasClick',\n SDKFeatures: 'sdkFeatures',\n RequestEntities: 'REQUEST_ENTITIES',\n} as const;\n\nexport const INCOMING_EVENTS = {\n RequestEditorMode: 'requestEditorMode',\n RequestReadOnlyMode: 'requestReadOnlyMode',\n ExperienceUpdated: 'componentTreeUpdated',\n ComponentDraggingChanged: 'componentDraggingChanged',\n ComponentDragCanceled: 'componentDragCanceled',\n ComponentDragStarted: 'componentDragStarted',\n ComponentDragEnded: 'componentDragEnded',\n ComponentMoveEnded: 'componentMoveEnded',\n CanvasResized: 'canvasResized',\n SelectComponent: 'selectComponent',\n HoverComponent: 'hoverComponent',\n UpdatedEntity: 'updatedEntity',\n AssembliesAdded: 'assembliesAdded',\n AssembliesRegistered: 'assembliesRegistered',\n MouseMove: 'mouseMove',\n RequestedEntities: 'REQUESTED_ENTITIES',\n} as const;\n\nexport const INTERNAL_EVENTS = {\n ComponentsRegistered: 'cfComponentsRegistered',\n VisualEditorInitialize: 'cfVisualEditorInitialize',\n} as const;\n\nexport const VISUAL_EDITOR_EVENTS = {\n Ready: 'cfVisualEditorReady',\n};\n\n/**\n * These modes are ONLY intended to be internally used within the context of\n * editing an experience inside of Contentful Studio. i.e. these modes\n * intentionally do not include preview/delivery modes.\n */\nexport enum StudioCanvasMode {\n READ_ONLY = 'readOnlyMode',\n EDITOR = 'editorMode',\n NONE = 'none',\n}\n\nexport const VISUAL_EDITOR_CONTAINER_ID = 'cf-visual-editor';\nexport const CONTENTFUL_COMPONENT_CATEGORY = 'contentful-component';\nexport const CONTENTFUL_DEFAULT_CATEGORY = 'Contentful';\n\nexport const CONTENTFUL_COMPONENTS = {\n section: {\n id: 'contentful-section',\n name: 'Section',\n },\n container: {\n id: 'contentful-container',\n name: 'Container',\n },\n columns: {\n id: 'contentful-columns',\n name: 'Columns',\n },\n singleColumn: {\n id: 'contentful-single-column',\n name: 'Column',\n },\n button: {\n id: 'contentful-button',\n name: 'Button',\n },\n heading: {\n id: 'contentful-heading',\n name: 'Heading',\n },\n image: {\n id: 'contentful-image',\n name: 'Image',\n },\n richText: {\n id: 'contentful-richText',\n name: 'Rich Text',\n },\n text: {\n id: 'contentful-text',\n name: 'Text',\n },\n divider: {\n id: 'contentful-divider',\n name: 'Divider',\n },\n carousel: {\n id: 'contentful-carousel',\n name: 'Carousel',\n },\n} as const;\n\nexport const ASSEMBLY_NODE_TYPE = 'assembly';\nexport const ASSEMBLY_DEFAULT_CATEGORY = 'Assemblies';\nexport const ASSEMBLY_BLOCK_NODE_TYPE = 'assemblyBlock';\nexport const ASSEMBLY_NODE_TYPES = [ASSEMBLY_NODE_TYPE, ASSEMBLY_BLOCK_NODE_TYPE];\nexport const LATEST_SCHEMA_VERSION = '2023-09-28';\nexport const CF_STYLE_ATTRIBUTES = [\n 'cfVisibility',\n 'cfHorizontalAlignment',\n 'cfVerticalAlignment',\n 'cfMargin',\n 'cfPadding',\n 'cfBackgroundColor',\n 'cfWidth',\n 'cfMaxWidth',\n 'cfHeight',\n 'cfImageAsset',\n 'cfImageOptions',\n 'cfBackgroundImageUrl',\n 'cfBackgroundImageOptions',\n 'cfFlexDirection',\n 'cfFlexWrap',\n 'cfFlexReverse',\n 'cfBorder',\n 'cfBorderRadius',\n 'cfGap',\n 'cfColumnSpan',\n 'cfColumnSpanLock',\n 'cfColumns',\n 'cfFontSize',\n 'cfFontWeight',\n 'cfLineHeight',\n 'cfLetterSpacing',\n 'cfTextColor',\n 'cfTextAlign',\n 'cfTextTransform',\n 'cfTextBold',\n 'cfTextItalic',\n 'cfTextUnderline',\n // For backwards compatibility\n // we need to keep those in this constant array\n // so that omit() in <VisualEditorBlock> and <CompositionBlock>\n // can filter them out and not pass as props\n 'cfBackgroundImageScaling',\n 'cfBackgroundImageAlignment',\n 'cfBackgroundImageAlignmentVertical',\n 'cfBackgroundImageAlignmentHorizontal',\n];\n\nexport const EMPTY_CONTAINER_HEIGHT = '80px';\n\nexport const HYPERLINK_DEFAULT_PATTERN = `/{locale}/{entry.fields.slug}/`;\n\nexport const DEFAULT_IMAGE_WIDTH = '500px';\n\nexport enum PostMessageMethods {\n REQUEST_ENTITIES = 'REQUEST_ENTITIES',\n REQUESTED_ENTITIES = 'REQUESTED_ENTITIES',\n}\n\nexport const SUPPORTED_IMAGE_FORMATS = ['jpg', 'png', 'webp', 'gif', 'avif'] as const;\n\nexport const PATTERN_PROPERTY_DIVIDER = '-----';\n"],"names":[],"mappings":"AAAa,MAAA,aAAa,GAAG;AAC3B,IAAA,KAAK,EAAE,aAAa;AACpB,IAAA,WAAW,EAAE,aAAa;AAC1B,IAAA,GAAG,EAAE,WAAW;EACP;AAEE,MAAA,eAAe,GAAG;AAC7B,IAAA,SAAS,EAAE,WAAW;AACtB,IAAA,YAAY,EAAE,sBAAsB;AACpC,IAAA,qBAAqB,EAAE,uBAAuB;AAC9C,IAAA,SAAS,EAAE,WAAW;AACtB,IAAA,iBAAiB,EAAE,mBAAmB;AACtC,IAAA,iBAAiB,EAAE,mBAAmB;AACtC,IAAA,oBAAoB,EAAE,sBAAsB;AAC5C,IAAA,0BAA0B,EAAE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CAAA;AAEM,MAAM,uBAAuB,GAAG,CAAC,KAAK,EAAE,KAAK,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,EAAW;AAE/E,MAAM,wBAAwB,GAAG;;;;"}
|
package/dist/exports.d.ts
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
export { ASSEMBLY_BLOCK_NODE_TYPE, ASSEMBLY_DEFAULT_CATEGORY, ASSEMBLY_NODE_TYPE, ASSEMBLY_NODE_TYPES, CF_STYLE_ATTRIBUTES, CONTENTFUL_COMPONENTS, CONTENTFUL_COMPONENT_CATEGORY, CONTENTFUL_DEFAULT_CATEGORY, DEFAULT_IMAGE_WIDTH, EMPTY_CONTAINER_HEIGHT, HYPERLINK_DEFAULT_PATTERN, INCOMING_EVENTS, INTERNAL_EVENTS, LATEST_SCHEMA_VERSION, OUTGOING_EVENTS, PATTERN_PROPERTY_DIVIDER, PostMessageMethods, SCROLL_STATES, SUPPORTED_IMAGE_FORMATS, StudioCanvasMode, VISUAL_EDITOR_CONTAINER_ID, VISUAL_EDITOR_EVENTS } from './constants.js';
|
|
2
|
-
export { AssembliesAddedPayload, AssembliesRegisteredPayload, BackgroundImageAlignmentOption, BackgroundImageOptions, BackgroundImageScalingOption, Binding, BindingMap, BindingMapByBlockId, BoundComponentPropertyTypes, CSSProperties, CanvasErrorPayload, CanvasReloadPayload, CanvasResizedPayload, CanvasScrollPayload, ComponentBinding, ComponentDefinition, ComponentDefinitionVariable, ComponentDefinitionVariableBase, ComponentDefinitionVariableTypeMap, ComponentDefinitionVariableValidation, ComponentDragCanceledPayload, ComponentDragEndedPayload, ComponentDragStartedPayload, ComponentDraggingChangedPayload, ComponentDroppedPayload, ComponentMoveEndedPayload, ComponentMoveStartedPayload, ComponentMovedPayload, ComponentRegistration, ComponentRegistrationOptions, ComponentSelectedPayload, ConnectedPayload, ContainerStyleVariableName, Coordinates, DataSourceEntryValueType, DesignTokensDefinition, DesignTokensPayload, DesignVariableMap, DesignVariableTypes, Experience, ExperienceEntry, ExperienceFields, ExperienceTree, ExperienceTreeNode, ExperienceUpdatedPayload, HoverComponentPayload, HoveredElement, ImageLoadingOption, ImageObjectFitOption, ImageObjectPositionOption, ImageOptions, IncomingComponentDragCanceledPayload, IncomingComponentMoveEndedPayload, IncomingEvent, IncomingMessage, IncomingMouseMovePayload, InternalEvent, Link, ManagementEntity, MouseMovePayload, NewHoveredElementPayload, OptimizedBackgroundImageAsset, OptimizedImageAsset, OutgoingEvent, OutgoingMessage, OutsideCanvasClickPayload, RawCoordinates, RecursiveDesignTokenDefinition, RegisteredBreakpointsPayload, RegisteredComponentsPayload, RequestComponentTreeUpdatePayload, RequestEditorModePayload, RequestEntitiesMessage, RequestEntitiesPayload, RequestReadOnlyModePayload, RequestedEntitiesMessage, RequestedEntitiesPayload, ResolveDesignValueType, SDKFeaturesPayload, ScrollState, SelectComponentPayload, SendMessageParams,
|
|
2
|
+
export { AssembliesAddedPayload, AssembliesRegisteredPayload, BackgroundImageAlignmentOption, BackgroundImageOptions, BackgroundImageScalingOption, Binding, BindingMap, BindingMapByBlockId, BoundComponentPropertyTypes, CSSProperties, CanvasErrorPayload, CanvasReloadPayload, CanvasResizedPayload, CanvasScrollPayload, ComponentBinding, ComponentDefinition, ComponentDefinitionVariable, ComponentDefinitionVariableBase, ComponentDefinitionVariableTypeMap, ComponentDefinitionVariableValidation, ComponentDragCanceledPayload, ComponentDragEndedPayload, ComponentDragStartedPayload, ComponentDraggingChangedPayload, ComponentDroppedPayload, ComponentMoveEndedPayload, ComponentMoveStartedPayload, ComponentMovedPayload, ComponentRegistration, ComponentRegistrationOptions, ComponentSelectedPayload, ConnectedPayload, ContainerStyleVariableName, Coordinates, DataSourceEntryValueType, DesignTokensDefinition, DesignTokensPayload, DesignVariableMap, DesignVariableTypes, DragWrapperProps, Experience, ExperienceEntry, ExperienceFields, ExperienceTree, ExperienceTreeNode, ExperienceUpdatedPayload, HoverComponentPayload, HoveredElement, ImageLoadingOption, ImageObjectFitOption, ImageObjectPositionOption, ImageOptions, IncomingComponentDragCanceledPayload, IncomingComponentMoveEndedPayload, IncomingEvent, IncomingMessage, IncomingMouseMovePayload, InternalEvent, Link, ManagementEntity, MouseMovePayload, NewHoveredElementPayload, OptimizedBackgroundImageAsset, OptimizedImageAsset, OutgoingEvent, OutgoingMessage, OutsideCanvasClickPayload, RawCoordinates, RecursiveDesignTokenDefinition, RegisteredBreakpointsPayload, RegisteredComponentsPayload, RequestComponentTreeUpdatePayload, RequestEditorModePayload, RequestEntitiesMessage, RequestEntitiesPayload, RequestReadOnlyModePayload, RequestedEntitiesMessage, RequestedEntitiesPayload, ResolveDesignValueType, SDKFeaturesPayload, ScrollState, SelectComponentPayload, SendMessageParams, StyleProps, UpdateSelectedComponentCoordinatesPayload, UpdatedEntityPayload, ValidationOption, VariableFormats, WrapperTags } from './types.js';
|
|
3
3
|
export { BoundValue, Breakpoint, ComponentDefinitionPropertyType as ComponentDefinitionVariableType, ComponentPropertyValue, ComponentTreeNode, ComponentValue, DesignValue, ExperienceComponentSettings, ExperienceDataSource, ExperienceUnboundValues, NoValue, PatternProperty, PatternPropertyDefinition, PrimitiveValue, SchemaVersions, UnboundValue, ValuesByBreakpoint, VariableMapping } from '@contentful/experiences-validators';
|
package/dist/index.d.ts
CHANGED
|
@@ -13,7 +13,7 @@ export { detachExperienceStyles, flattenDesignTokenRegistry, indexByBreakpoint,
|
|
|
13
13
|
export { transformBoundContentValue } from './utils/transformers/transformBoundContentValue.js';
|
|
14
14
|
export { treeMap, treeVisit } from './utils/treeTraversal.js';
|
|
15
15
|
export { isExperienceEntry } from './utils/typeguards.js';
|
|
16
|
-
export { checkIsAssembly, checkIsAssemblyDefinition, checkIsAssemblyEntry, checkIsAssemblyNode, generateRandomId, getDataFromTree, getTargetValueInPixels, parseCSSValue } from './utils/utils.js';
|
|
16
|
+
export { checkIsAssembly, checkIsAssemblyDefinition, checkIsAssemblyEntry, checkIsAssemblyNode, generateRandomId, getDataFromTree, getInsertionData, getTargetValueInPixels, parseCSSValue } from './utils/utils.js';
|
|
17
17
|
export { doesMismatchMessageSchema, tryParseMessage, validateExperienceBuilderConfig } from './utils/validations.js';
|
|
18
18
|
export { builtInStyles, columnsBuiltInStyles, containerBuiltInStyles, dividerBuiltInStyles, optionalBuiltInStyles, sectionBuiltInStyles, singleColumnBuiltInStyles } from './definitions/styles.js';
|
|
19
19
|
export { EditorModeEntityStore } from './entity/EditorModeEntityStore.js';
|
package/dist/index.js
CHANGED
|
@@ -3,31 +3,21 @@ import { omit, isArray, uniqBy } from 'lodash-es';
|
|
|
3
3
|
import md5 from 'md5';
|
|
4
4
|
import { BLOCKS } from '@contentful/rich-text-types';
|
|
5
5
|
|
|
6
|
-
/** @deprecated will be removed when dropping backward compatibility for old DND */
|
|
7
6
|
const INCOMING_EVENTS = {
|
|
8
7
|
RequestEditorMode: 'requestEditorMode',
|
|
9
8
|
RequestReadOnlyMode: 'requestReadOnlyMode',
|
|
10
9
|
ExperienceUpdated: 'componentTreeUpdated',
|
|
11
|
-
/** @deprecated will be removed when dropping backward compatibility for old DND */
|
|
12
10
|
ComponentDraggingChanged: 'componentDraggingChanged',
|
|
13
|
-
/** @deprecated will be removed when dropping backward compatibility for old DND */
|
|
14
11
|
ComponentDragCanceled: 'componentDragCanceled',
|
|
15
|
-
/** @deprecated will be removed when dropping backward compatibility for old DND */
|
|
16
12
|
ComponentDragStarted: 'componentDragStarted',
|
|
17
|
-
/** @deprecated will be removed when dropping backward compatibility for old DND */
|
|
18
13
|
ComponentDragEnded: 'componentDragEnded',
|
|
19
|
-
/** @deprecated will be removed when dropping backward compatibility for old DND */
|
|
20
14
|
ComponentMoveEnded: 'componentMoveEnded',
|
|
21
|
-
/** @deprecated will be removed when dropping backward compatibility for old DND */
|
|
22
15
|
CanvasResized: 'canvasResized',
|
|
23
|
-
/** @deprecated will be removed when dropping backward compatibility for old DND */
|
|
24
16
|
SelectComponent: 'selectComponent',
|
|
25
|
-
/** @deprecated will be removed when dropping backward compatibility for old DND */
|
|
26
17
|
HoverComponent: 'hoverComponent',
|
|
27
18
|
UpdatedEntity: 'updatedEntity',
|
|
28
19
|
AssembliesAdded: 'assembliesAdded',
|
|
29
20
|
AssembliesRegistered: 'assembliesRegistered',
|
|
30
|
-
/** @deprecated will be removed when dropping backward compatibility for old DND */
|
|
31
21
|
MouseMove: 'mouseMove',
|
|
32
22
|
RequestedEntities: 'REQUESTED_ENTITIES',
|
|
33
23
|
};
|
|
@@ -828,17 +818,16 @@ const PrimitiveValueSchema = z.union([
|
|
|
828
818
|
z.record(z.any(), z.any()),
|
|
829
819
|
z.undefined(),
|
|
830
820
|
]);
|
|
821
|
+
const UsedComponentsSchema = z.array(z.object({
|
|
822
|
+
sys: z.object({
|
|
823
|
+
type: z.literal('Link'),
|
|
824
|
+
id: z.string(),
|
|
825
|
+
linkType: z.literal('Entry'),
|
|
826
|
+
}),
|
|
827
|
+
}));
|
|
831
828
|
const uuidKeySchema = z
|
|
832
829
|
.string()
|
|
833
830
|
.regex(/^[a-zA-Z0-9-_]{1,21}$/, { message: 'Does not match /^[a-zA-Z0-9-_]{1,21}$/' });
|
|
834
|
-
/**
|
|
835
|
-
* Property keys for imported components have a limit of 32 characters (to be implemented) while
|
|
836
|
-
* property keys for patterns have a limit of 54 characters (<32-char-variabl-name>_<21-char-nanoid-id>).
|
|
837
|
-
* Because we cannot distinguish between the two in the componentTree, we will use the larger limit for both.
|
|
838
|
-
*/
|
|
839
|
-
const propertyKeySchema = z
|
|
840
|
-
.string()
|
|
841
|
-
.regex(/^[a-zA-Z0-9-_]{1,54}$/, { message: 'Does not match /^[a-zA-Z0-9-_]{1,54}$/' });
|
|
842
831
|
const DataSourceSchema = z.record(uuidKeySchema, z.object({
|
|
843
832
|
sys: z.object({
|
|
844
833
|
type: z.literal('Link'),
|
|
@@ -846,7 +835,62 @@ const DataSourceSchema = z.record(uuidKeySchema, z.object({
|
|
|
846
835
|
linkType: z.enum(['Entry', 'Asset']),
|
|
847
836
|
}),
|
|
848
837
|
}));
|
|
838
|
+
const UnboundValuesSchema = z.record(uuidKeySchema, z.object({
|
|
839
|
+
value: PrimitiveValueSchema,
|
|
840
|
+
}));
|
|
841
|
+
/**
|
|
842
|
+
* Property keys for imported components have a limit of 32 characters (to be implemented) while
|
|
843
|
+
* property keys for patterns have a limit of 54 characters (<32-char-variable-name>_<21-char-nanoid-id>).
|
|
844
|
+
* Because we cannot distinguish between the two in the componentTree, we will use the larger limit for both.
|
|
845
|
+
*/
|
|
846
|
+
const propertyKeySchema = z
|
|
847
|
+
.string()
|
|
848
|
+
.regex(/^[a-zA-Z0-9-_]{1,54}$/, { message: 'Does not match /^[a-zA-Z0-9-_]{1,54}$/' });
|
|
849
|
+
const ComponentTreeNodeIdSchema = z
|
|
850
|
+
.string()
|
|
851
|
+
.regex(/^[a-zA-Z0-9]{1,8}$/, { message: 'Does not match /^[a-zA-Z0-9]{1,8}$/' });
|
|
852
|
+
const breakpointsRefinement = (value, ctx) => {
|
|
853
|
+
if (!value.length || value[0].query !== '*') {
|
|
854
|
+
ctx.addIssue({
|
|
855
|
+
code: z.ZodIssueCode.custom,
|
|
856
|
+
message: `The first breakpoint should include the following attributes: { "query": "*" }`,
|
|
857
|
+
});
|
|
858
|
+
}
|
|
859
|
+
const hasDuplicateIds = value.some((currentBreakpoint, currentBreakpointIndex) => {
|
|
860
|
+
// check if the current breakpoint id is found in the rest of the array
|
|
861
|
+
const breakpointIndex = value.findIndex((breakpoint) => breakpoint.id === currentBreakpoint.id);
|
|
862
|
+
return breakpointIndex !== currentBreakpointIndex;
|
|
863
|
+
});
|
|
864
|
+
if (hasDuplicateIds) {
|
|
865
|
+
ctx.addIssue({
|
|
866
|
+
code: z.ZodIssueCode.custom,
|
|
867
|
+
message: `Breakpoint IDs must be unique`,
|
|
868
|
+
});
|
|
869
|
+
}
|
|
870
|
+
// Extract the queries boundary by removing the special characters around it
|
|
871
|
+
const queries = value.map((bp) => bp.query === '*' ? bp.query : parseInt(bp.query.replace(/px|<|>/, '')));
|
|
872
|
+
// sort updates queries array in place so we need to create a copy
|
|
873
|
+
const originalQueries = [...queries];
|
|
874
|
+
queries.sort((q1, q2) => {
|
|
875
|
+
if (q1 === '*') {
|
|
876
|
+
return -1;
|
|
877
|
+
}
|
|
878
|
+
if (q2 === '*') {
|
|
879
|
+
return 1;
|
|
880
|
+
}
|
|
881
|
+
return q1 > q2 ? -1 : 1;
|
|
882
|
+
});
|
|
883
|
+
if (originalQueries.join('') !== queries.join('')) {
|
|
884
|
+
ctx.addIssue({
|
|
885
|
+
code: z.ZodIssueCode.custom,
|
|
886
|
+
message: `Breakpoints should be ordered from largest to smallest pixel value`,
|
|
887
|
+
});
|
|
888
|
+
}
|
|
889
|
+
};
|
|
849
890
|
const ValuesByBreakpointSchema = z.record(z.lazy(() => PrimitiveValueSchema));
|
|
891
|
+
const BindingSourceTypeEnumSchema = z
|
|
892
|
+
.array(z.enum(['entry', 'asset', 'manual', 'experience']))
|
|
893
|
+
.nonempty();
|
|
850
894
|
const DesignValueSchema = z
|
|
851
895
|
.object({
|
|
852
896
|
type: z.literal('DesignValue'),
|
|
@@ -879,8 +923,6 @@ const ComponentValueSchema = z
|
|
|
879
923
|
key: z.string(),
|
|
880
924
|
})
|
|
881
925
|
.strict();
|
|
882
|
-
// TODO: finalize schema structure before release
|
|
883
|
-
// https://contentful.atlassian.net/browse/LUMOS-523
|
|
884
926
|
const NoValueSchema = z.object({ type: z.literal('NoValue') }).strict();
|
|
885
927
|
const ComponentPropertyValueSchema = z.discriminatedUnion('type', [
|
|
886
928
|
DesignValueSchema,
|
|
@@ -892,41 +934,12 @@ const ComponentPropertyValueSchema = z.discriminatedUnion('type', [
|
|
|
892
934
|
]);
|
|
893
935
|
// TODO: finalize schema structure before release
|
|
894
936
|
// https://contentful.atlassian.net/browse/LUMOS-523
|
|
895
|
-
const VariableMappingSchema = z.object({
|
|
896
|
-
patternPropertyDefinitionId: propertyKeySchema,
|
|
897
|
-
type: z.literal('ContentTypeMapping'),
|
|
898
|
-
pathsByContentType: z.record(z.string(), z.object({ path: z.string() })),
|
|
899
|
-
});
|
|
900
|
-
const VariableMappingsSchema = z.record(propertyKeySchema, VariableMappingSchema);
|
|
901
|
-
// TODO: finalize schema structure before release
|
|
902
|
-
// https://contentful.atlassian.net/browse/LUMOS-523
|
|
903
|
-
const PatternPropertyDefinitionSchema = z.object({
|
|
904
|
-
defaultValue: z
|
|
905
|
-
.record(z.string(), z.object({
|
|
906
|
-
sys: z.object({
|
|
907
|
-
type: z.literal('Link'),
|
|
908
|
-
id: z.string(),
|
|
909
|
-
linkType: z.enum(['Entry']),
|
|
910
|
-
}),
|
|
911
|
-
}))
|
|
912
|
-
.optional(),
|
|
913
|
-
contentTypes: z.record(z.string(), z.object({
|
|
914
|
-
sys: z.object({
|
|
915
|
-
type: z.literal('Link'),
|
|
916
|
-
id: z.string(),
|
|
917
|
-
linkType: z.enum(['ContentType']),
|
|
918
|
-
}),
|
|
919
|
-
})),
|
|
920
|
-
});
|
|
921
|
-
const PatternPropertyDefinitionsSchema = z.record(propertyKeySchema, PatternPropertyDefinitionSchema);
|
|
922
|
-
// TODO: finalize schema structure before release
|
|
923
|
-
// https://contentful.atlassian.net/browse/LUMOS-523
|
|
924
937
|
const PatternPropertySchema = z.object({
|
|
925
938
|
type: z.literal('BoundValue'),
|
|
926
939
|
path: z.string(),
|
|
927
940
|
contentType: z.string(),
|
|
928
941
|
});
|
|
929
|
-
const
|
|
942
|
+
const PatternPropertiesSchema = z.record(propertyKeySchema, PatternPropertySchema);
|
|
930
943
|
const BreakpointSchema = z
|
|
931
944
|
.object({
|
|
932
945
|
id: propertyKeySchema,
|
|
@@ -936,12 +949,6 @@ const BreakpointSchema = z
|
|
|
936
949
|
displayIcon: z.enum(['desktop', 'tablet', 'mobile']).optional(),
|
|
937
950
|
})
|
|
938
951
|
.strict();
|
|
939
|
-
const UnboundValuesSchema = z.record(uuidKeySchema, z.object({
|
|
940
|
-
value: PrimitiveValueSchema,
|
|
941
|
-
}));
|
|
942
|
-
const ComponentTreeNodeIdSchema = z
|
|
943
|
-
.string()
|
|
944
|
-
.regex(/^[a-zA-Z0-9]{1,8}$/, { message: 'Does not match /^[a-zA-Z0-9]{1,8}$/' });
|
|
945
952
|
// Use helper schema to define a recursive schema with its type correctly below
|
|
946
953
|
const BaseComponentTreeNodeSchema = z.object({
|
|
947
954
|
id: ComponentTreeNodeIdSchema.optional(),
|
|
@@ -949,14 +956,8 @@ const BaseComponentTreeNodeSchema = z.object({
|
|
|
949
956
|
displayName: z.string().optional(),
|
|
950
957
|
slotId: z.string().optional(),
|
|
951
958
|
variables: z.record(propertyKeySchema, ComponentPropertyValueSchema),
|
|
952
|
-
patternProperties:
|
|
959
|
+
patternProperties: PatternPropertiesSchema.optional(),
|
|
953
960
|
});
|
|
954
|
-
const ComponentTreeNodeSchema = BaseComponentTreeNodeSchema.extend({
|
|
955
|
-
children: z.lazy(() => ComponentTreeNodeSchema.array()),
|
|
956
|
-
});
|
|
957
|
-
const BindingSourceTypeEnumSchema = z
|
|
958
|
-
.array(z.enum(['entry', 'asset', 'manual', 'experience']))
|
|
959
|
-
.nonempty();
|
|
960
961
|
const ComponentVariableSchema = z.object({
|
|
961
962
|
displayName: z.string().optional(),
|
|
962
963
|
type: DefinitionPropertyTypeSchema,
|
|
@@ -977,8 +978,25 @@ const ComponentVariableSchema = z.object({
|
|
|
977
978
|
})
|
|
978
979
|
.optional(),
|
|
979
980
|
});
|
|
980
|
-
const
|
|
981
|
-
|
|
981
|
+
const ComponentTreeNodeSchema = BaseComponentTreeNodeSchema.extend({
|
|
982
|
+
children: z.lazy(() => ComponentTreeNodeSchema.array()),
|
|
983
|
+
});
|
|
984
|
+
const ComponentTreeSchema = z
|
|
985
|
+
.object({
|
|
986
|
+
breakpoints: z.array(BreakpointSchema).superRefine(breakpointsRefinement),
|
|
987
|
+
children: z.array(ComponentTreeNodeSchema),
|
|
988
|
+
schemaVersion: SchemaVersions,
|
|
989
|
+
})
|
|
990
|
+
.strict();
|
|
991
|
+
const localeWrapper = (fieldSchema) => z.record(z.string(), fieldSchema);
|
|
992
|
+
|
|
993
|
+
z.object({
|
|
994
|
+
componentTree: localeWrapper(ComponentTreeSchema),
|
|
995
|
+
dataSource: localeWrapper(DataSourceSchema),
|
|
996
|
+
unboundValues: localeWrapper(UnboundValuesSchema),
|
|
997
|
+
usedComponents: localeWrapper(UsedComponentsSchema).optional(),
|
|
998
|
+
});
|
|
999
|
+
|
|
982
1000
|
const THUMBNAIL_IDS = [
|
|
983
1001
|
'columns',
|
|
984
1002
|
'columnsPlusRight',
|
|
@@ -1004,6 +1022,37 @@ const THUMBNAIL_IDS = [
|
|
|
1004
1022
|
'textColumns',
|
|
1005
1023
|
'duplex',
|
|
1006
1024
|
];
|
|
1025
|
+
// TODO: finalize schema structure before release
|
|
1026
|
+
// https://contentful.atlassian.net/browse/LUMOS-523
|
|
1027
|
+
const VariableMappingSchema = z.object({
|
|
1028
|
+
patternPropertyDefinitionId: propertyKeySchema,
|
|
1029
|
+
type: z.literal('ContentTypeMapping'),
|
|
1030
|
+
pathsByContentType: z.record(z.string(), z.object({ path: z.string() })),
|
|
1031
|
+
});
|
|
1032
|
+
// TODO: finalize schema structure before release
|
|
1033
|
+
// https://contentful.atlassian.net/browse/LUMOS-523
|
|
1034
|
+
const PatternPropertyDefinitionSchema = z.object({
|
|
1035
|
+
defaultValue: z
|
|
1036
|
+
.record(z.string(), z.object({
|
|
1037
|
+
sys: z.object({
|
|
1038
|
+
type: z.literal('Link'),
|
|
1039
|
+
id: z.string(),
|
|
1040
|
+
linkType: z.enum(['Entry']),
|
|
1041
|
+
}),
|
|
1042
|
+
}))
|
|
1043
|
+
.optional(),
|
|
1044
|
+
contentTypes: z.record(z.string(), z.object({
|
|
1045
|
+
sys: z.object({
|
|
1046
|
+
type: z.literal('Link'),
|
|
1047
|
+
id: z.string(),
|
|
1048
|
+
linkType: z.enum(['ContentType']),
|
|
1049
|
+
}),
|
|
1050
|
+
})),
|
|
1051
|
+
});
|
|
1052
|
+
const PatternPropertyDefinitionsSchema = z.record(propertyKeySchema, PatternPropertyDefinitionSchema);
|
|
1053
|
+
const VariableMappingsSchema = z.record(propertyKeySchema, VariableMappingSchema);
|
|
1054
|
+
const ComponentVariablesSchema = z.record(z.string().regex(/^[a-zA-Z0-9-_]{1,54}$/), // Here the key is <variableName>_<nanoidId> so we need to allow for a longer length
|
|
1055
|
+
ComponentVariableSchema);
|
|
1007
1056
|
const ComponentSettingsSchema = z.object({
|
|
1008
1057
|
variableDefinitions: ComponentVariablesSchema,
|
|
1009
1058
|
thumbnailId: z.enum(THUMBNAIL_IDS).optional(),
|
|
@@ -1011,65 +1060,12 @@ const ComponentSettingsSchema = z.object({
|
|
|
1011
1060
|
variableMappings: VariableMappingsSchema.optional(),
|
|
1012
1061
|
patternPropertyDefinitions: PatternPropertyDefinitionsSchema.optional(),
|
|
1013
1062
|
});
|
|
1014
|
-
const UsedComponentsSchema = z.array(z.object({
|
|
1015
|
-
sys: z.object({
|
|
1016
|
-
type: z.literal('Link'),
|
|
1017
|
-
id: z.string(),
|
|
1018
|
-
linkType: z.literal('Entry'),
|
|
1019
|
-
}),
|
|
1020
|
-
}));
|
|
1021
|
-
const breakpointsRefinement = (value, ctx) => {
|
|
1022
|
-
if (!value.length || value[0].query !== '*') {
|
|
1023
|
-
ctx.addIssue({
|
|
1024
|
-
code: z.ZodIssueCode.custom,
|
|
1025
|
-
message: `The first breakpoint should include the following attributes: { "query": "*" }`,
|
|
1026
|
-
});
|
|
1027
|
-
}
|
|
1028
|
-
const hasDuplicateIds = value.some((currentBreakpoint, currentBreakpointIndex) => {
|
|
1029
|
-
// check if the current breakpoint id is found in the rest of the array
|
|
1030
|
-
const breakpointIndex = value.findIndex((breakpoint) => breakpoint.id === currentBreakpoint.id);
|
|
1031
|
-
return breakpointIndex !== currentBreakpointIndex;
|
|
1032
|
-
});
|
|
1033
|
-
if (hasDuplicateIds) {
|
|
1034
|
-
ctx.addIssue({
|
|
1035
|
-
code: z.ZodIssueCode.custom,
|
|
1036
|
-
message: `Breakpoint IDs must be unique`,
|
|
1037
|
-
});
|
|
1038
|
-
}
|
|
1039
|
-
// Extract the queries boundary by removing the special characters around it
|
|
1040
|
-
const queries = value.map((bp) => bp.query === '*' ? bp.query : parseInt(bp.query.replace(/px|<|>/, '')));
|
|
1041
|
-
// sort updates queries array in place so we need to create a copy
|
|
1042
|
-
const originalQueries = [...queries];
|
|
1043
|
-
queries.sort((q1, q2) => {
|
|
1044
|
-
if (q1 === '*') {
|
|
1045
|
-
return -1;
|
|
1046
|
-
}
|
|
1047
|
-
if (q2 === '*') {
|
|
1048
|
-
return 1;
|
|
1049
|
-
}
|
|
1050
|
-
return q1 > q2 ? -1 : 1;
|
|
1051
|
-
});
|
|
1052
|
-
if (originalQueries.join('') !== queries.join('')) {
|
|
1053
|
-
ctx.addIssue({
|
|
1054
|
-
code: z.ZodIssueCode.custom,
|
|
1055
|
-
message: `Breakpoints should be ordered from largest to smallest pixel value`,
|
|
1056
|
-
});
|
|
1057
|
-
}
|
|
1058
|
-
};
|
|
1059
|
-
const ComponentTreeSchema = z
|
|
1060
|
-
.object({
|
|
1061
|
-
breakpoints: z.array(BreakpointSchema).superRefine(breakpointsRefinement),
|
|
1062
|
-
children: z.array(ComponentTreeNodeSchema),
|
|
1063
|
-
schemaVersion: SchemaVersions,
|
|
1064
|
-
})
|
|
1065
|
-
.strict();
|
|
1066
|
-
const localeWrapper = (fieldSchema) => z.record(z.string(), fieldSchema);
|
|
1067
1063
|
z.object({
|
|
1068
1064
|
componentTree: localeWrapper(ComponentTreeSchema),
|
|
1069
1065
|
dataSource: localeWrapper(DataSourceSchema),
|
|
1070
1066
|
unboundValues: localeWrapper(UnboundValuesSchema),
|
|
1071
1067
|
usedComponents: localeWrapper(UsedComponentsSchema).optional(),
|
|
1072
|
-
componentSettings: localeWrapper(ComponentSettingsSchema)
|
|
1068
|
+
componentSettings: localeWrapper(ComponentSettingsSchema),
|
|
1073
1069
|
});
|
|
1074
1070
|
|
|
1075
1071
|
z.object({
|
|
@@ -2938,6 +2934,47 @@ const getDataFromTree = (tree) => {
|
|
|
2938
2934
|
unboundValues,
|
|
2939
2935
|
};
|
|
2940
2936
|
};
|
|
2937
|
+
/**
|
|
2938
|
+
* Gets calculates the index to drop the dragged component based on the mouse position
|
|
2939
|
+
* @returns {InsertionData} a object containing a node that will become a parent for dragged component and index at which it must be inserted
|
|
2940
|
+
*/
|
|
2941
|
+
const getInsertionData = ({ dropReceiverParentNode, dropReceiverNode, flexDirection, isMouseAtTopBorder, isMouseAtBottomBorder, isMouseInLeftHalf, isMouseInUpperHalf, isOverTopIndicator, isOverBottomIndicator, }) => {
|
|
2942
|
+
const APPEND_INSIDE = dropReceiverNode.children.length;
|
|
2943
|
+
const PREPEND_INSIDE = 0;
|
|
2944
|
+
if (isMouseAtTopBorder || isMouseAtBottomBorder) {
|
|
2945
|
+
const indexOfSectionInParentChildren = dropReceiverParentNode.children.findIndex((n) => n.data.id === dropReceiverNode.data.id);
|
|
2946
|
+
const APPEND_OUTSIDE = indexOfSectionInParentChildren + 1;
|
|
2947
|
+
const PREPEND_OUTSIDE = indexOfSectionInParentChildren;
|
|
2948
|
+
return {
|
|
2949
|
+
// when the mouse is around the border we want to drop the new component as a new section onto the root node
|
|
2950
|
+
node: dropReceiverParentNode,
|
|
2951
|
+
index: isMouseAtBottomBorder ? APPEND_OUTSIDE : PREPEND_OUTSIDE,
|
|
2952
|
+
};
|
|
2953
|
+
}
|
|
2954
|
+
// if over one of the section indicators
|
|
2955
|
+
if (isOverTopIndicator || isOverBottomIndicator) {
|
|
2956
|
+
const indexOfSectionInParentChildren = dropReceiverParentNode.children.findIndex((n) => n.data.id === dropReceiverNode.data.id);
|
|
2957
|
+
const APPEND_OUTSIDE = indexOfSectionInParentChildren + 1;
|
|
2958
|
+
const PREPEND_OUTSIDE = indexOfSectionInParentChildren;
|
|
2959
|
+
return {
|
|
2960
|
+
// when the mouse is around the border we want to drop the new component as a new section onto the root node
|
|
2961
|
+
node: dropReceiverParentNode,
|
|
2962
|
+
index: isOverBottomIndicator ? APPEND_OUTSIDE : PREPEND_OUTSIDE,
|
|
2963
|
+
};
|
|
2964
|
+
}
|
|
2965
|
+
if (flexDirection === undefined || flexDirection === 'row') {
|
|
2966
|
+
return {
|
|
2967
|
+
node: dropReceiverNode,
|
|
2968
|
+
index: isMouseInLeftHalf ? PREPEND_INSIDE : APPEND_INSIDE,
|
|
2969
|
+
};
|
|
2970
|
+
}
|
|
2971
|
+
else {
|
|
2972
|
+
return {
|
|
2973
|
+
node: dropReceiverNode,
|
|
2974
|
+
index: isMouseInUpperHalf ? PREPEND_INSIDE : APPEND_INSIDE,
|
|
2975
|
+
};
|
|
2976
|
+
}
|
|
2977
|
+
};
|
|
2941
2978
|
const generateRandomId = (letterCount) => {
|
|
2942
2979
|
const LETTERS = 'abcdefghijklmnopqvwxyzABCDEFGHIJKLMNOPQVWXYZ';
|
|
2943
2980
|
const NUMS = '0123456789';
|
|
@@ -4085,5 +4122,5 @@ async function fetchById({ client, experienceTypeId, id, localeCode, isEditorMod
|
|
|
4085
4122
|
}
|
|
4086
4123
|
}
|
|
4087
4124
|
|
|
4088
|
-
export { DebugLogger, DeepReference, EditorModeEntityStore, EntityStore, EntityStoreBase, MEDIA_QUERY_REGEXP, VisualEditorMode, addLocale, addMinHeightForEmptyStructures, breakpointsRegistry, buildCfStyles, buildStyleTag, buildTemplate, builtInStyles, calculateNodeDefaultHeight, checkIsAssembly, checkIsAssemblyDefinition, checkIsAssemblyEntry, checkIsAssemblyNode, columnsBuiltInStyles, containerBuiltInStyles, createExperience, debug, defineBreakpoints, defineDesignTokens, designTokensRegistry, detachExperienceStyles, disableDebug, dividerBuiltInStyles, doesMismatchMessageSchema, enableDebug, fetchAllAssets, fetchAllEntries, fetchById, fetchBySlug, fetchExperienceEntry, fetchReferencedEntities, findOutermostCoordinates, flattenDesignTokenRegistry, gatherDeepReferencesFromExperienceEntry, gatherDeepReferencesFromTree, generateRandomId, getActiveBreakpointIndex, getBreakpointRegistration, getDataFromTree, getDesignTokenRegistration, getElementCoordinates, getFallbackBreakpointIndex, getTargetValueInPixels, getTemplateValue, getValueForBreakpoint, indexByBreakpoint, isCfStyleAttribute, isComponentAllowedOnRoot, isContentfulComponent, isContentfulStructureComponent, isDeepPath, isExperienceEntry, isLink, isLinkToAsset, isPatternComponent, isStructureWithRelativeHeight, isValidBreakpointValue, lastPathNamedSegmentEq, localizeEntity, maybePopulateDesignTokenValue, mediaQueryMatcher, optionalBuiltInStyles, parseCSSValue, parseDataSourcePathIntoFieldset, parseDataSourcePathWithL1DeepBindings, resetBreakpointsRegistry, resetDesignTokenRegistry, resolveBackgroundImageBinding, resolveHyperlinkPattern, runBreakpointsValidation, sanitizeNodeProps, sectionBuiltInStyles, sendMessage, singleColumnBuiltInStyles, stringifyCssProperties, toCSSAttribute, toMediaQuery, transformBoundContentValue, treeMap, treeVisit, tryParseMessage, validateExperienceBuilderConfig };
|
|
4125
|
+
export { DebugLogger, DeepReference, EditorModeEntityStore, EntityStore, EntityStoreBase, MEDIA_QUERY_REGEXP, VisualEditorMode, addLocale, addMinHeightForEmptyStructures, breakpointsRegistry, buildCfStyles, buildStyleTag, buildTemplate, builtInStyles, calculateNodeDefaultHeight, checkIsAssembly, checkIsAssemblyDefinition, checkIsAssemblyEntry, checkIsAssemblyNode, columnsBuiltInStyles, containerBuiltInStyles, createExperience, debug, defineBreakpoints, defineDesignTokens, designTokensRegistry, detachExperienceStyles, disableDebug, dividerBuiltInStyles, doesMismatchMessageSchema, enableDebug, fetchAllAssets, fetchAllEntries, fetchById, fetchBySlug, fetchExperienceEntry, fetchReferencedEntities, findOutermostCoordinates, flattenDesignTokenRegistry, gatherDeepReferencesFromExperienceEntry, gatherDeepReferencesFromTree, generateRandomId, getActiveBreakpointIndex, getBreakpointRegistration, getDataFromTree, getDesignTokenRegistration, getElementCoordinates, getFallbackBreakpointIndex, getInsertionData, getTargetValueInPixels, getTemplateValue, getValueForBreakpoint, indexByBreakpoint, isCfStyleAttribute, isComponentAllowedOnRoot, isContentfulComponent, isContentfulStructureComponent, isDeepPath, isExperienceEntry, isLink, isLinkToAsset, isPatternComponent, isStructureWithRelativeHeight, isValidBreakpointValue, lastPathNamedSegmentEq, localizeEntity, maybePopulateDesignTokenValue, mediaQueryMatcher, optionalBuiltInStyles, parseCSSValue, parseDataSourcePathIntoFieldset, parseDataSourcePathWithL1DeepBindings, resetBreakpointsRegistry, resetDesignTokenRegistry, resolveBackgroundImageBinding, resolveHyperlinkPattern, runBreakpointsValidation, sanitizeNodeProps, sectionBuiltInStyles, sendMessage, singleColumnBuiltInStyles, stringifyCssProperties, toCSSAttribute, toMediaQuery, transformBoundContentValue, treeMap, treeVisit, tryParseMessage, validateExperienceBuilderConfig };
|
|
4089
4126
|
//# sourceMappingURL=index.js.map
|