@flozy/editor 11.0.9 → 11.1.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (158) hide show
  1. package/dist/Editor/ChatEditor.js +16 -17
  2. package/dist/Editor/CommonEditor.js +28 -141
  3. package/dist/Editor/DialogWrapper.js +25 -31
  4. package/dist/Editor/Editor.css +11 -39
  5. package/dist/Editor/Elements/AI/PopoverAIInput.js +3 -11
  6. package/dist/Editor/Elements/AI/Styles.js +0 -1
  7. package/dist/Editor/Elements/Accordion/Accordion.js +22 -28
  8. package/dist/Editor/Elements/Accordion/AccordionButton.js +3 -12
  9. package/dist/Editor/Elements/AppHeader/AppHeader.js +3 -3
  10. package/dist/Editor/Elements/Attachments/Attachments.js +11 -153
  11. package/dist/Editor/Elements/Attachments/AttachmentsButton.js +3 -8
  12. package/dist/Editor/Elements/Button/EditorButton.js +7 -23
  13. package/dist/Editor/Elements/Color Picker/ColorButtons.js +14 -61
  14. package/dist/Editor/Elements/Color Picker/ColorPicker.css +1 -25
  15. package/dist/Editor/Elements/Color Picker/ColorPicker.js +7 -10
  16. package/dist/Editor/Elements/Color Picker/Styles.js +13 -15
  17. package/dist/Editor/Elements/DataView/Layouts/DataTypes/Components/MultiSelect.js +454 -0
  18. package/dist/Editor/Elements/DataView/Layouts/DataTypes/Components/Select.js +55 -134
  19. package/dist/Editor/Elements/DataView/Layouts/DataTypes/Components/SelectV1.js +8 -7
  20. package/dist/Editor/Elements/DataView/Layouts/DataTypes/PersonType.js +3 -8
  21. package/dist/Editor/Elements/DataView/Layouts/Options/EditProperty.js +1 -1
  22. package/dist/Editor/Elements/DataView/Layouts/TableStyles.js +1 -1
  23. package/dist/Editor/Elements/Embed/Embed.css +0 -5
  24. package/dist/Editor/Elements/Embed/Embed.js +43 -36
  25. package/dist/Editor/Elements/Embed/Image.js +23 -242
  26. package/dist/Editor/Elements/Embed/Video.js +32 -277
  27. package/dist/Editor/Elements/Form/FormField.js +1 -1
  28. package/dist/Editor/Elements/Form/Workflow/Styles.js +22 -24
  29. package/dist/Editor/Elements/Form/Workflow/constant.js +1 -25
  30. package/dist/Editor/Elements/FreeGrid/FreeGrid.js +74 -31
  31. package/dist/Editor/Elements/FreeGrid/FreeGridBox.js +5 -9
  32. package/dist/Editor/Elements/FreeGrid/FreeGridItem.js +1 -3
  33. package/dist/Editor/Elements/FreeGrid/Options/More.js +7 -7
  34. package/dist/Editor/Elements/FreeGrid/styles.js +0 -15
  35. package/dist/Editor/Elements/Grid/GridItem.js +1 -1
  36. package/dist/Editor/Elements/PageSettings/PageSettingsButton.js +1 -2
  37. package/dist/Editor/Elements/Signature/SignaturePopup.js +6 -13
  38. package/dist/Editor/Elements/SimpleText/index.js +1 -4
  39. package/dist/Editor/Elements/SimpleText/style.js +2 -2
  40. package/dist/Editor/Elements/Table/Table.js +4 -5
  41. package/dist/Editor/Elements/Table/TableCell.js +3 -10
  42. package/dist/Editor/Elements/Title/title.js +11 -10
  43. package/dist/Editor/Elements/TopBanner/TopBanner.js +2 -4
  44. package/dist/Editor/Elements/TopBanner/TopBannerButton.js +3 -5
  45. package/dist/Editor/Elements/Variables/VariableButton.js +1 -10
  46. package/dist/Editor/MiniEditor.js +1 -2
  47. package/dist/Editor/Styles/EditorStyles.js +5 -20
  48. package/dist/Editor/Toolbar/FormatTools/Dropdown.js +3 -27
  49. package/dist/Editor/Toolbar/FormatTools/FontFamilyAutocomplete.js +3 -4
  50. package/dist/Editor/Toolbar/FormatTools/MarkButton.js +2 -2
  51. package/dist/Editor/Toolbar/FormatTools/TextSize.js +29 -33
  52. package/dist/Editor/Toolbar/Mini/MiniToolbar.js +1 -2
  53. package/dist/Editor/Toolbar/PopupTool/MiniTextFormat/MiniColorPicker.js +2 -4
  54. package/dist/Editor/Toolbar/PopupTool/MiniTextFormat/SelectFontSize.js +23 -25
  55. package/dist/Editor/Toolbar/PopupTool/MiniTextFormat/SelectList.js +7 -25
  56. package/dist/Editor/Toolbar/PopupTool/MiniTextFormat/SelectTypography.js +42 -167
  57. package/dist/Editor/Toolbar/PopupTool/MiniTextFormat/index.js +8 -24
  58. package/dist/Editor/Toolbar/PopupTool/PopperHeader.js +1 -2
  59. package/dist/Editor/Toolbar/PopupTool/PopupToolStyle.js +10 -70
  60. package/dist/Editor/Toolbar/PopupTool/TextFormat.js +14 -73
  61. package/dist/Editor/Toolbar/PopupTool/index.js +4 -7
  62. package/dist/Editor/Toolbar/toolbarGroups.js +10 -56
  63. package/dist/Editor/common/ColorPickerButton.js +16 -38
  64. package/dist/Editor/common/DnD/DragHandleButton.js +1 -1
  65. package/dist/Editor/common/FontLoader/FontLoader.js +0 -4
  66. package/dist/Editor/common/Icon.js +0 -28
  67. package/dist/Editor/common/ImageSelector/ImageSelector.js +7 -45
  68. package/dist/Editor/common/ImageSelector/Options/Upload.js +11 -26
  69. package/dist/Editor/common/ImageSelector/Styles.js +9 -3
  70. package/dist/Editor/common/LinkSettings/NavComponents.js +2 -6
  71. package/dist/Editor/common/MentionsPopup/index.js +1 -9
  72. package/dist/Editor/common/RnD/ElementSettings/OtherSettings/Settings.js +1 -2
  73. package/dist/Editor/common/RnD/ElementSettings/Settings/AppHeaderSettings.js +2 -3
  74. package/dist/Editor/common/RnD/ElementSettings/Settings/BoxSettings.js +2 -3
  75. package/dist/Editor/common/RnD/ElementSettings/Settings/ButtonSettings.js +2 -3
  76. package/dist/Editor/common/RnD/ElementSettings/Settings/CodeSettings.js +2 -3
  77. package/dist/Editor/common/RnD/ElementSettings/Settings/FormSettings.js +2 -4
  78. package/dist/Editor/common/RnD/ElementSettings/Settings/ImageSettings.js +7 -20
  79. package/dist/Editor/common/RnD/ElementSettings/Settings/TableSettings.js +2 -3
  80. package/dist/Editor/common/RnD/ElementSettings/Settings/TextSettings.js +1 -9
  81. package/dist/Editor/common/RnD/ElementSettings/Settings/VideoSettings.js +7 -20
  82. package/dist/Editor/common/RnD/GuideLines/styles.js +1 -1
  83. package/dist/Editor/common/RnD/SwitchViewport/SwitchViewport.js +2 -11
  84. package/dist/Editor/common/RnD/Theme/ViewportStimulator.js +3 -6
  85. package/dist/Editor/common/RnD/Utils/gridDropItem.js +11 -28
  86. package/dist/Editor/common/RnD/Utils/index.js +1 -3
  87. package/dist/Editor/common/RnD/VirtualElement/VirtualTextElement.js +63 -52
  88. package/dist/Editor/common/RnD/VirtualElement/helper.js +130 -320
  89. package/dist/Editor/common/RnD/VirtualElement/styles.js +0 -22
  90. package/dist/Editor/common/RnD/index.js +14 -61
  91. package/dist/Editor/common/Shorthands/elements.js +4 -62
  92. package/dist/Editor/common/StyleBuilder/buttonStyle.js +2 -4
  93. package/dist/Editor/common/StyleBuilder/embedVideoStyle.js +0 -4
  94. package/dist/Editor/common/StyleBuilder/fieldStyle.js +0 -1
  95. package/dist/Editor/common/StyleBuilder/fieldTypes/backgroundImage.js +2 -15
  96. package/dist/Editor/common/StyleBuilder/fieldTypes/bannerSpacing.js +2 -12
  97. package/dist/Editor/common/StyleBuilder/fieldTypes/borderRadius.js +7 -15
  98. package/dist/Editor/common/StyleBuilder/fieldTypes/card.js +8 -16
  99. package/dist/Editor/common/StyleBuilder/fieldTypes/color.js +10 -36
  100. package/dist/Editor/common/StyleBuilder/fieldTypes/fontSize.js +7 -16
  101. package/dist/Editor/common/StyleBuilder/fieldTypes/index.js +1 -3
  102. package/dist/Editor/common/StyleBuilder/fieldTypes/menusArray.js +0 -2
  103. package/dist/Editor/common/StyleBuilder/fieldTypes/textOptions.js +7 -15
  104. package/dist/Editor/common/StyleBuilder/formStyle.js +13 -19
  105. package/dist/Editor/common/StyleBuilder/index.js +4 -8
  106. package/dist/Editor/common/Uploader.js +17 -125
  107. package/dist/Editor/common/iconslist.js +0 -21
  108. package/dist/Editor/commonStyle.js +18 -67
  109. package/dist/Editor/helper/index.js +2 -10
  110. package/dist/Editor/helper/theme.js +2 -203
  111. package/dist/Editor/hooks/useMouseMove.js +3 -9
  112. package/dist/Editor/hooks/useTable.js +1 -62
  113. package/dist/Editor/plugins/withEmbeds.js +1 -12
  114. package/dist/Editor/plugins/withHTML.js +3 -58
  115. package/dist/Editor/plugins/withTable.js +1 -1
  116. package/dist/Editor/service/fileupload.js +0 -70
  117. package/dist/Editor/theme/ThemeList.js +173 -50
  118. package/dist/Editor/utils/SlateUtilityFunctions.js +40 -191
  119. package/dist/Editor/utils/accordion.js +39 -67
  120. package/dist/Editor/utils/button.js +17 -1
  121. package/dist/Editor/utils/draftToSlate.js +2 -3
  122. package/dist/Editor/utils/events.js +89 -94
  123. package/dist/Editor/utils/font.js +37 -40
  124. package/dist/Editor/utils/helper.js +23 -100
  125. package/dist/Editor/utils/insertAppHeader.js +4 -8
  126. package/package.json +4 -4
  127. package/dist/Editor/Elements/Attachments/AttachmentStyles.js +0 -16
  128. package/dist/Editor/Elements/FreeGrid/helper.js +0 -194
  129. package/dist/Editor/Toolbar/PopupTool/ThemeTextFormat.js +0 -439
  130. package/dist/Editor/assets/svg/BackIcon.js +0 -18
  131. package/dist/Editor/assets/svg/ThemeIcons.js +0 -293
  132. package/dist/Editor/common/CustomColorPicker/index.js +0 -130
  133. package/dist/Editor/common/CustomColorPicker/style.js +0 -53
  134. package/dist/Editor/common/CustomDialog2/index.js +0 -94
  135. package/dist/Editor/common/CustomDialog2/style.js +0 -67
  136. package/dist/Editor/common/CustomSelect.js +0 -43
  137. package/dist/Editor/common/RnD/Theme/MainThemeProvider.js +0 -17
  138. package/dist/Editor/common/StyleBuilder/fieldTypes/embedUpload.js +0 -115
  139. package/dist/Editor/common/UploaderWithProgress.js +0 -183
  140. package/dist/Editor/helper/textIndeces.js +0 -58
  141. package/dist/Editor/hooks/useEditorTheme.js +0 -153
  142. package/dist/Editor/hooks/useThemeValues.js +0 -63
  143. package/dist/Editor/theme/index.js +0 -149
  144. package/dist/Editor/themeSettings/ActiveTheme.js +0 -82
  145. package/dist/Editor/themeSettings/buttons/index.js +0 -300
  146. package/dist/Editor/themeSettings/buttons/style.js +0 -23
  147. package/dist/Editor/themeSettings/colorTheme/index.js +0 -310
  148. package/dist/Editor/themeSettings/colorTheme/style.js +0 -81
  149. package/dist/Editor/themeSettings/fonts/PreviewElement.js +0 -121
  150. package/dist/Editor/themeSettings/fonts/index.js +0 -240
  151. package/dist/Editor/themeSettings/fonts/style.js +0 -62
  152. package/dist/Editor/themeSettings/icons.js +0 -60
  153. package/dist/Editor/themeSettings/index.js +0 -380
  154. package/dist/Editor/themeSettings/style.js +0 -299
  155. package/dist/Editor/themeSettingsAI/icons.js +0 -96
  156. package/dist/Editor/themeSettingsAI/index.js +0 -355
  157. package/dist/Editor/themeSettingsAI/saveTheme.js +0 -202
  158. package/dist/Editor/themeSettingsAI/style.js +0 -332
