@flozy/editor 10.2.0 → 10.2.1

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 (172) hide show
  1. package/dist/Editor/ChatEditor.js +16 -17
  2. package/dist/Editor/CommonEditor.js +16 -120
  3. package/dist/Editor/DialogWrapper.js +25 -31
  4. package/dist/Editor/Editor.css +8 -46
  5. package/dist/Editor/Elements/AI/PopoverAIInput.js +3 -11
  6. package/dist/Editor/Elements/Accordion/Accordion.js +2 -6
  7. package/dist/Editor/Elements/AppHeader/AppHeader.js +3 -3
  8. package/dist/Editor/Elements/Button/EditorButton.js +9 -25
  9. package/dist/Editor/Elements/Carousel/CarouselItem.js +1 -2
  10. package/dist/Editor/Elements/Color Picker/ColorButtons.js +14 -61
  11. package/dist/Editor/Elements/Color Picker/ColorPicker.css +1 -25
  12. package/dist/Editor/Elements/Color Picker/ColorPicker.js +7 -10
  13. package/dist/Editor/Elements/Color Picker/Styles.js +13 -15
  14. package/dist/Editor/Elements/DataView/Layouts/ColumnView.js +2 -4
  15. package/dist/Editor/Elements/DataView/Layouts/DataTypes/MultiSelectType.js +6 -21
  16. package/dist/Editor/Elements/DataView/Layouts/Options/AddOptions.js +1 -5
  17. package/dist/Editor/Elements/DataView/Layouts/Options/EditOption.js +2 -3
  18. package/dist/Editor/Elements/DataView/Layouts/Options/index.js +0 -11
  19. package/dist/Editor/Elements/DataView/Layouts/ViewData.js +4 -8
  20. package/dist/Editor/Elements/Embed/Image.js +2 -3
  21. package/dist/Editor/Elements/Embed/Video.js +1 -1
  22. package/dist/Editor/Elements/EmbedScript/Code.js +2 -14
  23. package/dist/Editor/Elements/EmbedScript/EmbedScriptPopup.js +28 -57
  24. package/dist/Editor/Elements/Form/Form.js +168 -181
  25. package/dist/Editor/Elements/Form/FormElements/FormText.js +6 -23
  26. package/dist/Editor/Elements/Form/FormElements/FormTextArea.js +2 -3
  27. package/dist/Editor/Elements/Form/FormField.js +6 -13
  28. package/dist/Editor/Elements/Form/Workflow/Styles.js +22 -24
  29. package/dist/Editor/Elements/FreeGrid/FreeGrid.js +31 -36
  30. package/dist/Editor/Elements/FreeGrid/FreeGridBox.js +4 -7
  31. package/dist/Editor/Elements/FreeGrid/Options/More.js +8 -8
  32. package/dist/Editor/Elements/FreeGrid/styles.js +7 -67
  33. package/dist/Editor/Elements/Grid/Grid.js +2 -14
  34. package/dist/Editor/Elements/Grid/GridItem.js +1 -1
  35. package/dist/Editor/Elements/List/CheckList.js +2 -3
  36. package/dist/Editor/Elements/Search/SearchAttachment.js +9 -40
  37. package/dist/Editor/Elements/Search/SearchButton.js +8 -9
  38. package/dist/Editor/Elements/Search/SearchList.js +7 -9
  39. package/dist/Editor/Elements/Signature/Signature.css +1 -2
  40. package/dist/Editor/Elements/Signature/SignatureOptions/DrawSignature.js +5 -18
  41. package/dist/Editor/Elements/Signature/SignatureOptions/UploadSignature.js +3 -16
  42. package/dist/Editor/Elements/SimpleText/index.js +1 -6
  43. package/dist/Editor/Elements/SimpleText/style.js +2 -2
  44. package/dist/Editor/Elements/Table/DragButton.js +1 -0
  45. package/dist/Editor/Elements/Table/Draggable.js +2 -6
  46. package/dist/Editor/Elements/Table/Styles.js +0 -7
  47. package/dist/Editor/Elements/Table/Table.js +3 -3
  48. package/dist/Editor/Elements/Table/TableCell.js +5 -24
  49. package/dist/Editor/Elements/Title/title.js +6 -6
  50. package/dist/Editor/Elements/Variables/VariableButton.js +1 -10
  51. package/dist/Editor/MiniEditor.js +1 -2
  52. package/dist/Editor/Styles/EditorStyles.js +5 -5
  53. package/dist/Editor/Toolbar/FormatTools/Dropdown.js +3 -27
  54. package/dist/Editor/Toolbar/FormatTools/FontFamilyAutocomplete.js +3 -4
  55. package/dist/Editor/Toolbar/FormatTools/MarkButton.js +2 -2
  56. package/dist/Editor/Toolbar/FormatTools/TextSize.js +13 -10
  57. package/dist/Editor/Toolbar/Mini/MiniToolbar.js +1 -2
  58. package/dist/Editor/Toolbar/PopupTool/MiniTextFormat/MiniColorPicker.js +2 -4
  59. package/dist/Editor/Toolbar/PopupTool/MiniTextFormat/SelectFontSize.js +13 -6
  60. package/dist/Editor/Toolbar/PopupTool/MiniTextFormat/SelectTypography.js +42 -167
  61. package/dist/Editor/Toolbar/PopupTool/MiniTextFormat/index.js +4 -7
  62. package/dist/Editor/Toolbar/PopupTool/PopperHeader.js +1 -2
  63. package/dist/Editor/Toolbar/PopupTool/PopupToolStyle.js +12 -72
  64. package/dist/Editor/Toolbar/PopupTool/TextFormat.js +27 -100
  65. package/dist/Editor/Toolbar/PopupTool/index.js +1 -1
  66. package/dist/Editor/Toolbar/toolbarGroups.js +6 -48
  67. package/dist/Editor/assets/svg/SettingsIcon.js +0 -1
  68. package/dist/Editor/common/ColorPickerButton.js +16 -38
  69. package/dist/Editor/common/DnD/DragHandleButton.js +1 -1
  70. package/dist/Editor/common/FontLoader/FontLoader.js +0 -3
  71. package/dist/Editor/common/Icon.js +1 -31
  72. package/dist/Editor/common/ImageSelector/Styles.js +9 -3
  73. package/dist/Editor/common/LinkSettings/NavComponents.js +8 -34
  74. package/dist/Editor/common/LinkSettings/index.js +68 -84
  75. package/dist/Editor/common/LinkSettings/style.js +30 -245
  76. package/dist/Editor/common/RnD/ElementOptions/Actions.js +14 -13
  77. package/dist/Editor/common/RnD/ElementOptions/Icons/LinkIcon.js +0 -1
  78. package/dist/Editor/common/RnD/ElementOptions/index.js +2 -2
  79. package/dist/Editor/common/RnD/ElementOptions/styles.js +1 -28
  80. package/dist/Editor/common/RnD/ElementSettings/OtherSettings/Settings.js +5 -6
  81. package/dist/Editor/common/RnD/ElementSettings/OtherSettings/Signature.js +3 -4
  82. package/dist/Editor/common/RnD/ElementSettings/Settings/AppHeaderSettings.js +2 -3
  83. package/dist/Editor/common/RnD/ElementSettings/Settings/BoxSettings.js +2 -3
  84. package/dist/Editor/common/RnD/ElementSettings/Settings/ButtonSettings.js +2 -3
  85. package/dist/Editor/common/RnD/ElementSettings/Settings/CodeSettings.js +2 -3
  86. package/dist/Editor/common/RnD/ElementSettings/Settings/FormSettings.js +2 -4
  87. package/dist/Editor/common/RnD/ElementSettings/Settings/ImageSettings.js +2 -3
  88. package/dist/Editor/common/RnD/ElementSettings/Settings/TableSettings.js +2 -3
  89. package/dist/Editor/common/RnD/ElementSettings/Settings/TextSettings.js +1 -3
  90. package/dist/Editor/common/RnD/ElementSettings/Settings/VideoSettings.js +2 -3
  91. package/dist/Editor/common/RnD/ElementSettings/styles.js +12 -147
  92. package/dist/Editor/common/RnD/OptionsPopup/index.js +5 -8
  93. package/dist/Editor/common/RnD/OptionsPopup/style.js +19 -121
  94. package/dist/Editor/common/RnD/SwitchViewport/SwitchViewport.js +5 -8
  95. package/dist/Editor/common/RnD/Theme/ViewportStimulator.js +3 -6
  96. package/dist/Editor/common/RnD/Utils/gridDropItem.js +19 -28
  97. package/dist/Editor/common/RnD/Utils/index.js +1 -3
  98. package/dist/Editor/common/RnD/VirtualElement/VirtualTextElement.js +54 -48
  99. package/dist/Editor/common/RnD/VirtualElement/helper.js +131 -143
  100. package/dist/Editor/common/RnD/VirtualElement/styles.js +0 -16
  101. package/dist/Editor/common/RnD/index.js +11 -6
  102. package/dist/Editor/common/Select/index.js +0 -2
  103. package/dist/Editor/common/Shorthands/elements.js +11 -65
  104. package/dist/Editor/common/StyleBuilder/buttonStyle.js +2 -4
  105. package/dist/Editor/common/StyleBuilder/fieldTypes/backgroundImage.js +0 -5
  106. package/dist/Editor/common/StyleBuilder/fieldTypes/bannerSpacing.js +2 -12
  107. package/dist/Editor/common/StyleBuilder/fieldTypes/borderRadius.js +7 -15
  108. package/dist/Editor/common/StyleBuilder/fieldTypes/card.js +8 -16
  109. package/dist/Editor/common/StyleBuilder/fieldTypes/color.js +10 -36
  110. package/dist/Editor/common/StyleBuilder/fieldTypes/fontSize.js +7 -16
  111. package/dist/Editor/common/StyleBuilder/fieldTypes/lineSpacing.js +6 -7
  112. package/dist/Editor/common/StyleBuilder/fieldTypes/menusArray.js +6 -13
  113. package/dist/Editor/common/StyleBuilder/fieldTypes/textOptions.js +7 -15
  114. package/dist/Editor/common/StyleBuilder/pageSettingsStyle.js +7 -5
  115. package/dist/Editor/common/Uploader.js +0 -8
  116. package/dist/Editor/common/iconListV2.js +6 -156
  117. package/dist/Editor/common/iconslist.js +0 -24
  118. package/dist/Editor/commonStyle.js +62 -168
  119. package/dist/Editor/helper/index.js +0 -4
  120. package/dist/Editor/helper/theme.js +2 -203
  121. package/dist/Editor/hooks/useMouseMove.js +5 -8
  122. package/dist/Editor/hooks/useTable.js +4 -5
  123. package/dist/Editor/plugins/withEmbeds.js +1 -1
  124. package/dist/Editor/plugins/withHTML.js +1 -3
  125. package/dist/Editor/plugins/withTable.js +1 -1
  126. package/dist/Editor/theme/ThemeList.js +173 -50
  127. package/dist/Editor/utils/SlateUtilityFunctions.js +45 -169
  128. package/dist/Editor/utils/accordion.js +4 -14
  129. package/dist/Editor/utils/button.js +17 -1
  130. package/dist/Editor/utils/customHooks/useTableResize.js +9 -49
  131. package/dist/Editor/utils/draftToSlate.js +2 -3
  132. package/dist/Editor/utils/events.js +6 -50
  133. package/dist/Editor/utils/font.js +37 -40
  134. package/dist/Editor/utils/form.js +4 -4
  135. package/dist/Editor/utils/formfield.js +2 -8
  136. package/dist/Editor/utils/helper.js +19 -109
  137. package/dist/Editor/utils/signature.js +9 -2
  138. package/package.json +4 -4
  139. package/dist/Editor/Elements/DataView/Layouts/DataTypes/Components/MultiSelect.js +0 -454
  140. package/dist/Editor/Elements/EmbedScript/styles.js +0 -89
  141. package/dist/Editor/Elements/FreeGrid/helper.js +0 -113
  142. package/dist/Editor/Toolbar/PopupTool/ThemeTextFormat.js +0 -439
  143. package/dist/Editor/assets/svg/BackIcon.js +0 -18
  144. package/dist/Editor/assets/svg/ClearAllRounded.js +0 -31
  145. package/dist/Editor/assets/svg/ResetIconNew.js +0 -23
  146. package/dist/Editor/assets/svg/ThemeIcons.js +0 -293
  147. package/dist/Editor/common/CustomColorPicker/index.js +0 -130
  148. package/dist/Editor/common/CustomColorPicker/style.js +0 -53
  149. package/dist/Editor/common/CustomDialog2/index.js +0 -94
  150. package/dist/Editor/common/CustomDialog2/style.js +0 -67
  151. package/dist/Editor/common/CustomSelect.js +0 -43
  152. package/dist/Editor/common/RnD/Theme/MainThemeProvider.js +0 -17
  153. package/dist/Editor/common/SnackBar/index.js +0 -43
  154. package/dist/Editor/helper/textIndeces.js +0 -58
  155. package/dist/Editor/hooks/useEditorTheme.js +0 -153
  156. package/dist/Editor/hooks/useThemeValues.js +0 -63
  157. package/dist/Editor/theme/index.js +0 -149
  158. package/dist/Editor/themeSettings/ActiveTheme.js +0 -82
  159. package/dist/Editor/themeSettings/buttons/index.js +0 -300
  160. package/dist/Editor/themeSettings/buttons/style.js +0 -23
  161. package/dist/Editor/themeSettings/colorTheme/index.js +0 -310
  162. package/dist/Editor/themeSettings/colorTheme/style.js +0 -81
  163. package/dist/Editor/themeSettings/fonts/PreviewElement.js +0 -121
  164. package/dist/Editor/themeSettings/fonts/index.js +0 -240
  165. package/dist/Editor/themeSettings/fonts/style.js +0 -62
  166. package/dist/Editor/themeSettings/icons.js +0 -60
  167. package/dist/Editor/themeSettings/index.js +0 -361
  168. package/dist/Editor/themeSettings/style.js +0 -299
  169. package/dist/Editor/themeSettingsAI/icons.js +0 -96
  170. package/dist/Editor/themeSettingsAI/index.js +0 -355
  171. package/dist/Editor/themeSettingsAI/saveTheme.js +0 -202
  172. package/dist/Editor/themeSettingsAI/style.js +0 -332
