@flozy/editor 10.6.8 → 10.7.0

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 (128) hide show
  1. package/dist/Editor/ChatEditor.js +16 -17
  2. package/dist/Editor/CommonEditor.js +13 -116
  3. package/dist/Editor/DialogWrapper.js +25 -31
  4. package/dist/Editor/Editor.css +11 -31
  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 +17 -25
  8. package/dist/Editor/Elements/AppHeader/AppHeader.js +3 -3
  9. package/dist/Editor/Elements/Button/EditorButton.js +7 -23
  10. package/dist/Editor/Elements/Color Picker/ColorButtons.js +14 -61
  11. package/dist/Editor/Elements/Color Picker/ColorPicker.css +1 -25
  12. package/dist/Editor/Elements/Color Picker/ColorPicker.js +7 -10
  13. package/dist/Editor/Elements/Color Picker/Styles.js +13 -15
  14. package/dist/Editor/Elements/DataView/Layouts/DataTypes/Components/MultiSelect.js +454 -0
  15. package/dist/Editor/Elements/Embed/Video.js +1 -1
  16. package/dist/Editor/Elements/Form/FormField.js +1 -1
  17. package/dist/Editor/Elements/Form/Workflow/Styles.js +22 -24
  18. package/dist/Editor/Elements/FreeGrid/FreeGrid.js +30 -31
  19. package/dist/Editor/Elements/FreeGrid/FreeGridBox.js +4 -7
  20. package/dist/Editor/Elements/FreeGrid/Options/More.js +7 -7
  21. package/dist/Editor/Elements/FreeGrid/styles.js +0 -9
  22. package/dist/Editor/Elements/Grid/GridItem.js +1 -1
  23. package/dist/Editor/Elements/SimpleText/style.js +2 -2
  24. package/dist/Editor/Elements/Table/Table.js +3 -3
  25. package/dist/Editor/Elements/Title/title.js +6 -6
  26. package/dist/Editor/Elements/Variables/VariableButton.js +1 -10
  27. package/dist/Editor/MiniEditor.js +1 -2
  28. package/dist/Editor/Styles/EditorStyles.js +5 -9
  29. package/dist/Editor/Toolbar/FormatTools/Dropdown.js +3 -27
  30. package/dist/Editor/Toolbar/FormatTools/FontFamilyAutocomplete.js +3 -4
  31. package/dist/Editor/Toolbar/FormatTools/MarkButton.js +2 -2
  32. package/dist/Editor/Toolbar/FormatTools/TextSize.js +13 -10
  33. package/dist/Editor/Toolbar/Mini/MiniToolbar.js +1 -2
  34. package/dist/Editor/Toolbar/PopupTool/MiniTextFormat/MiniColorPicker.js +2 -4
  35. package/dist/Editor/Toolbar/PopupTool/MiniTextFormat/SelectFontSize.js +13 -6
  36. package/dist/Editor/Toolbar/PopupTool/MiniTextFormat/SelectList.js +2 -4
  37. package/dist/Editor/Toolbar/PopupTool/MiniTextFormat/SelectTypography.js +42 -167
  38. package/dist/Editor/Toolbar/PopupTool/MiniTextFormat/index.js +4 -7
  39. package/dist/Editor/Toolbar/PopupTool/PopperHeader.js +1 -2
  40. package/dist/Editor/Toolbar/PopupTool/PopupToolStyle.js +9 -69
  41. package/dist/Editor/Toolbar/PopupTool/TextFormat.js +10 -58
  42. package/dist/Editor/Toolbar/PopupTool/index.js +2 -5
  43. package/dist/Editor/Toolbar/toolbarGroups.js +6 -48
  44. package/dist/Editor/common/ColorPickerButton.js +16 -38
  45. package/dist/Editor/common/DnD/DragHandleButton.js +1 -1
  46. package/dist/Editor/common/FontLoader/FontLoader.js +0 -3
  47. package/dist/Editor/common/Icon.js +0 -28
  48. package/dist/Editor/common/ImageSelector/ImageSelector.js +2 -2
  49. package/dist/Editor/common/ImageSelector/Styles.js +9 -3
  50. package/dist/Editor/common/LinkSettings/NavComponents.js +2 -6
  51. package/dist/Editor/common/RnD/ElementSettings/OtherSettings/Settings.js +1 -2
  52. package/dist/Editor/common/RnD/ElementSettings/Settings/AppHeaderSettings.js +2 -3
  53. package/dist/Editor/common/RnD/ElementSettings/Settings/BoxSettings.js +2 -3
  54. package/dist/Editor/common/RnD/ElementSettings/Settings/ButtonSettings.js +2 -3
  55. package/dist/Editor/common/RnD/ElementSettings/Settings/CodeSettings.js +2 -3
  56. package/dist/Editor/common/RnD/ElementSettings/Settings/FormSettings.js +2 -4
  57. package/dist/Editor/common/RnD/ElementSettings/Settings/ImageSettings.js +2 -3
  58. package/dist/Editor/common/RnD/ElementSettings/Settings/TableSettings.js +2 -3
  59. package/dist/Editor/common/RnD/ElementSettings/Settings/TextSettings.js +1 -3
  60. package/dist/Editor/common/RnD/ElementSettings/Settings/VideoSettings.js +2 -3
  61. package/dist/Editor/common/RnD/SwitchViewport/SwitchViewport.js +2 -11
  62. package/dist/Editor/common/RnD/Theme/ViewportStimulator.js +3 -6
  63. package/dist/Editor/common/RnD/Utils/gridDropItem.js +18 -28
  64. package/dist/Editor/common/RnD/Utils/index.js +1 -3
  65. package/dist/Editor/common/RnD/VirtualElement/VirtualTextElement.js +58 -45
  66. package/dist/Editor/common/RnD/VirtualElement/helper.js +130 -320
  67. package/dist/Editor/common/RnD/VirtualElement/styles.js +0 -22
  68. package/dist/Editor/common/RnD/index.js +11 -42
  69. package/dist/Editor/common/Shorthands/elements.js +0 -54
  70. package/dist/Editor/common/StyleBuilder/buttonStyle.js +2 -4
  71. package/dist/Editor/common/StyleBuilder/embedVideoStyle.js +0 -4
  72. package/dist/Editor/common/StyleBuilder/fieldTypes/backgroundImage.js +0 -5
  73. package/dist/Editor/common/StyleBuilder/fieldTypes/bannerSpacing.js +2 -12
  74. package/dist/Editor/common/StyleBuilder/fieldTypes/borderRadius.js +7 -15
  75. package/dist/Editor/common/StyleBuilder/fieldTypes/card.js +8 -16
  76. package/dist/Editor/common/StyleBuilder/fieldTypes/color.js +10 -36
  77. package/dist/Editor/common/StyleBuilder/fieldTypes/fontSize.js +7 -16
  78. package/dist/Editor/common/StyleBuilder/fieldTypes/index.js +1 -3
  79. package/dist/Editor/common/StyleBuilder/fieldTypes/menusArray.js +0 -2
  80. package/dist/Editor/common/StyleBuilder/fieldTypes/textOptions.js +7 -15
  81. package/dist/Editor/common/Uploader.js +0 -16
  82. package/dist/Editor/common/iconslist.js +0 -21
  83. package/dist/Editor/commonStyle.js +64 -107
  84. package/dist/Editor/helper/index.js +2 -7
  85. package/dist/Editor/helper/theme.js +2 -203
  86. package/dist/Editor/hooks/useMouseMove.js +3 -9
  87. package/dist/Editor/plugins/withEmbeds.js +1 -1
  88. package/dist/Editor/plugins/withHTML.js +1 -3
  89. package/dist/Editor/plugins/withTable.js +1 -1
  90. package/dist/Editor/theme/ThemeList.js +173 -50
  91. package/dist/Editor/utils/SlateUtilityFunctions.js +24 -229
  92. package/dist/Editor/utils/accordion.js +34 -62
  93. package/dist/Editor/utils/button.js +17 -1
  94. package/dist/Editor/utils/draftToSlate.js +2 -3
  95. package/dist/Editor/utils/font.js +37 -40
  96. package/dist/Editor/utils/helper.js +21 -97
  97. package/dist/Editor/utils/insertAppHeader.js +4 -8
  98. package/package.json +4 -4
  99. package/dist/Editor/Elements/FreeGrid/helper.js +0 -115
  100. package/dist/Editor/Toolbar/PopupTool/ThemeTextFormat.js +0 -439
  101. package/dist/Editor/assets/svg/BackIcon.js +0 -18
  102. package/dist/Editor/assets/svg/ThemeIcons.js +0 -293
  103. package/dist/Editor/common/CustomColorPicker/index.js +0 -130
  104. package/dist/Editor/common/CustomColorPicker/style.js +0 -53
  105. package/dist/Editor/common/CustomDialog2/index.js +0 -94
  106. package/dist/Editor/common/CustomDialog2/style.js +0 -67
  107. package/dist/Editor/common/CustomSelect.js +0 -43
  108. package/dist/Editor/common/RnD/Theme/MainThemeProvider.js +0 -17
  109. package/dist/Editor/common/StyleBuilder/fieldTypes/embedUpload.js +0 -115
  110. package/dist/Editor/helper/textIndeces.js +0 -58
  111. package/dist/Editor/hooks/useEditorTheme.js +0 -153
  112. package/dist/Editor/hooks/useThemeValues.js +0 -63
  113. package/dist/Editor/theme/index.js +0 -149
  114. package/dist/Editor/themeSettings/ActiveTheme.js +0 -82
  115. package/dist/Editor/themeSettings/buttons/index.js +0 -300
  116. package/dist/Editor/themeSettings/buttons/style.js +0 -23
  117. package/dist/Editor/themeSettings/colorTheme/index.js +0 -310
  118. package/dist/Editor/themeSettings/colorTheme/style.js +0 -81
  119. package/dist/Editor/themeSettings/fonts/PreviewElement.js +0 -121
  120. package/dist/Editor/themeSettings/fonts/index.js +0 -240
  121. package/dist/Editor/themeSettings/fonts/style.js +0 -62
  122. package/dist/Editor/themeSettings/icons.js +0 -60
  123. package/dist/Editor/themeSettings/index.js +0 -380
  124. package/dist/Editor/themeSettings/style.js +0 -299
  125. package/dist/Editor/themeSettingsAI/icons.js +0 -96
  126. package/dist/Editor/themeSettingsAI/index.js +0 -355
  127. package/dist/Editor/themeSettingsAI/saveTheme.js +0 -202
  128. package/dist/Editor/themeSettingsAI/style.js +0 -332
