@flozy/editor 11.0.6 → 11.0.8

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 (160) hide show
  1. package/dist/Editor/ChatEditor.js +17 -16
  2. package/dist/Editor/CommonEditor.js +141 -28
  3. package/dist/Editor/DialogWrapper.js +31 -25
  4. package/dist/Editor/Editor.css +39 -11
  5. package/dist/Editor/Elements/AI/PopoverAIInput.js +11 -3
  6. package/dist/Editor/Elements/AI/Styles.js +1 -0
  7. package/dist/Editor/Elements/Accordion/Accordion.js +28 -22
  8. package/dist/Editor/Elements/Accordion/AccordionButton.js +12 -3
  9. package/dist/Editor/Elements/AppHeader/AppHeader.js +3 -3
  10. package/dist/Editor/Elements/Attachments/AttachmentStyles.js +16 -0
  11. package/dist/Editor/Elements/Attachments/Attachments.js +153 -11
  12. package/dist/Editor/Elements/Attachments/AttachmentsButton.js +8 -3
  13. package/dist/Editor/Elements/Button/EditorButton.js +23 -7
  14. package/dist/Editor/Elements/Color Picker/ColorButtons.js +61 -14
  15. package/dist/Editor/Elements/Color Picker/ColorPicker.css +25 -1
  16. package/dist/Editor/Elements/Color Picker/ColorPicker.js +10 -7
  17. package/dist/Editor/Elements/Color Picker/Styles.js +15 -13
  18. package/dist/Editor/Elements/DataView/Layouts/DataTypes/Components/Select.js +134 -55
  19. package/dist/Editor/Elements/DataView/Layouts/DataTypes/Components/SelectV1.js +7 -8
  20. package/dist/Editor/Elements/DataView/Layouts/DataTypes/PersonType.js +8 -3
  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.js +36 -43
  24. package/dist/Editor/Elements/Embed/Image.js +236 -23
  25. package/dist/Editor/Elements/Embed/Video.js +245 -15
  26. package/dist/Editor/Elements/Form/Form.js +35 -10
  27. package/dist/Editor/Elements/Form/FormField.js +1 -1
  28. package/dist/Editor/Elements/Form/Workflow/Styles.js +24 -22
  29. package/dist/Editor/Elements/Form/Workflow/constant.js +25 -1
  30. package/dist/Editor/Elements/FreeGrid/FreeGrid.js +31 -74
  31. package/dist/Editor/Elements/FreeGrid/FreeGridBox.js +9 -5
  32. package/dist/Editor/Elements/FreeGrid/FreeGridItem.js +3 -1
  33. package/dist/Editor/Elements/FreeGrid/Options/More.js +7 -7
  34. package/dist/Editor/Elements/FreeGrid/helper.js +194 -0
  35. package/dist/Editor/Elements/FreeGrid/styles.js +15 -0
  36. package/dist/Editor/Elements/Grid/GridItem.js +1 -1
  37. package/dist/Editor/Elements/PageSettings/PageSettingsButton.js +2 -1
  38. package/dist/Editor/Elements/Signature/SignatureOptions/TypeSignature.js +3 -2
  39. package/dist/Editor/Elements/Signature/SignaturePopup.js +24 -6
  40. package/dist/Editor/Elements/SimpleText/style.js +2 -2
  41. package/dist/Editor/Elements/Table/Table.js +5 -4
  42. package/dist/Editor/Elements/Table/TableCell.js +10 -3
  43. package/dist/Editor/Elements/Title/title.js +10 -11
  44. package/dist/Editor/Elements/TopBanner/TopBanner.js +4 -2
  45. package/dist/Editor/Elements/TopBanner/TopBannerButton.js +5 -3
  46. package/dist/Editor/Elements/Variables/VariableButton.js +10 -1
  47. package/dist/Editor/MiniEditor.js +2 -1
  48. package/dist/Editor/Styles/EditorStyles.js +23 -5
  49. package/dist/Editor/Toolbar/FormatTools/Dropdown.js +27 -3
  50. package/dist/Editor/Toolbar/FormatTools/FontFamilyAutocomplete.js +4 -3
  51. package/dist/Editor/Toolbar/FormatTools/MarkButton.js +2 -2
  52. package/dist/Editor/Toolbar/FormatTools/TextSize.js +33 -29
  53. package/dist/Editor/Toolbar/Mini/MiniToolbar.js +2 -1
  54. package/dist/Editor/Toolbar/PopupTool/MiniTextFormat/MiniColorPicker.js +4 -2
  55. package/dist/Editor/Toolbar/PopupTool/MiniTextFormat/SelectFontSize.js +25 -23
  56. package/dist/Editor/Toolbar/PopupTool/MiniTextFormat/SelectList.js +25 -7
  57. package/dist/Editor/Toolbar/PopupTool/MiniTextFormat/SelectTypography.js +167 -42
  58. package/dist/Editor/Toolbar/PopupTool/MiniTextFormat/index.js +24 -8
  59. package/dist/Editor/Toolbar/PopupTool/PopperHeader.js +2 -1
  60. package/dist/Editor/Toolbar/PopupTool/PopupToolStyle.js +70 -10
  61. package/dist/Editor/Toolbar/PopupTool/TextFormat.js +73 -14
  62. package/dist/Editor/Toolbar/PopupTool/ThemeTextFormat.js +439 -0
  63. package/dist/Editor/Toolbar/PopupTool/index.js +7 -4
  64. package/dist/Editor/Toolbar/toolbarGroups.js +56 -10
  65. package/dist/Editor/assets/svg/BackIcon.js +18 -0
  66. package/dist/Editor/assets/svg/ThemeIcons.js +293 -0
  67. package/dist/Editor/common/ColorPickerButton.js +38 -16
  68. package/dist/Editor/common/CustomColorPicker/index.js +130 -0
  69. package/dist/Editor/common/CustomColorPicker/style.js +53 -0
  70. package/dist/Editor/common/CustomDialog2/index.js +94 -0
  71. package/dist/Editor/common/CustomDialog2/style.js +67 -0
  72. package/dist/Editor/common/CustomSelect.js +43 -0
  73. package/dist/Editor/common/DnD/DragHandleButton.js +1 -1
  74. package/dist/Editor/common/FontLoader/FontLoader.js +4 -0
  75. package/dist/Editor/common/Icon.js +28 -0
  76. package/dist/Editor/common/ImageSelector/ImageSelector.js +45 -7
  77. package/dist/Editor/common/ImageSelector/Options/Upload.js +26 -11
  78. package/dist/Editor/common/ImageSelector/Styles.js +3 -9
  79. package/dist/Editor/common/LinkSettings/NavComponents.js +6 -2
  80. package/dist/Editor/common/MentionsPopup/index.js +9 -1
  81. package/dist/Editor/common/RnD/ElementSettings/OtherSettings/Settings.js +2 -1
  82. package/dist/Editor/common/RnD/ElementSettings/Settings/AppHeaderSettings.js +3 -2
  83. package/dist/Editor/common/RnD/ElementSettings/Settings/BoxSettings.js +3 -2
  84. package/dist/Editor/common/RnD/ElementSettings/Settings/ButtonSettings.js +3 -2
  85. package/dist/Editor/common/RnD/ElementSettings/Settings/CodeSettings.js +3 -2
  86. package/dist/Editor/common/RnD/ElementSettings/Settings/FormSettings.js +4 -2
  87. package/dist/Editor/common/RnD/ElementSettings/Settings/ImageSettings.js +20 -7
  88. package/dist/Editor/common/RnD/ElementSettings/Settings/TableSettings.js +3 -2
  89. package/dist/Editor/common/RnD/ElementSettings/Settings/TextSettings.js +9 -1
  90. package/dist/Editor/common/RnD/ElementSettings/Settings/VideoSettings.js +20 -7
  91. package/dist/Editor/common/RnD/GuideLines/styles.js +1 -1
  92. package/dist/Editor/common/RnD/SwitchViewport/SwitchViewport.js +11 -2
  93. package/dist/Editor/common/RnD/Theme/MainThemeProvider.js +17 -0
  94. package/dist/Editor/common/RnD/Theme/ViewportStimulator.js +6 -3
  95. package/dist/Editor/common/RnD/Utils/gridDropItem.js +28 -11
  96. package/dist/Editor/common/RnD/Utils/index.js +3 -1
  97. package/dist/Editor/common/RnD/VirtualElement/VirtualTextElement.js +52 -63
  98. package/dist/Editor/common/RnD/VirtualElement/helper.js +320 -130
  99. package/dist/Editor/common/RnD/VirtualElement/styles.js +22 -0
  100. package/dist/Editor/common/RnD/index.js +61 -14
  101. package/dist/Editor/common/Shorthands/elements.js +62 -4
  102. package/dist/Editor/common/StyleBuilder/buttonStyle.js +4 -2
  103. package/dist/Editor/common/StyleBuilder/embedVideoStyle.js +4 -0
  104. package/dist/Editor/common/StyleBuilder/fieldStyle.js +1 -0
  105. package/dist/Editor/common/StyleBuilder/fieldTypes/backgroundImage.js +15 -2
  106. package/dist/Editor/common/StyleBuilder/fieldTypes/bannerSpacing.js +12 -2
  107. package/dist/Editor/common/StyleBuilder/fieldTypes/borderRadius.js +15 -7
  108. package/dist/Editor/common/StyleBuilder/fieldTypes/card.js +16 -8
  109. package/dist/Editor/common/StyleBuilder/fieldTypes/color.js +36 -10
  110. package/dist/Editor/common/StyleBuilder/fieldTypes/embedUpload.js +115 -0
  111. package/dist/Editor/common/StyleBuilder/fieldTypes/fontSize.js +16 -7
  112. package/dist/Editor/common/StyleBuilder/fieldTypes/index.js +3 -1
  113. package/dist/Editor/common/StyleBuilder/fieldTypes/menusArray.js +2 -0
  114. package/dist/Editor/common/StyleBuilder/fieldTypes/text.js +1 -0
  115. package/dist/Editor/common/StyleBuilder/fieldTypes/textOptions.js +15 -7
  116. package/dist/Editor/common/StyleBuilder/formStyle.js +19 -13
  117. package/dist/Editor/common/StyleBuilder/index.js +8 -4
  118. package/dist/Editor/common/Uploader.js +125 -17
  119. package/dist/Editor/common/UploaderWithProgress.js +183 -0
  120. package/dist/Editor/common/iconslist.js +21 -0
  121. package/dist/Editor/commonStyle.js +136 -63
  122. package/dist/Editor/helper/index.js +10 -2
  123. package/dist/Editor/helper/textIndeces.js +58 -0
  124. package/dist/Editor/helper/theme.js +203 -2
  125. package/dist/Editor/hooks/useEditorTheme.js +153 -0
  126. package/dist/Editor/hooks/useMouseMove.js +9 -3
  127. package/dist/Editor/hooks/useTable.js +62 -1
  128. package/dist/Editor/hooks/useThemeValues.js +63 -0
  129. package/dist/Editor/plugins/withEmbeds.js +12 -1
  130. package/dist/Editor/plugins/withHTML.js +58 -3
  131. package/dist/Editor/plugins/withTable.js +1 -1
  132. package/dist/Editor/service/fileupload.js +70 -0
  133. package/dist/Editor/theme/ThemeList.js +50 -173
  134. package/dist/Editor/theme/index.js +149 -0
  135. package/dist/Editor/themeSettings/ActiveTheme.js +82 -0
  136. package/dist/Editor/themeSettings/buttons/index.js +300 -0
  137. package/dist/Editor/themeSettings/buttons/style.js +23 -0
  138. package/dist/Editor/themeSettings/colorTheme/index.js +310 -0
  139. package/dist/Editor/themeSettings/colorTheme/style.js +81 -0
  140. package/dist/Editor/themeSettings/fonts/PreviewElement.js +121 -0
  141. package/dist/Editor/themeSettings/fonts/index.js +240 -0
  142. package/dist/Editor/themeSettings/fonts/style.js +62 -0
  143. package/dist/Editor/themeSettings/icons.js +60 -0
  144. package/dist/Editor/themeSettings/index.js +380 -0
  145. package/dist/Editor/themeSettings/style.js +299 -0
  146. package/dist/Editor/themeSettingsAI/icons.js +96 -0
  147. package/dist/Editor/themeSettingsAI/index.js +355 -0
  148. package/dist/Editor/themeSettingsAI/saveTheme.js +202 -0
  149. package/dist/Editor/themeSettingsAI/style.js +332 -0
  150. package/dist/Editor/utils/SlateUtilityFunctions.js +192 -40
  151. package/dist/Editor/utils/accordion.js +67 -39
  152. package/dist/Editor/utils/button.js +1 -17
  153. package/dist/Editor/utils/draftToSlate.js +3 -2
  154. package/dist/Editor/utils/events.js +94 -89
  155. package/dist/Editor/utils/font.js +40 -37
  156. package/dist/Editor/utils/formfield.js +2 -2
  157. package/dist/Editor/utils/helper.js +100 -23
  158. package/dist/Editor/utils/insertAppHeader.js +8 -4
  159. package/package.json +4 -4
  160. package/dist/Editor/Elements/DataView/Layouts/DataTypes/Components/MultiSelect.js +0 -454