@@ -1,7 +1,6 @@
1
1
  import React from "react";
2
- import { useTheme, createTheme, useMediaQuery } from "@mui/material";
2
+ import { useTheme, ThemeProvider, createTheme, useMediaQuery } from "@mui/material";
3
3
  import { isStimulator, STIMULATOR_MOCK } from "../../../hooks/useBreakpoints";
4
- import MainThemeProvider from "./MainThemeProvider";
5
4
 
6
5
  // Custom breakpoints functions
7
6
  import { jsx as _jsx } from "react/jsx-runtime";
@@ -60,15 +59,13 @@ const extendedTheme = (prevTheme, isPrintMode) => createTheme({
60
59
  } : getBreakPoints(prevTheme)
61
60
  });
62
61
  const ViewportStimulator = ({
63
- children,
64
- selectedTheme
62
+ children
65
63
  }) => {
66
64
  const theme = useTheme();
67
65
  const isPrintMode = useMediaQuery("print");
68
66
  const viewportTheme = extendedTheme(theme, isPrintMode);
69
- return /*#__PURE__*/_jsx(MainThemeProvider, {
67
+ return /*#__PURE__*/_jsx(ThemeProvider, {
70
68
  theme: viewportTheme,
71
- userSelectedTheme: selectedTheme,
72
69
  children: children
73
70
  });
74
71
  };
@@ -2,7 +2,6 @@ import { Transforms, Node, Path, Editor } from "slate";
2
2
  import { ReactEditor } from "slate-react";
3
3
  import { getNode, handleNegativeInteger } from "../../../utils/helper";
4
4
  import { handleBoxAlignment } from "../VirtualElement/helper";
5
- import { convertToGridArea, findMaxYValue } from "../../../Elements/FreeGrid/helper";
6
5
  export const ROW_HEIGHT = 50;
7
6
 
8
7
  // const MARGIN_OF = {
@@ -23,27 +22,18 @@ export function updateRows() {}
23
22
  export function updateCols() {}
24
23
  const handleMoveNode = (editor, path, newPath, {
25
24
  isEmpty
26
- }, autoAlign, moveToNode) => {
25
+ }, autoAlign) => {
27
26
  try {
28
27
  let replaceNode = Node.get(editor, path);
29
- let heightDiff = 0;
30
28
  if (autoAlign) {
31
- const y = findMaxYValue(moveToNode?.children);
32
- const {
33
- gridArea,
34
- marginTop
35
- } = convertToGridArea(y);
29
+ // reset node for auto alignment in mobile
36
30
  replaceNode = {
37
31
  ...replaceNode,
38
- gridArea_xs: gridArea,
39
- marginTop_xs: marginTop + 12,
40
- xs_updatedOn: new Date().getTime()
32
+ gridArea_xs: null,
33
+ xs_updatedOn: null,
34
+ marginTop_xs: null
41
35
  };
42
- const newHeight = y + replaceNode?.height_xs + 12;
43
- const diffH = newHeight - moveToNode?.height_xs;
44
- heightDiff = diffH >= 0 ? diffH : 0;
45
36
  }
46
- let rPath;
47
37
  if (isEmpty) {
48
38
  const toPath = [...newPath, 0];
49
39
  Transforms.insertNodes(editor, [{
@@ -54,7 +44,7 @@ const handleMoveNode = (editor, path, newPath, {
54
44
  Transforms.removeNodes(editor, {
55
45
  at: path
56
46
  });
57
- rPath = toPath;
47
+ return toPath;
58
48
  } else {
59
49
  Transforms.insertNodes(editor, [{
60
50
  ...replaceNode
@@ -64,12 +54,8 @@ const handleMoveNode = (editor, path, newPath, {
64
54
  Transforms.removeNodes(editor, {
65
55
  at: path
66
56
  });
67
- rPath = newPath;
57
+ return newPath;
68
58
  }
69
- return {
70
- rPath,
71
- heightDiff
72
- };
73
59
  } catch (err) {
74
60
  console.log(err);
75
61
  console.log("Drop Node error");
@@ -224,7 +210,7 @@ export function onDropItem(props, parentClass) {
224
210
  at: moveTo,
225
211
  match: n => n.type === "freegrid"
226
212
  });
227
- const [, sectionPath] = sectionData || [];
213
+ const [sectionNode, sectionPath] = sectionData || [];
228
214
  if (needMove && isInsidePath(from, moveTo)) {
229
215
  reRenderSectionPath = sectionPath;
230
216
  } else {
@@ -243,6 +229,14 @@ export function onDropItem(props, parentClass) {
243
229
  const isBoxHeader = currentNode?.childType === "appHeader" && moveTo?.length > 2;
244
230
  if (isBoxHeader) {
245
231
  // will handle on <BoxHeaderAutoAlignment />
232
+ } else if (moveTo?.length === 2 && autoAlign) {
233
+ // auto align in mobile
234
+ Transforms.setNodes(editor, {
235
+ xs_updatedOn: null,
236
+ xs_updatedOn: new Date().getTime()
237
+ }, {
238
+ at: moveTo
239
+ });
246
240
  } else if (autoAlign) {
247
241
  Transforms.setNodes(editor, {
248
242
  autoAlign: true,
@@ -251,15 +245,12 @@ export function onDropItem(props, parentClass) {
251
245
  at: moveTo
252
246
  });
253
247
  }
254
- const {
255
- rPath,
256
- heightDiff
257
- } = handleMoveNode(editor, path, newPath, {
248
+ const rPath = handleMoveNode(editor, path, newPath, {
258
249
  isEmpty
259
- }, autoAlign, toSectionNode) || {};
250
+ }, autoAlign);
260
251
  reRenderChildNodes(editor, reRenderSectionPath || moveTo);
261
252
  if (autoAlign && !isBoxHeader) {
262
- handleBoxAlignment(editor, sectionPath, heightDiff);
253
+ handleBoxAlignment(editor, sectionNode, sectionPath);
263
254
  }
264
255
  return {
265
256
  updated_at: rPath
@@ -87,9 +87,7 @@ export function updatePositions(props, closestClass) {
87
87
  newPath = [...newPath, toSectionNode?.children?.length];
88
88
  }
89
89
  newPath = newPath.map(m => parseInt(m));
90
- const {
91
- rPath
92
- } = handleMoveNode(editor, path, newPath, {
90
+ const rPath = handleMoveNode(editor, path, newPath, {
93
91
  isEmpty
94
92
  });
95
93
  // to update path index need to re-render items in parent sections
@@ -1,57 +1,71 @@
1
1
  import { useEffect, useRef } from "react";
2
+ import { Path, Transforms } from "slate";
2
3
  import { getNode } from "../../../utils/helper";
3
4
  import { ROW_HEIGHT } from "../Utils/gridDropItem";
4
- import { getGridArea, handleTextAlignment } from "./helper";
5
+ import { findFirstRowOverlap, getGridArea, handleContainers, moveOverlappedItems } from "./helper";
5
6
  import { Box } from "@mui/material";
6
7
  import { jsx as _jsx } from "react/jsx-runtime";
7
- export const getElementOffset = element => {
8
- const {
9
- marginTop_xs: marginTop,
10
- gridArea_xs: gridArea,
11
- height_xs: height
12
- } = element;
13
- const [startRow] = getGridArea(gridArea);
14
- const top = (startRow - 1) * ROW_HEIGHT + marginTop;
15
- const bottom = top + height;
16
- return {
17
- top,
18
- bottom
19
- };
20
- };
21
8
  const updateTextHeight = (editor, path, height) => {
22
9
  if (!height) {
23
10
  return;
24
11
  }
25
- const textItem = getNode(editor, path);
26
- if (!textItem) {
12
+ const parentPath = Path.parent(path);
13
+ const currentNode = getNode(editor, parentPath);
14
+ const gridItems = currentNode?.children || [];
15
+ const isNewlyAddedElement = gridItems.some(gridItem => !gridItem.gridArea_xs && gridItem.type !== "paragraph");
16
+ if (isNewlyAddedElement) {
27
17
  return;
28
18
  }
19
+ const textItemIndex = path[parentPath.length];
20
+ const textItem = gridItems.find((_, index) => textItemIndex === index);
29
21
  const {
30
- height_xs,
31
- gridArea_xs,
32
- type
22
+ marginTop_xs: marginTop,
23
+ gridArea_xs: gridArea,
24
+ height_xs
33
25
  } = textItem;
34
- if (!gridArea_xs && type !== "paragraph") {
35
- return;
36
- }
37
- const oldHeight = height_xs;
38
- const newHeight = height;
39
- const heightDiff = newHeight - oldHeight;
40
- if (heightDiff !== 0) {
41
- const textNode = [textItem, path];
42
- handleTextAlignment(editor, textNode, heightDiff);
26
+ const oldHeight = height_xs + marginTop;
27
+ const newHeight = height + marginTop;
28
+ const extraHeight = newHeight - oldHeight;
29
+ let containerExtraHeight = extraHeight;
30
+ if (extraHeight > 0) {
31
+ const [startRow] = getGridArea(gridArea);
32
+ const newRows = Math.floor(newHeight / ROW_HEIGHT) + 1;
33
+ const endRow = startRow + newRows;
34
+ const firstOverlappedRow = findFirstRowOverlap(gridItems, startRow, endRow, textItemIndex);
35
+ if (firstOverlappedRow) {
36
+ const moveRows = endRow - firstOverlappedRow;
37
+ moveOverlappedItems(editor, moveRows, gridItems, parentPath, textItemIndex, startRow);
38
+ containerExtraHeight += moveRows * ROW_HEIGHT;
39
+ }
40
+
41
+ // handle containers (box and section)
42
+ const containerData = handleContainers(editor, parentPath, containerExtraHeight);
43
+ containerData.forEach(container => {
44
+ const {
45
+ moveRows,
46
+ containerNode,
47
+ containerPath,
48
+ newHeight,
49
+ childIndex,
50
+ lastChildStartRow
51
+ } = container;
52
+ if (moveRows) {
53
+ moveOverlappedItems(editor, moveRows, containerNode?.children, containerPath, childIndex, lastChildStartRow);
54
+ }
55
+ Transforms.setNodes(editor, {
56
+ height_xs: newHeight,
57
+ xs_updatedOn: new Date().getTime()
58
+ }, {
59
+ at: containerPath
60
+ });
61
+ });
62
+ Transforms.setNodes(editor, {
63
+ height_xs: height
64
+ }, {
65
+ at: path
66
+ });
43
67
  }
44
- // else if (heightDiff < 0) {
45
- // Transforms.setNodes(
46
- // editor,
47
- // {
48
- // height_xs: newHeight,
49
- // },
50
- // { at: path }
51
- // );
52
- // }
53
68
  };
54
-
55
69
  function VirtualTextElement(props) {
56
70
  const {
57
71
  dataSets,
@@ -69,7 +83,7 @@ function VirtualTextElement(props) {
69
83
  height
70
84
  } = entry.contentRect;
71
85
  const currentText = currElement?.innerText;
72
- const prevText = prevTextRef?.current;
86
+ const prevText = prevTextRef.current;
73
87
  if (currentText && currentText !== prevText) {
74
88
  updateTextHeight(editor, path, height);
75
89
  }
@@ -108,14 +122,6 @@ function VirtualTextElement(props) {
108
122
  },
109
123
  "& .editor-blocker": {
110
124
  display: "none"
111
- },
112
- "& .fgi_type_text": {
113
- "& .edt-headings": {
114
- margin: "0px"
115
- },
116
- "& .edt-paragraphs": {
117
- margin: "0px"
118
- }
119
125
  }
120
126
  },
121
127
  dangerouslySetInnerHTML: {
@@ -1,6 +1,5 @@
1
1
  import { ROW_HEIGHT, calculateGridArea } from "../Utils/gridDropItem";
2
2
  import { Transforms, Editor } from "slate";
3
- import { getElementOffset } from "./VirtualTextElement";
4
3
  const isBulletOrTickIcon = (width, itemStartRow, startRow) => {
5
4
  return width <= 40 && itemStartRow === startRow;
6
5
  };
@@ -40,83 +39,106 @@ export const getGridArea = gridArea => {
40
39
  const getBoxToAutoAlign = (editor, sectionPath) => {
41
40
  const [boxData] = Editor.nodes(editor, {
42
41
  at: sectionPath,
43
- match: node => ["freegridBox", "freegrid"].includes(node.type) && node.autoAlign
42
+ match: node => node.type === "freegridBox" && node.autoAlign
44
43
  });
45
44
  return boxData || [];
46
45
  };
46
+ const handleGridItems = (gridItems, lastRow) => {
47
+ // to find the previously occupied rows
48
+ gridItems.forEach(item => {
49
+ const {
50
+ gridArea_xs: gridArea,
51
+ marginTop_xs,
52
+ height_xs,
53
+ type
54
+ } = item;
55
+ if (type === "paragraph") {
56
+ // non-freegridItem,
57
+ // some "paragraph" node is defaulty coming inside in box's children
58
+ return;
59
+ }
60
+ const [startRow] = getGridArea(gridArea);
61
+ const marginTop = marginTop_xs ? Number(marginTop_xs) : 0;
62
+ const fullHeight = Number(height_xs) + marginTop;
63
+ const endRow = startRow + Math.floor(fullHeight / ROW_HEIGHT) + 1;
64
+ lastRow = Math.max(endRow, lastRow);
65
+ });
66
+ return {
67
+ lastRow
68
+ };
69
+ };
70
+ const handleNonGridItems = (nonGridItems, lastRow, editor, boxPath) => {
71
+ let containerHeight = (lastRow - 1) * ROW_HEIGHT;
72
+ let newlyAddedHeight = 0;
47
73
 
48
- // const handleGridItems = (gridItems, lastRow) => {
49
- // // to find the previously occupied rows
50
- // gridItems.forEach((item) => {
51
- // const { gridArea_xs: gridArea, marginTop_xs, height_xs, type } = item;
52
-
53
- // if (type === "paragraph") {
54
- // // non-freegridItem,
55
- // // some "paragraph" node is defaulty coming inside in box's children
56
- // return;
57
- // }
58
-
59
- // const [startRow] = getGridArea(gridArea);
60
- // const marginTop = marginTop_xs ? Number(marginTop_xs) : 0;
61
- // const fullHeight = Number(height_xs) + marginTop;
62
-
63
- // const endRow = startRow + Math.floor(fullHeight / ROW_HEIGHT) + 1;
64
-
65
- // lastRow = Math.max(endRow, lastRow);
66
- // });
67
-
68
- // return { lastRow };
69
- // };
70
-
71
- // const handleNonGridItems = (nonGridItems, lastRow, editor, boxPath) => {
72
- // let containerHeight = (lastRow - 1) * ROW_HEIGHT;
73
-
74
- // let newlyAddedHeight = 0;
75
-
76
- // //place it on the next rows that are available
77
- // nonGridItems.forEach((item, index) => {
78
- // const { height_xs, type, itemIndex } = item;
79
-
80
- // if (type === "paragraph") {
81
- // // non-freegridItem
82
- // return;
83
- // }
84
-
85
- // const startRow = lastRow || 1;
86
-
87
- // const DEFAULT_NEW_ELEMENT_MARGIN_TOP = 12;
88
- // let fullHeight = height_xs + DEFAULT_NEW_ELEMENT_MARGIN_TOP;
89
-
90
- // const endRow = startRow + Math.floor(fullHeight / ROW_HEIGHT) + 1;
91
-
92
- // const newGridArea = `${startRow} / 1 / ${startRow + 1} / 2`;
93
-
94
- // const currentElementPath = [...boxPath, itemIndex];
95
-
96
- // Transforms.setNodes(
97
- // editor,
98
- // {
99
- // gridArea_xs: newGridArea,
100
- // marginTop_xs: 12,
101
- // left_xs: 12,
102
- // xs_updatedOn: new Date().getTime(),
103
- // },
104
- // { at: currentElementPath }
105
- // );
106
-
107
- // lastRow = Math.max(endRow, lastRow);
108
-
109
- // containerHeight += fullHeight;
110
- // newlyAddedHeight += fullHeight;
111
- // });
112
-
113
- // return {
114
- // lastRow,
115
- // containerHeight,
116
- // newlyAddedHeight,
117
- // };
118
- // };
119
-
74
+ //place it on the next rows that are available
75
+ nonGridItems.forEach((item, index) => {
76
+ const {
77
+ height_xs,
78
+ type,
79
+ itemIndex
80
+ } = item;
81
+ if (type === "paragraph") {
82
+ // non-freegridItem
83
+ return;
84
+ }
85
+ const startRow = lastRow || 1;
86
+ const DEFAULT_NEW_ELEMENT_MARGIN_TOP = 12;
87
+ let fullHeight = height_xs + DEFAULT_NEW_ELEMENT_MARGIN_TOP;
88
+ const endRow = startRow + Math.floor(fullHeight / ROW_HEIGHT) + 1;
89
+ const newGridArea = `${startRow} / 1 / ${startRow + 1} / 2`;
90
+ const currentElementPath = [...boxPath, itemIndex];
91
+ Transforms.setNodes(editor, {
92
+ gridArea_xs: newGridArea,
93
+ marginTop_xs: 12,
94
+ left_xs: 12,
95
+ xs_updatedOn: new Date().getTime()
96
+ }, {
97
+ at: currentElementPath
98
+ });
99
+ lastRow = Math.max(endRow, lastRow);
100
+ containerHeight += fullHeight;
101
+ newlyAddedHeight += fullHeight;
102
+ });
103
+ return {
104
+ lastRow,
105
+ containerHeight,
106
+ newlyAddedHeight
107
+ };
108
+ };
109
+ const alignNewElementInContainer = (editor, boxPath, containerItems) => {
110
+ let lastRow = 1;
111
+ const gridItems = [];
112
+ const nonGridItems = [];
113
+ containerItems.forEach((item, index) => {
114
+ if (item?.gridArea_xs) {
115
+ gridItems.push({
116
+ ...item,
117
+ itemIndex: index
118
+ });
119
+ } else {
120
+ nonGridItems.push({
121
+ ...item,
122
+ itemIndex: index
123
+ });
124
+ }
125
+ });
126
+ const {
127
+ lastRow: lastRowOccupied
128
+ } = handleGridItems(gridItems, lastRow);
129
+ lastRow = lastRowOccupied;
130
+ const {
131
+ lastRow: lastRowTaken,
132
+ containerHeight,
133
+ newlyAddedHeight
134
+ } = handleNonGridItems(nonGridItems, lastRow, editor, boxPath);
135
+ lastRow = lastRowTaken;
136
+ return {
137
+ lastRow,
138
+ containerHeight,
139
+ newlyAddedHeight
140
+ };
141
+ };
120
142
  const getAncestorFreeGridContainers = (editor, path) => {
121
143
  const containers = [...Editor.nodes(editor, {
122
144
  at: path,
@@ -129,12 +151,6 @@ const getAncestorFreeGridContainers = (editor, path) => {
129
151
  })].filter(([node, nodePath]) => nodePath.length <= path.length);
130
152
  return containers;
131
153
  };
132
- export const handleTextAlignment = (editor, textNode, heightDiff) => {
133
- const [, textPath] = textNode;
134
- let containers = getAncestorFreeGridContainers(editor, textPath);
135
- containers = [...containers, textNode];
136
- handleContainersAlignment(editor, containers, heightDiff, 0);
137
- };
138
154
  export const handleContainers = (editor, boxPath, extraHeight) => {
139
155
  const containers = getAncestorFreeGridContainers(editor, boxPath);
140
156
  let lastChildStartRow;
@@ -197,7 +213,6 @@ export const moveOverlappedItems = (editor, moveRows, containerItems, containerP
197
213
  return;
198
214
  }
199
215
  if (gridItem.type === "paragraph") {
200
- // some empty paragraph node is inserted default'ly inside box, to avoid that
201
216
  return;
202
217
  }
203
218
  const {
@@ -220,61 +235,7 @@ export const moveOverlappedItems = (editor, moveRows, containerItems, containerP
220
235
  }
221
236
  });
222
237
  };
223
- export const handleContainersAlignment = (editor, containers, heightDiff, bufferSpace = 0) => {
224
- for (let i = containers.length - 1; i >= 0; i--) {
225
- const container = containers[i];
226
- const childContainer = containers[i + 1];
227
- const [containerNode, containerPath] = container;
228
- const [childContainerNode, childContainerPath] = childContainer || [];
229
- if (childContainer) {
230
- const {
231
- bottom
232
- } = getElementOffset(childContainerNode);
233
- containerNode.children.forEach((item, index) => {
234
- const currPath = [...containerPath, index];
235
- if (currPath.toString() === childContainerPath.toString()) {
236
- return;
237
- }
238
- if (item.type === "paragraph") {
239
- return;
240
- }
241
- const {
242
- top: itemTop
243
- } = getElementOffset(item);
244
- if (itemTop >= bottom) {
245
- const {
246
- gridArea_xs,
247
- marginTop_xs
248
- } = item;
249
- const [startRow] = getGridArea(gridArea_xs);
250
- const y = (startRow - 1) * ROW_HEIGHT + marginTop_xs + heightDiff;
251
-
252
- // Calculate grid position
253
- const row = Math.floor(y / ROW_HEIGHT) + 1;
254
-
255
- // to calculate difference inside the grid
256
- const marginTop = Math.abs((row - 1) * ROW_HEIGHT - y);
257
-
258
- // Update grid area
259
- const gridArea = `${row} / 1 / ${row + 1} / 2`;
260
- Transforms.setNodes(editor, {
261
- gridArea_xs: gridArea,
262
- marginTop_xs: marginTop + bufferSpace
263
- }, {
264
- at: currPath
265
- });
266
- }
267
- });
268
- }
269
- Transforms.setNodes(editor, {
270
- height_xs: containerNode?.height_xs + heightDiff + bufferSpace,
271
- xs_updatedOn: new Date().getTime()
272
- }, {
273
- at: containerPath
274
- });
275
- }
276
- };
277
- export const handleBoxAlignment = (editor, sectionPath, heightDiff) => {
238
+ export const handleBoxAlignment = (editor, sectionNode, sectionPath) => {
278
239
  const [boxNode, boxPath] = getBoxToAutoAlign(editor, sectionPath);
279
240
  Transforms.setNodes(editor, {
280
241
  autoAlign: false
@@ -284,11 +245,39 @@ export const handleBoxAlignment = (editor, sectionPath, heightDiff) => {
284
245
  if (!boxNode) {
285
246
  return;
286
247
  }
287
- if (heightDiff <= 0) {
288
- return;
248
+ const containerItems = boxNode?.children || [];
249
+ const {
250
+ containerHeight
251
+ } = alignNewElementInContainer(editor, boxPath, containerItems);
252
+ const bufferHeight = 12;
253
+ const newHeight = containerHeight + bufferHeight;
254
+ const {
255
+ height_xs
256
+ } = boxNode;
257
+ const oldHeight = Number(height_xs);
258
+ const extraHeight = newHeight - oldHeight;
259
+ if (extraHeight > 0) {
260
+ const containerData = handleContainers(editor, boxPath, extraHeight);
261
+ containerData.forEach(container => {
262
+ const {
263
+ moveRows,
264
+ containerNode,
265
+ containerPath,
266
+ newHeight,
267
+ childIndex,
268
+ lastChildStartRow
269
+ } = container;
270
+ if (moveRows) {
271
+ moveOverlappedItems(editor, moveRows, containerNode?.children, containerPath, childIndex, lastChildStartRow);
272
+ }
273
+ Transforms.setNodes(editor, {
274
+ height_xs: newHeight,
275
+ xs_updatedOn: new Date().getTime()
276
+ }, {
277
+ at: containerPath
278
+ });
279
+ });
289
280
  }
290
- let containers = getAncestorFreeGridContainers(editor, boxPath);
291
- handleContainersAlignment(editor, containers, heightDiff, 12);
292
281
  };
293
282
  export const getMarginTop = y => {
294
283
  const calcMargin = y % ROW_HEIGHT;
@@ -306,7 +295,7 @@ export const calculateProps = (curPath, dom, domClass, allData, parentDom, isBox
306
295
  const itemsData = [];
307
296
  const items = dom.querySelectorAll(domClass);
308
297
  const nextItemPathLength = curPath?.split("|").length + 2;
309
- // let sectionHeight = 12;
298
+ let sectionHeight = 12;
310
299
  for (let i = 0; i < items.length; i++) {
311
300
  const itemRect = items[i]?.getBoundingClientRect();
312
301
  if (items[i]?.classList.contains("type_box")) {
@@ -326,10 +315,9 @@ export const calculateProps = (curPath, dom, domClass, allData, parentDom, isBox
326
315
  gridArea: calculateGridArea(y)
327
316
  }
328
317
  });
329
- // sectionHeight += itemRect?.height;
318
+ sectionHeight += itemRect?.height;
330
319
  }
331
320
  }
332
-
333
321
  if (dom?.classList.contains("type_box") && parentDom) {
334
322
  const parentDomRect = parentDom?.getBoundingClientRect();
335
323
  const isAppHeader = isBoxHeader || dom?.classList.contains("appHeaderBox");
@@ -18,14 +18,6 @@ const useVirtualElementStyles = () => ({
18
18
  "& .editor-blocker": {
19
19
  display: "none"
20
20
  },
21
- "& .fgi_type_text": {
22
- "& .edt-headings": {
23
- margin: "0px"
24
- },
25
- "& .edt-paragraphs": {
26
- margin: "0px"
27
- }
28
- },
29
21
  "& .freegrid-item": {
30
22
  position: "relative !important",
31
23
  top: "0 !important",
@@ -105,14 +97,6 @@ export const useAutoAlignStyles = () => ({
105
97
  "&.type_text": {
106
98
  height: "auto !important"
107
99
  },
108
- "& .fgi_type_text": {
109
- "& .edt-headings": {
110
- margin: "0px"
111
- },
112
- "& .edt-paragraphs": {
113
- margin: "0px"
114
- }
115
- },
116
100
  // start - default signature classes on free-grid
117
101
  "& .fgi_type_signature": {
118
102
  height: "100%",