@flozy/editor 3.8.7 → 3.8.9

Sign up to get free protection for your applications and to get access to all the features.
Files changed (188) hide show
  1. package/dist/Editor/ChatEditor.js +2 -2
  2. package/dist/Editor/CommonEditor.js +170 -166
  3. package/dist/Editor/DialogWrapper.js +4 -3
  4. package/dist/Editor/Editor.css +4 -7
  5. package/dist/Editor/Elements/AI/AIInput.js +5 -16
  6. package/dist/Editor/Elements/AI/PopoverAIInput.js +64 -67
  7. package/dist/Editor/Elements/AI/Styles.js +1 -2
  8. package/dist/Editor/Elements/AppHeader/AppHeader.js +40 -49
  9. package/dist/Editor/Elements/Button/EditorButton.js +33 -38
  10. package/dist/Editor/Elements/Color Picker/ColorButtons.js +17 -60
  11. package/dist/Editor/Elements/Color Picker/ColorPicker.css +1 -25
  12. package/dist/Editor/Elements/Color Picker/ColorPicker.js +4 -4
  13. package/dist/Editor/Elements/Color Picker/Styles.js +1 -2
  14. package/dist/Editor/Elements/Embed/Image.js +15 -14
  15. package/dist/Editor/Elements/Embed/Video.js +12 -8
  16. package/dist/Editor/Elements/Emoji/EmojiButton.js +11 -7
  17. package/dist/Editor/Elements/Form/Workflow/FormWorkflow.js +3 -12
  18. package/dist/Editor/Elements/Form/Workflow/UserInputs.js +1 -2
  19. package/dist/Editor/Elements/FreeGrid/FreeGrid.js +391 -0
  20. package/dist/Editor/Elements/FreeGrid/FreeGridBox.js +193 -0
  21. package/dist/Editor/Elements/FreeGrid/FreeGridButton.js +23 -0
  22. package/dist/Editor/Elements/FreeGrid/FreeGridItem.js +184 -0
  23. package/dist/Editor/Elements/FreeGrid/Options/AddElement.js +36 -0
  24. package/dist/Editor/Elements/FreeGrid/Options/More.js +24 -0
  25. package/dist/Editor/Elements/FreeGrid/Options/SectionSettings.js +47 -0
  26. package/dist/Editor/Elements/FreeGrid/Options/sectionItemOptions.js +11 -0
  27. package/dist/Editor/Elements/FreeGrid/breakpointConstants.js +75 -0
  28. package/dist/Editor/Elements/FreeGrid/styles.js +159 -0
  29. package/dist/Editor/Elements/Grid/Grid.js +14 -34
  30. package/dist/Editor/Elements/Grid/GridItem.js +31 -23
  31. package/dist/Editor/Elements/Link/Link.js +1 -6
  32. package/dist/Editor/Elements/Link/LinkButton.js +2 -4
  33. package/dist/Editor/Elements/Link/LinkPopup.js +3 -10
  34. package/dist/Editor/Elements/PageSettings/PageSettingsButton.js +3 -3
  35. package/dist/Editor/Elements/Signature/SignaturePopup.js +3 -14
  36. package/dist/Editor/Elements/SimpleText/index.js +9 -8
  37. package/dist/Editor/Elements/SimpleText/style.js +37 -0
  38. package/dist/Editor/Elements/Table/Styles.js +1 -23
  39. package/dist/Editor/Elements/Table/Table.js +1 -2
  40. package/dist/Editor/Elements/Table/TableCell.js +7 -69
  41. package/dist/Editor/Elements/TableContextMenu/TableContextMenu.js +0 -1
  42. package/dist/Editor/ErrorBoundary.js +30 -0
  43. package/dist/Editor/MiniEditor.js +1 -3
  44. package/dist/Editor/Styles/EditorStyles.js +23 -0
  45. package/dist/Editor/Toolbar/Basic/index.js +2 -4
  46. package/dist/Editor/Toolbar/FormatTools/Dropdown.js +2 -26
  47. package/dist/Editor/Toolbar/FormatTools/MarkButton.js +2 -2
  48. package/dist/Editor/Toolbar/FormatTools/TextSize.js +18 -29
  49. package/dist/Editor/Toolbar/Mini/MiniToolbar.js +2 -4
  50. package/dist/Editor/Toolbar/Mini/Options/Options.js +0 -10
  51. package/dist/Editor/Toolbar/Mini/Styles.js +0 -7
  52. package/dist/Editor/Toolbar/PopupTool/MiniTextFormat/SelectFontSize.js +11 -4
  53. package/dist/Editor/Toolbar/PopupTool/MiniTextFormat/SelectTypography.js +86 -213
  54. package/dist/Editor/Toolbar/PopupTool/MiniTextFormat/index.js +1 -2
  55. package/dist/Editor/Toolbar/PopupTool/PopupToolStyle.js +13 -20
  56. package/dist/Editor/Toolbar/PopupTool/TextFormat.js +8 -52
  57. package/dist/Editor/Toolbar/PopupTool/index.js +13 -6
  58. package/dist/Editor/Toolbar/Toolbar.js +7 -0
  59. package/dist/Editor/Toolbar/toolbarGroups.js +11 -48
  60. package/dist/Editor/assets/svg/AIIcons.js +1 -153
  61. package/dist/Editor/assets/svg/AddTemplateIcon.js +10 -13
  62. package/dist/Editor/assets/svg/TextIcon.js +5 -8
  63. package/dist/Editor/common/ColorPickerButton.js +9 -25
  64. package/dist/Editor/common/DnD/DragHandleButton.js +47 -56
  65. package/dist/Editor/common/Icon.js +8 -41
  66. package/dist/Editor/common/LinkSettings/NavComponents.js +2 -5
  67. package/dist/Editor/common/LinkSettings/index.js +2 -4
  68. package/dist/Editor/common/LinkSettings/navOptions.js +2 -7
  69. package/dist/Editor/common/LinkSettings/style.js +8 -11
  70. package/dist/Editor/common/MentionsPopup/index.js +12 -8
  71. package/dist/Editor/common/RnD/ContextMenu/CMenus.js +105 -0
  72. package/dist/Editor/common/RnD/ContextMenu/index.js +38 -0
  73. package/dist/Editor/common/RnD/ContextMenu/styles.js +21 -0
  74. package/dist/Editor/common/RnD/DragInfo/index.js +31 -0
  75. package/dist/Editor/common/RnD/DragInfo/styles.js +15 -0
  76. package/dist/Editor/common/RnD/DragOver/index.js +46 -0
  77. package/dist/Editor/common/RnD/DragOver/styles.js +23 -0
  78. package/dist/Editor/common/RnD/ElementOptions/Actions.js +82 -0
  79. package/dist/Editor/common/RnD/ElementOptions/Icons/LinkIcon.js +26 -0
  80. package/dist/Editor/common/RnD/ElementOptions/index.js +93 -0
  81. package/dist/Editor/common/RnD/ElementOptions/styles.js +41 -0
  82. package/dist/Editor/common/RnD/ElementSettings/OtherSettings/Link.js +153 -0
  83. package/dist/Editor/common/RnD/ElementSettings/OtherSettings/Settings.js +58 -0
  84. package/dist/Editor/common/RnD/ElementSettings/OtherSettings/index.js +7 -0
  85. package/dist/Editor/common/RnD/ElementSettings/Settings/BoxSettings.js +46 -0
  86. package/dist/Editor/common/RnD/ElementSettings/Settings/ButtonSettings.js +46 -0
  87. package/dist/Editor/common/RnD/ElementSettings/Settings/ImageSettings.js +46 -0
  88. package/dist/Editor/common/RnD/ElementSettings/Settings/TextSettings.js +30 -0
  89. package/dist/Editor/common/RnD/ElementSettings/Settings/VideoSettings.js +46 -0
  90. package/dist/Editor/common/RnD/ElementSettings/Settings/index.js +13 -0
  91. package/dist/Editor/common/RnD/ElementSettings/index.js +17 -0
  92. package/dist/Editor/common/RnD/ElementSettings/settingsConstants.js +14 -0
  93. package/dist/Editor/common/RnD/ElementSettings/styles.js +76 -0
  94. package/dist/Editor/common/RnD/GuideLines/BoundaryLine.js +52 -0
  95. package/dist/Editor/common/RnD/GuideLines/index.js +33 -0
  96. package/dist/Editor/common/RnD/GuideLines/styles.js +60 -0
  97. package/dist/Editor/common/RnD/OptionsPopup/index.js +50 -0
  98. package/dist/Editor/common/RnD/OptionsPopup/style.js +36 -0
  99. package/dist/Editor/common/RnD/RnDCopy.js +23 -0
  100. package/dist/Editor/common/RnD/ShadowElement.js +34 -0
  101. package/dist/Editor/common/RnD/SwitchViewport/SwitchViewport.js +40 -0
  102. package/dist/Editor/common/RnD/SwitchViewport/styles.js +24 -0
  103. package/dist/Editor/common/RnD/Theme/ViewportStimulator.js +63 -0
  104. package/dist/Editor/common/RnD/TransformHandles/CornerHandle.js +19 -0
  105. package/dist/Editor/common/RnD/TransformHandles/Icons/BottomRightIcon.js +13 -0
  106. package/dist/Editor/common/RnD/TransformHandles/SizeHandle.js +18 -0
  107. package/dist/Editor/common/RnD/TransformHandles/index.js +62 -0
  108. package/dist/Editor/common/RnD/Utils/alignmentDetection.js +26 -0
  109. package/dist/Editor/common/RnD/Utils/calculateDropItem.js +98 -0
  110. package/dist/Editor/common/RnD/Utils/collisionDetection.js +52 -0
  111. package/dist/Editor/common/RnD/Utils/gridDropItem.js +148 -0
  112. package/dist/Editor/common/RnD/Utils/index.js +251 -0
  113. package/dist/Editor/common/RnD/VirtualElement/index.js +76 -0
  114. package/dist/Editor/common/RnD/VirtualElement/styles.js +27 -0
  115. package/dist/Editor/common/RnD/VirtualElement/updateAutoProps.js +28 -0
  116. package/dist/Editor/common/RnD/index.js +503 -0
  117. package/dist/Editor/common/RnD/styles.js +4 -0
  118. package/dist/Editor/common/Section/index.js +28 -69
  119. package/dist/Editor/common/Section/styles.js +6 -12
  120. package/dist/Editor/common/Shorthands/elements.js +12 -54
  121. package/dist/Editor/common/StyleBuilder/boxStyle.js +30 -0
  122. package/dist/Editor/common/StyleBuilder/buttonStyle.js +2 -4
  123. package/dist/Editor/common/StyleBuilder/fieldTypes/bannerSpacing.js +16 -19
  124. package/dist/Editor/common/StyleBuilder/fieldTypes/borderRadius.js +7 -15
  125. package/dist/Editor/common/StyleBuilder/fieldTypes/buttonLink.js +1 -1
  126. package/dist/Editor/common/StyleBuilder/fieldTypes/color.js +7 -31
  127. package/dist/Editor/common/StyleBuilder/fieldTypes/fontSize.js +4 -13
  128. package/dist/Editor/common/StyleBuilder/fieldTypes/text.js +4 -2
  129. package/dist/Editor/common/StyleBuilder/fieldTypes/textOptions.js +4 -14
  130. package/dist/Editor/common/StyleBuilder/index.js +1 -1
  131. package/dist/Editor/common/StyleBuilder/sectionStyle.js +13 -2
  132. package/dist/Editor/common/iconslist.js +31 -0
  133. package/dist/Editor/helper/RnD/focusOnNewItem.js +39 -0
  134. package/dist/Editor/helper/RnD/scrollToNewSection.js +24 -0
  135. package/dist/Editor/helper/breakpoint.js +5 -0
  136. package/dist/Editor/helper/index.js +139 -0
  137. package/dist/Editor/helper/theme.js +48 -185
  138. package/dist/Editor/hooks/useBreakpoints.js +34 -0
  139. package/dist/Editor/hooks/useMouseMove.js +37 -12
  140. package/dist/Editor/hooks/useWindowMessage.js +7 -10
  141. package/dist/Editor/hooks/withCommon.js +2 -1
  142. package/dist/Editor/hooks/withErrorHandling.js +14 -0
  143. package/dist/Editor/plugins/withEmbeds.js +1 -1
  144. package/dist/Editor/plugins/withHTML.js +1 -1
  145. package/dist/Editor/plugins/withTable.js +1 -1
  146. package/dist/Editor/theme/ThemeList.js +173 -50
  147. package/dist/Editor/utils/RnD/RnDCtrlCmds.js +168 -0
  148. package/dist/Editor/utils/SlateUtilityFunctions.js +47 -163
  149. package/dist/Editor/utils/button.js +17 -1
  150. package/dist/Editor/utils/events.js +7 -54
  151. package/dist/Editor/utils/font.js +37 -40
  152. package/dist/Editor/utils/freegrid.js +49 -0
  153. package/dist/Editor/utils/helper.js +31 -31
  154. package/dist/Editor/utils/table.js +43 -51
  155. package/package.json +6 -4
  156. package/dist/Editor/Elements/AI/VoiceToText/AudioWave.js +0 -73
  157. package/dist/Editor/Elements/AI/VoiceToText/index.js +0 -167
  158. package/dist/Editor/Elements/AI/VoiceToText/style.js +0 -40
  159. package/dist/Editor/Elements/Link/LinkPopupStyles.js +0 -28
  160. package/dist/Editor/Elements/Redo/RedoButton.js +0 -14
  161. package/dist/Editor/Elements/Undo/UndoButton.js +0 -14
  162. package/dist/Editor/Toolbar/PopupTool/ThemeTextFormat.js +0 -438
  163. package/dist/Editor/assets/svg/RedoIcon.js +0 -27
  164. package/dist/Editor/assets/svg/SettingsIcon.js +0 -28
  165. package/dist/Editor/assets/svg/ThemeIcons.js +0 -291
  166. package/dist/Editor/assets/svg/UndoIcon.js +0 -27
  167. package/dist/Editor/common/CustomColorPicker/index.js +0 -106
  168. package/dist/Editor/common/CustomColorPicker/style.js +0 -53
  169. package/dist/Editor/common/CustomDialog/index.js +0 -94
  170. package/dist/Editor/common/CustomDialog/style.js +0 -67
  171. package/dist/Editor/common/CustomSelect.js +0 -33
  172. package/dist/Editor/hooks/useEditorTheme.js +0 -139
  173. package/dist/Editor/theme/index.js +0 -144
  174. package/dist/Editor/themeSettings/ActiveTheme.js +0 -72
  175. package/dist/Editor/themeSettings/buttons/index.js +0 -290
  176. package/dist/Editor/themeSettings/buttons/style.js +0 -21
  177. package/dist/Editor/themeSettings/colorTheme/index.js +0 -290
  178. package/dist/Editor/themeSettings/colorTheme/style.js +0 -77
  179. package/dist/Editor/themeSettings/fonts/PreviewElement.js +0 -123
  180. package/dist/Editor/themeSettings/fonts/index.js +0 -213
  181. package/dist/Editor/themeSettings/fonts/style.js +0 -44
  182. package/dist/Editor/themeSettings/icons.js +0 -60
  183. package/dist/Editor/themeSettings/index.js +0 -320
  184. package/dist/Editor/themeSettings/style.js +0 -152
  185. package/dist/Editor/themeSettingsAI/icons.js +0 -96
  186. package/dist/Editor/themeSettingsAI/index.js +0 -356
  187. package/dist/Editor/themeSettingsAI/saveTheme.js +0 -190
  188. package/dist/Editor/themeSettingsAI/style.js +0 -247
