@flozy/editor 10.6.4 → 10.6.5

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 (173) hide show
  1. package/dist/Editor/ChatEditor.js +16 -17
  2. package/dist/Editor/CommonEditor.js +14 -129
  3. package/dist/Editor/DialogWrapper.js +25 -31
  4. package/dist/Editor/Editor.css +11 -57
  5. package/dist/Editor/Elements/AI/PopoverAIInput.js +3 -11
  6. package/dist/Editor/Elements/AI/Styles.js +0 -1
  7. package/dist/Editor/Elements/Accordion/Accordion.js +9 -45
  8. package/dist/Editor/Elements/Accordion/AccordionSummary.js +23 -1
  9. package/dist/Editor/Elements/AppHeader/AppHeader.js +5 -10
  10. package/dist/Editor/Elements/Button/EditorButton.js +10 -26
  11. package/dist/Editor/Elements/Carousel/CarouselItem.js +1 -2
  12. package/dist/Editor/Elements/Color Picker/ColorButtons.js +14 -61
  13. package/dist/Editor/Elements/Color Picker/ColorPicker.css +1 -25
  14. package/dist/Editor/Elements/Color Picker/ColorPicker.js +7 -10
  15. package/dist/Editor/Elements/Color Picker/Styles.js +13 -15
  16. package/dist/Editor/Elements/DataView/Layouts/DataTypes/Components/{SelectV1.js → MultiSelect.js} +69 -125
  17. package/dist/Editor/Elements/DataView/Layouts/DataTypes/MultiSelectType.js +10 -10
  18. package/dist/Editor/Elements/DataView/Layouts/DataTypes/SelectType.js +9 -28
  19. package/dist/Editor/Elements/DataView/Layouts/Options/AddOptions.js +5 -12
  20. package/dist/Editor/Elements/DataView/Layouts/Options/EditOption.js +14 -40
  21. package/dist/Editor/Elements/Divider/Divider.js +1 -1
  22. package/dist/Editor/Elements/Embed/Embed.css +0 -4
  23. package/dist/Editor/Elements/Embed/Video.js +1 -1
  24. package/dist/Editor/Elements/Form/Form.js +3 -3
  25. package/dist/Editor/Elements/Form/FormElements/FormTextArea.js +1 -0
  26. package/dist/Editor/Elements/Form/FormField.js +1 -1
  27. package/dist/Editor/Elements/Form/Workflow/Styles.js +22 -24
  28. package/dist/Editor/Elements/FreeGrid/FreeGrid.js +31 -35
  29. package/dist/Editor/Elements/FreeGrid/FreeGridBox.js +4 -7
  30. package/dist/Editor/Elements/FreeGrid/FreeGridItem.js +0 -1
  31. package/dist/Editor/Elements/FreeGrid/Options/More.js +7 -7
  32. package/dist/Editor/Elements/FreeGrid/Options/sectionItemOptions.js +1 -1
  33. package/dist/Editor/Elements/FreeGrid/styles.js +0 -14
  34. package/dist/Editor/Elements/Grid/Grid.js +2 -14
  35. package/dist/Editor/Elements/Grid/GridItem.js +1 -1
  36. package/dist/Editor/Elements/Signature/Signature.css +1 -2
  37. package/dist/Editor/Elements/Signature/SignatureOptions/DrawSignature.js +5 -18
  38. package/dist/Editor/Elements/Signature/SignatureOptions/UploadSignature.js +3 -16
  39. package/dist/Editor/Elements/SimpleText/style.js +2 -2
  40. package/dist/Editor/Elements/Table/AddRowCol.js +2 -8
  41. package/dist/Editor/Elements/Table/DragButton.js +1 -0
  42. package/dist/Editor/Elements/Table/Draggable.js +2 -6
  43. package/dist/Editor/Elements/Table/Styles.js +0 -7
  44. package/dist/Editor/Elements/Table/Table.js +3 -3
  45. package/dist/Editor/Elements/Table/TableCell.js +5 -24
  46. package/dist/Editor/Elements/Title/title.js +11 -8
  47. package/dist/Editor/Elements/Variables/VariableButton.js +1 -10
  48. package/dist/Editor/MiniEditor.js +1 -2
  49. package/dist/Editor/Styles/EditorStyles.js +4 -4
  50. package/dist/Editor/Toolbar/FormatTools/Dropdown.js +3 -27
  51. package/dist/Editor/Toolbar/FormatTools/FontFamilyAutocomplete.js +3 -4
  52. package/dist/Editor/Toolbar/FormatTools/MarkButton.js +2 -2
  53. package/dist/Editor/Toolbar/FormatTools/TextSize.js +13 -10
  54. package/dist/Editor/Toolbar/Mini/MiniToolbar.js +1 -2
  55. package/dist/Editor/Toolbar/PopupTool/MiniTextFormat/MiniColorPicker.js +2 -4
  56. package/dist/Editor/Toolbar/PopupTool/MiniTextFormat/SelectFontSize.js +13 -6
  57. package/dist/Editor/Toolbar/PopupTool/MiniTextFormat/SelectTypography.js +42 -167
  58. package/dist/Editor/Toolbar/PopupTool/MiniTextFormat/index.js +4 -7
  59. package/dist/Editor/Toolbar/PopupTool/PopperHeader.js +1 -2
  60. package/dist/Editor/Toolbar/PopupTool/PopupToolStyle.js +13 -73
  61. package/dist/Editor/Toolbar/PopupTool/TextFormat.js +10 -58
  62. package/dist/Editor/Toolbar/PopupTool/index.js +5 -12
  63. package/dist/Editor/Toolbar/toolbarGroups.js +6 -48
  64. package/dist/Editor/common/ColorPickerButton.js +16 -41
  65. package/dist/Editor/common/DnD/DragHandleButton.js +1 -1
  66. package/dist/Editor/common/FontLoader/FontLoader.js +0 -3
  67. package/dist/Editor/common/Icon.js +0 -28
  68. package/dist/Editor/common/ImageSelector/ImageSelector.js +2 -2
  69. package/dist/Editor/common/ImageSelector/Styles.js +9 -3
  70. package/dist/Editor/common/LinkSettings/NavComponents.js +63 -47
  71. package/dist/Editor/common/LinkSettings/index.js +28 -17
  72. package/dist/Editor/common/LinkSettings/navOptions.js +2 -2
  73. package/dist/Editor/common/LinkSettings/style.js +244 -164
  74. package/dist/Editor/common/RnD/ElementOptions/Actions.js +5 -4
  75. package/dist/Editor/common/RnD/ElementSettings/OtherSettings/Settings.js +1 -2
  76. package/dist/Editor/common/RnD/ElementSettings/OtherSettings/Signature.js +3 -4
  77. package/dist/Editor/common/RnD/ElementSettings/Settings/AppHeaderSettings.js +2 -3
  78. package/dist/Editor/common/RnD/ElementSettings/Settings/BoxSettings.js +2 -3
  79. package/dist/Editor/common/RnD/ElementSettings/Settings/ButtonSettings.js +2 -3
  80. package/dist/Editor/common/RnD/ElementSettings/Settings/CodeSettings.js +2 -3
  81. package/dist/Editor/common/RnD/ElementSettings/Settings/FormSettings.js +2 -4
  82. package/dist/Editor/common/RnD/ElementSettings/Settings/ImageSettings.js +2 -3
  83. package/dist/Editor/common/RnD/ElementSettings/Settings/TableSettings.js +2 -3
  84. package/dist/Editor/common/RnD/ElementSettings/Settings/TextSettings.js +1 -3
  85. package/dist/Editor/common/RnD/ElementSettings/Settings/VideoSettings.js +2 -3
  86. package/dist/Editor/common/RnD/ElementSettings/styles.js +1 -0
  87. package/dist/Editor/common/RnD/OptionsPopup/style.js +1 -0
  88. package/dist/Editor/common/RnD/SwitchViewport/SwitchViewport.js +2 -11
  89. package/dist/Editor/common/RnD/Theme/ViewportStimulator.js +3 -6
  90. package/dist/Editor/common/RnD/Utils/gridDropItem.js +19 -28
  91. package/dist/Editor/common/RnD/Utils/index.js +25 -58
  92. package/dist/Editor/common/RnD/VirtualElement/VirtualTextElement.js +58 -42
  93. package/dist/Editor/common/RnD/VirtualElement/helper.js +132 -323
  94. package/dist/Editor/common/RnD/VirtualElement/styles.js +0 -16
  95. package/dist/Editor/common/RnD/index.js +38 -72
  96. package/dist/Editor/common/Select/index.js +7 -44
  97. package/dist/Editor/common/Select/styles.js +2 -30
  98. package/dist/Editor/common/Shorthands/elements.js +0 -54
  99. package/dist/Editor/common/StyleBuilder/accordionTitleBtnStyle.js +2 -2
  100. package/dist/Editor/common/StyleBuilder/accordionTitleStyle.js +9 -12
  101. package/dist/Editor/common/StyleBuilder/buttonStyle.js +2 -4
  102. package/dist/Editor/common/StyleBuilder/embedVideoStyle.js +0 -4
  103. package/dist/Editor/common/StyleBuilder/fieldTypes/backgroundImage.js +0 -5
  104. package/dist/Editor/common/StyleBuilder/fieldTypes/bannerSpacing.js +2 -12
  105. package/dist/Editor/common/StyleBuilder/fieldTypes/borderRadius.js +7 -15
  106. package/dist/Editor/common/StyleBuilder/fieldTypes/card.js +8 -16
  107. package/dist/Editor/common/StyleBuilder/fieldTypes/color.js +10 -36
  108. package/dist/Editor/common/StyleBuilder/fieldTypes/fontSize.js +7 -16
  109. package/dist/Editor/common/StyleBuilder/fieldTypes/index.js +1 -3
  110. package/dist/Editor/common/StyleBuilder/fieldTypes/menusArray.js +0 -2
  111. package/dist/Editor/common/StyleBuilder/fieldTypes/textOptions.js +7 -15
  112. package/dist/Editor/common/SwipeableDrawer/style.js +12 -14
  113. package/dist/Editor/common/Uploader.js +0 -16
  114. package/dist/Editor/common/iconListV2.js +0 -76
  115. package/dist/Editor/common/iconslist.js +0 -21
  116. package/dist/Editor/commonStyle.js +61 -116
  117. package/dist/Editor/helper/deserialize/index.js +4 -6
  118. package/dist/Editor/helper/index.js +2 -6
  119. package/dist/Editor/helper/theme.js +2 -203
  120. package/dist/Editor/hooks/useMouseMove.js +3 -9
  121. package/dist/Editor/hooks/useTable.js +4 -5
  122. package/dist/Editor/plugins/withCustomDeleteBackward.js +1 -6
  123. package/dist/Editor/plugins/withEmbeds.js +1 -1
  124. package/dist/Editor/plugins/withHTML.js +5 -14
  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 +50 -173
  128. package/dist/Editor/utils/accordion.js +37 -158
  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 -18
  133. package/dist/Editor/utils/font.js +37 -40
  134. package/dist/Editor/utils/formfield.js +0 -1
  135. package/dist/Editor/utils/helper.js +30 -149
  136. package/dist/Editor/utils/insertAppHeader.js +5 -9
  137. package/dist/Editor/utils/signature.js +9 -2
  138. package/package.json +4 -4
  139. package/dist/Editor/Elements/FreeGrid/helper.js +0 -115
  140. package/dist/Editor/Toolbar/PopupTool/ThemeTextFormat.js +0 -439
  141. package/dist/Editor/assets/svg/BackIcon.js +0 -18
  142. package/dist/Editor/assets/svg/ThemeIcons.js +0 -293
  143. package/dist/Editor/common/Checkbox/index.js +0 -46
  144. package/dist/Editor/common/Checkbox/styles.js +0 -45
  145. package/dist/Editor/common/CustomColorPicker/index.js +0 -130
  146. package/dist/Editor/common/CustomColorPicker/style.js +0 -53
  147. package/dist/Editor/common/CustomDialog2/index.js +0 -94
  148. package/dist/Editor/common/CustomDialog2/style.js +0 -67
  149. package/dist/Editor/common/CustomSelect.js +0 -43
  150. package/dist/Editor/common/RadioGroup/index.js +0 -48
  151. package/dist/Editor/common/RadioGroup/styles.js +0 -29
  152. package/dist/Editor/common/RnD/Theme/MainThemeProvider.js +0 -17
  153. package/dist/Editor/common/StyleBuilder/fieldTypes/embedUpload.js +0 -115
  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 -380
  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
  173. package/dist/Editor/utils/updateFormName.js +0 -22
