@flozy/editor 4.0.3 → 4.0.5

Sign up to get free protection for your applications and to get access to all the features.
Files changed (148) hide show
  1. package/dist/Editor/CommonEditor.js +85 -13
  2. package/dist/Editor/DialogWrapper.js +4 -3
  3. package/dist/Editor/Editor.css +28 -2
  4. package/dist/Editor/Elements/AI/AIInput.js +31 -33
  5. package/dist/Editor/Elements/AI/CustomSelect.js +19 -12
  6. package/dist/Editor/Elements/AI/PopoverAIInput.js +124 -133
  7. package/dist/Editor/Elements/AI/Styles.js +2 -2
  8. package/dist/Editor/Elements/AI/VoiceToText/AudioWave.js +73 -0
  9. package/dist/Editor/Elements/AI/VoiceToText/index.js +184 -0
  10. package/dist/Editor/Elements/AI/VoiceToText/style.js +40 -0
  11. package/dist/Editor/Elements/AI/helper.js +5 -3
  12. package/dist/Editor/Elements/AppHeader/AppHeader.js +36 -23
  13. package/dist/Editor/Elements/Button/EditorButton.js +23 -16
  14. package/dist/Editor/Elements/Carousel/CarouselButton.js +2 -2
  15. package/dist/Editor/Elements/Color Picker/ColorButtons.js +1 -1
  16. package/dist/Editor/Elements/Color Picker/Styles.js +1 -0
  17. package/dist/Editor/Elements/Embed/Image.js +15 -14
  18. package/dist/Editor/Elements/Embed/Video.js +12 -8
  19. package/dist/Editor/Elements/Emoji/EmojiButton.js +11 -7
  20. package/dist/Editor/Elements/Form/Form.js +43 -27
  21. package/dist/Editor/Elements/Form/FormField.js +21 -10
  22. package/dist/Editor/Elements/Form/Workflow/index.js +5 -2
  23. package/dist/Editor/Elements/FreeGrid/FreeGrid.js +437 -0
  24. package/dist/Editor/Elements/FreeGrid/FreeGridBox.js +206 -0
  25. package/dist/Editor/Elements/FreeGrid/FreeGridButton.js +23 -0
  26. package/dist/Editor/Elements/FreeGrid/FreeGridItem.js +236 -0
  27. package/dist/Editor/Elements/FreeGrid/Options/AddElement.js +44 -0
  28. package/dist/Editor/Elements/FreeGrid/Options/More.js +24 -0
  29. package/dist/Editor/Elements/FreeGrid/Options/SectionSettings.js +47 -0
  30. package/dist/Editor/Elements/FreeGrid/Options/sectionItemOptions.js +19 -0
  31. package/dist/Editor/Elements/FreeGrid/breakpointConstants.js +75 -0
  32. package/dist/Editor/Elements/FreeGrid/styles.js +214 -0
  33. package/dist/Editor/Elements/Grid/Grid.js +12 -8
  34. package/dist/Editor/Elements/Grid/GridItem.js +31 -21
  35. package/dist/Editor/Elements/Link/LinkPopup.js +69 -13
  36. package/dist/Editor/Elements/Link/LinkPopupStyles.js +28 -0
  37. package/dist/Editor/Elements/NewLine/NewLineButton.js +2 -2
  38. package/dist/Editor/Elements/Signature/Signature.css +13 -6
  39. package/dist/Editor/Elements/Signature/SignatureOptions/UploadSignature.js +2 -1
  40. package/dist/Editor/Elements/Signature/SignaturePopup.js +186 -31
  41. package/dist/Editor/Elements/SimpleText/index.js +19 -7
  42. package/dist/Editor/Elements/SimpleText/style.js +44 -1
  43. package/dist/Editor/ErrorBoundary.js +30 -0
  44. package/dist/Editor/Styles/EditorStyles.js +28 -0
  45. package/dist/Editor/Toolbar/FormatTools/Dropdown.js +1 -1
  46. package/dist/Editor/Toolbar/FormatTools/TextSize.js +2 -2
  47. package/dist/Editor/Toolbar/Mini/MiniToolbar.js +33 -5
  48. package/dist/Editor/Toolbar/PopupTool/ButtonTemplatesCard.js +12 -13
  49. package/dist/Editor/Toolbar/PopupTool/FullViewCard.js +12 -13
  50. package/dist/Editor/Toolbar/PopupTool/MiniTextFormat/CustomSelectTool.js +3 -0
  51. package/dist/Editor/Toolbar/PopupTool/MiniTextFormat/SelectSuperSubscript.js +59 -0
  52. package/dist/Editor/Toolbar/PopupTool/MiniTextFormat/index.js +2 -1
  53. package/dist/Editor/Toolbar/PopupTool/PopupToolStyle.js +107 -40
  54. package/dist/Editor/Toolbar/PopupTool/TextFormat.js +57 -61
  55. package/dist/Editor/Toolbar/PopupTool/index.js +13 -3
  56. package/dist/Editor/Toolbar/Toolbar.js +7 -0
  57. package/dist/Editor/Toolbar/toolbarGroups.js +15 -5
  58. package/dist/Editor/assets/svg/AIIcons.js +153 -1
  59. package/dist/Editor/common/EditorCmds.js +0 -3
  60. package/dist/Editor/common/EditorIcons.js +7 -7
  61. package/dist/Editor/common/Icon.js +39 -30
  62. package/dist/Editor/common/ImageList.js +16 -3
  63. package/dist/Editor/common/ImageSelector/ImageSelector.js +30 -9
  64. package/dist/Editor/common/ImageSelector/Styles.js +2 -1
  65. package/dist/Editor/common/LinkSettings/index.js +2 -1
  66. package/dist/Editor/common/LinkSettings/style.js +11 -8
  67. package/dist/Editor/common/MentionsPopup/Styles.js +1 -1
  68. package/dist/Editor/common/MentionsPopup/index.js +12 -8
  69. package/dist/Editor/common/RnD/ContextMenu/CMenus.js +142 -0
  70. package/dist/Editor/common/RnD/ContextMenu/index.js +38 -0
  71. package/dist/Editor/common/RnD/ContextMenu/styles.js +21 -0
  72. package/dist/Editor/common/RnD/DragInfo/index.js +31 -0
  73. package/dist/Editor/common/RnD/DragInfo/styles.js +15 -0
  74. package/dist/Editor/common/RnD/DragOver/index.js +55 -0
  75. package/dist/Editor/common/RnD/DragOver/styles.js +23 -0
  76. package/dist/Editor/common/RnD/ElementOptions/Actions.js +102 -0
  77. package/dist/Editor/common/RnD/ElementOptions/Icons/LinkIcon.js +26 -0
  78. package/dist/Editor/common/RnD/ElementOptions/index.js +95 -0
  79. package/dist/Editor/common/RnD/ElementOptions/styles.js +41 -0
  80. package/dist/Editor/common/RnD/ElementSettings/OtherSettings/Link.js +153 -0
  81. package/dist/Editor/common/RnD/ElementSettings/OtherSettings/SaveAsTemplate.js +36 -0
  82. package/dist/Editor/common/RnD/ElementSettings/OtherSettings/Settings.js +60 -0
  83. package/dist/Editor/common/RnD/ElementSettings/OtherSettings/index.js +9 -0
  84. package/dist/Editor/common/RnD/ElementSettings/Settings/AppHeaderSettings.js +47 -0
  85. package/dist/Editor/common/RnD/ElementSettings/Settings/BoxSettings.js +47 -0
  86. package/dist/Editor/common/RnD/ElementSettings/Settings/ButtonSettings.js +47 -0
  87. package/dist/Editor/common/RnD/ElementSettings/Settings/FormSettings.js +48 -0
  88. package/dist/Editor/common/RnD/ElementSettings/Settings/ImageSettings.js +47 -0
  89. package/dist/Editor/common/RnD/ElementSettings/Settings/TextSettings.js +30 -0
  90. package/dist/Editor/common/RnD/ElementSettings/Settings/VideoSettings.js +47 -0
  91. package/dist/Editor/common/RnD/ElementSettings/Settings/index.js +17 -0
  92. package/dist/Editor/common/RnD/ElementSettings/index.js +17 -0
  93. package/dist/Editor/common/RnD/ElementSettings/settingsConstants.js +18 -0
  94. package/dist/Editor/common/RnD/ElementSettings/styles.js +94 -0
  95. package/dist/Editor/common/RnD/GuideLines/BoundaryLine.js +52 -0
  96. package/dist/Editor/common/RnD/GuideLines/index.js +33 -0
  97. package/dist/Editor/common/RnD/GuideLines/styles.js +62 -0
  98. package/dist/Editor/common/RnD/OptionsPopup/index.js +50 -0
  99. package/dist/Editor/common/RnD/OptionsPopup/style.js +36 -0
  100. package/dist/Editor/common/RnD/RnDCopy.js +23 -0
  101. package/dist/Editor/common/RnD/ShadowElement.js +34 -0
  102. package/dist/Editor/common/RnD/SwitchViewport/SwitchViewport.js +40 -0
  103. package/dist/Editor/common/RnD/SwitchViewport/styles.js +24 -0
  104. package/dist/Editor/common/RnD/Theme/ViewportStimulator.js +63 -0
  105. package/dist/Editor/common/RnD/TransformHandles/CornerHandle.js +19 -0
  106. package/dist/Editor/common/RnD/TransformHandles/Icons/BottomRightIcon.js +13 -0
  107. package/dist/Editor/common/RnD/TransformHandles/SizeHandle.js +20 -0
  108. package/dist/Editor/common/RnD/TransformHandles/index.js +67 -0
  109. package/dist/Editor/common/RnD/Utils/alignmentDetection.js +26 -0
  110. package/dist/Editor/common/RnD/Utils/calculateDropItem.js +98 -0
  111. package/dist/Editor/common/RnD/Utils/collisionDetection.js +52 -0
  112. package/dist/Editor/common/RnD/Utils/gridDropItem.js +181 -0
  113. package/dist/Editor/common/RnD/Utils/index.js +251 -0
  114. package/dist/Editor/common/RnD/VirtualElement/index.js +77 -0
  115. package/dist/Editor/common/RnD/VirtualElement/styles.js +27 -0
  116. package/dist/Editor/common/RnD/VirtualElement/updateAutoProps.js +28 -0
  117. package/dist/Editor/common/RnD/index.js +567 -0
  118. package/dist/Editor/common/RnD/styles.js +4 -0
  119. package/dist/Editor/common/Section/index.js +21 -12
  120. package/dist/Editor/common/Section/styles.js +7 -4
  121. package/dist/Editor/common/Shorthands/elements.js +21 -9
  122. package/dist/Editor/common/StyleBuilder/boxStyle.js +30 -0
  123. package/dist/Editor/common/StyleBuilder/fieldTypes/bannerSpacing.js +18 -10
  124. package/dist/Editor/common/StyleBuilder/fieldTypes/saveAsTemplate.js +18 -5
  125. package/dist/Editor/common/StyleBuilder/fieldTypes/text.js +4 -2
  126. package/dist/Editor/common/StyleBuilder/index.js +6 -4
  127. package/dist/Editor/common/StyleBuilder/sectionStyle.js +13 -2
  128. package/dist/Editor/common/iconListV2.js +843 -0
  129. package/dist/Editor/commonStyle.js +6 -0
  130. package/dist/Editor/helper/RnD/focusOnNewItem.js +39 -0
  131. package/dist/Editor/helper/RnD/scrollToNewSection.js +24 -0
  132. package/dist/Editor/helper/breakpoint.js +5 -0
  133. package/dist/Editor/helper/index.js +139 -0
  134. package/dist/Editor/helper/theme.js +50 -1
  135. package/dist/Editor/hooks/useBreakpoints.js +34 -0
  136. package/dist/Editor/hooks/useMouseMove.js +36 -8
  137. package/dist/Editor/hooks/useWindowMessage.js +10 -7
  138. package/dist/Editor/hooks/withCommon.js +2 -1
  139. package/dist/Editor/hooks/withErrorHandling.js +14 -0
  140. package/dist/Editor/utils/RnD/RnDCtrlCmds.js +197 -0
  141. package/dist/Editor/utils/SlateUtilityFunctions.js +36 -4
  142. package/dist/Editor/utils/events.js +5 -0
  143. package/dist/Editor/utils/form.js +7 -2
  144. package/dist/Editor/utils/formfield.js +1 -1
  145. package/dist/Editor/utils/freegrid.js +91 -0
  146. package/dist/Editor/utils/helper.js +43 -0
  147. package/dist/Editor/utils/insertAppHeader.js +47 -40
  148. package/package.json +6 -2
