@flozy/editor 3.8.9 → 3.9.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (194) hide show
  1. package/dist/Editor/ChatEditor.js +55 -45
  2. package/dist/Editor/CommonEditor.js +175 -168
  3. package/dist/Editor/DialogWrapper.js +3 -4
  4. package/dist/Editor/Editor.css +7 -4
  5. package/dist/Editor/Elements/AI/AIInput.js +17 -18
  6. package/dist/Editor/Elements/AI/CustomSelect.js +19 -12
  7. package/dist/Editor/Elements/AI/PopoverAIInput.js +58 -74
  8. package/dist/Editor/Elements/AI/Styles.js +2 -1
  9. package/dist/Editor/Elements/AI/VoiceToText/AudioWave.js +73 -0
  10. package/dist/Editor/Elements/AI/VoiceToText/index.js +177 -0
  11. package/dist/Editor/Elements/AI/VoiceToText/style.js +40 -0
  12. package/dist/Editor/Elements/AppHeader/AppHeader.js +49 -40
  13. package/dist/Editor/Elements/Button/EditorButton.js +38 -33
  14. package/dist/Editor/Elements/Color Picker/ColorButtons.js +60 -17
  15. package/dist/Editor/Elements/Color Picker/ColorPicker.css +25 -1
  16. package/dist/Editor/Elements/Color Picker/ColorPicker.js +4 -4
  17. package/dist/Editor/Elements/Color Picker/Styles.js +2 -1
  18. package/dist/Editor/Elements/Embed/Image.js +14 -15
  19. package/dist/Editor/Elements/Embed/Video.js +8 -12
  20. package/dist/Editor/Elements/Emoji/EmojiButton.js +7 -11
  21. package/dist/Editor/Elements/Emoji/EmojiPicker.js +4 -2
  22. package/dist/Editor/Elements/Form/Form.js +1 -1
  23. package/dist/Editor/Elements/Form/Workflow/FormWorkflow.js +12 -3
  24. package/dist/Editor/Elements/Form/Workflow/UserInputs.js +2 -1
  25. package/dist/Editor/Elements/Grid/Grid.js +34 -14
  26. package/dist/Editor/Elements/Grid/GridItem.js +23 -31
  27. package/dist/Editor/Elements/Link/Link.js +6 -1
  28. package/dist/Editor/Elements/Link/LinkButton.js +4 -2
  29. package/dist/Editor/Elements/Link/LinkPopup.js +10 -3
  30. package/dist/Editor/Elements/Link/LinkPopupStyles.js +28 -0
  31. package/dist/Editor/Elements/PageSettings/PageSettingsButton.js +8 -4
  32. package/dist/Editor/Elements/Redo/RedoButton.js +14 -0
  33. package/dist/Editor/Elements/Signature/SignaturePopup.js +14 -3
  34. package/dist/Editor/Elements/SimpleText/index.js +8 -9
  35. package/dist/Editor/Elements/SimpleText/style.js +0 -37
  36. package/dist/Editor/Elements/Table/Styles.js +23 -1
  37. package/dist/Editor/Elements/Table/Table.js +2 -1
  38. package/dist/Editor/Elements/Table/TableCell.js +69 -7
  39. package/dist/Editor/Elements/TableContextMenu/TableContextMenu.js +1 -0
  40. package/dist/Editor/Elements/Undo/UndoButton.js +14 -0
  41. package/dist/Editor/MiniEditor.js +3 -1
  42. package/dist/Editor/Styles/EditorStyles.js +1 -24
  43. package/dist/Editor/Toolbar/Basic/index.js +4 -2
  44. package/dist/Editor/Toolbar/FormatTools/Dropdown.js +26 -2
  45. package/dist/Editor/Toolbar/FormatTools/MarkButton.js +2 -2
  46. package/dist/Editor/Toolbar/FormatTools/TextSize.js +29 -18
  47. package/dist/Editor/Toolbar/Mini/MiniToolbar.js +29 -3
  48. package/dist/Editor/Toolbar/Mini/Options/Options.js +10 -0
  49. package/dist/Editor/Toolbar/Mini/Styles.js +7 -0
  50. package/dist/Editor/Toolbar/PopupTool/MiniTextFormat/SelectFontSize.js +4 -11
  51. package/dist/Editor/Toolbar/PopupTool/MiniTextFormat/SelectTypography.js +213 -86
  52. package/dist/Editor/Toolbar/PopupTool/MiniTextFormat/index.js +2 -1
  53. package/dist/Editor/Toolbar/PopupTool/PopupToolStyle.js +22 -16
  54. package/dist/Editor/Toolbar/PopupTool/TextFormat.js +52 -8
  55. package/dist/Editor/Toolbar/PopupTool/ThemeTextFormat.js +438 -0
  56. package/dist/Editor/Toolbar/PopupTool/index.js +7 -25
  57. package/dist/Editor/Toolbar/Toolbar.js +0 -7
  58. package/dist/Editor/Toolbar/toolbarGroups.js +48 -11
  59. package/dist/Editor/assets/svg/AIIcons.js +153 -1
  60. package/dist/Editor/assets/svg/AddTemplateIcon.js +13 -10
  61. package/dist/Editor/assets/svg/RedoIcon.js +27 -0
  62. package/dist/Editor/assets/svg/SettingsIcon.js +28 -0
  63. package/dist/Editor/assets/svg/TextIcon.js +8 -5
  64. package/dist/Editor/assets/svg/ThemeIcons.js +291 -0
  65. package/dist/Editor/assets/svg/UndoIcon.js +27 -0
  66. package/dist/Editor/common/ColorPickerButton.js +25 -9
  67. package/dist/Editor/common/CustomColorPicker/index.js +106 -0
  68. package/dist/Editor/common/CustomColorPicker/style.js +53 -0
  69. package/dist/Editor/common/CustomDialog/index.js +94 -0
  70. package/dist/Editor/common/CustomDialog/style.js +67 -0
  71. package/dist/Editor/common/CustomSelect.js +33 -0
  72. package/dist/Editor/common/DnD/DragHandleButton.js +56 -47
  73. package/dist/Editor/common/Icon.js +41 -8
  74. package/dist/Editor/common/LinkSettings/NavComponents.js +5 -2
  75. package/dist/Editor/common/LinkSettings/index.js +4 -2
  76. package/dist/Editor/common/LinkSettings/navOptions.js +7 -2
  77. package/dist/Editor/common/LinkSettings/style.js +11 -8
  78. package/dist/Editor/common/MentionsPopup/MentionsListCard.js +6 -1
  79. package/dist/Editor/common/MentionsPopup/index.js +8 -12
  80. package/dist/Editor/common/Section/index.js +69 -28
  81. package/dist/Editor/common/Section/styles.js +12 -6
  82. package/dist/Editor/common/Shorthands/elements.js +54 -12
  83. package/dist/Editor/common/StyleBuilder/buttonStyle.js +4 -2
  84. package/dist/Editor/common/StyleBuilder/fieldTypes/bannerSpacing.js +19 -16
  85. package/dist/Editor/common/StyleBuilder/fieldTypes/borderRadius.js +15 -7
  86. package/dist/Editor/common/StyleBuilder/fieldTypes/buttonLink.js +1 -1
  87. package/dist/Editor/common/StyleBuilder/fieldTypes/color.js +31 -7
  88. package/dist/Editor/common/StyleBuilder/fieldTypes/fontSize.js +13 -4
  89. package/dist/Editor/common/StyleBuilder/fieldTypes/selectBox.js +14 -3
  90. package/dist/Editor/common/StyleBuilder/fieldTypes/text.js +2 -4
  91. package/dist/Editor/common/StyleBuilder/fieldTypes/textOptions.js +14 -4
  92. package/dist/Editor/common/StyleBuilder/index.js +1 -1
  93. package/dist/Editor/common/StyleBuilder/sectionStyle.js +2 -13
  94. package/dist/Editor/common/iconslist.js +0 -31
  95. package/dist/Editor/helper/index.js +0 -139
  96. package/dist/Editor/helper/theme.js +185 -48
  97. package/dist/Editor/hooks/useEditorTheme.js +139 -0
  98. package/dist/Editor/hooks/useMouseMove.js +12 -37
  99. package/dist/Editor/hooks/useWindowMessage.js +10 -7
  100. package/dist/Editor/hooks/withCommon.js +1 -2
  101. package/dist/Editor/plugins/withEmbeds.js +1 -1
  102. package/dist/Editor/plugins/withHTML.js +1 -1
  103. package/dist/Editor/plugins/withTable.js +1 -1
  104. package/dist/Editor/theme/ThemeList.js +50 -173
  105. package/dist/Editor/theme/index.js +144 -0
  106. package/dist/Editor/themeSettings/ActiveTheme.js +72 -0
  107. package/dist/Editor/themeSettings/buttons/index.js +290 -0
  108. package/dist/Editor/themeSettings/buttons/style.js +21 -0
  109. package/dist/Editor/themeSettings/colorTheme/index.js +290 -0
  110. package/dist/Editor/themeSettings/colorTheme/style.js +77 -0
  111. package/dist/Editor/themeSettings/fonts/PreviewElement.js +123 -0
  112. package/dist/Editor/themeSettings/fonts/index.js +213 -0
  113. package/dist/Editor/themeSettings/fonts/style.js +44 -0
  114. package/dist/Editor/themeSettings/icons.js +60 -0
  115. package/dist/Editor/themeSettings/index.js +320 -0
  116. package/dist/Editor/themeSettings/style.js +152 -0
  117. package/dist/Editor/themeSettingsAI/icons.js +96 -0
  118. package/dist/Editor/themeSettingsAI/index.js +356 -0
  119. package/dist/Editor/themeSettingsAI/saveTheme.js +190 -0
  120. package/dist/Editor/themeSettingsAI/style.js +247 -0
  121. package/dist/Editor/utils/SlateUtilityFunctions.js +163 -47
  122. package/dist/Editor/utils/button.js +1 -17
  123. package/dist/Editor/utils/draftToSlate.js +1 -1
  124. package/dist/Editor/utils/events.js +54 -7
  125. package/dist/Editor/utils/font.js +40 -37
  126. package/dist/Editor/utils/helper.js +31 -31
  127. package/dist/Editor/utils/table.js +51 -43
  128. package/package.json +4 -6
  129. package/dist/Editor/Elements/FreeGrid/FreeGrid.js +0 -391
  130. package/dist/Editor/Elements/FreeGrid/FreeGridBox.js +0 -193
  131. package/dist/Editor/Elements/FreeGrid/FreeGridButton.js +0 -23
  132. package/dist/Editor/Elements/FreeGrid/FreeGridItem.js +0 -184
  133. package/dist/Editor/Elements/FreeGrid/Options/AddElement.js +0 -36
  134. package/dist/Editor/Elements/FreeGrid/Options/More.js +0 -24
  135. package/dist/Editor/Elements/FreeGrid/Options/SectionSettings.js +0 -47
  136. package/dist/Editor/Elements/FreeGrid/Options/sectionItemOptions.js +0 -11
  137. package/dist/Editor/Elements/FreeGrid/breakpointConstants.js +0 -75
  138. package/dist/Editor/Elements/FreeGrid/styles.js +0 -159
  139. package/dist/Editor/ErrorBoundary.js +0 -30
  140. package/dist/Editor/common/RnD/ContextMenu/CMenus.js +0 -105
  141. package/dist/Editor/common/RnD/ContextMenu/index.js +0 -38
  142. package/dist/Editor/common/RnD/ContextMenu/styles.js +0 -21
  143. package/dist/Editor/common/RnD/DragInfo/index.js +0 -31
  144. package/dist/Editor/common/RnD/DragInfo/styles.js +0 -15
  145. package/dist/Editor/common/RnD/DragOver/index.js +0 -46
  146. package/dist/Editor/common/RnD/DragOver/styles.js +0 -23
  147. package/dist/Editor/common/RnD/ElementOptions/Actions.js +0 -82
  148. package/dist/Editor/common/RnD/ElementOptions/Icons/LinkIcon.js +0 -26
  149. package/dist/Editor/common/RnD/ElementOptions/index.js +0 -93
  150. package/dist/Editor/common/RnD/ElementOptions/styles.js +0 -41
  151. package/dist/Editor/common/RnD/ElementSettings/OtherSettings/Link.js +0 -153
  152. package/dist/Editor/common/RnD/ElementSettings/OtherSettings/Settings.js +0 -58
  153. package/dist/Editor/common/RnD/ElementSettings/OtherSettings/index.js +0 -7
  154. package/dist/Editor/common/RnD/ElementSettings/Settings/BoxSettings.js +0 -46
  155. package/dist/Editor/common/RnD/ElementSettings/Settings/ButtonSettings.js +0 -46
  156. package/dist/Editor/common/RnD/ElementSettings/Settings/ImageSettings.js +0 -46
  157. package/dist/Editor/common/RnD/ElementSettings/Settings/TextSettings.js +0 -30
  158. package/dist/Editor/common/RnD/ElementSettings/Settings/VideoSettings.js +0 -46
  159. package/dist/Editor/common/RnD/ElementSettings/Settings/index.js +0 -13
  160. package/dist/Editor/common/RnD/ElementSettings/index.js +0 -17
  161. package/dist/Editor/common/RnD/ElementSettings/settingsConstants.js +0 -14
  162. package/dist/Editor/common/RnD/ElementSettings/styles.js +0 -76
  163. package/dist/Editor/common/RnD/GuideLines/BoundaryLine.js +0 -52
  164. package/dist/Editor/common/RnD/GuideLines/index.js +0 -33
  165. package/dist/Editor/common/RnD/GuideLines/styles.js +0 -60
  166. package/dist/Editor/common/RnD/OptionsPopup/index.js +0 -50
  167. package/dist/Editor/common/RnD/OptionsPopup/style.js +0 -36
  168. package/dist/Editor/common/RnD/RnDCopy.js +0 -23
  169. package/dist/Editor/common/RnD/ShadowElement.js +0 -34
  170. package/dist/Editor/common/RnD/SwitchViewport/SwitchViewport.js +0 -40
  171. package/dist/Editor/common/RnD/SwitchViewport/styles.js +0 -24
  172. package/dist/Editor/common/RnD/Theme/ViewportStimulator.js +0 -63
  173. package/dist/Editor/common/RnD/TransformHandles/CornerHandle.js +0 -19
  174. package/dist/Editor/common/RnD/TransformHandles/Icons/BottomRightIcon.js +0 -13
  175. package/dist/Editor/common/RnD/TransformHandles/SizeHandle.js +0 -18
  176. package/dist/Editor/common/RnD/TransformHandles/index.js +0 -62
  177. package/dist/Editor/common/RnD/Utils/alignmentDetection.js +0 -26
  178. package/dist/Editor/common/RnD/Utils/calculateDropItem.js +0 -98
  179. package/dist/Editor/common/RnD/Utils/collisionDetection.js +0 -52
  180. package/dist/Editor/common/RnD/Utils/gridDropItem.js +0 -148
  181. package/dist/Editor/common/RnD/Utils/index.js +0 -251
  182. package/dist/Editor/common/RnD/VirtualElement/index.js +0 -76
  183. package/dist/Editor/common/RnD/VirtualElement/styles.js +0 -27
  184. package/dist/Editor/common/RnD/VirtualElement/updateAutoProps.js +0 -28
  185. package/dist/Editor/common/RnD/index.js +0 -503
  186. package/dist/Editor/common/RnD/styles.js +0 -4
  187. package/dist/Editor/common/StyleBuilder/boxStyle.js +0 -30
  188. package/dist/Editor/helper/RnD/focusOnNewItem.js +0 -39
  189. package/dist/Editor/helper/RnD/scrollToNewSection.js +0 -24
  190. package/dist/Editor/helper/breakpoint.js +0 -5
  191. package/dist/Editor/hooks/useBreakpoints.js +0 -34
  192. package/dist/Editor/hooks/withErrorHandling.js +0 -14
  193. package/dist/Editor/utils/RnD/RnDCtrlCmds.js +0 -168
  194. package/dist/Editor/utils/freegrid.js +0 -49
