@griddo/ax 11.10.36 → 11.10.37

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.
Files changed (28) hide show
  1. package/package.json +2 -2
  2. package/src/__tests__/components/Fields/ComponentArray/MixableComponentArray/PasteModuleButton/PasteModuleButton.test.tsx +1 -3
  3. package/src/components/Browser/index.tsx +20 -18
  4. package/src/components/BrowserContent/index.tsx +8 -6
  5. package/src/components/Fields/ComponentArray/BulkHeader/index.tsx +1 -2
  6. package/src/components/Fields/ComponentArray/MixableComponentArray/AddItemButton/index.tsx +1 -1
  7. package/src/components/Fields/ComponentArray/MixableComponentArray/index.tsx +29 -43
  8. package/src/components/Fields/ComponentArray/{MixableComponentArray/PasteModuleButton → PasteModuleButton}/index.tsx +6 -6
  9. package/src/components/Fields/ComponentArray/SameComponentArray/AddItemButton/index.tsx +1 -1
  10. package/src/components/Fields/ComponentArray/SameComponentArray/index.tsx +103 -61
  11. package/src/components/Fields/ComponentArray/SameComponentArray/style.tsx +7 -1
  12. package/src/components/Fields/ComponentArray/helpers.tsx +2 -2
  13. package/src/components/Fields/ComponentArray/index.tsx +4 -4
  14. package/src/components/Fields/ComponentContainer/EmptyContainer/index.tsx +7 -8
  15. package/src/components/Fields/ComponentContainer/atoms.tsx +0 -2
  16. package/src/components/Fields/ComponentContainer/index.tsx +26 -30
  17. package/src/components/SideModal/SideModalOption/index.tsx +14 -11
  18. package/src/components/SideModal/index.tsx +16 -19
  19. package/src/containers/PageEditor/actions.tsx +17 -20
  20. package/src/helpers/containerEvaluations.tsx +1 -12
  21. package/src/hooks/iframe.ts +13 -9
  22. package/src/modules/Forms/FormEditor/PageBrowser/index.tsx +1 -15
  23. package/src/modules/FramePreview/index.tsx +17 -4
  24. package/src/modules/GlobalEditor/PageBrowser/index.tsx +5 -2
  25. package/src/modules/PageEditor/Editor/index.tsx +1 -2
  26. package/src/modules/PageEditor/PageBrowser/index.tsx +5 -2
  27. package/src/modules/PageEditor/index.tsx +0 -1
  28. package/src/types/index.tsx +11 -0
@@ -25,4 +25,10 @@ const Asterisk = styled.span`
25
25
  color: ${(p) => p.theme.color.error};
26
26
  `;
27
27
 
28
- export { Wrapper, Title, ItemRow, Subtitle, Asterisk };
28
+ const ActionsWrapper = styled.div`
29
+ display: flex;
30
+ margin-left: auto;
31
+ align-items: center;
32
+ `;
33
+
34
+ export { Wrapper, Title, ItemRow, Subtitle, Asterisk, ActionsWrapper };
@@ -1,6 +1,6 @@
1
1
  import differenceInSeconds from "date-fns/differenceInSeconds";
2
2
  import { getSchema, getDisplayName, getSchemaType, isComponentEmpty } from "@ax/helpers";
3
- import { IComponent, IModule, ISchemaField } from "@ax/types";
3
+ import type { IComponent, IModule, ISchemaField } from "@ax/types";
4
4
 