@@ -0,0 +1,567 @@
1
+ import React, { useEffect, useRef, useState } from "react";
2
+ import { Node, Path } from "slate";
3
+ import { ReactEditor } from "slate-react";
4
+ import { Box } from "@mui/material";
5
+ import { Rnd } from "react-rnd";
6
+ import Handles from "./TransformHandles";
7
+ import { useEditorContext } from "../../hooks/useMouseMove";
8
+ import ElementOptions from "./ElementOptions";
9
+ import ElementSettings from "./ElementSettings";
10
+ import { getClosestDraggable, getParentSectionPath, isDragOver } from "./Utils";
11
+ import DragInfo from "./DragInfo";
12
+ import GuideLines from "./GuideLines";
13
+ import ShadowElement from "./ShadowElement";
14
+ import BoundaryLine from "./GuideLines/BoundaryLine";
15
+ import DragOver from "./DragOver";
16
+ import ContextMenu from "./ContextMenu";
17
+ import VirtualElement from "./VirtualElement";
18
+ import { ItemTypes } from "./ElementSettings/settingsConstants";
19
+ import { focusSelection, clearSelection } from "../../helper";
20
+ import { selectText } from "../../utils/helper";
21
+ import { jsx as _jsx } from "react/jsx-runtime";
22
+ import { jsxs as _jsxs } from "react/jsx-runtime";
23
+ import { Fragment as _Fragment } from "react/jsx-runtime";
24
+ const ITEM_TYPES = ["child", "parent-container"];
25
+ let hover_on = new Set();
26
+ const RnD = props => {
27
+ const rndRef = useRef(null);
28
+ const {
29
+ id: eId,
30
+ className,
31
+ path,
32
+ children,
33
+ style,
34
+ defaultStyle,
35
+ disableDragging,
36
+ enableResizing,
37
+ actions,
38
+ actionsMap = {},
39
+ type = "child",
40
+ optionsProps = {},
41
+ settingsProps = {},
42
+ onChange = () => {},
43
+ delta = {
44
+ width: 0,
45
+ height: 0
46
+ },
47
+ handleDragEvent = () => {},
48
+ handleResizeEvent = () => {},
49
+ handleActionClick = () => {},
50
+ readOnly,
51
+ childType = "",
52
+ updated_at = null,
53
+ editor,
54
+ breakpoint = "",
55
+ handleContextMenuClick = () => {},
56
+ itemData = {}
57
+ } = props;
58
+ const {
59
+ isSelectedElement,
60
+ setSelectedElement,
61
+ dragging,
62
+ setDragging,
63
+ contextMenu,
64
+ setContextMenu
65
+ } = useEditorContext();
66
+ const str_path = path.join("|");
67
+ const selectedElementProps = isSelectedElement(str_path, type);
68
+ const {
69
+ enable,
70
+ cursor,
71
+ path: sp,
72
+ selectedAction,
73
+ elementProps
74
+ } = selectedElementProps;
75
+ const open = Boolean(enable);
76
+ const currentAction = str_path === sp ? selectedAction : null;
77
+ const positionRef = useRef();
78
+ const {
79
+ active,
80
+ id,
81
+ lines,
82
+ position,
83
+ dragOver,
84
+ parentPath
85
+ } = dragging;
86
+ const dragInfoOpen = id === str_path;
87
+ const dragOverStatus = dragOver === str_path && parentPath !== str_path;
88
+ const [absPosition, setAbsPosition] = useState({});
89
+ const openContextMenu = contextMenu?.path === str_path;
90
+ useEffect(() => {
91
+ if (ITEM_TYPES.includes(type)) {
92
+ if (enable === 1) {
93
+ updatePosition();
94
+ } else {
95
+ rndRef.current.posUpdated = false;
96
+ setAbsPosition({});
97
+ }
98
+ }
99
+ }, [enable]);
100
+ useEffect(() => {
101
+ if (position?.x !== undefined && position?.y !== undefined && active && (type === "parent" || type === "parent-container")) {
102
+ const dragOverSt = isDragOver(rndRef?.current?.getBoundingClientRect(), {
103
+ x: position.x,
104
+ y: position.y
105
+ });
106
+ if (dragOverSt) {
107
+ if (!dragInfoOpen) {
108
+ hover_on.add(str_path);
109
+ }
110
+ setDragging({
111
+ ...dragging,
112
+ dragOver: str_path
113
+ });
114
+ } else {
115
+ hover_on.delete(str_path);
116
+ }
117
+ }
118
+ }, [active, position?.x, position?.y]);
119
+ const getCurrentEle = () => {
120
+ return positionRef.current?.resizableElement?.current;
121
+ };
122
+ const updatePosition = () => {
123
+ if (rndRef?.current && !rndRef.current.posUpdated) {
124
+ const currentEle = getCurrentEle();
125
+ const parentDom = currentEle?.closest(".freegrid-container-parent");
126
+ const parentRect = parentDom?.getBoundingClientRect();
127
+ const {
128
+ left,
129
+ top,
130
+ width,
131
+ height
132
+ } = currentEle.getBoundingClientRect();
133
+ positionRef.current.updatePosition({
134
+ x: 0,
135
+ y: 0
136
+ });
137
+ positionRef.current.updateSize({
138
+ width: width,
139
+ height: height
140
+ });
141
+ rndRef.current.posUpdated = true;
142
+ setAbsPosition({
143
+ position: "absolute",
144
+ left: left - parentRect?.left,
145
+ top: Math.abs(parentRect?.top - top),
146
+ marginTop: 0,
147
+ marginLeft: 0
148
+ });
149
+ }
150
+ };
151
+ const onClick = e => {
152
+ if (readOnly) {
153
+ return;
154
+ }
155
+ if (e?.target?.dataset?.event === "rnd-click") {
156
+ // for context menu
157
+ setContextMenu({
158
+ path: null
159
+ });
160
+ if (e?.preventDefault && e?.stopPropagation && !enable) {
161
+ e.preventDefault();
162
+ e.stopPropagation();
163
+ }
164
+ switch (e.detail) {
165
+ case 1:
166
+ if (!enable) {
167
+ setSelectedElement({
168
+ path: str_path,
169
+ enable: 1,
170
+ cursor: "move",
171
+ anchorEl: rndRef?.current
172
+ });
173
+ }
174
+ ReactEditor.focus(editor);
175
+ break;
176
+ case 2:
177
+ focusSelection(editor, {
178
+ path
179
+ });
180
+ setSelectedElement({
181
+ path: str_path,
182
+ enable: 2,
183
+ cursor: "auto",
184
+ anchorEl: rndRef?.current
185
+ });
186
+ // for default selection
187
+ if (childType === "text" && ITEM_TYPES.includes(type)) {
188
+ selectText(editor, {
189
+ path: [...path, 0],
190
+ cursorOnly: false
191
+ }, 10);
192
+ }
193
+ break;
194
+ default:
195
+ return;
196
+ }
197
+ }
198
+ };
199
+ const handleAction = actionType => {
200
+ try {
201
+ switch (actionType) {
202
+ case 1:
203
+ setSelectedElement({
204
+ path: str_path,
205
+ enable: 1,
206
+ cursor: disableDragging ? "auto" : "move"
207
+ });
208
+ break;
209
+ case 2:
210
+ onClick({
211
+ detail: actionType,
212
+ target: {
213
+ dataset: {
214
+ event: "rnd-click"
215
+ }
216
+ }
217
+ });
218
+ break;
219
+ case 3:
220
+ clearSelection(editor);
221
+ setSelectedElement({});
222
+ break;
223
+ case "settings":
224
+ setSelectedElement({
225
+ ...selectedElementProps,
226
+ selectedAction: actionType,
227
+ selectedActionPath: path
228
+ });
229
+ break;
230
+ case "link":
231
+ setSelectedElement({
232
+ ...selectedElementProps,
233
+ selectedAction: actionType,
234
+ selectedActionPath: path
235
+ });
236
+ break;
237
+ case "saveAsTemplate":
238
+ const curPath = type === "parent" ? Path.parent(path) : path;
239
+ const currentNode = Node.get(editor, curPath);
240
+ setSelectedElement({
241
+ ...selectedElementProps,
242
+ selectedAction: actionType,
243
+ selectedActionPath: path,
244
+ elementProps: currentNode
245
+ });
246
+ break;
247
+ default:
248
+ handleActionClick(actionType);
249
+ return;
250
+ }
251
+ } catch (err) {
252
+ console.log(err);
253
+ }
254
+ };
255
+ const onAfterDrop = updated_data => {
256
+ const {
257
+ updated_at
258
+ } = updated_data || {};
259
+ setSelectedElement({});
260
+ // to maitain absolute
261
+ rndRef.current.posUpdated = false;
262
+ // need to retain drag option if section changes
263
+ setAbsPosition({});
264
+ updatePosition();
265
+ if (updated_at) {
266
+ // disable dragging
267
+ setDragging({
268
+ active: false,
269
+ id: null,
270
+ isDragging: false
271
+ });
272
+ }
273
+ };
274
+ const onDragStart = e => {
275
+ e.preventDefault();
276
+ console.log(e?.target?.dataset);
277
+ if (e?.target?.dataset?.path?.split(",").join("|") === sp) {
278
+ const {
279
+ left,
280
+ top,
281
+ width,
282
+ height
283
+ } = e?.target?.getBoundingClientRect();
284
+ const ref = positionRef.current?.resizableElement?.current;
285
+ setDragging({
286
+ ...dragging,
287
+ active: true,
288
+ id: str_path,
289
+ position: {
290
+ x: e.clientX,
291
+ y: e.clientY,
292
+ strXY: `${e.clientX},${e.clientY}`,
293
+ diffX: parseInt(Math.abs(Math.floor(left - e.clientX))),
294
+ diffY: parseInt(Math.abs(Math.floor(top - e.clientY)))
295
+ },
296
+ dimension: {
297
+ width,
298
+ height
299
+ },
300
+ isDragging: true,
301
+ parentPath: getParentSectionPath({
302
+ ref
303
+ }, ".freegrid-container-parent")
304
+ });
305
+ }
306
+ };
307
+ const onDrag = (e, d) => {
308
+ e.preventDefault();
309
+ const lines = getClosestDraggable(e.clientX, e.clientY, ".freegrid-item.path-3.inactive-drag:not(.exclude-virtual)", ".freegrid-item.path-3.active-drag:not(.exclude-virtual)");
310
+ setAbsPosition({
311
+ ...absPosition,
312
+ "--zIndex": 2000
313
+ });
314
+ setDragging({
315
+ isDragging: true,
316
+ ...dragging,
317
+ position: {
318
+ ...dragging.position,
319
+ x: e.clientX,
320
+ y: e.clientY
321
+ },
322
+ lines: lines
323
+ });
324
+ };
325
+ const getContainerPath = () => {
326
+ let maxLengthString = "";
327
+ let maxLength = 0;
328
+ // Iterate through the set
329
+ hover_on.forEach(str => {
330
+ if (str.length > maxLength) {
331
+ maxLength = str.length;
332
+ maxLengthString = str;
333
+ }
334
+ });
335
+ return maxLengthString;
336
+ };
337
+ const onDragStop = (e, d) => {
338
+ e.preventDefault();
339
+ e.stopPropagation();
340
+ if (dragging?.isDragging && position.strXY) {
341
+ d.x = e.x;
342
+ d.y = e.y;
343
+ d.offsetX = e.offsetX;
344
+ d.offsetY = e.offsetY;
345
+ d.dragOver = getContainerPath();
346
+ d.parentPath = parentPath;
347
+ d.diffX = position?.diffX;
348
+ d.diffY = position?.diffY;
349
+ d.calX = itemData?.left + d.lastX;
350
+ // avoid x, y value replace issue
351
+ const [x, y] = position.strXY.split(",");
352
+ d.startPosition = {
353
+ ...position,
354
+ x: parseInt(x),
355
+ y: parseInt(y)
356
+ };
357
+ d.endPosition = {
358
+ x: e.x,
359
+ y: e.y
360
+ };
361
+ handleDragEvent("stop", d, onAfterDrop);
362
+ // reset zIndex var on drag stop
363
+ const ud = {
364
+ ...absPosition
365
+ };
366
+ delete ud["--zIndex"];
367
+ hover_on.clear();
368
+ setAbsPosition({
369
+ ...ud
370
+ });
371
+ }
372
+ };
373
+ const onResizeStop = (e, direction, ref, d, position) => {
374
+ e.preventDefault();
375
+ const updatedSize = {
376
+ width: delta?.width + d.width,
377
+ height: delta?.height + d.height
378
+ };
379
+ // calculate the text height
380
+ // const nodeList =
381
+ // positionRef?.current?.resizableElement?.current?.childNodes || [];
382
+ // const textElement = Array.from(nodeList).filter((node) =>
383
+ // node.classList.contains("fgi_type_text")
384
+ // );
385
+ // if (textElement[0] && type === "child") {
386
+ // const textRect = textElement[0]?.getBoundingClientRect();
387
+ // updatedSize.height = textRect.height;
388
+ // positionRef.current.updateSize({ ...updatedSize });
389
+ // }
390
+ onChange({
391
+ ...updatedSize
392
+ });
393
+ handleResizeEvent("stop");
394
+ };
395
+ const onCloseSettings = () => {
396
+ setSelectedElement({
397
+ ...selectedElementProps,
398
+ selectedAction: null,
399
+ selectedActionPath: null
400
+ });
401
+ };
402
+ const handleContextMenu = e => {
403
+ if (readOnly) {
404
+ return;
405
+ }
406
+ e.preventDefault();
407
+ e.stopPropagation();
408
+ onClick({
409
+ detail: 1
410
+ });
411
+ setContextMenu({
412
+ x: e.clientX + 2,
413
+ y: e.clientY - 6,
414
+ path: path.join("|")
415
+ });
416
+ };
417
+ const handleClose = d => () => {
418
+ if (d) {
419
+ handleContextMenuClick(d);
420
+ }
421
+ if (d?.autoClose !== false) {
422
+ setContextMenu({
423
+ path: null
424
+ });
425
+ }
426
+ };
427
+ const getEventProps = () => {
428
+ if (!readOnly) {
429
+ return {
430
+ onResizeStart: e => {
431
+ e.preventDefault();
432
+ },
433
+ onDragStart: onDragStart,
434
+ onDrag: onDrag,
435
+ onDragStop: onDragStop,
436
+ onResizeStop: onResizeStop,
437
+ onClick: onClick,
438
+ onContextMenu: handleContextMenu
439
+ };
440
+ } else {
441
+ return {};
442
+ }
443
+ };
444
+ return /*#__PURE__*/_jsxs(_Fragment, {
445
+ children: [/*#__PURE__*/_jsxs(Box, {
446
+ component: Rnd,
447
+ placeholder: ItemTypes[childType] || "Item",
448
+ id: eId || "",
449
+ ref: c => {
450
+ positionRef.current = c;
451
+ },
452
+ className: `${className || ""} ${dragInfoOpen ? "active-drag" : "inactive-drag"} enable-${enable} type_${childType} section_type_${type || "parent"}`,
453
+ "data-path": str_path,
454
+ style: {
455
+ position: "relative",
456
+ outline: enable && ITEM_TYPES.includes(type) ? "#2563EB solid 2px" : 0,
457
+ cursor: cursor,
458
+ caretColor: enable === 2 ? "auto" : "transparent",
459
+ userSelect: enable === 2 || readOnly ? "auto" : "none",
460
+ ...style,
461
+ zIndex: enable === 1 ? 1 : "inherit",
462
+ left: "var(--left)",
463
+ ...absPosition
464
+ },
465
+ default: {
466
+ ...(defaultStyle || {})
467
+ },
468
+ dragGrid: [2, 2],
469
+ resizeHandleComponent: enable ? Handles({
470
+ type
471
+ }) : {},
472
+ disableDragging: readOnly || disableDragging || enable !== 1,
473
+ suppressContentEditableWarning: true,
474
+ enableResizing: readOnly ? false : enable && !active ? enableResizing : {},
475
+ ...getEventProps(),
476
+ children: [/*#__PURE__*/_jsx("div", {
477
+ id: `opt_ref_${str_path}`,
478
+ style: {
479
+ display: "block",
480
+ position: "absolute",
481
+ left: "-8px",
482
+ top: "-30px",
483
+ minWidth: "calc(100% + 24px)",
484
+ minHeight: "calc(100% + 42px)",
485
+ pointerEvents: "none"
486
+ },
487
+ ref: rndRef,
488
+ className: "options-wrapper",
489
+ contentEditable: false
490
+ }), children, enable !== 2 && type !== "parent" && !readOnly ? /*#__PURE__*/_jsx("button", {
491
+ "data-event": "rnd-click",
492
+ className: "editor-blocker",
493
+ "data-path": path,
494
+ contentEditable: false
495
+ }) : null, /*#__PURE__*/_jsx(DragOver, {
496
+ status: dragOverStatus,
497
+ hover_on: hover_on,
498
+ path: str_path,
499
+ parentPath: parentPath,
500
+ type: type,
501
+ childType: childType
502
+ })]
503
+ }, eId), !active && rndRef?.current && open ? /*#__PURE__*/_jsx(ElementOptions, {
504
+ id: `opt_ref_${str_path}`,
505
+ open: open,
506
+ anchorEl: rndRef?.current,
507
+ enable: enable,
508
+ handleAction: handleAction,
509
+ actions: actions,
510
+ actionsMap: actionsMap,
511
+ optionsProps: optionsProps,
512
+ selectedAction: currentAction,
513
+ path: str_path
514
+ }) : null, /*#__PURE__*/_jsx(ElementSettings, {
515
+ open: Boolean(currentAction),
516
+ currentAction: currentAction,
517
+ anchorEl: rndRef?.current,
518
+ placement: "right-start",
519
+ onClose: onCloseSettings,
520
+ childType: childType,
521
+ editor: editor,
522
+ path: sp,
523
+ ...settingsProps,
524
+ elementProps: elementProps
525
+ }), /*#__PURE__*/_jsx(DragInfo, {
526
+ anchorEl: rndRef?.current,
527
+ open: dragInfoOpen,
528
+ dragging: dragging
529
+ }), /*#__PURE__*/_jsx(GuideLines, {
530
+ lines: lines
531
+ }), !readOnly && type === "parent" ? /*#__PURE__*/_jsx(BoundaryLine, {}) : null, /*#__PURE__*/_jsx(ShadowElement, {
532
+ type: type,
533
+ enable: enable,
534
+ style: {
535
+ ...style,
536
+ ...defaultStyle,
537
+ left: "var(--left)",
538
+ marginTop: "var(--marginTop)",
539
+ gridArea: "var(--gridArea)"
540
+ }
541
+ }), /*#__PURE__*/_jsx(ContextMenu, {
542
+ type: type,
543
+ open: openContextMenu,
544
+ contextMenu: contextMenu,
545
+ handleClose: handleClose
546
+ }), type === "parent" && breakpoint === "lg" ? /*#__PURE__*/_jsx(VirtualElement, {
547
+ parentEle: positionRef?.current?.resizableElement?.current,
548
+ updated_at: updated_at,
549
+ path: str_path,
550
+ editor: editor
551
+ }) : null]
552
+ });
553
+ };
554
+ RnD.defaultProps = {
555
+ disableDragging: false,
556
+ enableResizing: {
557
+ bottom: true,
558
+ bottomLeft: true,
559
+ bottomRight: true,
560
+ left: true,
561
+ right: true,
562
+ top: true,
563
+ topLeft: true,
564
+ topRight: true
565
+ }
566
+ };
567
+ export default RnD;
@@ -0,0 +1,4 @@
1
+ const useRnDStyles = () => ({
2
+ root: {}
3
+ });
4
+ export default useRnDStyles;
@@ -1,10 +1,11 @@
1
1
  import React, { useRef, useState } from "react";