@@ -60,28 +60,4 @@
60
60
  padding: 0 15px !important;
61
61
  width: 60px !important;
62
62
  flex-shrink: 0;
63
- }
64
-
65
-
66
- .singleColorTitleWrapper {
67
- display: flex;
68
- justify-content: space-between;
69
- align-items: center;
70
- padding: 10px;
71
- width: 100%;
72
- border-bottom: 1px solid #DCE4EC;
73
- }
74
-
75
- .singleColorTitleWrapper .MuiTypography-root {
76
- font-weight: 600;
77
- }
78
-
79
- .singleColorTitleWrapper .editBtn {
80
- text-transform: none;
81
- color: #2563EB;
82
- text-decoration: underline;
83
- padding: 0px;
84
- min-width: unset;
85
- cursor: pointer;
86
- font-size: 14px;
87
- }
63
+ }
@@ -1,6 +1,7 @@
1
1
  import React, { useState } from "react";
2
2
  import { ReactEditor } from "slate-react";
3
3
  import { Transforms } from "slate";
4
+ import ColorPickerTool from "react-gcolor-picker";
4
5
  import { IconButton, Tooltip, Box, Popover } from "@mui/material";
5
6
  import { addMarkData, activeMark } from "../../utils/SlateUtilityFunctions";
6
7
  import ColorButtons from "./ColorButtons";