@@ -140,6 +140,7 @@ const useElementSettingsStyle = theme => ({
140
140
  }
141
141
  },
142
142
  "& .popUpHeader": {
143
+ fontSize: "16px",
143
144
  fontFamily: "'Inter',sans-serif",
144
145
  fontWeight: "700",
145
146
  fontSize: "16px",
@@ -15,6 +15,7 @@ const useOptionsPopupStyle = ({
15
15
  background: theme?.palette?.editor?.miniToolBarBackground
16
16
  },
17
17
  "& .sectionOptionTitle": {
18
+ fontSize: "16px",
18
19
  fontFamily: "'Inter',sans-serif",
19
20
  fontWeight: "700",
20
21
  fontSize: "16px",
@@ -3,29 +3,20 @@ import PersonalVideoIcon from "@mui/icons-material/PersonalVideo";
3
3
  import PhoneIphoneIcon from "@mui/icons-material/PhoneIphone";
4
4
  import useSwitchViewport from "./styles";
5
5
  import { useEffect } from "react";
6
- import { useEditorContext } from "../../../hooks/useMouseMove";
7
6
  import { jsx as _jsx } from "react/jsx-runtime";
8
7
  import { jsxs as _jsxs } from "react/jsx-runtime";
9
8
  const SwitchViewport = props => {
10
9
  const {
11
10
  breakpoint,
12
11
  onChange,
13
- translation,
14
- show
12
+ translation
15
13
  } = props;
16
14
  const classes = useSwitchViewport();
17
- const {
18
- setSelectedElement
19
- } = useEditorContext();
20
15
  useEffect(() => {
21
- // to reset selection on viewport changes - FS-6589
22
- setSelectedElement({});
16
+ console.log(breakpoint);
23
17
  }, [breakpoint]);
24
18
  return /*#__PURE__*/_jsxs(Box, {
25
19
  sx: classes.root,
26
- style: {
27
- display: show ? "block" : "none"
28
- },
29
20
  children: [/*#__PURE__*/_jsx(Tooltip, {
30
21
  title: translation("Desktop View"),
31
22
  children: /*#__PURE__*/_jsx(IconButton, {
@@ -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
@@ -124,39 +122,14 @@ const isOverLapLine = ({
124
122
  export function getClosestDraggable(x, y, className, activeClassName) {
125
123
  const draggables = document.querySelectorAll(className);
126
124
  const activeDragEle = document.querySelectorAll(activeClassName)[0];
127
- const container = document.querySelector("#slate-wrapper-scroll-container");
128
- if (!activeDragEle || !container) return [];
129
- const containerRect = container.getBoundingClientRect();
130
125
  const {
131
126
  left: aLeft,
132
127
  top: aTop,
133
128
  width: aWidth,
134
129
  height: aHeight
135
130
  } = activeDragEle?.getBoundingClientRect() || {};
136
- const lines = [];
137
- const clampLine = ({
138
- x,
139
- y,
140
- width,
141
- height
142
- }) => {
143
- if (width > 1) {
144
- if (x < containerRect.left) x = containerRect.left;
145
- if (x + width > containerRect.right) width = containerRect.right - x;
146
- }
147
- if (height > 1) {
148
- if (y < containerRect.top) y = containerRect.top;
149
- if (y + height > containerRect.bottom) height = containerRect.bottom - y;
150
- }
151
- return {
152
- x,
153
- y,
154
- width,
155
- height
156
- };
157
- };
131
+ let lines = [];
158
132
  draggables.forEach(draggable => {
159
- if (draggable === activeDragEle) return;
160
133
  const {
161
134
  left,
162
135
  top,
@@ -173,45 +146,42 @@ export function getClosestDraggable(x, y, className, activeClassName) {
173
146
  x: xVal,
174
147
  y: yVal
175
148
  }, lines)) {
176
- const line = {
149
+ lines.push({
150
+ y: top,
177
151
  x: xVal,
178
- y: yVal,
179
152
  width: x > left ? Math.abs(aLeft + aWidth - left) : Math.abs(aLeft - (left + width)),
180
153
  height: 1
181
- };
182
- lines.push(clampLine(line));
154
+ });
183
155
  }
184
156
 
185
157
  // bottom match
186
158
  xVal = x < left ? aLeft : left;
187
159
  yVal = top + height;
188
- if (Math.abs(yVal - (aTop + aHeight)) <= GUIDE_LINE_THRESHOLD && !isOverLapLine({
160
+ if (Math.abs(top + height - (aTop + aHeight)) <= GUIDE_LINE_THRESHOLD && !isOverLapLine({
189
161
  x: xVal,
190
162
  y: yVal
191
163
  }, lines)) {
192
- const line = {
193
- x: xVal,
164
+ lines.push({
194
165
  y: yVal,
166
+ x: xVal,
195
167
  width: x > left ? Math.abs(aLeft + aWidth - left) : Math.abs(aLeft - (left + width)),
196
168
  height: 1
197
- };
198
- lines.push(clampLine(line));
169
+ });
199
170
  }
200
171
 
201
- // center match (horizontal)
172
+ // center match
202
173
  xVal = x < left ? aLeft : left;
203
174
  yVal = top + height / 2;
204
- if (Math.abs(yVal - (aTop + aHeight / 2)) <= GUIDE_LINE_THRESHOLD && !isOverLapLine({
175
+ if (Math.abs(top + height / 2 - (aTop + aHeight / 2)) <= GUIDE_LINE_THRESHOLD && !isOverLapLine({
205
176
  x: xVal,
206
177
  y: yVal
207
178
  }, lines, "y")) {
208
- const line = {
209
- x: xVal,
179
+ lines.push({
210
180
  y: yVal,
181
+ x: xVal,
211
182
  width: x > left ? Math.abs(aLeft + aWidth - left) : Math.abs(aLeft - (left + width)),
212
183
  height: 1
213
- };
214
- lines.push(clampLine(line));
184
+ });
215
185
  }
216
186
 
217
187
  // right match
@@ -221,13 +191,12 @@ export function getClosestDraggable(x, y, className, activeClassName) {
221
191
  x: xVal,
222
192
  y: yVal
223
193
  }, lines)) {
224
- const line = {
225
- x: xVal,
194
+ lines.push({
226
195
  y: yVal,
196
+ x: xVal,
227
197
  width: 1,
228
198
  height: Math.abs(aTop - top)
229
- };
230
- lines.push(clampLine(line));
199
+ });
231
200
  }
232
201
 
233
202
  // left match
@@ -237,29 +206,27 @@ export function getClosestDraggable(x, y, className, activeClassName) {
237
206
  x: xVal,
238
207
  y: yVal
239
208
  }, lines)) {
240
- const line = {
241
- x: xVal,
209
+ lines.push({
242
210
  y: yVal,
211
+ x: xVal,
243
212
  width: 1,
244
213
  height: Math.abs(aTop - top)
245
- };
246
- lines.push(clampLine(line));
214
+ });
247
215
  }
248
216
 
249
- // middle match (vertical)
217
+ // middle match
250
218
  xVal = left + width / 2;
251
219
  yVal = top < aTop ? top : aTop;
252
- if (Math.abs(aLeft + aWidth / 2 - xVal) <= GUIDE_LINE_THRESHOLD && !isOverLapLine({
220
+ if (Math.abs(aLeft + aWidth / 2 - (left + width / 2)) <= GUIDE_LINE_THRESHOLD && !isOverLapLine({
253
221
  x: xVal,
254
222
  y: yVal
255
223
  }, lines)) {
256
- const line = {
257
- x: xVal,
224
+ lines.push({
258
225
  y: yVal,
226
+ x: xVal,
259
227
  width: 1,
260
228
  height: Math.abs(aTop - top)
261
- };
262
- lines.push(clampLine(line));
229
+ });
263
230
  }
264
231
  });
265
232
  return lines;
@@ -1,45 +1,69 @@
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, getNodeValues, 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, breakpoint) => {
8
- const {
9
- height,
10
- gridArea,
11
- marginTop
12
- } = getNodeValues(element, breakpoint);
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
- export const updateTextHeight = (editor, path, currHeight, updateBreakpoint) => {
22
- if (!currHeight) {
8
+ const updateTextHeight = (editor, path, height) => {
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,
31
- gridArea,
32
- type
33
- } = getNodeValues(textItem, updateBreakpoint);
34
- if (!gridArea && type !== "paragraph") {
35
- return;
36
- }
37
- const oldHeight = height;
38
- const newHeight = currHeight;
39
- const heightDiff = newHeight - oldHeight;
40
- if (heightDiff !== 0) {
41
- const textNode = [textItem, path];
42
- handleTextAlignment(editor, textNode, heightDiff, updateBreakpoint);
22
+ marginTop_xs: marginTop,
23
+ gridArea_xs: gridArea,
24
+ height_xs
25
+ } = textItem;
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
68
  };
45
69
  function VirtualTextElement(props) {
@@ -59,9 +83,9 @@ function VirtualTextElement(props) {
59
83
  height
60
84
  } = entry.contentRect;
61
85
  const currentText = currElement?.innerText;
62
- const prevText = prevTextRef?.current;
86
+ const prevText = prevTextRef.current;
63
87
  if (currentText && currentText !== prevText) {
64
- updateTextHeight(editor, path, height, "xs");
88
+ updateTextHeight(editor, path, height);
65
89
  }
66
90
  prevTextRef.current = currentText;
67
91
  }
@@ -98,14 +122,6 @@ function VirtualTextElement(props) {
98
122
  },
99
123
  "& .editor-blocker": {
100
124
  display: "none"
101
- },
102
- "& .fgi_type_text": {
103
- "& .edt-headings": {
104
- margin: "0px"
105
- },
106
- "& .edt-paragraphs": {
107
- margin: "0px"
108
- }
109
125
  }
110
126
  },
111
127
  dangerouslySetInnerHTML: {