@flozy/editor 10.3.8 → 10.3.9

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 (165) hide show
  1. package/dist/Editor/ChatEditor.js +16 -17
  2. package/dist/Editor/CommonEditor.js +16 -131
  3. package/dist/Editor/DialogWrapper.js +25 -31
  4. package/dist/Editor/Editor.css +8 -46
  5. package/dist/Editor/Elements/AI/PopoverAIInput.js +3 -11
  6. package/dist/Editor/Elements/Accordion/Accordion.js +9 -46
  7. package/dist/Editor/Elements/Accordion/AccordionSummary.js +23 -1
  8. package/dist/Editor/Elements/AppHeader/AppHeader.js +5 -10
  9. package/dist/Editor/Elements/Button/EditorButton.js +9 -27
  10. package/dist/Editor/Elements/Carousel/CarouselItem.js +1 -2
  11. package/dist/Editor/Elements/Color Picker/ColorButtons.js +14 -61
  12. package/dist/Editor/Elements/Color Picker/ColorPicker.css +1 -25
  13. package/dist/Editor/Elements/Color Picker/ColorPicker.js +7 -10
  14. package/dist/Editor/Elements/Color Picker/Styles.js +13 -15
  15. package/dist/Editor/Elements/DataView/Layouts/ColumnView.js +2 -4
  16. package/dist/Editor/Elements/DataView/Layouts/DataTypes/Components/MultiSelect.js +28 -30
  17. package/dist/Editor/Elements/DataView/Layouts/DataTypes/MultiSelectType.js +7 -9
  18. package/dist/Editor/Elements/DataView/Layouts/Options/AddOptions.js +1 -0
  19. package/dist/Editor/Elements/DataView/Layouts/ViewData.js +4 -8
  20. package/dist/Editor/Elements/Embed/Video.js +1 -1
  21. package/dist/Editor/Elements/Form/Form.js +3 -3
  22. package/dist/Editor/Elements/Form/FormElements/FormTextArea.js +1 -0
  23. package/dist/Editor/Elements/Form/FormField.js +2 -3
  24. package/dist/Editor/Elements/Form/Workflow/Styles.js +22 -24
  25. package/dist/Editor/Elements/FreeGrid/FreeGrid.js +31 -35
  26. package/dist/Editor/Elements/FreeGrid/FreeGridBox.js +4 -7
  27. package/dist/Editor/Elements/FreeGrid/FreeGridItem.js +0 -1
  28. package/dist/Editor/Elements/FreeGrid/Options/More.js +7 -7
  29. package/dist/Editor/Elements/FreeGrid/styles.js +0 -14
  30. package/dist/Editor/Elements/Grid/Grid.js +2 -14
  31. package/dist/Editor/Elements/Grid/GridItem.js +1 -1
  32. package/dist/Editor/Elements/Signature/Signature.css +1 -2
  33. package/dist/Editor/Elements/Signature/SignatureOptions/DrawSignature.js +5 -18
  34. package/dist/Editor/Elements/Signature/SignatureOptions/UploadSignature.js +3 -16
  35. package/dist/Editor/Elements/SimpleText/style.js +2 -2
  36. package/dist/Editor/Elements/Table/DragButton.js +1 -0
  37. package/dist/Editor/Elements/Table/Draggable.js +2 -6
  38. package/dist/Editor/Elements/Table/Styles.js +0 -7
  39. package/dist/Editor/Elements/Table/Table.js +3 -3
  40. package/dist/Editor/Elements/Table/TableCell.js +5 -24
  41. package/dist/Editor/Elements/Title/title.js +6 -6
  42. package/dist/Editor/Elements/Variables/VariableButton.js +1 -10
  43. package/dist/Editor/MiniEditor.js +1 -2
  44. package/dist/Editor/Styles/EditorStyles.js +5 -5
  45. package/dist/Editor/Toolbar/FormatTools/Dropdown.js +3 -27
  46. package/dist/Editor/Toolbar/FormatTools/FontFamilyAutocomplete.js +3 -4
  47. package/dist/Editor/Toolbar/FormatTools/MarkButton.js +2 -2
  48. package/dist/Editor/Toolbar/FormatTools/TextSize.js +13 -10
  49. package/dist/Editor/Toolbar/Mini/MiniToolbar.js +1 -2
  50. package/dist/Editor/Toolbar/PopupTool/MiniTextFormat/MiniColorPicker.js +2 -4
  51. package/dist/Editor/Toolbar/PopupTool/MiniTextFormat/SelectFontSize.js +13 -6
  52. package/dist/Editor/Toolbar/PopupTool/MiniTextFormat/SelectTypography.js +42 -167
  53. package/dist/Editor/Toolbar/PopupTool/MiniTextFormat/index.js +4 -7
  54. package/dist/Editor/Toolbar/PopupTool/PopperHeader.js +1 -2
  55. package/dist/Editor/Toolbar/PopupTool/PopupToolStyle.js +12 -72
  56. package/dist/Editor/Toolbar/PopupTool/TextFormat.js +10 -58
  57. package/dist/Editor/Toolbar/PopupTool/index.js +1 -1
  58. package/dist/Editor/Toolbar/toolbarGroups.js +6 -48
  59. package/dist/Editor/common/ColorPickerButton.js +16 -41
  60. package/dist/Editor/common/DnD/DragHandleButton.js +1 -1
  61. package/dist/Editor/common/FontLoader/FontLoader.js +0 -3
  62. package/dist/Editor/common/Icon.js +0 -28
  63. package/dist/Editor/common/ImageSelector/ImageSelector.js +2 -2
  64. package/dist/Editor/common/ImageSelector/Styles.js +9 -3
  65. package/dist/Editor/common/LinkSettings/NavComponents.js +66 -45
  66. package/dist/Editor/common/LinkSettings/index.js +29 -14
  67. package/dist/Editor/common/LinkSettings/navOptions.js +2 -2
  68. package/dist/Editor/common/LinkSettings/style.js +244 -164
  69. package/dist/Editor/common/RnD/ElementOptions/Actions.js +5 -4
  70. package/dist/Editor/common/RnD/ElementSettings/OtherSettings/Settings.js +1 -2
  71. package/dist/Editor/common/RnD/ElementSettings/OtherSettings/Signature.js +3 -4
  72. package/dist/Editor/common/RnD/ElementSettings/Settings/AppHeaderSettings.js +2 -3
  73. package/dist/Editor/common/RnD/ElementSettings/Settings/BoxSettings.js +2 -3
  74. package/dist/Editor/common/RnD/ElementSettings/Settings/ButtonSettings.js +2 -3
  75. package/dist/Editor/common/RnD/ElementSettings/Settings/CodeSettings.js +2 -3
  76. package/dist/Editor/common/RnD/ElementSettings/Settings/FormSettings.js +2 -4
  77. package/dist/Editor/common/RnD/ElementSettings/Settings/ImageSettings.js +2 -3
  78. package/dist/Editor/common/RnD/ElementSettings/Settings/TableSettings.js +2 -3
  79. package/dist/Editor/common/RnD/ElementSettings/Settings/TextSettings.js +1 -3
  80. package/dist/Editor/common/RnD/ElementSettings/Settings/VideoSettings.js +2 -3
  81. package/dist/Editor/common/RnD/ElementSettings/styles.js +1 -0
  82. package/dist/Editor/common/RnD/OptionsPopup/style.js +1 -0
  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 +19 -28
  86. package/dist/Editor/common/RnD/Utils/index.js +1 -3
  87. package/dist/Editor/common/RnD/VirtualElement/VirtualTextElement.js +58 -42
  88. package/dist/Editor/common/RnD/VirtualElement/helper.js +132 -323
  89. package/dist/Editor/common/RnD/VirtualElement/styles.js +0 -16
  90. package/dist/Editor/common/RnD/index.js +39 -68
  91. package/dist/Editor/common/Select/index.js +7 -44
  92. package/dist/Editor/common/Select/styles.js +2 -30
  93. package/dist/Editor/common/Shorthands/elements.js +0 -54
  94. package/dist/Editor/common/StyleBuilder/accordionTitleBtnStyle.js +2 -2
  95. package/dist/Editor/common/StyleBuilder/accordionTitleStyle.js +9 -12
  96. package/dist/Editor/common/StyleBuilder/buttonStyle.js +2 -4
  97. package/dist/Editor/common/StyleBuilder/embedVideoStyle.js +0 -4
  98. package/dist/Editor/common/StyleBuilder/fieldTypes/backgroundImage.js +0 -5
  99. package/dist/Editor/common/StyleBuilder/fieldTypes/bannerSpacing.js +2 -12
  100. package/dist/Editor/common/StyleBuilder/fieldTypes/borderRadius.js +7 -15
  101. package/dist/Editor/common/StyleBuilder/fieldTypes/card.js +8 -16
  102. package/dist/Editor/common/StyleBuilder/fieldTypes/color.js +10 -36
  103. package/dist/Editor/common/StyleBuilder/fieldTypes/fontSize.js +7 -16
  104. package/dist/Editor/common/StyleBuilder/fieldTypes/index.js +1 -3
  105. package/dist/Editor/common/StyleBuilder/fieldTypes/textOptions.js +7 -15
  106. package/dist/Editor/common/SwipeableDrawer/style.js +12 -14
  107. package/dist/Editor/common/Uploader.js +0 -16
  108. package/dist/Editor/common/iconListV2.js +0 -76
  109. package/dist/Editor/common/iconslist.js +0 -21
  110. package/dist/Editor/commonStyle.js +61 -116
  111. package/dist/Editor/helper/index.js +1 -5
  112. package/dist/Editor/helper/theme.js +2 -203
  113. package/dist/Editor/hooks/useMouseMove.js +3 -9
  114. package/dist/Editor/hooks/useTable.js +4 -5
  115. package/dist/Editor/plugins/withEmbeds.js +1 -1
  116. package/dist/Editor/plugins/withHTML.js +1 -3
  117. package/dist/Editor/plugins/withTable.js +1 -1
  118. package/dist/Editor/theme/ThemeList.js +173 -50
  119. package/dist/Editor/utils/SlateUtilityFunctions.js +37 -161
  120. package/dist/Editor/utils/accordion.js +4 -14
  121. package/dist/Editor/utils/button.js +17 -1
  122. package/dist/Editor/utils/customHooks/useTableResize.js +9 -49
  123. package/dist/Editor/utils/draftToSlate.js +2 -3
  124. package/dist/Editor/utils/events.js +6 -50
  125. package/dist/Editor/utils/font.js +37 -40
  126. package/dist/Editor/utils/formfield.js +0 -1
  127. package/dist/Editor/utils/helper.js +26 -188
  128. package/dist/Editor/utils/insertAppHeader.js +1 -1
  129. package/dist/Editor/utils/signature.js +9 -2
  130. package/package.json +4 -4
  131. package/dist/Editor/Elements/FreeGrid/helper.js +0 -115
  132. package/dist/Editor/Toolbar/PopupTool/ThemeTextFormat.js +0 -439
  133. package/dist/Editor/assets/svg/BackIcon.js +0 -18
  134. package/dist/Editor/assets/svg/ThemeIcons.js +0 -293
  135. package/dist/Editor/common/Checkbox/index.js +0 -46
  136. package/dist/Editor/common/Checkbox/styles.js +0 -45
  137. package/dist/Editor/common/CustomColorPicker/index.js +0 -130
  138. package/dist/Editor/common/CustomColorPicker/style.js +0 -53
  139. package/dist/Editor/common/CustomDialog2/index.js +0 -94
  140. package/dist/Editor/common/CustomDialog2/style.js +0 -67
  141. package/dist/Editor/common/CustomSelect.js +0 -43
  142. package/dist/Editor/common/RadioGroup/index.js +0 -48
  143. package/dist/Editor/common/RadioGroup/styles.js +0 -29
  144. package/dist/Editor/common/RnD/Theme/MainThemeProvider.js +0 -17
  145. package/dist/Editor/common/StyleBuilder/fieldTypes/embedUpload.js +0 -115
  146. package/dist/Editor/helper/textIndeces.js +0 -58
  147. package/dist/Editor/hooks/useEditorTheme.js +0 -153
  148. package/dist/Editor/hooks/useThemeValues.js +0 -63
  149. package/dist/Editor/theme/index.js +0 -149
  150. package/dist/Editor/themeSettings/ActiveTheme.js +0 -82
  151. package/dist/Editor/themeSettings/buttons/index.js +0 -300
  152. package/dist/Editor/themeSettings/buttons/style.js +0 -23
  153. package/dist/Editor/themeSettings/colorTheme/index.js +0 -310
  154. package/dist/Editor/themeSettings/colorTheme/style.js +0 -81
  155. package/dist/Editor/themeSettings/fonts/PreviewElement.js +0 -121
  156. package/dist/Editor/themeSettings/fonts/index.js +0 -240
  157. package/dist/Editor/themeSettings/fonts/style.js +0 -62
  158. package/dist/Editor/themeSettings/icons.js +0 -60
  159. package/dist/Editor/themeSettings/index.js +0 -380
  160. package/dist/Editor/themeSettings/style.js +0 -299
  161. package/dist/Editor/themeSettingsAI/icons.js +0 -96
  162. package/dist/Editor/themeSettingsAI/index.js +0 -355
  163. package/dist/Editor/themeSettingsAI/saveTheme.js +0 -202
  164. package/dist/Editor/themeSettingsAI/style.js +0 -332
  165. package/dist/Editor/utils/updateFormName.js +0 -22