2
+ import { useTheme } from "@mui/material";
2
3
  import { Transforms } from "slate";
3
4
  import { ReactEditor, useSlateStatic } from "slate-react";
4
5
  import { Box, IconButton, Popper, Tooltip } from "@mui/material";
5
6
  import TuneIcon from "@mui/icons-material/Tune";
6
7
  import SectionPopup from "../../Elements/Grid/SectionPopup";
7
- import { getBreakPointsValue, getTRBLBreakPoints } from "../../helper/theme";
8
+ import { getBreakPointsValue, getTRBLBreakPoints, groupByBreakpoint } from "../../helper/theme";
8
9
  import DragHandle from "../DnD/DragHandleButton";
9
10
  import { useEditorSelection } from "../../hooks/useMouseMove";
10
11
  import SectionStyle from "./styles";
@@ -14,7 +15,8 @@ import { jsxs as _jsxs } from "react/jsx-runtime";
14
15
  import { Fragment as _Fragment } from "react/jsx-runtime";
15
16
  const list_types = ["orderedList", "unorderedList"];
16
17
  const Section = props => {
17
- const classes = SectionStyle();
18
+ const theme = useTheme();
19
+ const classes = SectionStyle(theme);
18
20
  const {
19
21
  children,
20
22
  element,
@@ -99,23 +101,32 @@ const Section = props => {
99
101
  at: path
100
102
  });
101
103
  };