@@ -1,6 +1,6 @@
1
1
  import React, { useCallback, useMemo, useRef, useState, useEffect, useImperativeHandle, forwardRef } from "react";
2
2
  import { Editable, Slate, ReactEditor } from 'slate-react';
3
- import { createEditor, Transforms } from 'slate';
3
+ import { createEditor, Transforms, Editor } from 'slate';
4
4
  import { useDebounce } from "use-debounce";
5
5
  import withCommon from "./hooks/withCommon";
6
6
  import { getBlock, getMarked } from "./utils/chatEditor/SlateUtilityFunctions";
@@ -31,7 +31,12 @@ const ChatEditor = /*#__PURE__*/forwardRef((props, ref) => {
31
31
  } = props;
32
32
  const classes = usePopupStyle(theme);
33
33
  const convertedContent = draftToSlate({
34
- data: content
34
+ data: content && content?.length > 0 ? content : [{
35
+ type: 'paragraph',
36
+ children: [{
37
+ text: ''
38
+ }]
39
+ }]
35
40
  });
36
41
  const [isInteracted, setIsInteracted] = useState(false);
37
42
  const [value, setValue] = useState(convertedContent);
@@ -47,57 +52,62 @@ const ChatEditor = /*#__PURE__*/forwardRef((props, ref) => {
47
52
  useImperativeHandle(ref, () => ({
48
53
  emojiClick: emoji => {
49
54
  if (editor) {
55
+ ReactEditor.focus(editor);
50
56
  insertEmoji(editor, emoji?.native, editor.selection);
51
- if (editor.selection) {
52
- const path = editor.selection.anchor.path;
53
- const offset = editor.selection.anchor.offset + emoji?.native.length;
54
- const position = {
55
- anchor: {
56
- path: [0],
57
- offset: 0
58
- },
59
- focus: {
60
- path: [0],
61
- offset: 0
62
- }
63
- };
64
- // Create a new selection
65
- Transforms.select(editor, position);
66
- }
67
57
  ReactEditor.focus(editor);
68
58
  }
69
59
  },
70
- setContent: newContent => {
71
- setIsExternalUpdate(true);
72
- setValue(newContent);
73
- ReactEditor.focus(editor);
60
+ submitChat: () => {
61
+ const {
62
+ value: strVal,
63
+ ...restVal
64
+ } = getOnSaveData(value);
65
+ onsubmit(false, {
66
+ strVal,
67
+ restVal
68
+ });
74
69
  },
75
70
  // Focus enable
76
- // enableFocus: () => {
77
- // if (editor) {
78
- // const position = {
79
- // anchor: { path: [0], offset: 0 },
80
- // focus: { path: [0], offset: 0 },
81
- // };
82
- // Transforms.select(editor, position);
83
- // ReactEditor.focus(editor);
84
- // }
85
- // },
86
-
87
- clearAll: () => {
71
+ enableFocus: () => {
72
+ if (editor) {
73
+ const position = {
74
+ anchor: {
75
+ path: [0],
76
+ offset: 0
77
+ },
78
+ focus: {
79
+ path: [0],
80
+ offset: 0
81
+ }
82
+ };
83
+ Transforms.select(editor, position);
84
+ ReactEditor.focus(editor);
85
+ }
86
+ },
87
+ clearAll: (content = null, clear = true) => {
88
88
  if (!editor) return;
89
- while (editor.children.length > 0) {
90
- Transforms.removeNodes(editor, {
91
- at: [0]
89
+ try {
90
+ if (clear) {
91
+ while (editor.children.length > 0) {
92
+ Transforms.removeNodes(editor, {
93
+ at: [0]
94
+ });
95
+ }
96
+ }
97
+ const newValue = draftToSlate({
98
+ data: content
92
99
  });
100
+ setValue(newValue);
101
+ setTimeout(() => {
102
+ if (editor.children.length === 0) {
103
+ Transforms.insertNodes(editor, newValue);
104
+ }
105
+ Transforms.select(editor, Editor.end(editor, []));
106
+ ReactEditor.focus(editor);
107
+ }, 300);
108
+ } catch {
109
+ console.log("error:");
93
110
  }
94
- Transforms.insertNodes(editor, {
95
- type: 'paragraph',
96
- children: [{
97
- text: ''
98
- }]
99
- });
100
- ReactEditor.focus(editor);
101
111
  }
102
112
  }));
103
113
  useEffect(() => {
@@ -105,7 +115,7 @@ const ChatEditor = /*#__PURE__*/forwardRef((props, ref) => {
105
115
  setValue(draftToSlate({
106
116
  data: content
107
117
  }));
108
- }, [id, content]);
118
+ }, [content]);
109
119
  useEffect(() => {
110
120
  if (JSON.stringify(loadedValue) !== JSON.stringify(deboundedValue) && isInteracted && onSave) {
111
121
  const {
@@ -1,6 +1,5 @@
1
1
  /* eslint-disable no-unused-vars */
2
- import React, { useRef, useCallback, useEffect, useMemo, useState, forwardRef, useImperativeHandle } from "react";
3
- import PropTypes, { object } from "prop-types";
2
+ import React, { useRef, useCallback, useEffect, useMemo, useState, forwardRef, useImperativeHandle, createContext } from "react";
4
3
  import { createEditor, Transforms } from "slate";
5
4
  import { Slate, Editable, ReactEditor } from "slate-react";
6
5
  import { useDebounce, useDebouncedCallback } from "use-debounce";
@@ -19,7 +18,7 @@ import { getThumbnailImage, invertColor } from "./helper";
19
18
  import PopupTool from "./Toolbar/PopupTool";
20
19
  import "./font.css";
21
20
  import "./Editor.css";
22
- import { Box, Typography, useTheme } from "@mui/material";
21
+ import { Box, IconButton, Typography } from "@mui/material";
23
22
  import Shorthands from "./common/Shorthands";
24
23
  import MiniToolbar from "./Toolbar/Mini/MiniToolbar";
25
24
  import { EditorProvider } from "./hooks/useMouseMove";
@@ -27,16 +26,21 @@ import TopBanner from "./Elements/TopBanner/TopBanner";
27
26
  import editorStyles from "./Styles/EditorStyles";
28
27
  import DragAndDrop from "./common/DnD";
29
28
  import Section from "./common/Section";
29
+ import "animate.css";
30
30
  import decorators from "./utils/Decorators";
31
- import { getTRBLBreakPoints } from "./helper/theme";
31
+ import { getTRBLBreakPoints, getVariableValue } from "./helper/theme";
32
32
  import { handleInsertLastElement, onDeleteKey, outsideEditorClickLabel } from "./utils/helper";
33
33
  import useWindowResize from "./hooks/useWindowResize";
34
+ import { getTheme } from "./theme";
35
+ import { useTheme } from "@emotion/react";
36
+ import ThemeSettings from "./themeSettings";
37
+ import ThemeSettingsAI from "./themeSettingsAI";
38
+ import { Experimental_CssVarsProvider as CssVarsProvider, experimental_extendTheme as extendTheme } from "@mui/material/styles";
34
39
  import PopoverAIInput from "./Elements/AI/PopoverAIInput";
35
- import RnDCopy from "./common/RnD/RnDCopy";
36
- import "animate.css";
37
- import SwitchViewport from "./common/RnD/SwitchViewport/SwitchViewport";
40
+ import { ThemeAIIcon, ThemePaintIcon } from "./assets/svg/ThemeIcons";
38
41
  import { jsx as _jsx } from "react/jsx-runtime";
39
42
  import { jsxs as _jsxs } from "react/jsx-runtime";
43
+ export const ThemeContext = /*#__PURE__*/createContext(null);
40
44
  const Item = /*#__PURE__*/forwardRef(({
41
45
  children,
42
46
  ...props
@@ -83,7 +87,8 @@ const CommonEditor = /*#__PURE__*/forwardRef((props, ref) => {
83
87
  toolbarOptions,
84
88
  otherProps,
85
89
  isIframe,
86
- theme
90
+ theme,
91
+ showThemeButtons
87
92
  } = props;
88
93
  const editorWrapper = useRef();
89
94
  const mentionsRef = useRef();
@@ -103,7 +108,6 @@ const CommonEditor = /*#__PURE__*/forwardRef((props, ref) => {
103
108
  });
104
109
  const [isScrolling, setIsScrolling] = useState(false);
105
110
  const [isTextSelected, setIsTextSelected] = useState(false);
106
- const [breakpoint, setBreakpoint] = useState("");
107
111
  const [size] = useWindowResize();
108
112
  const {
109
113
  needDotsBG,
@@ -115,6 +119,7 @@ const CommonEditor = /*#__PURE__*/forwardRef((props, ref) => {
115
119
  fullWidth = "80%",
116
120
  hideTools
117
121
  } = otherProps || {};
122
+ const [drag, setDrag] = useState(null);
118
123
  const editor = useMemo(() => {
119
124
  if (collaborativeEditor) return collaborativeEditor;
120
125
  return withCommon(createEditor(), {
@@ -127,10 +132,11 @@ const CommonEditor = /*#__PURE__*/forwardRef((props, ref) => {
127
132
  const {
128
133
  bannerSpacing,
129
134
  pageBgImage,
130
- pageColor,
135
+ pageColor = "",
131
136
  color: pageTextColor,
132
137
  pageWidth,
133
- maxWidth: pageMaxWidth
138
+ maxWidth: pageMaxWidth,
139
+ theme: selectedTheme
134
140
  } = pageSt?.pageProps || {
135
141
  bannerSpacing: {
136
142
  left: 0,
@@ -141,16 +147,15 @@ const CommonEditor = /*#__PURE__*/forwardRef((props, ref) => {
141
147
  };
142
148
  const classes = editorStyles({
143
149
  padHeight: !fullScreen ? otherProps?.padHeight : 20,
144
- placeHolderColor: invertColor(pageColor || "#FFF"),
150
+ placeHolderColor: invertColor(pageColor.startsWith("var") ? getVariableValue(pageColor) : pageColor || "#FFF"),
145
151
  theme
146
152
  });
153
+ const [openTheme, setOpenTheme] = useState(false);
154
+ const [openAITheme, setOpenAITheme] = useState(false);
147
155
  useEffect(() => {
148
156
  setValue(draftToSlate({
149
157
  data: content
150
158
  }));
151
- if (!ReactEditor.isFocused(editor)) {
152
- ReactEditor.focus(editor);
153
- }
154
159
  }, [id, content]);
155
160
  useEffect(() => {
156
161
  if (editorWrapper && editorWrapper?.current && JSON.stringify(loadedValue) !== JSON.stringify(deboundedValue) && isInteracted && onSave) {
@@ -179,17 +184,6 @@ const CommonEditor = /*#__PURE__*/forwardRef((props, ref) => {
179
184
  });
180
185
  return c;
181
186
  };
182
-
183
- // Example of resetting or re-rendering all nodes
184
- const reRenderAllNodes = () => {
185
- const newNodes = JSON.parse(JSON.stringify(value));
186
- setValue(newNodes); // This will re-render the whole document
187
- };
188
-
189
- const onSwitchBreakpoint = b => {
190
- setBreakpoint(b);
191
- reRenderAllNodes();
192
- };
193
187
  useImperativeHandle(ref, () => ({
194
188
  async getThumbnail(needBackground = false, options = {}) {
195
189
  try {
@@ -251,15 +245,18 @@ const CommonEditor = /*#__PURE__*/forwardRef((props, ref) => {
251
245
  h
252
246
  });
253
247
  },
254
- switchViewport(bp) {
255
- setBreakpoint(bp);
256
- },
257
248
  undo() {
258
249
  editor?.undo();
259
250
  },
260
251
  redo() {
261
252
  editor?.redo();
262
253
  },
254
+ toggleTheme() {
255
+ setOpenTheme(!openTheme);
256
+ },
257
+ toggleAITheme() {
258
+ setOpenAITheme(!openAITheme);
259
+ },
263
260
  getPageSettings: {
264
261
  background: pageBgImage && pageBgImage !== "none" ? `url(${pageBgImage})` : pageColor || ""
265
262
  }
@@ -326,8 +323,6 @@ const CommonEditor = /*#__PURE__*/forwardRef((props, ref) => {
326
323
  const onKeyDown = useCallback(event => {
327
324
  const isMetaKey = event.metaKey && event.keyCode >= 65 && event.keyCode <= 90;
328
325
  const isCtrlKey = event.ctrlKey || isMetaKey;
329
- // for RnD item move front and back
330
- const isUpandDown = event.metaKey && [38, 40].indexOf(event.keyCode) > -1;
331
326
  if (target && chars.length > 0 && !isCtrlKey) {
332
327
  mentionsEvent({
333
328
  event,
@@ -339,7 +334,7 @@ const CommonEditor = /*#__PURE__*/forwardRef((props, ref) => {
339
334
  type,
340
335
  mentionsRef
341
336
  });
342
- } else if (isCtrlKey || isUpandDown) {
337
+ } else if (isCtrlKey) {
343
338
  commands({
344
339
  event,
345
340
  editor,
@@ -409,154 +404,166 @@ const CommonEditor = /*#__PURE__*/forwardRef((props, ref) => {
409
404
  }
410
405
  return style;
411
406
  }, [pageBgImage, pageColor]);
412
- const handleContextMenu = e => {
413
- if (!readOnly) {
414
- e.preventDefault();
415
- e.stopPropagation();
407
+ const themeProps = getTheme(selectedTheme);
408
+ const handleCursorScroll = container => {
409
+ const cursorPosition = window.getSelection()?.getRangeAt(0).getBoundingClientRect();
410
+ const containerBottom = container.getBoundingClientRect().bottom;
411
+ if (cursorPosition?.bottom > containerBottom - 250) {
412
+ container.scrollBy({
413
+ top: 200,
414
+ behavior: 'smooth'
415
+ });
416
416
  }
417
417
  };
418
- return /*#__PURE__*/_jsx(EditorProvider, {
419
- theme: theme,
420
- editor: editor,
421
- children: /*#__PURE__*/_jsx(DialogWrapper, {
422
- classes: classes,
423
- ...props,
424
- fullScreen: fullScreen,
425
- footer: footer || "",
426
- children: /*#__PURE__*/_jsx(Box, {
427
- component: "div",
428
- className: `et-wrpr stimulate-${breakpoint} ${editorClass || ""} ${isIframe ? "iframe-editor" : ""}`,
429
- sx: classes.root,
430
- style: {
431
- ...dotBg
432
- },
433
- "data-breakpoint": breakpoint,
434
- onContextMenu: handleContextMenu,
435
- children: /*#__PURE__*/_jsxs(Slate, {
436
- editor: editor,
437
- initialValue: value,
438
- onChange: handleEditorChange,
439
- children: [/*#__PURE__*/_jsx(DragAndDrop, {
440
- children: /*#__PURE__*/_jsxs(Overlay, {
441
- children: [/*#__PURE__*/_jsx(Box, {
442
- className: `${hasTopBanner() ? "has-topbanner" : ""} ${!pageColor ? "no-color" : ""} ${isScrolling ? "" : "hideScroll"} scrollable-content scrollSmooth`,
443
- sx: classes.slateWrapper,
444
- id: "slate-wrapper-scroll-container"
445
- // style={editorWrapperStyle}
446
- ,
447
- ref: editorWrapper,
448
- onClick: e => {
449
- handleInsertLastElement(e, editor);
450
- },
451
- onScroll: handleScroll,
452
- style: editorWrapperStyle,
453
- children: /*#__PURE__*/_jsxs(Box, {
454
- component: "div",
455
- className: "max-content",
456
- "data-info": outsideEditorClickLabel,
457
- children: [renderTopBanner(), /*#__PURE__*/_jsx("div", {
458
- className: "scroll-area",
459
- "data-info": outsideEditorClickLabel,
418
+ return /*#__PURE__*/_jsx(ThemeContext.Provider, {
419
+ value: {
420
+ openTheme,
421
+ setOpenTheme
422
+ },
423
+ children: /*#__PURE__*/_jsx(CssVarsProvider, {
424
+ theme: extendTheme(selectedTheme?.theme?.cssVars || {}),
425
+ children: /*#__PURE__*/_jsxs(EditorProvider, {
426
+ theme: theme,
427
+ editor: editor,
428
+ children: [showThemeButtons ? /*#__PURE__*/_jsxs("div", {
429
+ style: {
430
+ display: "flex",
431
+ justifyContent: "end",
432
+ alignItems: "center",
433
+ gap: "8px",
434
+ width: "70vw",
435
+ margin: "auto"
436
+ },
437
+ children: [/*#__PURE__*/_jsx(IconButton, {
438
+ onClick: () => setOpenTheme(true),
439
+ children: /*#__PURE__*/_jsx(ThemePaintIcon, {})
440
+ }), /*#__PURE__*/_jsx(IconButton, {
441
+ onClick: () => setOpenAITheme(true),
442
+ style: {
443
+ marginTop: "4px"
444
+ },
445
+ children: /*#__PURE__*/_jsx(ThemeAIIcon, {})
446
+ })]
447
+ }) : null, /*#__PURE__*/_jsx(DialogWrapper, {
448
+ classes: classes,
449
+ ...props,
450
+ fullScreen: fullScreen,
451
+ footer: footer || "",
452
+ children: /*#__PURE__*/_jsx(Box, {
453
+ component: "div",
454
+ className: `${editorClass || ""} ${isIframe ? "iframe-editor" : ""}`,
455
+ sx: classes.root,
456
+ style: {
457
+ ...dotBg
458
+ },
459
+ children: /*#__PURE__*/_jsxs(Slate, {
460
+ editor: editor,
461
+ initialValue: value,
462
+ onChange: handleEditorChange,
463
+ children: [/*#__PURE__*/_jsx(DragAndDrop, {
464
+ children: /*#__PURE__*/_jsxs(Overlay, {
465
+ children: [/*#__PURE__*/_jsx(Box, {
466
+ className: `${hasTopBanner() ? "has-topbanner" : ""} ${!pageColor ? "no-color" : ""} ${isScrolling ? "" : "hideScroll"} scrollable-content scrollSmooth`,
467
+ sx: classes.slateWrapper,
468
+ id: "slate-wrapper-scroll-container"
469
+ // style={editorWrapperStyle}
470
+ ,
471
+ ref: editorWrapper,
472
+ onClick: e => {
473
+ handleInsertLastElement(e, editor);
474
+ },
475
+ onScroll: handleScroll,
476
+ style: editorWrapperStyle,
460
477
  children: /*#__PURE__*/_jsxs(Box, {
461
478
  component: "div",
462
- className: `editor-wrapper ${pageWidth === "fixed" ? "fixed" : "full"}`,
463
- sx: {
464
- backgroundColor: "transparent",
465
- padding: {
466
- ...getTRBLBreakPoints(bannerSpacing)
467
- },
468
- width: !pageWidth || pageWidth === "fixed" ? fixedWidth : fullWidth,
469
- height: viewport.h ? `${viewport.h}px` : `100%`,
470
- alignSelf: "center",
471
- transformOrigin: "left top",
472
- transition: "all 0.3s",
473
- minHeight: "87%",
474
- maxWidth: pageMaxWidth ? `${parseInt(pageMaxWidth)}px !important` : "auto"
475
- },
479
+ className: "max-content",
480
+ sx: themeProps?.sxProps || {},
476
481
  "data-info": outsideEditorClickLabel,
477
- children: [/*#__PURE__*/_jsx(Editable, {
478
- className: "innert-editor-textbox",
479
- readOnly: isReadOnly,
480
- renderElement: renderElement,
481
- renderLeaf: renderLeaf,
482
- decorate: decorators,
483
- onKeyDown: onKeyDown
484
- }), !readOnly ? /*#__PURE__*/_jsx(MentionsPopup, {
485
- ref: mentionsRef,
486
- mentions: mentions,
487
- setMentions: setMentions,
488
- editor: editor,
489
- target: target,
490
- index: index,
491
- chars: chars,
492
- type: type,
482
+ children: [renderTopBanner(), /*#__PURE__*/_jsx("div", {
483
+ className: "scroll-area",
484
+ "data-info": outsideEditorClickLabel,
485
+ children: /*#__PURE__*/_jsxs(Box, {
486
+ component: "div",
487
+ className: `editor-wrapper ${pageWidth === "fixed" ? "fixed" : "full"}`,
488
+ sx: {
489
+ backgroundColor: "transparent",
490
+ padding: {
491
+ ...getTRBLBreakPoints(bannerSpacing)
492
+ },
493
+ width: !pageWidth || pageWidth === "fixed" ? fixedWidth : fullWidth,
494
+ height: viewport.h ? `${viewport.h}px` : `100%`,
495
+ alignSelf: "center",
496
+ transformOrigin: "left top",
497
+ transition: "all 0.3s",
498
+ minHeight: "87%",
499
+ maxWidth: pageMaxWidth ? `${parseInt(pageMaxWidth)}px !important` : "auto"
500
+ },
501
+ "data-info": outsideEditorClickLabel,
502
+ children: [/*#__PURE__*/_jsx(Editable, {
503
+ className: "innert-editor-textbox",
504
+ readOnly: isReadOnly,
505
+ renderElement: renderElement,
506
+ renderLeaf: renderLeaf,
507
+ decorate: decorators,
508
+ onKeyDown: onKeyDown,
509
+ onSelect: () => handleCursorScroll(editorWrapper.current)
510
+ }), !readOnly ? /*#__PURE__*/_jsx(MentionsPopup, {
511
+ ref: mentionsRef,
512
+ mentions: mentions,
513
+ setMentions: setMentions,
514
+ editor: editor,
515
+ target: target,
516
+ index: index,
517
+ chars: chars,
518
+ type: type,
519
+ theme: theme
520
+ }) : null]
521
+ })
522
+ }), !hideMiniToolBar ? /*#__PURE__*/_jsx(MiniToolbar, {
523
+ customProps: customProps,
524
+ toolbarOptions: toolbarOptions,
493
525
  theme: theme
494
- }) : null, /*#__PURE__*/_jsx(RnDCopy, {
495
- readOnly: readOnly
526
+ }) : null, /*#__PURE__*/_jsx(PopoverAIInput, {
527
+ otherProps: otherProps || {}
528
+ }), footer && (fullScreen || readOnly) && /*#__PURE__*/_jsx(Typography, {
529
+ sx: {
530
+ color: "rgb(100, 116, 139)",
531
+ fontSize: "13px",
532
+ paddingBottom: hideMiniToolBar ? "0px" : "12px",
533
+ cursor: "pointer"
534
+ },
535
+ align: "center",
536
+ "data-info": outsideEditorClickLabel,
537
+ onClick: handleFooterClick,
538
+ children: footer
539
+ }), openTheme ? /*#__PURE__*/_jsx(ThemeSettings, {
540
+ open: openTheme,
541
+ setOpen: setOpenTheme,
542
+ editor: editor,
543
+ services: otherProps?.services
544
+ }) : null, /*#__PURE__*/_jsx(ThemeSettingsAI, {
545
+ openAITheme: openAITheme,
546
+ setOpenAITheme: setOpenAITheme,
547
+ onSaveTheme: otherProps?.onSaveTheme
496
548
  })]
497
549
  })
498
- }), !hideMiniToolBar ? /*#__PURE__*/_jsx(MiniToolbar, {
499
- customProps: customProps,
500
- theme: theme
501
- }) : null, /*#__PURE__*/_jsx(PopoverAIInput, {
502
- otherProps: otherProps || {}
503
- }), footer && (fullScreen || readOnly) && /*#__PURE__*/_jsx(Typography, {
504
- sx: {
505
- color: "rgb(100, 116, 139)",
506
- fontSize: "13px",
507
- paddingBottom: hideMiniToolBar ? "0px" : "12px",
508
- cursor: "pointer"
509
- },
510
- align: "center",
511
- "data-info": outsideEditorClickLabel,
512
- onClick: handleFooterClick,
513
- children: footer
514
- })]
550
+ }), !readOnly ? /*#__PURE__*/_jsx(PopupTool, {
551
+ onDrawerOpen: onDrawerOpen,
552
+ theme: theme,
553
+ setIsTextSelected: setIsTextSelected,
554
+ customProps: customProps
555
+ }) : null]
515
556
  })
516
- }), !readOnly ? /*#__PURE__*/_jsx(PopupTool, {
517
- onDrawerOpen: onDrawerOpen,
518
- theme: theme,
519
- setIsTextSelected: setIsTextSelected,
520
- customProps: customProps
521
- }) : null, !readOnly ? /*#__PURE__*/_jsx(SwitchViewport, {
522
- breakpoint: breakpoint,
523
- onChange: b => onSwitchBreakpoint(b)
524
- }) : null]
525
- })
526
- }), htmlAction.showInput && /*#__PURE__*/_jsx(CodeToText, {
527
- ...htmlAction,
528
- handleCodeToText: handleCodeToText
529
- })]
530
- }, id)
557
+ }), htmlAction.showInput && /*#__PURE__*/_jsx(CodeToText, {
558
+ ...htmlAction,
559
+ handleCodeToText: handleCodeToText
560
+ })]
561
+ }, id)
562
+ })
563
+ })]
531
564
  })
532
565
  })
533
566
  });
534
567
  });
535
568
  CommonEditor.displayName = "CommonEditor";
536
- CommonEditor.propTypes = {
537
- /** Id of the content */
538
- id: PropTypes.string,
539
- /** Set to true for readonly mode */
540
- readOnly: PropTypes.oneOf(["readonly", ""]),
541
- /** It can be a draft js content or a slate js content */
542
- content: PropTypes.any,
543
- /** User details */
544
- user: PropTypes.object,
545
- /** API URL base for pages api calls */
546
- apiHOST: PropTypes.string,
547
- /** A callback function with updated edited content,
548
- * this method will get called whenever the content changes happen and wait idle for 500ms
549
- * uses the debounce mechanism
550
- */
551
- onSave: PropTypes.func,
552
- /**
553
- * MUI theme object form parent application
554
- */
555
- theme: PropTypes.object,
556
- /**
557
- * Editor component based props can be passed here
558
- * @property {bool} isSignerDetailsRequired - To make username and email required in Forms
559
- */
560
- otherProps: PropTypes.object
561
- };
562
569
  export default CommonEditor;
@@ -1,7 +1,8 @@
1
1
  import React from "react";
2
2
  import { Dialog, DialogTitle, DialogContent, IconButton, Grid } from "@mui/material";
3
3
  import CloseIcon from "@mui/icons-material/Close";
4
- import ViewportStimulator from "./common/RnD/Theme/ViewportStimulator";
4
+ // import styled from "@emotion/styled";
5
+ // import commonStyle from "./commonStyle";
5
6
  import { jsx as _jsx } from "react/jsx-runtime";
6
7
  import { jsxs as _jsxs } from "react/jsx-runtime";
7
8
  const DialogWrapper = props => {
@@ -42,9 +43,7 @@ const DialogWrapper = props => {
42
43
  }), /*#__PURE__*/_jsx(DialogContent, {
43
44
  children: children
44
45
  })]
45
- }) : /*#__PURE__*/_jsx(ViewportStimulator, {
46
- children: children
47
- });
46
+ }) : children;
48
47
  };
49
48
  DialogWrapper.defaultProps = {
50
49
  fullScreen: false,
@@ -245,6 +245,13 @@ blockquote {
245
245
  width: 17px !important;
246
246
  }
247
247
 
248
+ .react-datepicker__input-container input {
249
+ height: 40px !important;
250
+ border: 1px solid #ccc;
251
+ border-radius: 5px;
252
+ width: 100%;
253
+ }
254
+
248
255
  .close-popupbtn {
249
256
  border-radius: 4px !important;
250
257
  width: 24px;
@@ -1127,8 +1134,4 @@ blockquote {
1127
1134
 
1128
1135
  .scrollSmooth {
1129
1136
  scroll-behavior: smooth;
1130
- }
1131
-
1132
- .freegrid-section {
1133
- max-width: 100% !important;
1134
1137
  }