@@ -197,9 +197,102 @@ 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
+ };
200
294
  export const enterEvent = (e, editor, isMobile) => {
201
295
  try {
202
- const ele = isListItem(editor);
203
296
  // on shift enter break line in same node
204
297
  if (e.shiftKey && !isMobile) {
205
298
  e.preventDefault();
@@ -211,94 +304,6 @@ export const enterEvent = (e, editor, isMobile) => {
211
304
  } else {
212
305
  Transforms.insertText(editor, "\n");
213
306
  }
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
- }
302
307
  }
303
308
  // Handle blockquote splitting
304
309
  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: "'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"
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'
47
47
  };
48
48
  export const fontOptions = Object.keys(fontFamilyMap).map(m => {
49
49
  return {
@@ -62,7 +62,10 @@ 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"
65
+ headingThree: "19px",
66
+ headingFour: "16px",
67
+ headingFive: "13px",
68
+ headingSix: "11px"
66
69
  };
67
70
  export const fontWeightOptions = [{
68
71
  text: "Bold",
@@ -13,8 +13,8 @@ export const formField = data => {
13
13
  text: ""
14
14
  }],
15
15
  field_type: "text",
16
- bgColor: data?.bgColor ? data?.bgColor : "rgba(255, 255, 255, 1)",
17
- borderColor: data?.borderColor ? data?.borderColor : "#ccc",
16
+ bgColor: data?.bgColor ? data?.bgColor : "",
17
+ borderColor: data?.borderColor ? data?.borderColor : "",
18
18
  bannerSpacing: {
19
19
  left: 16,
20
20
  right: 16,
@@ -2,7 +2,9 @@ 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";
5
6
  import { getCurrentElementText } from "../plugins/withHTML";
7
+ import { isEmptyTextNode } from "../helper";
6
8
  export const windowVar = {};
7
9
  let ST_TIMEOUT = null;
8
10
  const BLOCKS = ["grid", "dataView"];
@@ -173,7 +175,7 @@ export const handleInsertLastElement = (event, editor) => {
173
175
  if (isFreeGrid) {
174
176
  return;
175
177
  }
176
- const isLastElementEmpty = lastElement && lastElement.type === "paragraph" && !lastElement.children[0]?.text && !lastElement.children?.some(c => BLOCKS.includes(c.type));
178
+ const isLastElementEmpty = isEmptyTextNode(lastElement) && !lastElement.children?.some(c => BLOCKS.includes(c.type));
177
179
  if (!ReactEditor.isFocused(editor)) {
178
180
  if (isLastElementEmpty) {
179
181
  if (hasPath) {
@@ -217,9 +219,13 @@ export const handleInsertLastElement = (event, editor) => {
217
219
  };
218
220
  export const isListItem = editor => {
219
221
  const format = ["list-item", "check-list-item", "accordion-summary", "headingOne", "headingTwo", "headingThree"];
220
- const [node] = Editor.nodes(editor, {
222
+ const [node1, node2] = Editor.nodes(editor, {
221
223
  match: n => !Editor.isEditor(n) && Element.isElement(n) && format.indexOf(n.type) > -1
222
224
  });
225
+ let node = node1;
226
+ if (node2 && node2[0] && node2[0].type === "accordion-summary") {
227
+ node = node2;
228
+ }
223
229
  return node;
224
230
  };
225
231
  export const getNode = (editor, path) => {
@@ -492,6 +498,34 @@ export const decodeString = str => {
492
498
  console.log(err);
493
499
  }
494
500
  };
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
+ };
495
529
  export const onDeleteKey = (event, {
496
530
  editor
497
531
  }) => {
@@ -709,6 +743,10 @@ export const isRestrictedNode = (event, editor) => {
709
743
  return isNodeRestricted;
710
744
  }
711
745
  };
746
+ export function capitalizeFirstLetter(str) {
747
+ if (!str) return str;
748
+ return str.charAt(0).toUpperCase() + str.slice(1);
749
+ }
712
750
  export const insertLineBreakAtEndOfPath = (editor, path) => {
713
751
  try {
714
752
  const [node, nodePath] = Editor.node(editor, path); // Get the node at the specified path
@@ -727,6 +765,13 @@ export const insertLineBreakAtEndOfPath = (editor, path) => {
727
765
  console.log(err);
728
766
  }
729
767
  };
768
+ export function isHavingSelection(editor) {
769
+ try {
770
+ return editor?.selection && !Range.isCollapsed(editor.selection);
771
+ } catch (err) {
772
+ console.log(err);
773
+ }
774
+ }
730
775
  const omitNodes = ["site-settings", "page-settings"];
731
776
  export function getInitialValue(value = [], readOnly) {
732
777
  if (readOnly === "readonly" && value?.length) {
@@ -757,20 +802,17 @@ export function getInitialValue(value = [], readOnly) {
757
802
  }
758
803
  return value;
759
804
  }
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
- }
771
805
  export function getSelectedCls(defaultCls = "", selected, selectedClsName = "selected") {
772
806
  return `${defaultCls} ${selected ? selectedClsName : ""}`;
773
807
  }
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
+ };
774
816
  export const getNodeWithType = (editor, nodeType = "", otherOptions) => {
775
817
  try {
776
818
  const options = {
@@ -784,11 +826,6 @@ export const getNodeWithType = (editor, nodeType = "", otherOptions) => {
784
826
  return [];
785
827
  }
786
828
  };
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
- };
792
829
  export const getSlateDom = (editor, range) => {
793
830
  try {
794
831
  const slateDom = ReactEditor.toDOMRange(editor, range);
@@ -829,7 +866,8 @@ export const clearWindowSelection = () => {
829
866
 
830
867
  export const viewSlateSelection = () => {
831
868
  // 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
832
- clearWindowSelection();
869
+ // clearWindowSelection();
870
+
833
871
  const selectionBg = "rgba(35, 131, 226, 0.35)";
834
872
  const root = document.documentElement;
835
873
  root.style.setProperty("--slate-highlight-bg", selectionBg);
@@ -838,9 +876,6 @@ export const hideSlateSelection = () => {
838
876
  const root = document.documentElement;
839
877
  root.style.setProperty("--slate-highlight-bg", "none");
840
878
  };
841
- export function handleNegativeInteger(val) {
842
- return val < 0 ? 0 : val;
843
- }
844
879
  export const insertSlashNode = (editor, insertNode) => {
845
880
  try {
846
881
  // Delete the currently selected text
@@ -983,4 +1018,46 @@ export const handleCopy = (event, editor) => {
983
1018
  event.clipboardData?.setData("text/plain", text);
984
1019
  event.clipboardData?.setData("application/x-slate-fragment", encodedFragment);
985
1020
  };
986
- export const ALLOWED_TEXT_NODES = ["paragraph", "title", "headingOne", "headingTwo", "headingThree", "headingFour", "headingFive", "headingSix", "blockquote"];
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
+ };
@@ -8,27 +8,31 @@ export const appHeaderNode = ({
8
8
  appLogo: "none",
9
9
  menus: menus || [{
10
10
  type: "menu",
11
- url: "home",
11
+ url: "",
12
+ placeholder: "home",
12
13
  target: "",
13
14
  text: "Home",
14
15
  linkType: "page"
15
16
  }, {
16
17
  type: "menu",
17
- url: "wireframe2",
18
+ url: "",
19
+ placeholder: "wireframe2",
18
20
  target: "",
19
21
  text: "Wireframe",
20
22
  linkType: "page"
21
23
  }, {
22
24
  type: "menu",
23
- url: "https://www.google.com",
25
+ url: "",
24
26
  target: "",
27
+ placeholder: "Work",
25
28
  text: "Work",
26
29
  linkType: "webAddress"
27
30
  }, {
28
31
  type: "menu",
29
- url: "https://www.google.com",
32
+ url: "",
30
33
  target: "",
31
34
  text: "Contact",
35
+ placeholder: "Contact",
32
36
  linkType: "webAddress"
33
37
  }],
34
38
  menuStyle: "stacked",
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@flozy/editor",
3
- "version": "11.0.6",
3
+ "version": "11.0.8",
4
4
  "description": "An Editor for flozy app brain",
5
5
  "files": [
6
6
  "dist"
@@ -38,7 +38,6 @@
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",
42
41
  "react-signature-canvas": "^1.0.6",
43
42
  "react-slick": "^0.29.0",
44
43
  "sanitize-html": "^2.13.0",
@@ -69,7 +68,7 @@
69
68
  "storybook": "storybook dev -p 6006",
70
69
  "build-storybook": "NODE_OPTIONS='--max_old_space_size=4096' storybook build",
71
70
  "publish:npm": "rm -rf dist && mkdir dist && babel src/components -d 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",
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",
73
72
  "publish:flozy": "./publish-flozy.sh",
74
73
  "publish:flozy2": "./publish-flozy2.sh",
75
74
  "publish:permission": "chmod +x publish-flozy.sh && chmod +x publish-flozy2.sh"
@@ -122,7 +121,8 @@
122
121
  "prop-types": "^15.8.1",
123
122
  "source-map-explorer": "^2.5.3",
124
123
  "storybook": "^7.4.0",
125
- "webpack": "^5.88.2"
124
+ "webpack": "^5.88.2",
125
+ "react-scripts": "5.0.1"
126
126
  },
127
127
  "overrides": {
128
128
  "react-refresh": "0.11.0"