@@ -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",
@@ -7,7 +7,6 @@ export const formField = data => {
7
7
  name: `field_${new Date().getTime()}`,
8
8
  key: `field_${new Date().getTime()}`,
9
9
  label: `field_${new Date().getTime()}`,
10
- uid: `field_${new Date().getTime()}`,
11
10
  placeholder: "Placeholder...",
12
11
  children: [{
13
12
  text: ""
@@ -2,8 +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
- import { getCurrentElementText } from "../plugins/withHTML";
7
5
  export const windowVar = {};
8
6
  let ST_TIMEOUT = null;
9
7
  const BLOCKS = ["grid", "dataView"];
@@ -335,8 +333,7 @@ const handleLinkBtnClick = (e, props, isMobilePreview, metadata) => {
335
333
  }
336
334
  }
337
335
  };
338
- export const handleLinkType = (url, linkType, readOnly, openInNewTab, onClick = () => {}, metadata = {}, isEditMode, isCustomMobile // for drawer in App Header
339
- ) => {
336
+ export const handleLinkType = (url, linkType, readOnly, openInNewTab, onClick = () => {}, metadata = {}) => {
340
337
  const props = {};
341
338
  if (!readOnly) {
342
339
  return {
@@ -368,9 +365,6 @@ export const handleLinkType = (url, linkType, readOnly, openInNewTab, onClick =
368
365
  case "page":
369
366
  const [page = "", section] = url?.split("#") || [];
370
367
  const sec = section ? `#${section}` : "";
371
- if (isEditMode) {
372
- break;
373
- }
374
368
  if (page === "_currentPage") {
375
369
  props.component = "button";
376
370
  props.onClick = () => {
@@ -391,12 +385,11 @@ export const handleLinkType = (url, linkType, readOnly, openInNewTab, onClick =
391
385
  const currentUserPage = getCurrentUserPage();
392
386
  props.href = isCurrentPage(page) ? `./${currentUserPage}${sec}` : `./${url}`;
393
387
  if (openInNewTab) {
394
- // if (isCurrentPage(page)) {
395
- // // temp fix, if user is presented in current page, open in new tab option is restricted, we will scroll to the element in current page
396
- // } else {
397
- // props.target = "_blank";
398
- // }
399
- props.target = "_blank";
388
+ if (isCurrentPage(page)) {
389
+ // temp fix, if user is presented in current page, open in new tab option is restricted, we will scroll to the element in current page
390
+ } else {
391
+ props.target = "_blank";
392
+ }
400
393
  }
401
394
  }
402
395
  break;
@@ -431,7 +424,7 @@ export const handleLinkType = (url, linkType, readOnly, openInNewTab, onClick =
431
424
 
432
425
  // for iphone fix
433
426
  if (props.component === "a" && props.href) {
434
- const isMobile = isCustomMobile || getDevice(window.innerWidth) === "xs";
427
+ const isMobile = getDevice(window.innerWidth) === "xs";
435
428
  if (isMobile) {
436
429
  props.component = "button"; // iphone is opening two tabs, on open in new tab because of a tag.
437
430
  }
@@ -492,34 +485,6 @@ export const decodeString = str => {
492
485
  console.log(err);
493
486
  }
494
487
  };
495
- export const getContrastColor = color => {
496
- let r, g, b;
497
-
498
- // Check if the color is in hex format
499
- if (color.startsWith("#")) {
500
- r = parseInt(color.substring(1, 3), 16);
501
- g = parseInt(color.substring(3, 5), 16);
502
- b = parseInt(color.substring(5, 7), 16);
503
- }
504
- // Check if the color is in RGB/RGBA format
505
- else if (color.startsWith("rgb")) {
506
- const rgbValues = color.replace(/^rgba?\(|\s+|\)$/g, "") // Remove the rgb/rgba and spaces
507
- .split(","); // Split the values into an array
508
-
509
- r = parseInt(rgbValues[0]);
510
- g = parseInt(rgbValues[1]);
511
- b = parseInt(rgbValues[2]);
512
- } else {
513
- // If the format is not recognized, default to black text
514
- return "#000000";
515
- }
516
-
517
- // Calculate relative luminance
518
- const luminance = (0.299 * r + 0.587 * g + 0.114 * b) / 255;
519
-
520
- // Return black for light colors, white for dark colors
521
- return luminance > 0.5 ? "#000000" : "#FFFFFF";
522
- };
523
488
  export const onDeleteKey = (event, {
524
489
  editor
525
490
  }) => {
@@ -737,10 +702,6 @@ export const isRestrictedNode = (event, editor) => {
737
702
  return isNodeRestricted;
738
703
  }
739
704
  };
740
- export function capitalizeFirstLetter(str) {
741
- if (!str) return str;
742
- return str.charAt(0).toUpperCase() + str.slice(1);
743
- }
744
705
  export const insertLineBreakAtEndOfPath = (editor, path) => {
745
706
  try {
746
707
  const [node, nodePath] = Editor.node(editor, path); // Get the node at the specified path
@@ -759,13 +720,6 @@ export const insertLineBreakAtEndOfPath = (editor, path) => {
759
720
  console.log(err);
760
721
  }
761
722
  };
762
- export function isHavingSelection(editor) {
763
- try {
764
- return editor?.selection && !Range.isCollapsed(editor.selection);
765
- } catch (err) {
766
- console.log(err);
767
- }
768
- }
769
723
  const omitNodes = ["site-settings", "page-settings"];
770
724
  export function getInitialValue(value = [], readOnly) {
771
725
  if (readOnly === "readonly" && value?.length) {
@@ -796,17 +750,20 @@ export function getInitialValue(value = [], readOnly) {
796
750
  }
797
751
  return value;
798
752
  }
753
+ export function capitalizeFirstLetter(str) {
754
+ if (!str) return str;
755
+ return str.charAt(0).toUpperCase() + str.slice(1);
756
+ }
757
+ export function isHavingSelection(editor) {
758
+ try {
759
+ return editor?.selection && !Range.isCollapsed(editor.selection);
760
+ } catch (err) {
761
+ console.log(err);
762
+ }
763
+ }
799
764
  export function getSelectedCls(defaultCls = "", selected, selectedClsName = "selected") {
800
765
  return `${defaultCls} ${selected ? selectedClsName : ""}`;
801
766
  }
802
- export function handleNegativeInteger(val) {
803
- return val < 0 ? 0 : val;
804
- }
805
- export const containsSurrogatePair = text => {
806
- // Match surrogate pairs (high and low surrogate)
807
- const surrogatePairRegex = /[\uD800-\uDBFF][\uDC00-\uDFFF]/;
808
- return surrogatePairRegex.test(text);
809
- };
810
767
  export const getNodeWithType = (editor, nodeType = "", otherOptions) => {
811
768
  try {
812
769
  const options = {
@@ -820,6 +777,11 @@ export const getNodeWithType = (editor, nodeType = "", otherOptions) => {
820
777
  return [];
821
778
  }
822
779
  };
780
+ export const containsSurrogatePair = text => {
781
+ // Match surrogate pairs (high and low surrogate)
782
+ const surrogatePairRegex = /[\uD800-\uDBFF][\uDC00-\uDFFF]/;
783
+ return surrogatePairRegex.test(text);
784
+ };
823
785
  export const getSlateDom = (editor, range) => {
824
786
  try {
825
787
  const slateDom = ReactEditor.toDOMRange(editor, range);
@@ -869,24 +831,9 @@ export const hideSlateSelection = () => {
869
831
  const root = document.documentElement;
870
832
  root.style.setProperty("--slate-highlight-bg", "none");
871
833
  };
872
- export const insertSlashNode = (editor, insertNode) => {
873
- try {
874
- // Delete the currently selected text
875
- editor.deleteFragment();
876
- const currentText = getCurrentElementText(editor);
877
- const currentPath = editor?.selection?.anchor?.path;
878
- let insertAt = currentPath;
879
- if (currentText?.trim()) {
880
- const parentPath = Path.parent(currentPath);
881
- insertAt = Path.next(parentPath);
882
- }
883
- Transforms.insertNodes(editor, insertNode, {
884
- at: insertAt
885
- });
886
- } catch (err) {
887
- console.log(err);
888
- }
889
- };
834
+ export function handleNegativeInteger(val) {
835
+ return val < 0 ? 0 : val;
836
+ }
890
837
  export const isEverythingSelected = editor => {
891
838
  const {
892
839
  selection
@@ -916,113 +863,4 @@ export const getCurrentNodeText = editor => {
916
863
  } catch (error) {
917
864
  console.log("Error:", error);
918
865
  }
919
- };
920
- function convertColorToRgb(color) {
921
- if (color?.startsWith("#")) {
922
- // HEX to RGB
923
- let hex = color.replace("#", "");
924
- let r, g, b;
925
- if (hex.length === 3) {
926
- hex = hex.split("").map(x => x + x).join("");
927
- }
928
- if (hex.length === 6) {
929
- [r, g, b] = [hex.substring(0, 2), hex.substring(2, 4), hex.substring(4, 6)].map(val => parseInt(val, 16));
930
- return `rgb(${r}, ${g}, ${b})`;
931
- }
932
- } else {
933
- return color;
934
- }
935
- }
936
- export const getSelectedColor = (selectedColor, theme, hideThemeColors) => {
937
- const colorVars = hideThemeColors ? null : theme?.vars?.colors;
938
- let selectedValue = selectedColor;
939
- if (colorVars) {
940
- const convertedColor = convertColorToRgb(selectedColor);
941
- Object.entries(theme.colors).forEach(([key, value]) => {
942
- const convertedThemeColor = convertColorToRgb(value);
943
- if (convertedThemeColor === convertedColor) {
944
- selectedValue = colorVars[key];
945
- }
946
- });
947
- }
948
- return selectedValue;
949
- };
950
- const themeTextFormats = ["headingOne", "headingTwo", "headingThree", "headingFour", "headingFive", "headingSix", "paragraphOne", "paragraphTwo", "paragraphThree"];
951
- export const getSelectedElementColor = (editor, format, theme) => {
952
- const [isThemeText] = Editor.nodes(editor, {
953
- at: editor.selection,
954
- match: n => themeTextFormats.includes(n?.type)
955
- });
956
- if (!isThemeText) {
957
- return activeMark(editor, "color") || "#000000";
958
- }
959
- const color = getSelectedElementStyle(format, editor, format);
960
- return getSelectedColor(color, theme);
961
- };
962
- export const isHavingColor = color => {
963
- if (!color) {
964
- return false;
965
- }
966
- if (color.includes("rgba")) {
967
- const match = color.match(/rgba?\((\d+),\s*(\d+),\s*(\d+),?\s*(\d*\.?\d+)?\)/);
968
- if (!match) return false; // Invalid format
969
-
970
- const alpha = match[4] !== undefined ? parseFloat(match[4]) : 1; // Default alpha = 1
971
- return alpha !== 0;
972
- }
973
- return true;
974
- };
975
- const getCopiedTextFormat = domRange => {
976
- const contents = domRange.cloneContents();
977
- const div = document.createElement("div");
978
- div.appendChild(contents);
979
-
980
- // Replace <br> with newlines
981
- div.querySelectorAll("br").forEach(br => br.replaceWith("\n"));
982
- const BLOCK_TAGS = ["DIV", "P", "LI", "H1", "H2", "H3", "H4", "H5", "H6"];
983
- div.querySelectorAll(BLOCK_TAGS.join(",")).forEach(el => {
984
- el.insertAdjacentText("beforeend", "\n");
985
- });
986
- let text = div.textContent || "";
987
- text = text
988
- // Remove spaces or tabs that appear just before a newline
989
- // e.g., "text \n" → "text\n"
990
- .replace(/[ \t]+\n/g, "\n")
991
-
992
- // Collapse multiple consecutive newlines into a single newline
993
- // e.g., "\n\n\n" → "\n"
994
- .replace(/\n{2,}/g, "\n")
995
-
996
- // Remove leading and trailing whitespace from the final text
997
- .trim();
998
- return text;
999
- };
1000
- const getCopiedHTMLFormat = domRange => {
1001
- const htmlContents = domRange.cloneContents();
1002
- const container = document.createElement("div");
1003
- container.appendChild(htmlContents);
1004
- const html = container.innerHTML;
1005
- return html;
1006
- };
1007
- const getCopiedSlateFormat = editor => {
1008
- // Get Slate fragment
1009
- const fragment = JSON.stringify(Editor.fragment(editor, editor.selection));
1010
- const encodedFragment = window.btoa(encodeURIComponent(fragment));
1011
- return encodedFragment;
1012
- };
1013
- export const handleCopy = (event, editor) => {
1014
- const {
1015
- selection
1016
- } = editor;
1017
- if (!selection || Range.isCollapsed(selection)) return;
1018
- event.preventDefault();
1019
- const domRange = ReactEditor.toDOMRange(editor, selection);
1020
- const text = getCopiedTextFormat(domRange);
1021
- const html = getCopiedHTMLFormat(domRange);
1022
- const encodedFragment = getCopiedSlateFormat(editor);
1023
-
1024
- // Set all formats manually
1025
- event.clipboardData?.setData("text/html", html);
1026
- event.clipboardData?.setData("text/plain", text);
1027
- event.clipboardData?.setData("application/x-slate-fragment", encodedFragment);
1028
866
  };
@@ -51,7 +51,7 @@ export const createAppHeaderNode = ({
51
51
  children: [{
52
52
  type: "grid-item",
53
53
  grid: 12,
54
- children: [appHeaderNode({
54
+ children: [...appHeaderNode({
55
55
  menus
56
56
  })],
57
57
  bgColor: "rgba(255, 255, 255, 0)",
@@ -1,5 +1,9 @@
1
- import { insertSlashNode } from "./helper";
1
+ import { Path, Transforms } from "slate";
2
+ import insertNewLine from "./insertNewLine";
3
+ import { getCurrentElementText } from "../plugins/withHTML";
2
4
  export const insertSignature = editor => {
5
+ const hasText = getCurrentElementText(editor);
6
+ const insertPath = hasText ? Path.next(Path.parent(editor?.selection.focus.path)) : editor.selection.anchor.path;
3
7
  const signature = {
4
8
  type: "signature",
5
9
  alignment: "center",
@@ -13,5 +17,8 @@ export const insertSignature = editor => {
13
17
  text: " "
14
18
  }]
15
19
  };
16
- insertSlashNode(editor, signature);
20
+ Transforms.insertNodes(editor, signature, {
21
+ at: insertPath
22
+ });
23
+ insertNewLine(editor);
17
24
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@flozy/editor",
3
- "version": "10.3.8",
3
+ "version": "10.3.9",
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
- };