@@ -8,7 +9,6 @@ import ColorPickerStyles from "./Styles";
8
9
  import colorWheel from "./colorWheel.png";
9
10
  import "./ColorPicker.css";
10
11
  import { useEditorContext } from "../../hooks/useMouseMove";
11
- import CustomColorPicker from "../../common/CustomColorPicker";
12
12
  import { jsx as _jsx } from "react/jsx-runtime";
13
13
  import { Fragment as _Fragment } from "react/jsx-runtime";
14
14
  import { jsxs as _jsxs } from "react/jsx-runtime";
@@ -95,10 +95,10 @@ const ColorPicker = props => {
95
95
  horizontal: "top"
96
96
  },
97
97
  sx: classes.colorPickerPopup,
98
- children: /*#__PURE__*/_jsx(CustomColorPicker, {
98
+ children: /*#__PURE__*/_jsx(ColorPickerTool, {
99
99
  gradient: true,
100
- onChange: handleFormSubmit,
101
- color: activeColor
100
+ value: activeColor,
101
+ onChange: handleFormSubmit
102
102
  })
103
103
  })]
104
104
  });
@@ -15,8 +15,7 @@ const ColorPickerStyles = theme => ({
15
15
  colorPopper: {
16
16
  "& .MuiPaper-root": {
17
17
  backgroundColor: theme?.palette?.editor?.background,
18
- padding: "4px 14px",
19
- "@media only screen and (max-width: 600px)": {
18
+ '@media only screen and (max-width: 600px)': {
20
19
  marginTop: "-40px"
21
20
  }
22
21
  }
@@ -4,15 +4,16 @@ import { Node, Transforms, Editor } from "slate";
4
4
  import AspectRatioIcon from "@mui/icons-material/AspectRatio";
5
5
  import useResize from "../../utils/customHooks/useResize";
6
6
  import EmbedPopup from "./EmbedPopup";
7
- import { IconButton, Tooltip, Box } from "@mui/material";
7
+ import { IconButton, Tooltip, Box, useTheme } from "@mui/material";
8
8
  import { GridSettingsIcon, LinkIcon } from "../../common/iconslist";
9
9
  import { useEditorContext } from "../../hooks/useMouseMove";
10
- import { getTRBLBreakPoints, getBreakPointsValue } from "../../helper/theme";
10
+ import { getTRBLBreakPoints, getBreakPointsValue, groupByBreakpoint } from "../../helper/theme";
11
11
  import Icon from "../../common/Icon";
12
12
  import frames from "./Frames";
13
13
  import ImageFrame from "./Frames/ImageFrame";
14
14
  import LinkSettings from "../../common/LinkSettings";
15
15
  import { handleLinkType } from "../../utils/helper";
16
+ import { wrapThemeBreakpoints } from "../FreeGrid/breakpointConstants";
16
17
  import { jsx as _jsx } from "react/jsx-runtime";
17
18
  import { jsxs as _jsxs } from "react/jsx-runtime";
18
19
  const ToolBar = ({
@@ -65,6 +66,7 @@ const ImageContent = ({
65
66
  objectFit,
66
67
  webAddress
67
68
  } = element;
69
+ const theme = useTheme();
68
70
  return !url && !readOnly ? /*#__PURE__*/_jsxs(Box, {
69
71
  component: "button",
70
72
  className: "element-empty-btn",
@@ -79,9 +81,7 @@ const ImageContent = ({
79
81
  component: "img",
80
82
  className: "emb-img",
81
83
  sx: {
82
- borderRadius: {
83
- ...getBreakPointsValue(borderRadius || {}, null, "overrideBorderRadius", true)
84
- },
84
+ ...wrapThemeBreakpoints(getBreakPointsValue(borderRadius || {}, null, "overrideBorderRadius", true), "borderRadius", theme),
85
85
  objectFit: "cover",
86
86
  boxShadow: boxShadow || "none",
87
87
  height: objectFit ? "100%" : "auto",
@@ -105,6 +105,7 @@ const Image = ({
105
105
  children,
106
106
  customProps
107
107
  }) => {
108
+ const theme = useTheme();
108
109
  const {
109
110
  url,
110
111
  bannerSpacing,
@@ -227,12 +228,14 @@ const Image = ({
227
228
  };
228
229
  } else {
229
230
  return {
230
- width: url ? {
231
- ...getBreakPointsValue(getSize(), null, "overrideReSize", true)
232
- } : "100%",
233
- height: objectFit && url ? {
234
- ...getBreakPointsValue(getSize(), null, "overrideReSizeH", true)
235
- } : "auto"
231
+ ...groupByBreakpoint({
232
+ width: url ? {
233
+ ...getBreakPointsValue(getSize(), null, "overrideReSize", true)
234
+ } : "100%",
235
+ height: objectFit && url ? {
236
+ ...getBreakPointsValue(getSize(), null, "overrideReSizeH", true)
237
+ } : "auto"
238
+ }, theme)
236
239
  };
237
240
  }
238
241
  };
@@ -247,9 +250,7 @@ const Image = ({
247
250
  },
248
251
  width: `100%`,
249
252
  maxWidth: "100%",
250
- padding: {
251
- ...getTRBLBreakPoints(bannerSpacing)
252
- },
253
+ ...wrapThemeBreakpoints(getTRBLBreakPoints(bannerSpacing), "padding", theme),
253
254
  backgroundColor: bgColor,
254
255
  justifyContent: horizantal,
255
256
  alignContent: vertical
@@ -1,7 +1,7 @@
1
1
  import React, { useState, useEffect } from "react";
2
2
  import { useSlateStatic, ReactEditor } from "slate-react";
3
3
  import { Node, Transforms } from "slate";
4
- import { IconButton, Tooltip, Box } from "@mui/material";
4
+ import { IconButton, Tooltip, Box, useTheme } from "@mui/material";
5
5
  import DeleteIcon from "@mui/icons-material/Delete";
6
6
  import AspectRatioIcon from "@mui/icons-material/AspectRatio";
7
7
  import Icon from "../../common/Icon";
@@ -10,7 +10,7 @@ import EmbedPopup from "./EmbedPopup";
10
10
  import { GridSettingsIcon } from "../../common/iconslist";
11
11
  import { gradientBorder } from "../../utils/helper";
12
12
  import { getEmbedURL } from "../../helper";
13
- import { getBreakPointsValue } from "../../helper/theme";
13
+ import { getBreakPointsValue, groupByBreakpoint } from "../../helper/theme";
14
14
  import { jsx as _jsx } from "react/jsx-runtime";
15
15
  import { jsxs as _jsxs } from "react/jsx-runtime";
16
16
  const Video = ({
@@ -19,6 +19,7 @@ const Video = ({
19
19
  children,
20
20
  customProps
21
21
  }) => {
22
+ const theme = useTheme();
22
23
  const {
23
24
  alt,
24
25
  alignment,
@@ -126,12 +127,14 @@ const Video = ({
126
127
  };
127
128
  } else {
128
129
  return {
129
- width: {
130
- ...getBreakPointsValue(getSize(), null, "overrideReSize", true)
131
- },
132
- height: url ? {
133
- ...getBreakPointsValue(getSize(), null, "overrideReSizeH", true)
134
- } : "auto"
130
+ ...groupByBreakpoint({
131
+ width: {
132
+ ...getBreakPointsValue(getSize(), null, "overrideReSize", true)
133
+ },
134
+ height: url ? {
135
+ ...getBreakPointsValue(getSize(), null, "overrideReSizeH", true)
136
+ } : "auto"
137
+ }, theme)
135
138
  };
136
139
  }
137
140
  };
@@ -205,6 +208,7 @@ const Video = ({
205
208
  onDelete: onDelete
206
209
  }) : null, /*#__PURE__*/_jsxs(Box, {
207
210
  component: "div",
211
+ className: "embed-video-wrpr-in",
208
212
  contentEditable: false,
209
213
  sx: {
210
214
  position: "relative",
@@ -25,13 +25,17 @@ const EmojiButton = /*#__PURE__*/forwardRef((props, ref) => {
25
25
  }
26
26
  }));
27
27
  const onClick = () => {
28
- if (editor.selection) {
29
- const domRange = ReactEditor.toDOMRange(editor, editor.selection);
30
- const rect = domRange.getBoundingClientRect();
31
- setAnchorEl({
32
- getBoundingClientRect: () => rect,
33
- nodeType: 1
34
- });
28
+ try {
29
+ if (editor.selection) {
30
+ const domRange = ReactEditor.toDOMRange(editor, editor.selection);
31
+ const rect = domRange.getBoundingClientRect();
32
+ setAnchorEl({
33
+ getBoundingClientRect: () => rect,
34
+ nodeType: 1
35
+ });
36
+ }
37
+ } catch (err) {
38
+ console.log(err);
35
39
  }
36
40
  };
37
41
  const onEmojiSelect = emoji => {
@@ -71,11 +71,11 @@ const FormWorkflow = props => {
71
71
  children: [/*#__PURE__*/_jsx(Grid, {
72
72
  item: true,
73
73
  sx: classes.radioBtn,
74
- children: /*#__PURE__*/_jsxs(RadioGroup, {
74
+ children: /*#__PURE__*/_jsx(RadioGroup, {
75
75
  name: "set timing",
76
76
  value: schedule,
77
77
  defaultValue: 1,
78
- children: [/*#__PURE__*/_jsx(FormControlLabel, {
78
+ children: /*#__PURE__*/_jsx(FormControlLabel, {
79
79
  value: "immediately",
80
80
  label: "Immediately",
81
81
  onChange: () => {
@@ -84,16 +84,7 @@ const FormWorkflow = props => {
84
84
  control: /*#__PURE__*/_jsx(Radio, {
85
85
  size: "small"
86
86
  })
87
- }), /*#__PURE__*/_jsx(FormControlLabel, {
88
- value: "after",
89
- label: "After",
90
- onChange: () => {
91
- setSchedule("after");
92
- },
93
- control: /*#__PURE__*/_jsx(Radio, {
94
- size: "small"
95
- })
96
- })]
87
+ })
97
88
  })
98
89
  }), schedule === "after" && /*#__PURE__*/_jsx(Grid, {
99
90
  item: true,
@@ -39,8 +39,7 @@ const UserInputs = props => {
39
39
  fontStyleOptions: ['underline'],
40
40
  hideLink: true,
41
41
  hideTextColor: true
42
- },
43
- theme: theme
42
+ }
44
43
  })
45
44
  })
46
45
  });
@@ -0,0 +1,391 @@
1
+ import React from "react";
2
+ import { Path, Transforms, Node } from "slate";
3
+ import { ReactEditor, useSlateStatic } from "slate-react";
4
+ import { Box, useTheme } from "@mui/material";
5
+ import RnD from "../../common/RnD";
6
+ import More from "./Options/More";
7
+ import { ROW_HEIGHT } from "../../common/RnD/Utils/gridDropItem";
8
+ import AddElement from "./Options/AddElement";
9
+ import useBreakpoints from "../../hooks/useBreakpoints";
10
+ import { breakpointValues } from "./breakpointConstants";
11
+ import useFreeGridStyles from "./styles";
12
+ import { insertFreeGrid, insertFreeGridItem } from "../../utils/freegrid";
13
+ import { useEditorContext } from "../../hooks/useMouseMove";
14
+ import SectionSettings from "./Options/SectionSettings";
15
+ import scrollToNewSection from "../../helper/RnD/scrollToNewSection";
16
+ import { createEmbedNode } from "../../utils/embed";
17
+ import { onPasteRnDNode } from "../../helper";
18
+ import focusOnNewItem from "../../helper/RnD/focusOnNewItem";
19
+ import { jsx as _jsx } from "react/jsx-runtime";
20
+ import { jsxs as _jsxs } from "react/jsx-runtime";
21
+ const MAX_DEVICE_WIDTH = {
22
+ lg: 980,
23
+ xs: 320
24
+ };
25
+ const FreeGrid = props => {
26
+ const theme = useTheme();
27
+ const breakpoint = useBreakpoints(theme);
28
+ const classes = useFreeGridStyles({
29
+ theme,
30
+ MAX_DEVICE_WIDTH: MAX_DEVICE_WIDTH[breakpoint]
31
+ });
32
+ const editor = useSlateStatic();
33
+ const {
34
+ element,
35
+ attributes,
36
+ children,
37
+ customProps
38
+ } = props;
39
+ const {
40
+ sectionName
41
+ } = element;
42
+ const {
43
+ readOnly
44
+ } = customProps;
45
+ const {
46
+ updated_at,
47
+ sectionBgColor,
48
+ sectionBackgroundImage
49
+ } = element;
50
+ const path = ReactEditor.findPath(editor, element);
51
+ // get values based on breakpoint size
52
+ const {
53
+ height
54
+ } = breakpointValues(element.type, breakpoint, element);
55
+ const {
56
+ setSelectedElement
57
+ } = useEditorContext();
58
+ const onChange = data => {
59
+ const append = breakpoint === "lg" ? "" : `_${breakpoint}`;
60
+ const updateData = {
61
+ ...data,
62
+ [`height${append}`]: height + data.height
63
+ };
64
+ if (append !== "") {
65
+ delete updateData.height;
66
+ }
67
+ if (breakpoint === "xs") {
68
+ updateData.xs_updatedOn = new Date().getTime();
69
+ }
70
+ delete updateData.children;
71
+ Transforms.setNodes(editor, {
72
+ ...updateData
73
+ }, {
74
+ at: path
75
+ });
76
+ };
77
+ const moveUp = () => {
78
+ const cur_root_path = Path.parent(path);
79
+ if (Path.hasPrevious(cur_root_path)) {
80
+ Transforms.moveNodes(editor, {
81
+ at: cur_root_path,
82
+ to: Path.previous(cur_root_path)
83
+ });
84
+ }
85
+ };
86
+ const moveDown = () => {
87
+ const cur_root_path = Path.parent(path);
88
+ Transforms.moveNodes(editor, {
89
+ at: cur_root_path,
90
+ to: Path.next(cur_root_path)
91
+ });
92
+ };
93
+ const handleActionClick = actionType => {
94
+ switch (actionType) {
95
+ case "moveUp":
96
+ moveUp();
97
+ break;
98
+ case "moveDown":
99
+ moveDown();
100
+ break;
101
+ default:
102
+ }
103
+ };
104
+ const handleMoreClick = moreAction => () => {
105
+ try {
106
+ const cur_root_path = Path.parent(path);
107
+ const next_path = Path.next(cur_root_path);
108
+ switch (moreAction) {
109
+ case "addSection":
110
+ insertFreeGrid(editor, next_path, {
111
+ setSelectedElement
112
+ });
113
+ break;
114
+ case "duplicateSection":
115
+ Transforms.insertNodes(editor, [{
116
+ ...JSON.parse(JSON.stringify(Node.get(editor, cur_root_path)))
117
+ }], {
118
+ at: next_path
119
+ });
120
+ scrollToNewSection(editor, next_path, {
121
+ setSelectedElement
122
+ });
123
+ break;
124
+ default:
125
+ }
126
+ } catch (err) {
127
+ console.log(err);
128
+ }
129
+ };
130
+ const isEmptySection = () => {
131
+ try {
132
+ const emptyNode = element?.children?.find(f => !f.type) && element?.children.length === 1;
133
+ return emptyNode;
134
+ } catch (err) {
135
+ console.log(err);
136
+ }
137
+ };
138
+ const handleAddElementClick = type => () => {
139
+ const isEmpty = isEmptySection();
140
+ const insertAt = isEmpty ? [...path, 0] : [...path, element?.children?.length];
141
+ switch (type) {
142
+ case "addText":
143
+ Transforms.insertNodes(editor, [{
144
+ type: "freegridItem",
145
+ childType: "text",
146
+ children: [{
147
+ type: "paragraph",
148
+ children: [{
149
+ text: "Text"
150
+ }]
151
+ }],
152
+ gridArea: "3 / 1 / 4 / 2",
153
+ left: 50,
154
+ marginTop: 0,
155
+ top: 0,
156
+ width: 170,
157
+ height: 80
158
+ }], {
159
+ at: [...insertAt]
160
+ });
161
+ break;
162
+ case "addButton":
163
+ Transforms.insertNodes(editor, [{
164
+ type: "freegridItem",
165
+ childType: "button",
166
+ children: [{
167
+ type: "button",
168
+ children: [{
169
+ text: ""
170
+ }],
171
+ buttonLink: {
172
+ linkType: "webAddress"
173
+ },
174
+ iconPosition: "start",
175
+ bgColor: "#2563EB",
176
+ textColor: "#FFF",
177
+ borderRadius: {
178
+ topLeft: 30,
179
+ topRight: 30,
180
+ bottomLeft: 30,
181
+ bottomRight: 30
182
+ },
183
+ bannerSpacing: {
184
+ left: 12,
185
+ top: 12,
186
+ right: 12,
187
+ bottom: 12
188
+ }
189
+ }],
190
+ gridArea: "3 / 1 / 4 / 2",
191
+ left: 50,
192
+ marginTop: 0,
193
+ top: 0,
194
+ width: 170,
195
+ height: 80
196
+ }], {
197
+ at: [...insertAt]
198
+ });
199
+ break;
200
+ case "addImage":
201
+ Transforms.insertNodes(editor, [{
202
+ type: "freegridItem",
203
+ childType: "image",
204
+ children: [{
205
+ type: "image",
206
+ url: "",
207
+ images: [],
208
+ children: [{
209
+ text: ""
210
+ }]
211
+ }],
212
+ gridArea: "3 / 1 / 4 / 2",
213
+ left: 50,
214
+ marginTop: 0,
215
+ top: 0,
216
+ width: 170,
217
+ height: 80
218
+ }], {
219
+ at: [...insertAt]
220
+ });
221
+ break;
222
+ case "addVideo":
223
+ Transforms.insertNodes(editor, [{
224
+ ...insertFreeGridItem("video", createEmbedNode("video", {
225
+ url: "",
226
+ alt: "",
227
+ images: []
228
+ }), {
229
+ height: 300,
230
+ width: 250
231
+ })
232
+ }], {
233
+ at: [...insertAt]
234
+ });
235
+ break;
236
+ case "addBox":
237
+ Transforms.insertNodes(editor, [{
238
+ ...insertFreeGridItem("box", {
239
+ type: "paragraph",
240
+ children: [{
241
+ text: ""
242
+ }]
243
+ }, {}, "freegridBox")
244
+ }], {
245
+ at: [...insertAt]
246
+ });
247
+ break;
248
+ default:
249
+ }
250
+ // focus on newly added element
251
+ focusOnNewItem(editor, insertAt, {
252
+ setSelectedElement
253
+ });
254
+ };
255
+ const onPaste = () => {
256
+ try {
257
+ const cur_root_path = Path.parent(path);
258
+ const parsed_node = JSON.parse(window.copiedNode);
259
+ if (parsed_node?.type === "freegridItem" || parsed_node?.type === "freegridBox") {
260
+ const np = onPasteRnDNode(editor, {
261
+ path,
262
+ children: children
263
+ });
264
+ if (np) {
265
+ focusOnNewItem(editor, np, {
266
+ setSelectedElement
267
+ });
268
+ }
269
+ } else {
270
+ // for pasting whole section
271
+ const new_path = Path.next(cur_root_path);
272
+ Transforms.insertNodes(editor, [{
273
+ ...parsed_node
274
+ }], {
275
+ at: new_path
276
+ });
277
+ scrollToNewSection(editor, new_path, {
278
+ setSelectedElement
279
+ });
280
+ }
281
+ } catch (err) {
282
+ console.log(err);
283
+ }
284
+ };
285
+ const onDelete = () => {
286
+ try {
287
+ Transforms.removeNodes(editor, {
288
+ at: Path.parent(path)
289
+ });
290
+ } catch (err) {
291
+ console.log(err);
292
+ }
293
+ };
294
+ const handleContextMenuClick = d => {
295
+ switch (d?.name) {
296
+ case "cut":
297
+ window.copiedNode = JSON.stringify(Node.get(editor, Path.parent(path)));
298
+ onDelete();
299
+ break;
300
+ case "copy":
301
+ window.copiedNode = JSON.stringify(Node.get(editor, Path.parent(path)));
302
+ break;
303
+ case "paste":
304
+ onPaste();
305
+ break;
306
+ case "delete":
307
+ onDelete();
308
+ break;
309
+ default:
310
+ return;
311
+ }
312
+ };
313
+ const repeatTimes = Math.floor(height / ROW_HEIGHT);
314
+ return /*#__PURE__*/_jsx(RnD, {
315
+ id: `freegrid_container_${path.join("|")}_${updated_at}_${breakpoint}`,
316
+ className: `freegrid-section breakpoint-${breakpoint}`,
317
+ editor: editor,
318
+ path: path,
319
+ disableDragging: true,
320
+ style: {
321
+ position: "relative",
322
+ "--height": `${height}px`
323
+ },
324
+ defaultStyle: {
325
+ width: "100%",
326
+ height: height ? `${height}px` : "auto"
327
+ },
328
+ enableResizing: {
329
+ bottom: true
330
+ },
331
+ actions: ["addElement", "settings", "moveUp", "moveDown", "more"],
332
+ type: "parent",
333
+ optionsProps: {
334
+ placement: "right",
335
+ sx: classes.sectionPopper
336
+ },
337
+ onChange: onChange,
338
+ handleActionClick: handleActionClick,
339
+ actionsMap: {
340
+ addElement: {
341
+ Component: AddElement,
342
+ placement: "left",
343
+ title: "Add Element",
344
+ props: {
345
+ handleClick: handleAddElementClick
346
+ }
347
+ },
348
+ more: {
349
+ Component: More,
350
+ placement: "left",
351
+ title: "More Options",
352
+ props: {
353
+ handleClick: handleMoreClick
354
+ }
355
+ },
356
+ settings: {
357
+ Component: SectionSettings,
358
+ placement: "left",
359
+ title: "Section Settings",
360
+ props: {
361
+ editor,
362
+ path,
363
+ classes
364
+ }
365
+ }
366
+ },
367
+ readOnly: readOnly,
368
+ updated_at: updated_at,
369
+ breakpoint: breakpoint,
370
+ handleContextMenuClick: handleContextMenuClick,
371
+ children: /*#__PURE__*/_jsxs(Box, {
372
+ ...attributes,
373
+ className: "freegrid-container",
374
+ sx: classes.root,
375
+ "data-path": path.join("|"),
376
+ style: {
377
+ "--cols": `100%`,
378
+ "--rows": `repeat(${repeatTimes}, ${ROW_HEIGHT}px)`,
379
+ background: sectionBgColor,
380
+ backgroundImage: `url('${sectionBackgroundImage}')`,
381
+ backgroundSize: "cover"
382
+ },
383
+ children: [children, !readOnly ? /*#__PURE__*/_jsx("span", {
384
+ placeholder: `Section (${sectionName || "Welcome"})`,
385
+ className: "freegrid-section-infos",
386
+ contentEditable: false
387
+ }) : null]
388
+ })
389
+ });
390
+ };
391
+ export default FreeGrid;