@@ -1,5 +1,7 @@
1
1
  import { Editor, Element, Path, Transforms } from "slate";
2
+ import insertNewLine from "./insertNewLine";
2
3
  import { ALLOWED_TEXT_NODES, getNode, getNodeText, getNodeWithType, getSelectedText } from "./helper";
4
+ import { isMobileWindow } from "../helper";
3
5
  import { removeAccordion } from "./events";
4
6
  import { ReactEditor } from "slate-react";
5
7
  const focusAccordion = (editor, upPath) => {
@@ -7,74 +9,51 @@ const focusAccordion = (editor, upPath) => {
7
9
  path: upPath,
8
10
  offset: 0
9
11
  });
10
- ReactEditor.focus(editor);
11
12
  };
12
- const getAccordionNode = summaryNode => {
13
- return {
14
- type: "accordion",
15
- children: [{
16
- type: "accordion-summary",
17
- children: summaryNode
18
- }, {
19
- type: "accordion-details",
13
+ export const insertAccordion = (editor, path) => {
14
+ try {
15
+ const selectedText = getSelectedText(editor);
16
+ const accordion = {
17
+ type: "accordion",
20
18
  children: [{
21
- type: "paragraph",
19
+ type: "accordion-summary",
22
20
  children: [{
23
- text: ""
21
+ type: "paragraph",
22
+ children: [{
23
+ text: selectedText || ""
24
+ }]
24
25
  }]
25
- }]
26
- }]
27
- };
28
- };
29
- export const insertAccordion = (editor, path) => {
30
- try {
31
- const {
32
- selection
33
- } = editor;
34
- let accordionPath;
35
- if (path) {
36
- const summaryNode = {
37
- type: "paragraph",
26
+ }, {
27
+ type: "accordion-details",
38
28
  children: [{
39
- text: ""
29
+ type: "paragraph",
30
+ children: [{
31
+ text: ""
32
+ }]
40
33
  }]
41
- };
42
- const accordion = getAccordionNode([summaryNode]);
43
- Transforms.insertNodes(editor, accordion, {
44
- at: path
45
- });
46
- accordionPath = path;
47
- } else if (selection) {
48
- const selectedNodes = Array.from(Editor.nodes(editor, {
49
- match: n => Element.isElement(n),
50
- mode: "lowest" // use 'lowest' to get individual blocks
51
- }));
52
-
53
- for (const [node, path] of selectedNodes) {
54
- let currNode = node;
55
- // const isListItem = node.type === "list-item";
56
- // if (isListItem) {
57
- // currNode = {
58
- // type: "paragraph",
59
- // children: node.children,
60
- // };
61
- // }
34
+ }]
35
+ };
36
+ const props = path ? {
37
+ at: path,
38
+ select: true
39
+ } : {
40
+ select: true
41
+ };
42
+ Transforms.insertNodes(editor, accordion, props);
43
+ const curPath = [...editor?.selection?.anchor?.path];
44
+ const upPath = [...curPath];
45
+ // get title index
46
+ const summaryIndex = upPath.length - 3;
47
+ upPath[summaryIndex] = upPath[summaryIndex] === 0 ? 0 : upPath[summaryIndex] - 1;
62
48
 
63
- let accordion = getAccordionNode([currNode]);
64
- Transforms.removeNodes(editor, {
65
- at: path
66
- });
67
- Transforms.insertNodes(editor, accordion, {
68
- at: path
69
- });
70
- accordionPath = path;
71
- }
72
- const lastNode = selectedNodes[selectedNodes.length - 1];
73
- const lastNodePath = lastNode[1];
74
- accordionPath = lastNodePath;
49
+ // select accordion title by default
50
+ if (isMobileWindow()) {
51
+ // timeout to resolve focus issue in mobile
52
+ setTimeout(() => focusAccordion(editor, upPath), 0);
53
+ } else {
54
+ focusAccordion(editor, upPath);
75
55
  }
76
- const focusPath = [...accordionPath, 0, 0, 0];
77
- focusAccordion(editor, focusPath);
56
+ insertNewLine(editor);
78
57
  } catch (err) {
79
58
  console.log(err);
80
59
  }
@@ -154,11 +133,4 @@ export const onDeleteBackwardAccordion = editor => {
154
133
  } catch (err) {
155
134
  console.log(err);
156
135
  }
157
- };
158
- export const toggleAccordion = editor => {
159
- const parentAccordion = Editor.above(editor, {
160
- match: node => Element.isElement(node) && node.type === "accordion"
161
- });
162
- const [, accordionPath] = parentAccordion;
163
- removeAccordion(editor, accordionPath);
164
136
  };
@@ -1,5 +1,6 @@
1
1
  import { Path, Transforms } from "slate";
2
2
  import insertNewLine from "./insertNewLine";
3
+ import { windowVar } from "./helper";
3
4
  import { getCurrentElementText } from "../plugins/withHTML";
4
5
  export const insertButton = editor => {
5
6
  const button = {
@@ -10,7 +11,22 @@ export const insertButton = editor => {
10
11
  buttonLink: {
11
12
  linkType: "webAddress"
12
13
  },
13
- iconPosition: "start"
14
+ iconPosition: "start",
15
+ bgColor: "#2563EB",
16
+ textColor: "#FFF",
17
+ borderRadius: {
18
+ topLeft: 30,
19
+ topRight: 30,
20
+ bottomLeft: 30,
21
+ bottomRight: 30
22
+ },
23
+ bannerSpacing: {
24
+ left: 16,
25
+ top: 8,
26
+ right: 16,
27
+ bottom: 8
28
+ },
29
+ ...(windowVar.lastButtonProps || {})
14
30
  };
15
31
  const hasText = getCurrentElementText(editor);
16
32
  const insertPath = hasText ? Path.next(Path.parent(editor?.selection.focus.path)) : editor?.selection.focus.path;
@@ -82,8 +82,7 @@ const splitInlineStyleRanges = (text, inlineStyleRanges, data) => {
82
82
  };
83
83
  export const draftToSlate = props => {
84
84
  const {
85
- data,
86
- needLayout
85
+ data
87
86
  } = props;
88
87
  if (data?.blocks && data?.blocks?.length > 0) {
89
88
  const converted = data?.blocks?.reduce((a, b) => {
@@ -105,7 +104,7 @@ export const draftToSlate = props => {
105
104
  return data;
106
105
  } else {
107
106
  return [{
108
- type: needLayout ? "title" : "paragraph",
107
+ type: "paragraph",
109
108
  children: [{
110
109
  text: ""
111
110
  }]
@@ -197,102 +197,9 @@ export const removeAccordion = (editor, accordionPath) => {
197
197
  select: true
198
198
  });
199
199
  };
200
- export const customizeEnterEvent = (editor, ele, e) => {
201
- const {
202
- type
203
- } = ele[0];
204
- const path = ele[1];
205
- const text = Node.string(ele[0]);
206
- let breakNext = false;
207
- switch (type) {
208
- case "list-item":
209
- if (!text) {
210
- e?.preventDefault();
211
- escapeEvent({
212
- editor
213
- });
214
- }
215
- break;
216
- case "check-list-item":
217
- const selectionPath = editor?.selection?.anchor?.path;
218
- const currEle = Node.parent(editor, selectionPath);
219
- const currEleText = Node.string(currEle);
220
- if (!currEleText) {
221
- e?.preventDefault();
222
- checkListEnterEvent(editor, type);
223
- }
224
- break;
225
- case "accordion-summary":
226
- e?.preventDefault();
227
- breakNext = true;
228
- if (!text) {
229
- const accordionIndex = ele[1].slice(0, Math.max(ele[1].length - 1));
230
- removeAccordion(editor, accordionIndex);
231
- } else {
232
- const nextPath = Path.next(Path.parent(ele[1]));
233
- insertAccordion(editor, nextPath);
234
- }
235
- break;
236
- case "headingOne":
237
- case "headingTwo":
238
- case "headingThree":
239
- const {
240
- selection
241
- } = editor;
242
- if (selection && Range.isCollapsed(selection)) {
243
- const isAtEnd = Editor.isEnd(editor, selection.anchor, path);
244
- const isAtStart = Editor.isStart(editor, selection.anchor, path);
245
- if (isAtEnd) {
246
- e?.preventDefault();
247
- Transforms.insertNodes(editor, {
248
- type: "paragraph",
249
- children: [{
250
- text: ""
251
- }]
252
- });
253
- const newLocation = Editor.after(editor, selection);
254
- if (newLocation) {
255
- Transforms.select(editor, newLocation);
256
- }
257
- } else if (!isAtStart) {
258
- e?.preventDefault();
259
- Transforms.splitNodes(editor);
260
- Transforms.setNodes(editor, {
261
- type: "paragraph"
262
- }, {
263
- at: Editor.after(editor, selection)
264
- });
265
- const newLocation = Editor.after(editor, selection);
266
- if (newLocation) {
267
- Transforms.select(editor, newLocation);
268
- }
269
- } else if (isAtStart) {
270
- e?.preventDefault();
271
- Transforms.insertNodes(editor, {
272
- type: "paragraph",
273
- children: [{
274
- text: ""
275
- }]
276
- }, {
277
- at: Editor.before(editor, selection)
278
- });
279
- Transforms.select(editor, Editor.before(editor, selection));
280
- const newLocation = Editor.before(editor, selection);
281
- if (newLocation) {
282
- Transforms.select(editor, newLocation);
283
- }
284
- }
285
- return;
286
- }
287
- break;
288
- default:
289
- }
290
- return {
291
- breakNext
292
- };
293
- };
294
200
  export const enterEvent = (e, editor, isMobile) => {
295
201
  try {
202
+ const ele = isListItem(editor);
296
203
  // on shift enter break line in same node
297
204
  if (e.shiftKey && !isMobile) {
298
205
  e.preventDefault();
@@ -304,6 +211,94 @@ export const enterEvent = (e, editor, isMobile) => {
304
211
  } else {
305
212
  Transforms.insertText(editor, "\n");
306
213
  }
214
+ } else if (ele && ele[0]) {
215
+ const {
216
+ type
217
+ } = ele[0];
218
+ const path = ele[1];
219
+ const text = Node.string(ele[0]);
220
+ switch (type) {
221
+ case "list-item":
222
+ if (!text) {
223
+ e.preventDefault();
224
+ escapeEvent({
225
+ editor
226
+ });
227
+ }
228
+ break;
229
+ case "check-list-item":
230
+ const selectionPath = editor?.selection?.anchor?.path;
231
+ const currEle = Node.parent(editor, selectionPath);
232
+ const currEleText = Node.string(currEle);
233
+ if (!currEleText) {
234
+ e.preventDefault();
235
+ checkListEnterEvent(editor, type);
236
+ }
237
+ break;
238
+ case "accordion-summary":
239
+ e.preventDefault();
240
+ if (!text) {
241
+ const accordionIndex = ele[1].slice(0, Math.max(ele[1].length - 1));
242
+ removeAccordion(editor, accordionIndex);
243
+ } else {
244
+ const nextPath = Path.next(Path.parent(ele[1]));
245
+ insertAccordion(editor, nextPath);
246
+ }
247
+ break;
248
+ case "headingOne":
249
+ case "headingTwo":
250
+ case "headingThree":
251
+ const {
252
+ selection
253
+ } = editor;
254
+ if (selection && Range.isCollapsed(selection)) {
255
+ const isAtEnd = Editor.isEnd(editor, selection.anchor, path);
256
+ const isAtStart = Editor.isStart(editor, selection.anchor, path);
257
+ if (isAtEnd) {
258
+ e.preventDefault();
259
+ Transforms.insertNodes(editor, {
260
+ type: "paragraph",
261
+ children: [{
262
+ text: ""
263
+ }]
264
+ });
265
+ const newLocation = Editor.after(editor, selection);
266
+ if (newLocation) {
267
+ Transforms.select(editor, newLocation);
268
+ }
269
+ } else if (!isAtStart) {
270
+ e.preventDefault();
271
+ Transforms.splitNodes(editor);
272
+ Transforms.setNodes(editor, {
273
+ type: "paragraph"
274
+ }, {
275
+ at: Editor.after(editor, selection)
276
+ });
277
+ const newLocation = Editor.after(editor, selection);
278
+ if (newLocation) {
279
+ Transforms.select(editor, newLocation);
280
+ }
281
+ } else if (isAtStart) {
282
+ e.preventDefault();
283
+ Transforms.insertNodes(editor, {
284
+ type: "paragraph",
285
+ children: [{
286
+ text: ""
287
+ }]
288
+ }, {
289
+ at: Editor.before(editor, selection)
290
+ });
291
+ Transforms.select(editor, Editor.before(editor, selection));
292
+ const newLocation = Editor.before(editor, selection);
293
+ if (newLocation) {
294
+ Transforms.select(editor, newLocation);
295
+ }
296
+ }
297
+ return;
298
+ }
299
+ break;
300
+ default:
301
+ }
307
302
  }
308
303
  // Handle blockquote splitting
309
304
  if (!e.shiftKey) {
@@ -7,43 +7,43 @@ export const sizeMap = {
7
7
  export const fontFamilyMap = {
8
8
  PoppinsRegular: "PoppinsRegular",
9
9
  PoppinsBold: "PoppinsBold",
10
- sans: 'Helvetica, Arial, "sans serif"',
11
- serif: 'Georgia, "Times New Roaman", serif',
12
- monospace: 'Monaco, "Courier New", monospace',
13
- roboto: "Roboto, sans-serif",
14
- qwitcher: '"Qwitcher Grypen", cursive',
15
- garamond: '"EB Garamond", serif',
16
- anton: "Anton, sans-serif",
17
- dmserif: '"DM Serif Text", serif',
18
- inter: "Inter, sans-serif",
19
- libre: '"Libre Baskerville", serif',
20
- montserrat: "Montserrat, sans-serif",
21
- opensans: '"Open Sans", sans-serif',
22
- publicsans: '"Public Sans", sans-serif',
23
- raleway: "Raleway, sans-serif",
24
- spacemono: '"Space Mono", sans-serif',
25
- bulgarian: '"Bulgarian Garamond", monospace',
26
- impact: "Impact, serif",
27
- redacted: '"Redacted Script", cursive',
28
- greatVibes: '"Great Vibes", cursive',
29
- zeyada: "Zeyada, cursive",
30
- allura: "Allura, cursive",
31
- pinyon: '"Pinyon Script", cursive',
32
- muellerhoff: '"Herr Von Muellerhoff", cursive',
33
- dawning: '"Dawning of a New Day", cursive',
10
+ sans: "Helvetica,Arial, sans serif",
11
+ serif: "Georgia, Times New Roaman,serif",
12
+ monospace: "Monaco, Courier New,monospace",
13
+ roboto: "'Roboto', sans-serif",
14
+ qwitcher: "'Qwitcher Grypen', cursive",
15
+ garamond: "'EB Garamond', serif",
16
+ anton: "'Anton', sans-serif",
17
+ dmserif: "'DM Serif Text', serif",
18
+ inter: "'Inter', sans-serif",
19
+ libre: "'Libre Baskerville', serif",
20
+ montserrat: "'Montserrat', sans-serif",
21
+ opensans: "'Open Sans', sans-serif",
22
+ publicsans: "'Public Sans', sans-serif",
23
+ raleway: "'Raleway', sans-serif",
24
+ spacemono: "'Space Mono', sans-serif",
25
+ bulgarian: "'Bulgarian Garamond', monospace",
26
+ impact: "'Impact', serif",
27
+ redacted: "'Redacted Script', cursive",
28
+ greatVibes: "'Great Vibes', cursive",
29
+ zeyada: "'Zeyada', cursive",
30
+ allura: "'Allura', cursive",
31
+ pinyon: "'Pinyon Script', cursive",
32
+ muellerhoff: "'Herr Von Muellerhoff', cursive",
33
+ dawning: "'Dawning of a New Day', cursive",
34
34
  // New Font Added for Type Signature
35
- comingsoon: '"Coming Soon", cursive',
36
- dancingScript: '"Dancing Script", cursive',
37
- engagement: "Engagement, cursive",
38
- gaegu: "Gaegu, cursive",
39
- ingridDarling: '"Ingrid Darling", cursive',
40
- kitaOne: "Times",
41
- laBelleAurore: '"La Belle Aurore", cursive',
42
- lobster: "Lobster, cursive",
43
- meaCulpa: '"Mea Culpa", cursive',
44
- meddon: "Meddon, cursive",
45
- merriWeather: "Merriweather, serif",
46
- theGirlNextDoor: '"The Girl Next Door", cursive'
35
+ comingsoon: "'Coming Soon', cursive",
36
+ dancingScript: "'Dancing Script', cursive",
37
+ engagement: "'Engagement', cursive",
38
+ gaegu: "'Gaegu', cursive",
39
+ ingridDarling: "'Ingrid Darling', cursive",
40
+ kitaOne: "'Kite One', sans - serif",
41
+ laBelleAurore: "'La Belle Aurore', cursive",
42
+ lobster: "'Lobster', cursive",
43
+ meaCulpa: "'Mea Culpa', cursive",
44
+ meddon: "'Meddon', cursive",
45
+ merriWeather: "'Merriweather', serif",
46
+ theGirlNextDoor: "'The Girl Next Door', cursive"
47
47
  };
48
48
  export const fontOptions = Object.keys(fontFamilyMap).map(m => {
49
49
  return {
@@ -62,10 +62,7 @@ export const signedTextFonts = Object.keys(fontFamilyMap).slice(-12).map(m => {
62
62
  export const headingMap = {
63
63
  headingOne: "32px",
64
64
  headingTwo: "24px",
65
- headingThree: "19px",
66
- headingFour: "16px",
67
- headingFive: "13px",
68
- headingSix: "11px"
65
+ headingThree: "19px"
69
66
  };
70
67
  export const fontWeightOptions = [{
71
68
  text: "Bold",
@@ -2,9 +2,7 @@ import { Editor, Node, Transforms, Element, Path, Range, Text } from "slate";
2
2
  import { ReactEditor } from "slate-react";
3
3
  import insertNewLine from "./insertNewLine";
4
4
  import { getDevice } from "../helper/theme";
5
- import { activeMark, getSelectedElementStyle } from "./SlateUtilityFunctions";
6
5
  import { getCurrentElementText } from "../plugins/withHTML";
7
- import { isEmptyTextNode } from "../helper";
8
6
  export const windowVar = {};
9
7
  let ST_TIMEOUT = null;
10
8
  const BLOCKS = ["grid", "dataView"];
@@ -175,7 +173,7 @@ export const handleInsertLastElement = (event, editor) => {
175
173
  if (isFreeGrid) {
176
174
  return;
177
175
  }
178
- const isLastElementEmpty = isEmptyTextNode(lastElement) && !lastElement.children?.some(c => BLOCKS.includes(c.type));
176
+ const isLastElementEmpty = lastElement && lastElement.type === "paragraph" && !lastElement.children[0]?.text && !lastElement.children?.some(c => BLOCKS.includes(c.type));
179
177
  if (!ReactEditor.isFocused(editor)) {
180
178
  if (isLastElementEmpty) {
181
179
  if (hasPath) {
@@ -219,13 +217,9 @@ export const handleInsertLastElement = (event, editor) => {
219
217
  };
220
218
  export const isListItem = editor => {
221
219
  const format = ["list-item", "check-list-item", "accordion-summary", "headingOne", "headingTwo", "headingThree"];
222
- const [node1, node2] = Editor.nodes(editor, {
220
+ const [node] = Editor.nodes(editor, {
223
221
  match: n => !Editor.isEditor(n) && Element.isElement(n) && format.indexOf(n.type) > -1
224
222
  });
225
- let node = node1;
226
- if (node2 && node2[0] && node2[0].type === "accordion-summary") {
227
- node = node2;
228
- }
229
223
  return node;
230
224
  };
231
225
  export const getNode = (editor, path) => {
@@ -498,34 +492,6 @@ export const decodeString = str => {
498
492
  console.log(err);
499
493
  }
500
494
  };
501
- export const getContrastColor = color => {
502
- let r, g, b;
503
-
504
- // Check if the color is in hex format
505
- if (color.startsWith("#")) {
506
- r = parseInt(color.substring(1, 3), 16);
507
- g = parseInt(color.substring(3, 5), 16);
508
- b = parseInt(color.substring(5, 7), 16);
509
- }
510
- // Check if the color is in RGB/RGBA format
511
- else if (color.startsWith("rgb")) {
512
- const rgbValues = color.replace(/^rgba?\(|\s+|\)$/g, "") // Remove the rgb/rgba and spaces
513
- .split(","); // Split the values into an array
514
-
515
- r = parseInt(rgbValues[0]);
516
- g = parseInt(rgbValues[1]);
517
- b = parseInt(rgbValues[2]);
518
- } else {
519
- // If the format is not recognized, default to black text
520
- return "#000000";
521
- }
522
-
523
- // Calculate relative luminance
524
- const luminance = (0.299 * r + 0.587 * g + 0.114 * b) / 255;
525
-
526
- // Return black for light colors, white for dark colors
527
- return luminance > 0.5 ? "#000000" : "#FFFFFF";
528
- };
529
495
  export const onDeleteKey = (event, {
530
496
  editor
531
497
  }) => {
@@ -743,10 +709,6 @@ export const isRestrictedNode = (event, editor) => {
743
709
  return isNodeRestricted;
744
710
  }
745
711
  };
746
- export function capitalizeFirstLetter(str) {
747
- if (!str) return str;
748
- return str.charAt(0).toUpperCase() + str.slice(1);
749
- }
750
712
  export const insertLineBreakAtEndOfPath = (editor, path) => {
751
713
  try {
752
714
  const [node, nodePath] = Editor.node(editor, path); // Get the node at the specified path
@@ -765,13 +727,6 @@ export const insertLineBreakAtEndOfPath = (editor, path) => {
765
727
  console.log(err);
766
728
  }
767
729
  };
768
- export function isHavingSelection(editor) {
769
- try {
770
- return editor?.selection && !Range.isCollapsed(editor.selection);
771
- } catch (err) {
772
- console.log(err);
773
- }
774
- }
775
730
  const omitNodes = ["site-settings", "page-settings"];
776
731
  export function getInitialValue(value = [], readOnly) {
777
732
  if (readOnly === "readonly" && value?.length) {
@@ -802,17 +757,20 @@ export function getInitialValue(value = [], readOnly) {
802
757
  }
803
758
  return value;
804
759
  }
760
+ export function capitalizeFirstLetter(str) {
761
+ if (!str) return str;
762
+ return str.charAt(0).toUpperCase() + str.slice(1);
763
+ }
764
+ export function isHavingSelection(editor) {
765
+ try {
766
+ return editor?.selection && !Range.isCollapsed(editor.selection);
767
+ } catch (err) {
768
+ console.log(err);
769
+ }
770
+ }
805
771
  export function getSelectedCls(defaultCls = "", selected, selectedClsName = "selected") {
806
772
  return `${defaultCls} ${selected ? selectedClsName : ""}`;
807
773
  }
808
- export function handleNegativeInteger(val) {
809
- return val < 0 ? 0 : val;
810
- }
811
- export const containsSurrogatePair = text => {
812
- // Match surrogate pairs (high and low surrogate)
813
- const surrogatePairRegex = /[\uD800-\uDBFF][\uDC00-\uDFFF]/;
814
- return surrogatePairRegex.test(text);
815
- };
816
774
  export const getNodeWithType = (editor, nodeType = "", otherOptions) => {
817
775
  try {
818
776
  const options = {
@@ -826,6 +784,11 @@ export const getNodeWithType = (editor, nodeType = "", otherOptions) => {
826
784
  return [];
827
785
  }
828
786
  };
787
+ export const containsSurrogatePair = text => {
788
+ // Match surrogate pairs (high and low surrogate)
789
+ const surrogatePairRegex = /[\uD800-\uDBFF][\uDC00-\uDFFF]/;
790
+ return surrogatePairRegex.test(text);
791
+ };
829
792
  export const getSlateDom = (editor, range) => {
830
793
  try {
831
794
  const slateDom = ReactEditor.toDOMRange(editor, range);
@@ -866,8 +829,7 @@ export const clearWindowSelection = () => {
866
829
 
867
830
  export const viewSlateSelection = () => {
868
831
  // if ai is opened, remove the window selection class and open then slate selection, To resolve: focussing on the ai input removes window selection automatically
869
- // clearWindowSelection();
870
-
832
+ clearWindowSelection();
871
833
  const selectionBg = "rgba(35, 131, 226, 0.35)";
872
834
  const root = document.documentElement;
873
835
  root.style.setProperty("--slate-highlight-bg", selectionBg);
@@ -876,6 +838,9 @@ export const hideSlateSelection = () => {
876
838
  const root = document.documentElement;
877
839
  root.style.setProperty("--slate-highlight-bg", "none");
878
840
  };
841
+ export function handleNegativeInteger(val) {
842
+ return val < 0 ? 0 : val;
843
+ }
879
844
  export const insertSlashNode = (editor, insertNode) => {
880
845
  try {
881
846
  // Delete the currently selected text
@@ -1018,46 +983,4 @@ export const handleCopy = (event, editor) => {
1018
983
  event.clipboardData?.setData("text/plain", text);
1019
984
  event.clipboardData?.setData("application/x-slate-fragment", encodedFragment);
1020
985
  };
1021
- export const ALLOWED_TEXT_NODES = ["paragraph", "title", "headingOne", "headingTwo", "headingThree", "headingFour", "headingFive", "headingSix", "blockquote"];
1022
- function convertColorToRgb(color) {
1023
- if (color?.startsWith("#")) {
1024
- // HEX to RGB
1025
- let hex = color.replace("#", "");
1026
- let r, g, b;
1027
- if (hex.length === 3) {
1028
- hex = hex.split("").map(x => x + x).join("");
1029
- }
1030
- if (hex.length === 6) {
1031
- [r, g, b] = [hex.substring(0, 2), hex.substring(2, 4), hex.substring(4, 6)].map(val => parseInt(val, 16));
1032
- return `rgb(${r}, ${g}, ${b})`;
1033
- }
1034
- } else {
1035
- return color;
1036
- }
1037
- }
1038
- export const getSelectedColor = (selectedColor, theme, hideThemeColors) => {
1039
- const colorVars = hideThemeColors ? null : theme?.vars?.colors;
1040
- let selectedValue = selectedColor;
1041
- if (colorVars) {
1042
- const convertedColor = convertColorToRgb(selectedColor);
1043
- Object.entries(theme.colors).forEach(([key, value]) => {
1044
- const convertedThemeColor = convertColorToRgb(value);
1045
- if (convertedThemeColor === convertedColor) {
1046
- selectedValue = colorVars[key];
1047
- }
1048
- });
1049
- }
1050
- return selectedValue;
1051
- };
1052
- const themeTextFormats = ["headingOne", "headingTwo", "headingThree", "headingFour", "headingFive", "headingSix", "paragraphOne", "paragraphTwo", "paragraphThree"];
1053
- export const getSelectedElementColor = (editor, format, theme) => {
1054
- const [isThemeText] = Editor.nodes(editor, {
1055
- at: editor.selection,
1056
- match: n => themeTextFormats.includes(n?.type)
1057
- });
1058
- if (!isThemeText) {
1059
- return activeMark(editor, "color") || "#000000";
1060
- }
1061
- const color = getSelectedElementStyle(format, editor, format);
1062
- return getSelectedColor(color, theme);
1063
- };
986
+ export const ALLOWED_TEXT_NODES = ["paragraph", "title", "headingOne", "headingTwo", "headingThree", "headingFour", "headingFive", "headingSix", "blockquote"];