@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
@@ -1,58 +1,181 @@
1
- import { Box, MenuItem, Select } from "@mui/material";
2
- import { defaultTheme } from ".";
3
- import { useEditorTheme } from "../hooks/useEditorTheme";
4
- import { useEffect, useState } from "react";
1
+ import { MenuItem, Select, useTheme } from "@mui/material";
2
+ import { fontOptions } from "../utils/font";
3
+ import { toolbarGroups } from "../Toolbar/toolbarGroups";
5
4
  import { jsx as _jsx } from "react/jsx-runtime";
6
5
  import { jsxs as _jsxs } from "react/jsx-runtime";
7
- function ThemeList({
8
- editor,
9
- services = () => {}
10
- }) {
11
- const [themes, setThemes] = useState([]);
12
- const [loading, setLoading] = useState(false);
13
- console.log("loading", loading);
14
- const getThemesList = async () => {
15
- setLoading(true);
16
- try {
17
- const result = await services("getThemes", {});
18
- setThemes(result?.data || []);
19
- } catch (err) {
20
- console.log(err);
21
- }
22
- setLoading(false);
23
- };
6
+ const themes = [{
7
+ label: "Theme 1",
8
+ colors: ["#c90c1f", "#ff5d05"]
9
+ }, {
10
+ label: "Theme 2",
11
+ colors: ["#4c0be3", "#43f7ee"]
12
+ }, {
13
+ label: "Theme 3",
14
+ colors: ["#22f20f", "#fff705"]
15
+ }];
16
+ const allTools = toolbarGroups.flat();
17
+ function ThemeList(props) {
24
18
  const {
25
- updateTheme
26
- } = useEditorTheme();
27
- useEffect(() => {
28
- getThemesList();
29
- }, []);
30
- const handleThemeChange = e => {
31
- const {
32
- value
33
- } = e.target;
34
- const selectedTheme = themes.find(t => t.id === value) || defaultTheme;
35
- updateTheme(selectedTheme, "THEME_CHANGE");
19
+ selectedTheme,
20
+ setSelectedTheme
21
+ } = props;
22
+ const fontWeight = allTools.find(f => f.format === "fontWeight");
23
+ const fontStyles = [{
24
+ text: "Bold",
25
+ value: "bold",
26
+ styleField: "fontWeight"
27
+ }, {
28
+ text: "Italic",
29
+ value: "italic",
30
+ styleField: "fontStyle"
31
+ }
32
+ // {
33
+ // text: "Underline",
34
+ // value: "underline",
35
+ // styleField: "textDecoration",
36
+ // },
37
+ // {
38
+ // text: "Line through",
39
+ // value: "line-through",
40
+ // styleField: "textDecoration",
41
+ // },
42
+ ];
43
+
44
+ const theme = useTheme();
45
+ const colorVars = theme?.vars?.colors || {};
46
+ const handleTypographyTheme = (key, value, elementType) => {
47
+ setSelectedTheme(prev => {
48
+ const newValue = {
49
+ ...prev,
50
+ typography: {
51
+ ...(prev.typography || {}),
52
+ [elementType]: {
53
+ ...(prev?.typography?.[elementType] || {}),
54
+ [key]: value
55
+ }
56
+ }
57
+ };
58
+ if (!value) {
59
+ delete newValue?.typography?.[elementType]?.[key];
60
+ }
61
+ return newValue;
62
+ });
36
63
  };
37
- return /*#__PURE__*/_jsx(Box, {
38
- sx: {
39
- padding: "10px",
40
- background: "#efefef",
41
- borderRadius: "6px"
42
- },
43
- children: /*#__PURE__*/_jsxs(Select, {
44
- onChange: handleThemeChange,
45
- defaultValue: 0,
46
- children: [/*#__PURE__*/_jsx(MenuItem, {
47
- value: 0,
48
- children: "Default Theme"
49
- }), themes.map((theme, i) => {
50
- return /*#__PURE__*/_jsx(MenuItem, {
51
- value: theme?.id,
52
- children: theme?.name
53
- }, i);
64
+ return /*#__PURE__*/_jsxs("div", {
65
+ children: [themes.map((theme, i) => {
66
+ return /*#__PURE__*/_jsxs("button", {
67
+ style: {
68
+ margin: "10px"
69
+ },
70
+ onClick: () => setSelectedTheme(prev => ({
71
+ ...prev,
72
+ colors: theme.colors
73
+ })),
74
+ children: [theme.label, /*#__PURE__*/_jsx("div", {
75
+ children: theme.colors.map((c, j) => {
76
+ return /*#__PURE__*/_jsx("div", {
77
+ style: {
78
+ width: "20px",
79
+ height: "20px",
80
+ background: c,
81
+ margin: "10px"
82
+ }
83
+ }, j);
84
+ })
85
+ })]
86
+ }, i);
87
+ }), /*#__PURE__*/_jsxs("div", {
88
+ children: ["Heading 1 Font Family", /*#__PURE__*/_jsx(Select
89
+ // value={""}
90
+ , {
91
+ label: "Font Family",
92
+ onChange: e => {
93
+ handleTypographyTheme("fontFamily", e.target.value, "h1");
94
+ },
95
+ children: fontOptions.map((font, i) => {
96
+ const {
97
+ text,
98
+ value
99
+ } = font;
100
+ return /*#__PURE__*/_jsx(MenuItem, {
101
+ value: value,
102
+ children: text
103
+ }, i);
104
+ })
105
+ }), "Font Weight", /*#__PURE__*/_jsx(Select
106
+ // value={""}
107
+ , {
108
+ label: "Font Weight",
109
+ onChange: e => {
110
+ handleTypographyTheme("fontWeight", e.target.value, "h1");
111
+ },
112
+ children: fontWeight.options.map((option, i) => {
113
+ const {
114
+ text,
115
+ value
116
+ } = option;
117
+ return /*#__PURE__*/_jsx(MenuItem, {
118
+ value: value,
119
+ children: text
120
+ }, i);
121
+ })
122
+ }), /*#__PURE__*/_jsx("input", {
123
+ type: "number",
124
+ placeholder: "font size",
125
+ onChange: e => {
126
+ handleTypographyTheme("fontSize", e.target.value, "h1");
127
+ }
128
+ }), /*#__PURE__*/_jsxs("div", {
129
+ children: ["Text", /*#__PURE__*/_jsx("br", {}), "Theme color", Object.values(colorVars).map((colorVar, i) => {
130
+ return /*#__PURE__*/_jsx("button", {
131
+ style: {
132
+ width: "20px",
133
+ height: "20px",
134
+ background: colorVar,
135
+ margin: "10px",
136
+ outline: "none"
137
+ },
138
+ onClick: () => handleTypographyTheme("color", colorVar, "h1")
139
+ }, i);
140
+ }), "normal color", /*#__PURE__*/_jsx("button", {
141
+ style: {
142
+ width: "20px",
143
+ height: "20px",
144
+ background: "#ff00e1",
145
+ margin: "10px",
146
+ outline: "none"
147
+ },
148
+ onClick: () => handleTypographyTheme("color", "#ff00e1", "h1")
149
+ })]
150
+ }), /*#__PURE__*/_jsxs("div", {
151
+ children: ["Font styles", fontStyles.map((option, i) => {
152
+ const styles = selectedTheme?.typography?.h1 || {};
153
+ const {
154
+ text,
155
+ value,
156
+ styleField
157
+ } = option;
158
+ return /*#__PURE__*/_jsxs("button", {
159
+ onClick: () => {
160
+ handleTypographyTheme(styleField, styles[styleField] === value ? null : value, "h1");
161
+ },
162
+ children: [text, " ", styles[styleField] === value]
163
+ }, i);
164
+ })]
165
+ }), /*#__PURE__*/_jsx("input", {
166
+ type: "number",
167
+ placeholder: "Margin text Spacing",
168
+ onChange: e => {
169
+ handleTypographyTheme("letterSpacing", e.target.value, "h1");
170
+ }
171
+ }), /*#__PURE__*/_jsx("input", {
172
+ type: "number",
173
+ placeholder: "Line spacing",
174
+ onChange: e => {
175
+ handleTypographyTheme("lineHeight", e.target.value, "h1");
176
+ }
54
177
  })]
55
- })
178
+ })]
56
179
  });
57
180
  }
58
181
  export default ThemeList;
@@ -0,0 +1,168 @@
1
+ import { Editor, Transforms, Node, Path } from "slate";
2
+ import { isSelectionInNodeType, getCaretPosition, onPasteRnDNode, bringItemToFB } from "../../helper";
3
+ import focusOnNewItem from "../../helper/RnD/focusOnNewItem";
4
+ const RND_ITEM_TYPES = ["freegrid", "freegridItem", "freegridBox"];
5
+ const parsePath = path => path?.split("|").map(m => parseInt(m));
6
+ const selectAll = (event, {
7
+ editor
8
+ }) => {
9
+ try {
10
+ const {
11
+ selected,
12
+ match
13
+ } = isSelectionInNodeType(editor, "freegridItem");
14
+ const sel = getCaretPosition(editor);
15
+
16
+ // if not selection prevent the events
17
+ if (!sel) {
18
+ event.preventDefault();
19
+ return;
20
+ }
21
+
22
+ // only prevent default for freegrid item
23
+ if (selected) {
24
+ event.preventDefault();
25
+ const [item, path] = match;
26
+ switch (item?.childType) {
27
+ case "text":
28
+ const range = Editor.range(editor, path);
29
+ Transforms.select(editor, range);
30
+ break;
31
+ default:
32
+ return null;
33
+ }
34
+ }
35
+ } catch (err) {
36
+ console.log(err);
37
+ }
38
+ };
39
+ const onCopy = async (event, {
40
+ editor
41
+ }) => {
42
+ try {
43
+ const {
44
+ path,
45
+ enable
46
+ } = window?.selectedRnDElement || {};
47
+ // only copy RnD items in Srag enable mode not in edit mode
48
+ if (path && enable === 1) {
49
+ let pPath = parsePath(path);
50
+ let node = Node.get(editor, pPath);
51
+ const isRnD = RND_ITEM_TYPES.indexOf(node?.type) > -1;
52
+ if (isRnD) {
53
+ event.preventDefault();
54
+ if (node?.type === "freegrid") {
55
+ node = Node.get(editor, Path.parent(pPath));
56
+ }
57
+ const jsonFragment = JSON.stringify(node);
58
+ window.copiedNode = jsonFragment;
59
+ }
60
+ }
61
+ } catch (err) {
62
+ console.log(err);
63
+ }
64
+ };
65
+ const onCut = (event, {
66
+ editor
67
+ }) => {
68
+ try {
69
+ const {
70
+ path,
71
+ enable
72
+ } = window?.selectedRnDElement || {};
73
+ onCopy(event, {
74
+ editor
75
+ });
76
+ // remove the node
77
+ if (path && enable === 1) {
78
+ const pPath = parsePath(path);
79
+ Transforms.removeNodes(editor, {
80
+ at: pPath
81
+ });
82
+ // change / remove the focus to parent
83
+ const currentSelectedNode = Node.get(editor, pPath);
84
+ const sPath = currentSelectedNode?.type !== "freegrid" ? Path.parent(pPath) : pPath;
85
+ focusOnNewItem(editor, sPath, {
86
+ setSelectedElement: window.updateSelectedItem
87
+ });
88
+ }
89
+ } catch (err) {
90
+ console.log(err);
91
+ }
92
+ };
93
+ const onPaste = async (event, {
94
+ editor
95
+ }) => {
96
+ try {
97
+ const {
98
+ path,
99
+ enable
100
+ } = window?.selectedRnDElement || {};
101
+ if (path && enable === 1) {
102
+ event.preventDefault();
103
+ const pPath = parsePath(path);
104
+ const currentSelectedNode = Node.get(editor, pPath);
105
+ let sPath = currentSelectedNode?.type !== "freegrid" ? Path.parent(pPath) : pPath;
106
+ const sectionNode = Node.get(editor, sPath);
107
+ const np = onPasteRnDNode(editor, {
108
+ path: sPath,
109
+ children: sectionNode?.children,
110
+ slateNodes: null
111
+ });
112
+ if (np && window.updateSelectedItem) {
113
+ focusOnNewItem(editor, np, {
114
+ setSelectedElement: window.updateSelectedItem
115
+ });
116
+ }
117
+ }
118
+ } catch (err) {
119
+ console.log(err);
120
+ }
121
+ };
122
+ const onBringFront = (event, {
123
+ editor
124
+ }) => {
125
+ try {
126
+ const {
127
+ path,
128
+ enable
129
+ } = window?.selectedRnDElement || {};
130
+ if (path && enable === 1) {
131
+ event.preventDefault();
132
+ bringItemToFB(editor, {
133
+ path: parsePath(path),
134
+ moveFront: true
135
+ });
136
+ }
137
+ } catch (err) {
138
+ console.log(err);
139
+ }
140
+ };
141
+ const onBringBack = (event, {
142
+ editor
143
+ }) => {
144
+ try {
145
+ const {
146
+ path,
147
+ enable
148
+ } = window?.selectedRnDElement || {};
149
+ if (path && enable === 1) {
150
+ event.preventDefault();
151
+ bringItemToFB(editor, {
152
+ path: parsePath(path),
153
+ moveFront: false
154
+ });
155
+ }
156
+ } catch (err) {
157
+ console.log(err);
158
+ }
159
+ };
160
+ const RnDCtrlCmds = {
161
+ ArrowUp: onBringFront,
162
+ ArrowDown: onBringBack,
163
+ a: selectAll,
164
+ c: onCopy,
165
+ v: onPaste,
166
+ x: onCut
167
+ };
168
+ export default RnDCtrlCmds;