104
+ const isFreeGrid = element?.children?.find(f => f.type === "freegrid");
102
105
  const needHover = element?.children?.find(f => f.type === "grid" && !list_types.includes(element.type)) ? "needHover" : "";
103
106
  const sectionBgImage = sectionBackgroundImage && sectionBackgroundImage !== "none" ? {
104
107
  backgroundImage: `url(${sectionBackgroundImage})`
105
108
  } : {};
106
- return path.length === 1 ? /*#__PURE__*/_jsxs(Box, {
109
+ const edSectionSp = groupByBreakpoint({
110
+ padding: {
111
+ ...getTRBLBreakPoints(sectionBannerSpacing)
112
+ },
113
+ borderRadius: {
114
+ ...getBreakPointsValue(sectionBorderRadius || {}, null, "overrideBorderRadius", true)
115
+ }
116
+ }, theme);
117
+ const edInnerSp = groupByBreakpoint({
118
+ width: {
119
+ ...getBreakPointsValue(sectionGridSize || 8, null, "overrideGridSize", true)
120
+ }
121
+ }, theme);
122
+ return path.length === 1 && !isFreeGrid ? /*#__PURE__*/_jsxs(Box, {
107
123
  component: "div",
108
124
  className: `ed-section-wrapper ${readOnly ? "" : "hselect"} ${needHover}`,
109
125
  sx: {
110
126
  ...classes.root,
111
127
  background: sectionBgColor,
112
128
  ...sectionBgImage,
113
- padding: {
114
- ...getTRBLBreakPoints(sectionBannerSpacing)
115
- },
116
- borderRadius: {
117
- ...getBreakPointsValue(sectionBorderRadius || {}, null, "overrideBorderRadius", true)
118
- },
129
+ ...edSectionSp,
119
130
  flexDirection: flexDirection || "column",
120
131
  alignItems: horizantal,
121
132
  justifyContent: vertical
@@ -126,9 +137,7 @@ const Section = props => {
126
137
  className: "ed-section-inner",
127
138
  sx: {
128
139
  position: "relative",
129
- width: {
130
- ...getBreakPointsValue(sectionGridSize || 8, null, "overrideGridSize", true)
131
- }
140
+ ...edInnerSp
132
141
  },
133
142
  ref: anchorEl,
134
143
  children: [isHovering && isSectionFullWidth ? /*#__PURE__*/_jsx(Popper, {
@@ -1,4 +1,4 @@
1
- const SectionStyle = () => ({
1
+ const SectionStyle = theme => ({
2
2
  root: {
3
3
  "&:hover": {
4
4
  "& .dh-para": {
@@ -17,13 +17,11 @@ const SectionStyle = () => ({
17
17
  }
18
18
  },
19
19
  "& .sectionPopper": {
20
+ opacity: 0,
20
21
  "&:hover": {
21
22
  opacity: 1
22
23
  }
23
24
  },
24
- "& .sectionPopper": {
25
- opacity: 0
26
- },
27
25
  "& .sectionIcon": {
28
26
  opacity: 0,
29
27
  padding: "0px",
@@ -49,6 +47,11 @@ const SectionStyle = () => ({
49
47
  "&.active": {
50
48
  opacity: 1
51
49
  }
50
+ },
51
+ "& .ed-section-inner": {
52
+ [theme.breakpoints.between("xs", "md")]: {
53
+ maxWidth: `320px !important`
54
+ }
52
55
  }
53
56
  }
54
57
  });