5
5
  const getComponentTitle = (component: string, title: any): string => {
6
6
  if (!title) return "";
@@ -32,7 +32,7 @@ const getComponentProps = (element: IModule, activatedModules: string[], isModul
32
32
  const isModuleDeactivated = isModuleArr && activatedModules && !activatedModules.includes(component);
33
33
  const isModuleDisabled = !schemaType;
34
34
 
35
- return { moduleTitle, isModuleDeactivated, componentTitle, displayName, isModule, isModuleDisabled };
35
+ return { moduleTitle, isModuleDeactivated, componentTitle, displayName, isModuleDisabled };
36
36
  };
37
37
 
38
38
  const containerToComponentArray = (value?: Record<string, IComponent>): IComponent[] =>
@@ -1,7 +1,7 @@
1
- import React from "react";
2
-
3
- import SameComponentArray, { ISameComponentArrayProps } from "./SameComponentArray";
4
- import MixableComponentArray, { IMixableComponentArrayProps } from "./MixableComponentArray";
1
+ import MixableComponentArray from "./MixableComponentArray";
2
+ import SameComponentArray from "./SameComponentArray";
3
+ import type { ISameComponentArrayProps } from "./SameComponentArray";
4
+ import type { IMixableComponentArrayProps } from "./MixableComponentArray";
5
5
 
6
6
  const ComponentArraySelector = (props: ISameComponentArrayProps & IMixableComponentArrayProps): JSX.Element => {
7
7
  const { elementUniqueSelection = false } = props;
@@ -1,7 +1,6 @@
1
- import React from "react";
2
- import { useModal } from "@ax/hooks";
3
-
4
1
  import { HiddenField, SideModal } from "@ax/components";
2
+ import { useModal } from "@ax/hooks";
3
+ import type { IComponent, ModuleCategoryInfo } from "@ax/types";
5
4
 
6
5
  const EmptyContainer = (props: IProps) => {
7
6
  const { hasMultipleOptions, whiteList, handleAdd, goTo, componentOptions, title, categories, theme, disabled } =
@@ -10,12 +9,12 @@ const EmptyContainer = (props: IProps) => {
10
9
 
11
10
  const handleClick = () => (hasMultipleOptions ? toggleModal() : goTo());
12
11
 
13
- const displayName = title ? title : whiteList && whiteList[0];
12
+ const displayName = title ? title : whiteList?.[0];
14
13
 
15
14
  return (
16
15
  <>
17
16
  <HiddenField
18
- title={displayName}
17
+ title={displayName || ""}
19
18
  showField={handleClick}
20
19
  hasMultipleOptions={hasMultipleOptions}
21
20
  disabled={disabled}
@@ -38,12 +37,12 @@ const EmptyContainer = (props: IProps) => {
38
37
 
39
38
  interface IProps {
40
39
  hasMultipleOptions: boolean | undefined;
41
- whiteList: any[] | undefined;
40
+ whiteList: string[] | undefined;
42
41
  goTo: () => void;
43
42
  componentOptions: any;
44
43
  title?: string;
45
- categories?: any;
46
- handleAdd: (option: any) => void;
44
+ categories?: ModuleCategoryInfo[];
45
+ handleAdd: (option: string | IComponent) => void;
47
46
  theme: string;
48
47
  disabled?: boolean;
49
48
  }
@@ -1,5 +1,3 @@
1
- import React from "react";
2
-
3
1
  import { ActionMenu } from "@ax/components";
4
2
 
5
3
  import * as S from "./style";
@@ -1,10 +1,10 @@
1
- import React from "react";
1
+ import type React from "react";
2
2
  import { useSortable } from "@dnd-kit/sortable";
3
3
 
4
4
  import { useModal } from "@ax/hooks";
5
5
  import { isEmptyContainer, getDisplayName, trimText } from "@ax/helpers";
6
6
  import { CheckField, Icon, SideModal } from "@ax/components";
7
- import { ICheck } from "@ax/types";
7
+ import type { ICheck, IComponent, ModuleCategoryInfo } from "@ax/types";
8
8
  import EmptyContainer from "./EmptyContainer";
9
9
  import { ArrayContainerButtons, ContainerButtons } from "./atoms";
10
10
 
@@ -32,7 +32,6 @@ const ComponentContainer = (props: IComponentContainerProps): JSX.Element => {
32
32
  canReplace,
33
33
  actionReplace,
34
34
  arrayLength,
35
- isModule,
36
35
  isSelected,
37
36
  onChange,
38
37
  hasMenu = true,
@@ -52,19 +51,19 @@ const ComponentContainer = (props: IComponentContainerProps): JSX.Element => {
52
51
  id: editorID,
53
52
  });
54
53
 
55
- const whiteListFirstItem: any = whiteList && whiteList[0];
56
- const hasMultipleOptions: boolean | undefined = whiteList && whiteList.length > 1;
54
+ const whiteListFirstItem: string | undefined = whiteList?.[0];
55
+ const hasMultipleOptions = !!(whiteList && whiteList.length > 1);
57
56
 
58
- const containerOptions: any =
57
+ const containerOptions =
59
58
  parentKey && objKey ? selectedContent[parentKey][objKey] : objKey && selectedContent[objKey];
60
59
 
61
- let containerText: string = text ? text : getDisplayName(whiteListFirstItem);
60
+ let containerText: string = text ? text : whiteListFirstItem ? getDisplayName(whiteListFirstItem) : "";
62
61
  let componentID: number = editorID ? editorID : containerOptions?.editorID;
63
62
 
64
- const containerInfo: any = !isArray && value && isEmptyContainer(value, hasMultipleOptions);
65
- const isEmpty: boolean = containerInfo?.isEmpty;
63
+ const containerInfo = !isArray && value ? isEmptyContainer(value, hasMultipleOptions) : null;
64
+ const isEmpty: boolean = !!containerInfo?.isEmpty;
66
65
 
67
- const currentComponent: any = containerInfo?.containedComponent;
66
+ const currentComponent = containerInfo?.containedComponent;
68
67
 
69
68
  if (currentComponent) {
70
69
  containerText = currentComponent.containerText;
@@ -79,13 +78,13 @@ const ComponentContainer = (props: IComponentContainerProps): JSX.Element => {
79
78
 
80
79
  const handleCheckClick = (e: React.MouseEvent<HTMLDivElement>) => e.stopPropagation();
81
80
 
82
- const removeItem = () => deleteModuleAction && deleteModuleAction([editorID], parentKey);
81
+ const removeItem = () => deleteModuleAction?.([editorID], parentKey);
83
82
 
84
- const duplicateItem = () => parentKey && duplicateModuleAction && duplicateModuleAction([editorID], parentKey);
83
+ const duplicateItem = () => parentKey && duplicateModuleAction?.([editorID], parentKey);
85
84
 
86
85
  const copyItem = () => {
87
- const isCopied = copyModuleAction && copyModuleAction([editorID]);
88
- isCopied && toggleToast && toggleToast("1 module copied to clipboard");
86
+ const isCopied = copyModuleAction?.([editorID]);
87
+ isCopied && toggleToast?.("1 module copied to clipboard");
89
88
  };
90
89
 
91
90
  const copyOpt = {
@@ -111,11 +110,11 @@ const ComponentContainer = (props: IComponentContainerProps): JSX.Element => {
111
110
  const replaceOpt = {
112
111
  label: "replace",
113
112
  icon: "change",
114
- action: () => actionReplace && actionReplace(),
113
+ action: () => actionReplace?.(),
115
114
  };
116
115
 
117
116
  const actionArrayMenuOptions = [
118
- ...(isModule ? [copyOpt] : []),
117
+ copyOpt,
119
118
  ...(canDuplicate ? [duplicateOpt] : []),
120
119
  deleteOpt,
121
120
  ...(canReplace ? [replaceOpt] : []),
@@ -131,24 +130,22 @@ const ComponentContainer = (props: IComponentContainerProps): JSX.Element => {
131
130
 
132
131
  const actionMenuIcon = "more";
133
132
 
134
- const handleEmptyContainerClick = () => {
135
- if (addComponentAction) addComponentAction(value, objKey);
136
- };
133
+ const handleEmptyContainerClick = () => addComponentAction?.(value, objKey);
137
134
 
138
- const handleOptionClick = (option: any) => {
139
- if (addComponentAction) addComponentAction(option, objKey);
140
- };
135
+ const handleOptionClick = (option: string | IComponent) => addComponentAction?.(option, objKey);
141
136
 
142
137
  const compoundKey = parentKey ? `${parentKey}.${objKey}` : objKey;
143
- const handleReplace = (option: any) =>
144
- compoundKey && replaceModuleAction && replaceModuleAction(option, selectedContent, compoundKey);
138
+
139
+ const handleReplace = (option: string | IComponent) => {
140
+ compoundKey && typeof option !== "string" && replaceModuleAction?.(option, selectedContent, compoundKey);
141
+ }
145
142
 
146
143
  const arrayContainerButtonsProps = {
147
144
  options: actionArrayMenuOptions,
148
145
  icon: actionMenuIcon,
149
146
  };
150
147
 
151
- const handleChange = (value: ICheck) => onChange && onChange(value);
148
+ const handleChange = (value: ICheck) => onChange?.(value);
152
149
 
153
150
  const textComponents = isMultiDragging ? (
154
151
  <S.LabelDrag>
@@ -156,7 +153,7 @@ const ComponentContainer = (props: IComponentContainerProps): JSX.Element => {
156
153
  </S.LabelDrag>
157
154
  ) : (
158
155
  <>
159
- <S.Label containerInfo={containerInfo} disabled={disabled}>
156
+ <S.Label containerInfo={!!containerInfo} disabled={disabled}>
160
157
  {trimText(containerText, 25)}
161
158
  </S.Label>
162
159
  {moduleTitle && <S.Title disabled={disabled}>{trimText(moduleTitle, 25)}</S.Title>}
@@ -240,7 +237,7 @@ export interface IComponentContainerProps {
240
237
  text: string;
241
238
  editorID: number;
242
239
  whiteList: string[] | undefined;
243
- categories?: any[];
240
+ categories?: ModuleCategoryInfo[];
244
241
  goTo(editorID: number): void;
245
242
  isArray?: boolean | undefined;
246
243
  value?: any;
@@ -249,11 +246,11 @@ export interface IComponentContainerProps {
249
246
  selectedContent?: any;
250
247
  objKey?: string;
251
248
  actions?: {
252
- addComponentAction: (componentType: any, key?: string) => void;
249
+ addComponentAction: (componentType: IComponent | string, key?: string) => void;
253
250
  deleteModuleAction: (editorID: number[], key?: string) => void;
254
251
  duplicateModuleAction: (editorID: number[], key?: string) => number;
255
252
  copyModuleAction: (editorID: number[]) => boolean | number;
256
- replaceModuleAction: (module: any, parent: any, objKey: string) => void;
253
+ replaceModuleAction: (module: IComponent, parent: any, objKey: string) => void;
257
254
  };
258
255
  disabled?: boolean;
259
256
  canDuplicate?: boolean;
@@ -263,7 +260,6 @@ export interface IComponentContainerProps {
263
260
  canReplace?: boolean;
264
261
  actionReplace?: () => void;
265
262
  arrayLength: number;
266
- isModule?: boolean;
267
263
  isSelected?: boolean;
268
264
  onChange?: (value: ICheck) => void;
269
265
  hasMenu?: boolean;
@@ -1,27 +1,30 @@
1
- import React, { memo } from "react";
1
+ import { memo } from "react";
2
+ import type React from "react";
2
3
 
3
4
  import { getDisplayName, getThumbnailProps, filterImageText } from "@ax/helpers";
4
5
  import { Tag } from "@ax/components";
6
+ import type { IComponent } from "@ax/types";
5
7
 
6
8
  import * as S from "./style";
7
9
 
8
- const getThumbnailData = (option: any, theme: string) => {
9
- option = filterImageText(option.component ? option.component : option);
10
-
10
+ const getThumbnailData = (component: string, theme: string) => {
11
+ const option = filterImageText(component);
11
12
  return getThumbnailProps(option, false, theme);
12
13
  };
13
14
 
14
15
  const SideModalOption = (props: IProps) => {
15
16
  const { option, handleClick, theme } = props;
17
+ const isComponentString = typeof option === "string";
18
+ const optionComponent = isComponentString ? option : option.component
16
19
 
17
- const isNavigationDefault = ["header", "footer"].includes(option.type);
20
+ const isNavigationDefault = !isComponentString && ["header", "footer"].includes(option.type);
18
21
 
19
22
  const navigationThumbnail = isNavigationDefault &&
20
23
  option.thumbnail && { alt: option.title, src: option.thumbnail.url };
21
- const thumbnailProps = navigationThumbnail || getThumbnailData(option, theme);
22
24
 
23
- const optionParam = option.component || option;
24
- const label = isNavigationDefault ? option.title : getDisplayName(optionParam);
25
+ const thumbnailProps = navigationThumbnail || getThumbnailData(optionComponent, theme);
26
+
27
+ const label = isNavigationDefault ? option.title : getDisplayName(optionComponent);
25
28
 
26
29
  const setOption = () => {
27
30
  if (handleClick) {
@@ -35,7 +38,7 @@ const SideModalOption = (props: IProps) => {
35
38
  }
36
39
  };
37
40
 
38
- const defaultTag = option.tag ? (
41
+ const defaultTag = !isComponentString && option.tag ? (
39
42
  <S.TagWrapper data-testid="side-modal-option-tag">
40
43
  <Tag text={option.tag} type="square" />
41
44
  </S.TagWrapper>
@@ -51,8 +54,8 @@ const SideModalOption = (props: IProps) => {
51
54
  };
52
55
 
53
56
  interface IProps {
54
- option: any;
55
- handleClick?: (option: any) => void;
57
+ option: string | IComponent;
58
+ handleClick?: (option: string | IComponent) => void;
56
59
  children: string;
57
60
  theme: string;
58
61
  }
@@ -1,11 +1,11 @@
1
- import React, { useEffect, useRef, useState } from "react";
1
+ import { useEffect, useRef, useState } from "react";
2
2
  import { createPortal } from "react-dom";
3
3
 
4
4
  import { useHandleClickOutside } from "@ax/hooks";
5
5
  import { getDisplayName, filterByCategory } from "@ax/helpers";
6
6
  import SideModalOption from "@ax/components/SideModal/SideModalOption";
7
7
  import { MenuItem, SearchField, IconAction } from "@ax/components";
8
- import { ModuleCategoryInfo } from "@ax/types";
8
+ import type { IComponent, IContainedComponent, ModuleCategoryInfo } from "@ax/types";
9
9
 
10
10
  import * as S from "./style";
11
11
 
@@ -23,10 +23,9 @@ const SideModal = (props: ISideModalProps): JSX.Element | null => {
23
23
  theme,
24
24
  } = props;
25
25
 
26
- const componentList: any = [];
27
- const hasCategories = categories && categories.length > 1;
28
-
29
- const optionList = componentOptions ? componentList : whiteList;
26
+ const componentList: IComponent[] = [];
27
+ const hasCategories = !!(categories && categories.length > 1);
28
+ const optionList = componentOptions ? componentList : whiteList || [];
30
29
 
31
30
  const filteredValues = {
32
31
  options: optionList,
@@ -57,7 +56,7 @@ const SideModal = (props: ISideModalProps): JSX.Element | null => {
57
56
  useEffect(() => {
58
57
  if (componentOptions) {
59
58
  for (const key in componentOptions) {
60
- const currentComponent = current && current.component;
59
+ const currentComponent = current?.component;
61
60
  const availableComponent = componentOptions[key].component;
62
61
  if (availableComponent !== currentComponent) {
63
62
  componentList.push(componentOptions[key]);
@@ -73,7 +72,7 @@ const SideModal = (props: ISideModalProps): JSX.Element | null => {
73
72
  }
74
73
  }, [current, whiteList]);
75
74
 
76
- const handleClick = (moduleType: string) => {
75
+ const handleClick = (moduleType: string | IComponent) => {
77
76
  if (onClick) {
78
77
  onClick(moduleType);
79
78
  }
@@ -125,33 +124,31 @@ const SideModal = (props: ISideModalProps): JSX.Element | null => {
125
124
 
126
125
  const featuredFilters =
127
126
  hasCategories &&
128
- categories &&
129
127
  categories
130
- .filter((cat: any) => cat.featured)
128
+ .filter((cat) => cat.featured)
131
129
  .map((category: ModuleCategoryInfo, i: number) => {
132
130
  return getCategoryItem(category, i);
133
131
  });
134
132
 
135
133
  const filters =
136
134
  hasCategories &&
137
- categories &&
138
135
  categories
139
- .filter((cat: any) => !cat.featured)
136
+ .filter((cat) => !cat.featured)
140
137
  .map((category: ModuleCategoryInfo, i: number) => {
141
138
  return getCategoryItem(category, i);
142
139
  });
143
140
 
144
141
  const filteredOptions =
145
- options.options &&
146
- options.options.map((option: any, i: number) => {
147
- const displayName = getDisplayName(option.component ? option.component : option);
142
+ options.options?.map((option) => {
143
+ const optionComponent = typeof option === "string" ? option : option.component
144
+ const displayName = getDisplayName(optionComponent);
148
145
  if (searchQuery.length > 0) {
149
146
  const name = displayName.toLowerCase();
150
147
  const search = searchQuery.toLocaleLowerCase();
151
148
  if (!name.includes(search)) return null;
152
149
  }
153
150
  return (
154
- <SideModalOption option={option} handleClick={handleClick} key={`${option}${i}`} theme={theme}>
151
+ <SideModalOption option={option} handleClick={handleClick} key={optionComponent} theme={theme}>
155
152
  {displayName}
156
153
  </SideModalOption>
157
154
  );
@@ -201,9 +198,9 @@ export interface ISideModalProps {
201
198
  categories?: ModuleCategoryInfo[];
202
199
  optionsType: string;
203
200
  toggleModal: () => void;
204
- onClick?: (moduleType: string) => void;
205
- componentOptions?: any;
206
- current?: any;
201
+ onClick?: (moduleType: string | IComponent) => void;
202
+ componentOptions?: Record<string,IComponent>;
203
+ current?: IContainedComponent;
207
204
  showSearch?: boolean;
208
205
  theme: string;
209
206
  }
@@ -411,10 +411,10 @@ function getTemplatePage(template: string): (dispatch: Dispatch, getState: () =>
411
411
  }
412
412
 
413
413
  function savePage(data?: {
414
- createDraft?: boolean,
415
- publishPage?: { status: string },
416
- publishDraft?: boolean,
417
- setToast?: (msg: string) => void
414
+ createDraft?: boolean;
415
+ publishPage?: { status: string };
416
+ publishDraft?: boolean;
417
+ setToast?: (msg: string) => void;
418
418
  }): (dispatch: Dispatch, getState: any) => Promise<boolean> {
419
419
  return async (dispatch, getState) => {
420
420
  try {
@@ -460,8 +460,7 @@ function savePage(data?: {
460
460
  }
461
461
 
462
462
  /* remove header and footer if page should get the default */
463
- const { defaultHeader, defaultFooter } =
464
- (templateConfig?.templates?.[template.templateType]) || {};
463
+ const { defaultHeader, defaultFooter } = templateConfig?.templates?.[template.templateType] || {};
465
464
 
466
465
  if (header && ((header.setAsDefault && !defaultHeader) || header.id === defaultHeader)) {
467
466
  values.header = null;
@@ -509,7 +508,7 @@ function savePage(data?: {
509
508
  dispatch(setIsSaving(false));
510
509
  return true;
511
510
  } else {
512
- if(typeof setToast === 'function'){
511
+ if (typeof setToast === "function") {
513
512
  setToast(saveResponse.data.message);
514
513
  } else {
515
514
  appActions.handleError(saveResponse)(dispatch);
@@ -849,7 +848,7 @@ function addModule(
849
848
  }
850
849
 
851
850
  function replaceModule(
852
- module: any,
851
+ module: IComponent,
853
852
  parent: any,
854
853
  objKey: string,
855
854
  ): (dispatch: Dispatch, getState: () => IRootState) => void {
@@ -1077,9 +1076,9 @@ function pasteModule(
1077
1076
  const response = await structuredData.getDataContentBulk(fixed, currentSiteInfo?.id);
1078
1077
  if (isReqOk(response.status)) {
1079
1078
  const validDataIds: number[] = [];
1080
- response.data.items.forEach(
1081
- (data: IStructuredDataContent) => { data.relatedSite && validDataIds.push(data.id) },
1082
- );
1079
+ response.data.items.forEach((data: IStructuredDataContent) => {
1080
+ data.relatedSite && validDataIds.push(data.id);
1081
+ });
1083
1082
  const hasInvalidData = validDataIds.length < fixed.length;
1084
1083
  validatedModuleCopy.data.fixed = validDataIds;
1085
1084
  if (hasInvalidData) {
@@ -1121,10 +1120,10 @@ function overwriteHeaderConfig(params: IFieldProps): (dispatch: Dispatch, getSta
1121
1120
  const updatedContent = deepClone(content);
1122
1121
  const { headerConfig } = updatedContent.editorContent;
1123
1122
 
1124
- if(headerConfig[id]){
1125
- headerConfig[id][key] = value
1123
+ if (headerConfig[id]) {
1124
+ headerConfig[id][key] = value;
1126
1125
  } else {
1127
- headerConfig[id] = { [key]: value }
1126
+ headerConfig[id] = { [key]: value };
1128
1127
  }
1129
1128
 
1130
1129
  dispatch(setEditorContent({ ...updatedContent }));
@@ -1140,7 +1139,7 @@ function generatePageContent(editorContent: IPage): (dispatch: Dispatch, getStat
1140
1139
  } = getState();
1141
1140
 
1142
1141
  const { header, footer, isGlobal } = editorContent;
1143
- const { defaultHeader, defaultFooter } = (configFormData?.templates?.[template]) || {};
1142
+ const { defaultHeader, defaultFooter } = configFormData?.templates?.[template] || {};
1144
1143
 
1145
1144
  const headerID =
1146
1145
  header === null || header === undefined ? defaultHeader : typeof header === "object" ? header.id : header;
@@ -1321,7 +1320,7 @@ function moveElement(
1321
1320
  ): (dispatch: Dispatch, getState: () => IRootState) => void {
1322
1321
  return async (dispatch, getState) => {
1323
1322
  try {
1324
- const { editorContent, editorID, selectedContent } = getStateValues(getState);
1323
+ const { editorContent, selectedContent } = getStateValues(getState);
1325
1324
 
1326
1325
  const newContent = moveModule({
1327
1326
  elementID,
@@ -1332,9 +1331,7 @@ function moveElement(
1332
1331
  key,
1333
1332
  });
1334
1333
 
1335
- dispatch(setEditorContent(newContent));
1336
- const { element: selectedPageContent } = findByEditorID(newContent, editorID);
1337
- dispatch(setSelectedPageContent(selectedPageContent));
1334
+ generatePageContent(newContent)(dispatch, getState);
1338
1335
  } catch (e) {
1339
1336
  console.log(e);
1340
1337
  }
@@ -1623,7 +1620,7 @@ function schedulePublication(
1623
1620
  const updatedEditorContent = { ...editorContent, publicationScheduled: date };
1624
1621
 
1625
1622
  dispatch(setEditorContent(updatedEditorContent));
1626
- return await savePage({createDraft: false, publishPage: { status }})(dispatch, getState);
1623
+ return await savePage({ createDraft: false, publishPage: { status } })(dispatch, getState);
1627
1624
  } catch (e) {
1628
1625
  console.log("Error", e);
1629
1626
  return false;
@@ -1,4 +1,4 @@
1
- import { IComponent } from "@ax/types";
1
+ import type { IComponent, IContainedComponent, IContainerEvaluation } from "@ax/types";
2
2
  import { getDisplayName } from "./schemas";
3
3
 
4
4
  const isComponentEmpty = (component: IComponent): boolean => {
@@ -70,15 +70,4 @@ const areEqual = (prevProps: any, newProps: any): boolean => {
70
70
  return prevValue === newValue;
71
71
  };
72
72
 
73
- interface IContainerEvaluation {
74
- isEmpty: boolean;
75
- containedComponent: IContainedComponent;
76
- }
77
-
78
- interface IContainedComponent {
79
- containerText: string;
80
- component: string;
81
- componentID: number;
82
- }
83
-
84
73
  export { isComponentEmpty, setAsContainedComponent, areAllComponentsEmpty, isEmptyContainer, areEqual };
@@ -1,10 +1,11 @@
1
1
  import { useCallback, useEffect } from "react";
2
2
 
3
3
  const useOnMessageReceivedFromIframe = (actions?: {
4
- setSelectedContentAction: any;
5
- deleteModuleAction(editorID: number[]): void;
6
- duplicateModuleAction(editorID: number[]): number;
7
- setScrollEditorIDAction(editorID: number | null): void;
4
+ setSelectedContentAction(editorID: number): void;
5
+ deleteModuleAction?(editorID: number[]): void;
6
+ duplicateModuleAction?(editorID: number[]): number;
7
+ copyModuleAction?(editorID: number[]): number | boolean;
8
+ setScrollEditorIDAction?(editorID: number | null): void;
8
9
  }): void => {
9
10
  const onMessageReceivedFromIframe = useCallback(
10
11
  (ev: MessageEvent<{ type: string; message: string }>) => {
@@ -12,18 +13,21 @@ const useOnMessageReceivedFromIframe = (actions?: {
12
13
  if (!ev.data.type) return;
13
14
  if (!ev.data.message) return;
14
15
  if (ev.data.type === "module-click") {
15
- actions?.setSelectedContentAction(ev.data.message);
16
+ actions?.setSelectedContentAction(parseInt(ev.data.message));
16
17
  }
17
18
  if (ev.data.type === "module-delete") {
18
19
  actions?.setSelectedContentAction(0);
19
- actions?.deleteModuleAction([parseInt(ev.data.message)]);
20
+ actions?.deleteModuleAction?.([parseInt(ev.data.message)]);
20
21
  }
21
22
  if (ev.data.type === "module-duplicate") {
22
- const duplicatedEditorID = actions?.duplicateModuleAction([parseInt(ev.data.message)]);
23
- actions?.setSelectedContentAction(duplicatedEditorID);
23
+ const duplicatedEditorID = actions?.duplicateModuleAction?.([parseInt(ev.data.message)]);
24
+ duplicatedEditorID && actions?.setSelectedContentAction(duplicatedEditorID);
24
25
  }
25
26
  if (ev.data.type === "module-scroll") {
26
- actions?.setScrollEditorIDAction(parseInt(ev.data.message));
27
+ actions?.setScrollEditorIDAction?.(parseInt(ev.data.message));
28
+ }
29
+ if (ev.data.type === "module-copy") {
30
+ actions?.copyModuleAction?.([parseInt(ev.data.message)]);
27
31
  }
28
32
  },
29
33
  [actions],
@@ -1,10 +1,8 @@
1
- import React from "react";
2
1
  import { connect } from "react-redux";
3
- import { pageEditorActions } from "@ax/containers/PageEditor";
4
2
  import { formsActions } from "@ax/containers/Forms";
5
3
 
6
4
  import { Browser } from "@ax/components";
7
- import { ILanguage, IRootState, ISchema, ISite, ISocialState } from "@ax/types";
5
+ import type { ILanguage, IRootState, ISchema, ISite, ISocialState } from "@ax/types";
8
6
 
9
7
  import * as S from "./style";
10
8
 
@@ -20,18 +18,12 @@ const PageBrowser = (props: IProps) => {
20
18
  isPreview,
21
19
  browserRef,
22
20
  currentSiteInfo,
23
- deleteModule,
24
- duplicateModule,
25
- setScrollEditorID,
26
21
  } = props;
27
22
 
28
23
  const { id: siteID } = currentSiteInfo || {};
29
24
 
30
25
  const actions = {
31
- deleteModuleAction: deleteModule,
32
- duplicateModuleAction: duplicateModule,
33
26
  setSelectedContentAction: setSelectedContent,
34
- setScrollEditorIDAction: setScrollEditorID,
35
27
  };
36
28
 
37
29
  return (
@@ -73,9 +65,6 @@ interface IPageBrowserDispatchProps {
73
65
  isReadOnly: boolean;
74
66
  isPreview?: boolean;
75
67
  browserRef?: any;
76
- deleteModule(editorID: number[]): void;
77
- duplicateModule(editorID: number[]): number;
78
- setScrollEditorID(editorID: number | null): void;
79
68
  }
80
69
 
81
70
  type IProps = IPageBrowserStateProps & IPageBrowserDispatchProps;
@@ -92,9 +81,6 @@ const mapStateToProps = (state: IRootState): IPageBrowserStateProps => ({
92
81
 
93
82
  const mapDispatchToProps = {
94
83
  setSelectedContent: formsActions.setSelectedContent,
95
- deleteModule: pageEditorActions.deleteModule,
96
- duplicateModule: pageEditorActions.duplicateModule,
97
- setScrollEditorID: pageEditorActions.setScrollEditorID,
98
84
  };
99
85
 
100
86
  export default connect(mapStateToProps, mapDispatchToProps)(PageBrowser);