@@ -1,6 +1,6 @@
1
1
  import { Editor, Element, Path, Transforms } from "slate";
2
2
  import insertNewLine from "./insertNewLine";
3
- import { ALLOWED_TEXT_NODES, getNode, getNodeText, getNodeWithType } from "./helper";
3
+ import { ALLOWED_TEXT_NODES, getNode, getNodeText, getNodeWithType, getSelectedText } from "./helper";
4
4
  import { isMobileWindow } from "../helper";
5
5
  import { removeAccordion } from "./events";
6
6
  import { ReactEditor } from "slate-react";
@@ -10,76 +10,48 @@ const focusAccordion = (editor, upPath) => {
10
10
  offset: 0
11
11
  });
12
12
  };
13
- const getAccordionNode = summaryNode => {
14
- return {
15
- type: "accordion",
16
- children: [{
17
- type: "accordion-summary",
18
- children: summaryNode
19
- }, {
20
- type: "accordion-details",
13
+ export const insertAccordion = (editor, path) => {
14
+ try {
15
+ const selectedText = getSelectedText(editor);
16
+ const accordion = {
17
+ type: "accordion",
21
18
  children: [{
22
- type: "paragraph",
19
+ type: "accordion-summary",
23
20
  children: [{
24
- text: ""
21
+ type: "paragraph",
22
+ children: [{
23
+ text: selectedText || ""
24
+ }]
25
25
  }]
26
- }]
27
- }]
28
- };
29
- };
30
- export const insertAccordion = (editor, path) => {
31
- try {
32
- const {
33
- selection
34
- } = editor;
35
- let accordionPath;
36
- if (path) {
37
- const summaryNode = {
38
- type: "paragraph",
26
+ }, {
27
+ type: "accordion-details",
39
28
  children: [{
40
- text: ""
29
+ type: "paragraph",
30
+ children: [{
31
+ text: ""
32
+ }]
41
33
  }]
42
- };
43
- const accordion = getAccordionNode([summaryNode]);
44
- Transforms.insertNodes(editor, accordion, {
45
- at: path
46
- });
47
- accordionPath = path;
48
- } else if (selection) {
49
- const selectedNodes = Array.from(Editor.nodes(editor, {
50
- at: selection,
51
- match: n => Element.isElement(n),
52
- mode: "lowest" // use 'lowest' to get individual blocks
53
- }));
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;
54
48
 
55
- for (const [node, path] of selectedNodes) {
56
- let currNode = node;
57
- const isListItem = node.type === "list-item";
58
- if (isListItem) {
59
- currNode = {
60
- type: "paragraph",
61
- children: node.children
62
- };
63
- }
64
- let accordion = getAccordionNode([currNode]);
65
- Transforms.removeNodes(editor, {
66
- at: path
67
- });
68
- Transforms.insertNodes(editor, accordion, {
69
- at: path
70
- });
71
- accordionPath = path;
72
- }
73
- const lastNode = selectedNodes[selectedNodes.length - 1];
74
- const lastNodePath = lastNode[1];
75
- accordionPath = lastNodePath;
76
- }
77
- const focusPath = [...accordionPath, 0, 0, 0];
49
+ // select accordion title by default
78
50
  if (isMobileWindow()) {
79
51
  // timeout to resolve focus issue in mobile
80
- setTimeout(() => focusAccordion(editor, focusPath), 0);
52
+ setTimeout(() => focusAccordion(editor, upPath), 0);
81
53
  } else {
82
- focusAccordion(editor, focusPath);
54
+ focusAccordion(editor, upPath);
83
55
  }
84
56
  insertNewLine(editor);
85
57
  } catch (err) {
@@ -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
  }]
@@ -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,7 +2,6 @@ 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
6
  export const windowVar = {};
8
7
  let ST_TIMEOUT = null;
@@ -218,13 +217,9 @@ export const handleInsertLastElement = (event, editor) => {
218
217
  };
219
218
  export const isListItem = editor => {
220
219
  const format = ["list-item", "check-list-item", "accordion-summary", "headingOne", "headingTwo", "headingThree"];
221
- const [node1, node2] = Editor.nodes(editor, {
220
+ const [node] = Editor.nodes(editor, {
222
221
  match: n => !Editor.isEditor(n) && Element.isElement(n) && format.indexOf(n.type) > -1
223
222
  });
224
- let node = node1;
225
- if (node2 && node2[0] && node2[0].type === "accordion-summary") {
226
- node = node2;
227
- }
228
223
  return node;
229
224
  };
230
225
  export const getNode = (editor, path) => {
@@ -497,34 +492,6 @@ export const decodeString = str => {
497
492
  console.log(err);
498
493
  }
499
494
  };
500
- export const getContrastColor = color => {
501
- let r, g, b;
502
-
503
- // Check if the color is in hex format
504
- if (color.startsWith("#")) {
505
- r = parseInt(color.substring(1, 3), 16);
506
- g = parseInt(color.substring(3, 5), 16);
507
- b = parseInt(color.substring(5, 7), 16);
508
- }
509
- // Check if the color is in RGB/RGBA format
510
- else if (color.startsWith("rgb")) {
511
- const rgbValues = color.replace(/^rgba?\(|\s+|\)$/g, "") // Remove the rgb/rgba and spaces
512
- .split(","); // Split the values into an array
513
-
514
- r = parseInt(rgbValues[0]);
515
- g = parseInt(rgbValues[1]);
516
- b = parseInt(rgbValues[2]);
517
- } else {
518
- // If the format is not recognized, default to black text
519
- return "#000000";
520
- }
521
-
522
- // Calculate relative luminance
523
- const luminance = (0.299 * r + 0.587 * g + 0.114 * b) / 255;
524
-
525
- // Return black for light colors, white for dark colors
526
- return luminance > 0.5 ? "#000000" : "#FFFFFF";
527
- };
528
495
  export const onDeleteKey = (event, {
529
496
  editor
530
497
  }) => {
@@ -742,10 +709,6 @@ export const isRestrictedNode = (event, editor) => {
742
709
  return isNodeRestricted;
743
710
  }
744
711
  };
745
- export function capitalizeFirstLetter(str) {
746
- if (!str) return str;
747
- return str.charAt(0).toUpperCase() + str.slice(1);
748
- }
749
712
  export const insertLineBreakAtEndOfPath = (editor, path) => {
750
713
  try {
751
714
  const [node, nodePath] = Editor.node(editor, path); // Get the node at the specified path
@@ -764,13 +727,6 @@ export const insertLineBreakAtEndOfPath = (editor, path) => {
764
727
  console.log(err);
765
728
  }
766
729
  };
767
- export function isHavingSelection(editor) {
768
- try {
769
- return editor?.selection && !Range.isCollapsed(editor.selection);
770
- } catch (err) {
771
- console.log(err);
772
- }
773
- }
774
730
  const omitNodes = ["site-settings", "page-settings"];
775
731
  export function getInitialValue(value = [], readOnly) {
776
732
  if (readOnly === "readonly" && value?.length) {
@@ -801,17 +757,20 @@ export function getInitialValue(value = [], readOnly) {
801
757
  }
802
758
  return value;
803
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
+ }
804
771
  export function getSelectedCls(defaultCls = "", selected, selectedClsName = "selected") {
805
772
  return `${defaultCls} ${selected ? selectedClsName : ""}`;
806
773
  }
807
- export function handleNegativeInteger(val) {
808
- return val < 0 ? 0 : val;
809
- }
810
- export const containsSurrogatePair = text => {
811
- // Match surrogate pairs (high and low surrogate)
812
- const surrogatePairRegex = /[\uD800-\uDBFF][\uDC00-\uDFFF]/;
813
- return surrogatePairRegex.test(text);
814
- };
815
774
  export const getNodeWithType = (editor, nodeType = "", otherOptions) => {
816
775
  try {
817
776
  const options = {
@@ -825,6 +784,11 @@ export const getNodeWithType = (editor, nodeType = "", otherOptions) => {
825
784
  return [];
826
785
  }
827
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
+ };
828
792
  export const getSlateDom = (editor, range) => {
829
793
  try {
830
794
  const slateDom = ReactEditor.toDOMRange(editor, range);
@@ -865,8 +829,7 @@ export const clearWindowSelection = () => {
865
829
 
866
830
  export const viewSlateSelection = () => {
867
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
868
- // clearWindowSelection();
869
-
832
+ clearWindowSelection();
870
833
  const selectionBg = "rgba(35, 131, 226, 0.35)";
871
834
  const root = document.documentElement;
872
835
  root.style.setProperty("--slate-highlight-bg", selectionBg);
@@ -875,6 +838,9 @@ export const hideSlateSelection = () => {
875
838
  const root = document.documentElement;
876
839
  root.style.setProperty("--slate-highlight-bg", "none");
877
840
  };
841
+ export function handleNegativeInteger(val) {
842
+ return val < 0 ? 0 : val;
843
+ }
878
844
  export const insertSlashNode = (editor, insertNode) => {
879
845
  try {
880
846
  // Delete the currently selected text
@@ -923,48 +889,6 @@ export const getCurrentNodeText = editor => {
923
889
  console.log("Error:", error);
924
890
  }
925
891
  };
926
- function convertColorToRgb(color) {
927
- if (color?.startsWith("#")) {
928
- // HEX to RGB
929
- let hex = color.replace("#", "");
930
- let r, g, b;
931
- if (hex.length === 3) {
932
- hex = hex.split("").map(x => x + x).join("");
933
- }
934
- if (hex.length === 6) {
935
- [r, g, b] = [hex.substring(0, 2), hex.substring(2, 4), hex.substring(4, 6)].map(val => parseInt(val, 16));
936
- return `rgb(${r}, ${g}, ${b})`;
937
- }
938
- } else {
939
- return color;
940
- }
941
- }
942
- export const getSelectedColor = (selectedColor, theme, hideThemeColors) => {
943
- const colorVars = hideThemeColors ? null : theme?.vars?.colors;
944
- let selectedValue = selectedColor;
945
- if (colorVars) {
946
- const convertedColor = convertColorToRgb(selectedColor);
947
- Object.entries(theme.colors).forEach(([key, value]) => {
948
- const convertedThemeColor = convertColorToRgb(value);
949
- if (convertedThemeColor === convertedColor) {
950
- selectedValue = colorVars[key];
951
- }
952
- });
953
- }
954
- return selectedValue;
955
- };
956
- const themeTextFormats = ["headingOne", "headingTwo", "headingThree", "headingFour", "headingFive", "headingSix", "paragraphOne", "paragraphTwo", "paragraphThree"];
957
- export const getSelectedElementColor = (editor, format, theme) => {
958
- const [isThemeText] = Editor.nodes(editor, {
959
- at: editor.selection,
960
- match: n => themeTextFormats.includes(n?.type)
961
- });
962
- if (!isThemeText) {
963
- return activeMark(editor, "color") || "#000000";
964
- }
965
- const color = getSelectedElementStyle(format, editor, format);
966
- return getSelectedColor(color, theme);
967
- };
968
892
  export const isHavingColor = color => {
969
893
  if (!color) {
970
894
  return false;
@@ -8,31 +8,27 @@ export const appHeaderNode = ({
8
8
  appLogo: "none",
9
9
  menus: menus || [{
10
10
  type: "menu",
11
- url: "",
12
- placeholder: "home",
11
+ url: "home",
13
12
  target: "",
14
13
  text: "Home",
15
14
  linkType: "page"
16
15
  }, {
17
16
  type: "menu",
18
- url: "",
19
- placeholder: "wireframe2",
17
+ url: "wireframe2",
20
18
  target: "",
21
19
  text: "Wireframe",
22
20
  linkType: "page"
23
21
  }, {
24
22
  type: "menu",
25
- url: "",
23
+ url: "https://www.google.com",
26
24
  target: "",
27
- placeholder: "Work",
28
25
  text: "Work",
29
26
  linkType: "webAddress"
30
27
  }, {
31
28
  type: "menu",
32
- url: "",
29
+ url: "https://www.google.com",
33
30
  target: "",
34
31
  text: "Contact",
35
- placeholder: "Contact",
36
32
  linkType: "webAddress"
37
33
  }],
38
34
  menuStyle: "stacked",
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@flozy/editor",
3
- "version": "10.6.8",
3
+ "version": "10.7.0",
4
4
  "description": "An Editor for flozy app brain",
5
5
  "files": [
6
6
  "dist"
@@ -38,6 +38,7 @@
38
38
  "react-icons": "^4.10.1",
39
39
  "react-katex": "^3.0.1",
40
40
  "react-rnd": "^10.4.11",
41
+ "react-scripts": "5.0.1",
41
42
  "react-signature-canvas": "^1.0.6",
42
43
  "react-slick": "^0.29.0",
43
44
  "sanitize-html": "^2.13.0",
@@ -68,7 +69,7 @@
68
69
  "storybook": "storybook dev -p 6006",
69
70
  "build-storybook": "NODE_OPTIONS='--max_old_space_size=4096' storybook build",
70
71
  "publish:npm": "rm -rf dist && mkdir dist && babel src/components -d dist --copy-files",
71
- "publish:local": "rm -rf /Users/agenciflow08/Documents/flozyapp/client/node_modules/@flozy/editor/dist && babel src/components -d /Users/agenciflow08/Documents/flozyapp/client/node_modules/@flozy/editor/dist --copy-files",
72
+ "publish:local": "rm -rf /Users/agmac03/flozy/client/node_modules/@flozy/editor/dist && babel src/components -d /Users/agmac03/flozy/client/node_modules/@flozy/editor/dist --copy-files",
72
73
  "publish:flozy": "./publish-flozy.sh",
73
74
  "publish:flozy2": "./publish-flozy2.sh",
74
75
  "publish:permission": "chmod +x publish-flozy.sh && chmod +x publish-flozy2.sh"
@@ -121,8 +122,7 @@
121
122
  "prop-types": "^15.8.1",
122
123
  "source-map-explorer": "^2.5.3",
123
124
  "storybook": "^7.4.0",
124
- "webpack": "^5.88.2",
125
- "react-scripts": "5.0.1"
125
+ "webpack": "^5.88.2"
126
126
  },
127
127
  "overrides": {
128
128
  "react-refresh": "0.11.0"
@@ -1,115 +0,0 @@
1
- import { ROW_HEIGHT } from "../../common/RnD/Utils/gridDropItem";
2
- import { getElementOffset } from "../../common/RnD/VirtualElement/VirtualTextElement";
3
- import { RND_ITEMS } from "../../helper";
4
- export const ELEMENT_CASE = {
5
- ADD_TEXT: "addText",
6
- ADD_BUTTON: "addButton",
7
- ADD_SIGNATURE: "addSignature",
8
- ADD_IMAGE: "addImage",
9
- ADD_VIDEO: "addVideo",
10
- ADD_TABLE: "addTable",
11
- ADD_CODE: "addCode",
12
- ADD_BOX: "addBox",
13
- ADD_FORM: "addForm",
14
- ADD_APP_HEADER: "addAppHeader",
15
- ADD_DIVIDER: "addDivider"
16
- };
17
- const commonXsValues = {
18
- top_xs: 0,
19
- marginTop_xs: 12,
20
- left_xs: 24,
21
- width_xs: 272,
22
- xs_updatedOn: new Date().getTime()
23
- };
24
- const elementXsValues = {
25
- [ELEMENT_CASE.ADD_TEXT]: {
26
- ...commonXsValues,
27
- height_xs: 50
28
- },
29
- [ELEMENT_CASE.ADD_BUTTON]: {
30
- ...commonXsValues,
31
- height_xs: 50
32
- },
33
- [ELEMENT_CASE.ADD_SIGNATURE]: {
34
- ...commonXsValues,
35
- height_xs: 173
36
- },
37
- [ELEMENT_CASE.ADD_IMAGE]: {
38
- ...commonXsValues,
39
- height_xs: 80
40
- },
41
- [ELEMENT_CASE.ADD_VIDEO]: {
42
- ...commonXsValues,
43
- height_xs: 300
44
- },
45
- [ELEMENT_CASE.ADD_TABLE]: {
46
- ...commonXsValues,
47
- height_xs: 165
48
- },
49
- [ELEMENT_CASE.ADD_CODE]: {
50
- ...commonXsValues,
51
- height: 300
52
- },
53
- [ELEMENT_CASE.ADD_BOX]: {
54
- ...commonXsValues,
55
- height_xs: 300
56
- },
57
- [ELEMENT_CASE.ADD_FORM]: {
58
- ...commonXsValues,
59
- height_xs: 80
60
- },
61
- [ELEMENT_CASE.ADD_APP_HEADER]: {
62
- ...commonXsValues,
63
- height_xs: 80
64
- },
65
- [ELEMENT_CASE.ADD_DIVIDER]: {
66
- ...commonXsValues,
67
- height_xs: 24
68
- }
69
- };
70
- export const findMaxYValue = (sectionItems, breakpoint) => {
71
- let maxY = 0;
72
- sectionItems.forEach(item => {
73
- const isHidden = breakpoint === "xs" && item.children.some(c => c.xsHidden);
74
- if (item?.type && RND_ITEMS.includes(item.type) && !isHidden) {
75
- const {
76
- bottom
77
- } = getElementOffset(item, breakpoint === "lg" ? "lg" : "xs");
78
- maxY = Math.max(maxY, bottom);
79
- }
80
- });
81
- return maxY;
82
- };
83
- export const convertToGridArea = y => {
84
- // Calculate grid position
85
- const row = Math.floor(y / ROW_HEIGHT) + 1;
86
-
87
- // to calculate difference inside the grid
88
- const marginTop = Math.abs((row - 1) * ROW_HEIGHT - y);
89
-
90
- // Update grid area
91
- const gridArea = `${row} / 1 / ${row + 1} / 2`;
92
- return {
93
- gridArea,
94
- marginTop
95
- };
96
- };
97
- export const getNewElementXsValues = (type, sectionItems) => {
98
- const values = elementXsValues[type] || {};
99
- const y = sectionItems?.length ? findMaxYValue(sectionItems) : 0;
100
- const {
101
- gridArea,
102
- marginTop
103
- } = convertToGridArea(y);
104
- const BUFFER_MARGIN_TOP = 12;
105
- const xsVal = {
106
- ...values,
107
- gridArea_xs: gridArea,
108
- marginTop_xs: marginTop + BUFFER_MARGIN_TOP
109
- };
110
- const sectionHeightXs = y + values?.height_xs + BUFFER_MARGIN_TOP + 12;
111
- return {
112
- xsVal,
113
- sectionHeightXs
114
- };
115
- };