@flozy/editor 6.0.4 → 6.0.5

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 (50) hide show
  1. package/dist/Editor/CommonEditor.js +17 -15
  2. package/dist/Editor/Editor.css +3 -4
  3. package/dist/Editor/Elements/AI/PopoverAIInput.js +12 -2
  4. package/dist/Editor/Elements/Button/EditorButton.js +0 -1
  5. package/dist/Editor/Elements/DataView/DataView.js +3 -4
  6. package/dist/Editor/Elements/DataView/Layouts/DataTypes/NumberType.js +1 -5
  7. package/dist/Editor/Elements/DataView/Layouts/DataTypes/TextType.js +1 -5
  8. package/dist/Editor/Elements/DataView/Layouts/FilterView.js +19 -23
  9. package/dist/Editor/Elements/Form/Form.js +0 -1
  10. package/dist/Editor/Elements/FreeGrid/styles.js +0 -1
  11. package/dist/Editor/Elements/List/CheckList.js +1 -2
  12. package/dist/Editor/Elements/Search/SearchAttachment.js +0 -1
  13. package/dist/Editor/Elements/Search/SearchList.js +1 -8
  14. package/dist/Editor/Elements/SimpleText/index.js +7 -19
  15. package/dist/Editor/Elements/SimpleText/style.js +1 -5
  16. package/dist/Editor/Elements/Table/Table.js +15 -15
  17. package/dist/Editor/Elements/Table/TableCell.js +9 -14
  18. package/dist/Editor/MiniEditor.js +2 -4
  19. package/dist/Editor/Toolbar/PopupTool/AddTemplates.js +28 -37
  20. package/dist/Editor/Toolbar/PopupTool/MiniTextFormat/SelectAlignment.js +1 -3
  21. package/dist/Editor/Toolbar/PopupTool/MiniTextFormat/SelectFontSize.js +1 -1
  22. package/dist/Editor/Toolbar/PopupTool/MiniTextFormat/SelectList.js +1 -3
  23. package/dist/Editor/Toolbar/PopupTool/MiniTextFormat/SelectTypography.js +8 -3
  24. package/dist/Editor/Toolbar/PopupTool/MiniTextFormat/index.js +3 -9
  25. package/dist/Editor/Toolbar/PopupTool/TemplateCard.js +1 -1
  26. package/dist/Editor/Toolbar/PopupTool/TextFormat.js +0 -45
  27. package/dist/Editor/Toolbar/PopupTool/index.js +29 -39
  28. package/dist/Editor/common/FontLoader/FontList.js +11 -11
  29. package/dist/Editor/common/FontLoader/FontLoader.js +75 -45
  30. package/dist/Editor/common/ImageSelector/Options/Upload.js +1 -1
  31. package/dist/Editor/common/ImageSelector/UploadStyles.js +1 -2
  32. package/dist/Editor/common/RnD/ElementSettings/styles.js +0 -1
  33. package/dist/Editor/common/RnD/SwitchViewport/SwitchViewport.js +0 -6
  34. package/dist/Editor/common/Section/index.js +60 -89
  35. package/dist/Editor/common/StyleBuilder/fieldTypes/index.js +1 -3
  36. package/dist/Editor/common/StyleBuilder/pageSettingsStyle.js +0 -4
  37. package/dist/Editor/commonStyle.js +0 -5
  38. package/dist/Editor/helper/deserialize/index.js +1 -1
  39. package/dist/Editor/helper/theme.js +1 -24
  40. package/dist/Editor/hooks/useEditorScroll.js +1 -1
  41. package/dist/Editor/hooks/useMouseMove.js +4 -6
  42. package/dist/Editor/plugins/withHTML.js +1 -7
  43. package/dist/Editor/utils/SlateUtilityFunctions.js +10 -11
  44. package/dist/Editor/utils/customHooks/useTableResize.js +1 -2
  45. package/dist/Editor/utils/helper.js +0 -41
  46. package/dist/Editor/utils/pageSettings.js +2 -14
  47. package/dist/Editor/utils/table.js +0 -21
  48. package/package.json +3 -3
  49. package/dist/Editor/common/StyleBuilder/fieldTypes/lineSpacing.js +0 -79
  50. package/dist/Editor/helper/ensureWrappedVariables.js +0 -28
@@ -4,7 +4,6 @@ import TemplateCard from "./TemplateCard";
4
4
  import FullViewCard from "./FullViewCard";
5
5
  import ButtonTemplateCard from "./ButtonTemplatesCard";
6
6
  import { jsx as _jsx } from "react/jsx-runtime";
7
- import { Fragment as _Fragment } from "react/jsx-runtime";
8
7
  import { jsxs as _jsxs } from "react/jsx-runtime";
9
8
  const CATEGORIES_SORT_INDEX = {
10
9
  Brief: 1,
@@ -47,7 +46,7 @@ const ProgressBar = ({
47
46
  alignItems: "center",
48
47
  margin: 0,
49
48
  padding: 0,
50
- height: "300px",
49
+ height: "50px",
51
50
  overflow: "hidden"
52
51
  },
53
52
  children: /*#__PURE__*/_jsx(CircularProgress, {})
@@ -70,49 +69,41 @@ const AddTemplates = props => {
70
69
  const [categories, setCategories] = useState([]);
71
70
  const [category, setCategory] = useState("");
72
71
  const [templates, setTemplates] = useState([]);
72
+ const [filteredTemplates, setFilteredTemplates] = useState([]);
73
73
  useEffect(() => {
74
- getCategoryList();
74
+ getTemplatesList();
75
75
  }, []);
76
- const getCategoryList = async () => {
77
- setLoading(true);
78
- const categoryDB = await services("listCategory");
79
- if (categoryDB?.data?.Template?.length > 0) {
80
- setCategories(categoryDB.data.Template);
81
- setCategory(categoryDB.data.Template[0]);
82
- getTemplatesList(categoryDB.data.Template[0]);
83
- }
84
- setLoading(false);
76
+ const sortCategory = (a, b) => {
77
+ return (CATEGORIES_SORT_INDEX[a] || Infinity) - (CATEGORIES_SORT_INDEX[b] || Infinity);
85
78
  };
86
- const getTemplatesList = async selectedCategory => {
79
+ const getTemplatesList = async () => {
87
80
  setLoading(true);
88
- const result = await services("listTemplates", {
89
- category: selectedCategory
90
- });
91
- setTemplates(result?.data || []);
81
+ const result = await services("listTemplates", {});
82
+ const tempList = result?.data?.filter(f => f.type === "Template");
83
+ const lic = tempList?.reduce((a, b) => {
84
+ if (a.indexOf(b.category) < 0) {
85
+ a.push(b.category);
86
+ }
87
+ return a;
88
+ }, []).sort(sortCategory);
89
+ const ft = tempList?.filter(f => f.category === lic[0]);
90
+ setTemplates(tempList);
91
+ setCategories(lic);
92
+ setCategory(lic[0]);
93
+ setFilteredTemplates(ft);
92
94
  setLoading(false);
93
95
  };
94
96
  const handleChange = (event, newValue) => {
95
- setTemplates([]);
96
97
  onSearch("");
97
98
  setCategory(newValue);
98
- getTemplatesList(newValue);
99
+ setFilteredTemplates(templates.filter(f => f.category === newValue));
99
100
  };
100
- const onSelectTemplate = card => async () => {
101
+ const onSelectTemplate = card => () => {
101
102
  try {
102
- const {
103
- data
104
- } = await services("templateContent", {
105
- id: card?.id
106
- });
107
- const content = data?.content;
108
- if (content) {
109
- editor.insertNode(JSON.parse(content));
110
- } else {
111
- console.log("No data found");
112
- }
103
+ editor.insertNode(JSON.parse(card.content));
113
104
  onClose();
114
105
  } catch (err) {
115
- console.log("Error inserting template content into editor:", err);
106
+ console.log(err);
116
107
  }
117
108
  };
118
109
  const filterByTitle = f => {
@@ -182,16 +173,16 @@ const AddTemplates = props => {
182
173
  data: categories,
183
174
  handleChange: handleChange
184
175
  })
185
- }), /*#__PURE__*/_jsx(Grid, {
176
+ }), /*#__PURE__*/_jsxs(Grid, {
186
177
  container: true,
187
178
  spacing: 0,
188
179
  className: `${fullScreen ? "fullscreen" : ""}`,
189
180
  sx: classes.templateCardsWrpr,
190
- children: loading ? /*#__PURE__*/_jsx(ProgressBar, {
181
+ children: [/*#__PURE__*/_jsx(ProgressBar, {
191
182
  loading: loading
192
- }) : /*#__PURE__*/_jsx(_Fragment, {
193
- children: templates.filter(filterByTitle).map(renderTemplate)
194
- })
183
+ }), filteredTemplates.filter(filterByTitle).map(m => {
184
+ return renderTemplate(m);
185
+ })]
195
186
  })]
196
187
  });
197
188
  };
@@ -51,8 +51,7 @@ const alignmentOptions = [{
51
51
  }];
52
52
  function SelectAlignment({
53
53
  editor,
54
- classes,
55
- closeMainPopup
54
+ classes
56
55
  }) {
57
56
  const selected = useMemo(() => {
58
57
  return alignmentOptions.find(t => isBlockActive(editor, t.value));
@@ -60,7 +59,6 @@ function SelectAlignment({
60
59
  const onChange = (format, option) => {
61
60
  if (option.type === "block") {
62
61
  toggleBlock(editor, format);
63
- closeMainPopup();
64
62
  }
65
63
  };
66
64
  return /*#__PURE__*/_jsx(CustomSelectTool, {
@@ -59,7 +59,7 @@ function SelectFontSize({
59
59
  size = value;
60
60
  }
61
61
  });
62
- return isNaN(parseInt(size)) ? 14 : parseInt(size);
62
+ return parseInt(size);
63
63
  } catch (err) {
64
64
  return "";
65
65
  }
@@ -68,8 +68,7 @@ const listOptions = [{
68
68
  }];
69
69
  function SelectList({
70
70
  editor,
71
- classes,
72
- closeMainPopup
71
+ classes
73
72
  }) {
74
73
  const selectedList = useMemo(() => {
75
74
  return listOptions.find(t => isBlockActive(editor, t.value));
@@ -80,7 +79,6 @@ function SelectList({
80
79
  } else if (option.type === "accordion") {
81
80
  insertAccordion(editor);
82
81
  }
83
- closeMainPopup();
84
82
  };
85
83
  return /*#__PURE__*/_jsx(CustomSelectTool, {
86
84
  options: listOptions,
@@ -125,6 +125,7 @@ function SelectTypography({
125
125
  ...upData
126
126
  }
127
127
  });
128
+ closeMainPopup();
128
129
  };
129
130
  const selectedBlock = useMemo(() => {
130
131
  return typographyOptions.find(t => {
@@ -151,17 +152,21 @@ function SelectTypography({
151
152
  toggleBlock(editor, format);
152
153
  if (option.type === "block") {
153
154
  // reset old font size
154
- // let updatedValue = !selectedBlock ? {} : { xs: "16px", sm: "16px", md: "16px", lg: "16px" }
155
+ let updatedValue = !selectedBlock ? {} : {
156
+ xs: "16px",
157
+ sm: "16px",
158
+ md: "16px",
159
+ lg: "16px"
160
+ };
155
161
  addMarkData(editor, {
156
162
  format: "fontSize",
157
- value: {}
163
+ value: updatedValue
158
164
  });
159
165
  } else if (option.type === "mark") {
160
166
  const size = sizeMap[option.value] || "";
161
167
  const [sizeInNumber] = size.split("px");
162
168
  updateMarkData(Number(sizeInNumber));
163
169
  }
164
- closeMainPopup();
165
170
  };
166
171
  return /*#__PURE__*/_jsx(CustomSelectTool, {
167
172
  options: typographyOptions,
@@ -14,7 +14,6 @@ import MiniColorPicker from "./MiniColorPicker";
14
14
  import SelectAlignment from "./SelectAlignment";
15
15
  import SelectFontSize from "./SelectFontSize";
16
16
  import InfinityAITool from "./InfinityAITool";
17
- import { viewSlateSelection } from "../../../utils/helper";
18
17
  import { jsx as _jsx } from "react/jsx-runtime";
19
18
  import { jsxs as _jsxs } from "react/jsx-runtime";
20
19
  const DEFAULT_COLOR = {
@@ -61,15 +60,13 @@ const MiniTextFormat = props => {
61
60
  className: "verticalLine"
62
61
  }), /*#__PURE__*/_jsx(SelectList, {
63
62
  classes: classes,
64
- editor: editor,
65
- closeMainPopup: closeMainPopup
63
+ editor: editor
66
64
  }), /*#__PURE__*/_jsx("div", {
67
65
  className: "verticalLine mr-1"
68
66
  }), /*#__PURE__*/_jsx(SelectAlignment, {
69
67
  fontAlign: fontAlign,
70
68
  classes: classes,
71
- editor: editor,
72
- closeMainPopup: closeMainPopup
69
+ editor: editor
73
70
  }), /*#__PURE__*/_jsx("div", {
74
71
  className: "verticalLine mr-1"
75
72
  }), /*#__PURE__*/_jsx(SelectFontSize, {
@@ -101,10 +98,7 @@ const MiniTextFormat = props => {
101
98
  editor: editor,
102
99
  customProps: customProps
103
100
  }, link.id), /*#__PURE__*/_jsx(IconButton, {
104
- onClick: e => {
105
- viewSlateSelection();
106
- setAnchorEl(document.getElementById("mini-text-editor-wrapper"));
107
- },
101
+ onClick: e => setAnchorEl(document.getElementById("mini-text-editor-wrapper")),
108
102
  className: `textSettingsIcon ${open ? "btnActive" : ""}`,
109
103
  children: /*#__PURE__*/_jsx(TextToolIcon, {})
110
104
  }), /*#__PURE__*/_jsx(Popper, {
@@ -47,7 +47,7 @@ const TemplateCard = props => {
47
47
  }), /*#__PURE__*/_jsx(CardMedia, {
48
48
  className: `template-card-media ${fullScreen ? "fullscreen" : ""}`,
49
49
  component: "div",
50
- image: m?.compressedThum || m?.thumbnail,
50
+ image: m?.thumbnail,
51
51
  alt: m?.title,
52
52
  sx: classes.templateCardMedia
53
53
  }), /*#__PURE__*/_jsx(PreviewAndSelect, {
@@ -14,8 +14,6 @@ import SelectSuperSubscript from "./MiniTextFormat/SelectSuperSubscript";
14
14
  import { ColorResetIcon, TextDefaultStyleIcon } from "../../common/iconListV2";
15
15
  import FontFamilyAutocomplete from "../FormatTools/FontFamilyAutocomplete";
16
16
  import { useEditorContext } from "../../hooks/useMouseMove";
17
- import LineSpacing from "../../common/StyleBuilder/fieldTypes/lineSpacing";
18
- import { getPageSettings } from "../../utils/pageSettings";
19
17
  import { jsx as _jsx } from "react/jsx-runtime";
20
18
  import { jsxs as _jsxs } from "react/jsx-runtime";
21
19
  const allTools = toolbarGroups.flat();
@@ -33,18 +31,10 @@ const TextFormat = props => {
33
31
  const [anchorEl, setAnchorEl] = useState(null);
34
32
  const [type, setType] = useState(null);
35
33
  const open = Boolean(anchorEl);
36
- const {
37
- element: pageSt
38
- } = getPageSettings(editor) || {};
39
- const pageSettingLine = pageSt?.pageProps?.lineHeight;
40
34
  const {
41
35
  fontFamilies,
42
36
  theme
43
37
  } = useEditorContext();
44
- const {
45
- activeBreakPoint
46
- } = useEditorContext();
47
- const breakpoint = activeBreakPoint === "" ? "lg" : activeBreakPoint;
48
38
  const fontWeight = allTools.find(f => f.format === "fontWeight");
49
39
  const fontStyle = allTools.filter(f => f.type === "mark" && f.format !== "strikethrough" && f.format !== "superscript" && f.format !== "subscript");
50
40
  const fontAlign = allTools.filter(f => f.format?.indexOf("align") >= 0);
@@ -61,8 +51,6 @@ const TextFormat = props => {
61
51
  color: "",
62
52
  bgColor: ""
63
53
  };
64
- let lineSpacingValue = activeMark(editor, 'lineHeight');
65
- lineSpacingValue = lineSpacingValue?.[breakpoint] !== undefined ? lineSpacingValue : pageSettingLine;
66
54
  const handleColorPicker = type => e => {
67
55
  setType(type);
68
56
  setAnchorEl(e.currentTarget);
@@ -103,13 +91,6 @@ const TextFormat = props => {
103
91
  value
104
92
  });
105
93
  };
106
- const handleLineSpacing = data => {
107
- const [[format, value]] = Object.entries(data);
108
- addMarkData(editor, {
109
- format,
110
- value
111
- });
112
- };
113
94
  return /*#__PURE__*/_jsxs(Grid, {
114
95
  container: true,
115
96
  sx: classes.textFormatWrapper,
@@ -379,32 +360,6 @@ const TextFormat = props => {
379
360
  xs: 12,
380
361
  sx: classes.dividerGrid,
381
362
  children: /*#__PURE__*/_jsx(Divider, {})
382
- }), /*#__PURE__*/_jsxs(Grid, {
383
- item: true,
384
- xs: 12,
385
- children: [/*#__PURE__*/_jsx(Typography, {
386
- variant: "body1",
387
- color: "primary",
388
- sx: classes.typoLabel,
389
- children: "Line Spacing"
390
- }), /*#__PURE__*/_jsx(Grid, {
391
- item: true,
392
- xs: 12,
393
- className: "typo-icons",
394
- sx: classes.evenSpace,
395
- children: /*#__PURE__*/_jsx(LineSpacing, {
396
- value: lineSpacingValue,
397
- onChange: handleLineSpacing,
398
- data: {
399
- key: 'lineHeight'
400
- }
401
- })
402
- })]
403
- }), /*#__PURE__*/_jsx(Grid, {
404
- item: true,
405
- xs: 12,
406
- sx: classes.dividerGrid,
407
- children: /*#__PURE__*/_jsx(Divider, {})
408
363
  }), /*#__PURE__*/_jsx(Grid, {
409
364
  item: true,
410
365
  xs: 12,
@@ -1,5 +1,5 @@
1
- import React, { useCallback, useEffect, useState } from "react";
2
- import { Popper, Fade, Paper, ClickAwayListener } from "@mui/material";
1
+ import React, { useEffect, useState } from "react";
2
+ import { Popper, Paper, ClickAwayListener } from "@mui/material";
3
3
  import { Editor, Range, Transforms } from "slate";
4
4
  import { ReactEditor, useSlate } from "slate-react";
5
5
  import useDrag from "../../hooks/useDrag";
@@ -9,7 +9,6 @@ import { useEditorContext } from "../../hooks/useMouseMove";
9
9
  import usePopupStyles from "../PopupTool/PopupToolStyle";
10
10
  import useEditorScroll from "../../hooks/useEditorScroll";
11
11
  import { isCarouselSelected } from "../../helper";
12
- import { hideSlateSelection } from "../../utils/helper";
13
12
  import { jsx as _jsx } from "react/jsx-runtime";
14
13
  const PopupTool = props => {
15
14
  const {
@@ -21,7 +20,8 @@ const PopupTool = props => {
21
20
  const classes = usePopupStyles(theme);
22
21
  const {
23
22
  setPopupType,
24
- openAI
23
+ openAI,
24
+ selectedElement
25
25
  } = useEditorContext();
26
26
  const [anchorEl, setAnchorEl] = useState(null);
27
27
  const [open, setOpen] = useState(false);
@@ -32,13 +32,10 @@ const PopupTool = props => {
32
32
  const [event] = useDrag(anchorEl);
33
33
  const id = open ? "popup-edit-tool" : "";
34
34
  const [size] = useWindowResize();
35
- const {
36
- selectedElement
37
- } = useEditorContext();
38
- const updateAnchorEl = useCallback(() => {
35
+ const updateAnchorEl = isScroll => {
39
36
  try {
40
37
  const isHavingSelection = selection && !Range.isCollapsed(selection);
41
- if (isHavingSelection) {
38
+ if (isHavingSelection && event === "end") {
42
39
  const domRange = ReactEditor.toDOMRange(editor, editor.selection);
43
40
  const editorContainer = document.querySelector("#slate-wrapper-scroll-container")?.getBoundingClientRect();
44
41
  const rect = domRange.getBoundingClientRect();
@@ -47,16 +44,21 @@ const PopupTool = props => {
47
44
  rect.y = -500; // hide the popper
48
45
  }
49
46
 
50
- setAnchorEl({
51
- clientWidth: rect.width,
52
- clientHeight: rect.height,
53
- getBoundingClientRect: () => rect
54
- });
47
+ // Create a dummy anchor element to match Popper's requirements
48
+ const anchor = document.createElement("div");
49
+ anchor.style.position = "absolute";
50
+ anchor.style.top = `${rect.top + window.scrollY}px`;
51
+ anchor.style.left = `${rect.left + window.scrollX}px`;
52
+ document.body.appendChild(anchor);
53
+ if (!anchorEl || isScroll === "scroll") {
54
+ setAnchorEl(anchor);
55
+ setOpen(true);
56
+ }
55
57
  }
56
58
  } catch (err) {
57
59
  console.log(err);
58
60
  }
59
- }, [selection]);
61
+ };
60
62
  useEditorScroll(editorWrapper, updateAnchorEl);
61
63
  useEffect(() => {
62
64
  const userStoppedSelection = size?.device === "xs" ? true : event === "end"; // for mobile, when user starts the selection, we are gonna show the popup tool
@@ -80,18 +82,12 @@ const PopupTool = props => {
80
82
  }
81
83
  }, [event, anchorEl]);
82
84
  useEffect(() => {
83
- if (!selection || Range.isCollapsed(selection) || Editor.string(editor, selection) === "") {
85
+ if (!selection || Range.isCollapsed(selection) || Editor.string(editor, selection) === "" || selectedElement?.enable === 1) {
84
86
  setAnchorEl(null);
85
87
  } else {
86
88
  updateAnchorEl();
87
- hideSlateSelection(); // removes slate selection background, when there is no selection
88
- }
89
- }, [selection]);
90
- useEffect(() => {
91
- if (selectedElement?.enable === 1) {
92
- setAnchorEl(null);
93
89
  }
94
- }, [selection, selectedElement?.path, selectedElement?.enable]);
90
+ }, [selection, event, selectedElement?.enable]);
95
91
  const handleClose = () => {
96
92
  // setAnchorEl(null);
97
93
  setOpen(false);
@@ -117,24 +113,18 @@ const PopupTool = props => {
117
113
  id: id,
118
114
  open: open,
119
115
  anchorEl: anchorEl,
120
- transition: true,
121
116
  sx: classes.popupWrapper,
122
117
  placement: "top-start",
123
- children: ({
124
- TransitionProps
125
- }) => /*#__PURE__*/_jsx(Fade, {
126
- ...TransitionProps,
127
- children: /*#__PURE__*/_jsx(Paper, {
128
- style: {
129
- borderRadius: "6px",
130
- border: "1px solid #8360FD"
131
- },
132
- children: /*#__PURE__*/_jsx(MiniTextFormat, {
133
- editor: editor,
134
- classes: classes,
135
- closeMainPopup: handleClose,
136
- customProps: customProps
137
- })
118
+ children: /*#__PURE__*/_jsx(Paper, {
119
+ style: {
120
+ borderRadius: "6px",
121
+ border: "1px solid #8360FD"
122
+ },
123
+ children: /*#__PURE__*/_jsx(MiniTextFormat, {
124
+ editor: editor,
125
+ classes: classes,
126
+ closeMainPopup: handleClose,
127
+ customProps: customProps
138
128
  })
139
129
  })
140
130
  })
@@ -1,11 +1,11 @@
1
- export const defaultFonts = [
2
- // "EB Garamond",
3
- "Anton", "DM Serif Text", "Libre Baskerville", "Montserrat", "Open Sans", "Public Sans", "Raleway", "Space Mono", "Great Vibes", "Zeyada", "Allura", "Pinyon Script", "Dancing Script", "Gaegu", "Kite One", "Merriweather"];
4
- export const otherFonts = ["PoppinsRegular", "PoppinsBold", "Monaco", "Qwitcher Grypen", "Bulgarian Garamond", "Redacted Script", "Herr Von Muellerhoff", "Dawning of a New Day", "Coming Soon", "Engagement", "Ingrid Darling", "La Belle Aurore", "Mea Culpa", "The Girl Next Door", "Helvetica", "Georgia", "Times New Roman", "Courier New", "Impact"];
5
- export const googleFontList = ["Roboto", "Noto Sans JP", "Poppins", "Lato", "Inter", "Roboto Condensed", "Roboto Mono", "Oswald", "Noto Sans", "Nunito", "Nunito Sans", "Ubuntu", "Rubik", "Playfair Display", "Noto Sans KR", "Roboto Slab", "PT Sans", "Kanit", "Work Sans", "Lora", "DM Sans", "Mulish", "Quicksand", "Fira Sans", "Noto Sans TC", "Inconsolata", "Barlow", "Manrope", "IBM Plex Sans", "PT Serif", "Karla", "Titillium Web", "Heebo", "Noto Serif", "Nanum Gothic", "Noto Color Emoji", "Agdasima", "Bebas Neue", "Libre Franklin", "Mukta", "Outfit", "Josefin Sans", "Source Code Pro", "Jost", "Space Grotesk", "Hind Siliguri", "Arimo", "Cabin", "Barlow Condensed", "Dosis", "Fira Sans Condensed", "Bitter", "Archivo", "Figtree", "Noto Serif JP", "PT Sans Narrow", "Abel", "Noto Sans SC",
6
- // "Source Sans 3",
7
- "Hind",
8
- // "Exo 2",
9
- "Teko", "Oxygen", "Cairo", "Crimson Text", "Plus Jakarta Sans", "Overpass", "Pacifico", "Prompt", "Red Hat Display", "Varela Round", "Cormorant Garamond", "Assistant", "Comfortaa", "Lexend", "Signika Negative",
10
- // "M PLUS Rounded 1c",
11
- "Fjalla One", "Caveat", "IBM Plex Mono", "Arvo", "Lobster", "Schibsted Grotesk", "Chakra Petch", "Maven Pro", "Sora", "Kalam", "Onest", "Space Grotesk", "Outfit", 'Titillium Web', ...defaultFonts];
1
+ const otherFonts = ["PoppinsRegular", "PoppinsBold", "Qwitcher Grypen", "Bulgarian Garamond", "Redacted Script", "Herr Von Muellerhoff", "Dawning of a New Day", "Coming Soon", "Engagement", "Ingrid Darling", "La Belle Aurore", "Mea Culpa", "The Girl Next Door"];
2
+ const mostUsedGoogleFonts = ["Roboto", "Poppins", "Lato", "Inter", "Nunito", "Ubuntu", "Oswald", "Rubik", "Roboto Slab", "PT Sans", "Work Sans", "Lora", "Mulish", "DM Sans", "Fira Sans", "Quicksand", "Barlow", "Manrope", "IBM Plex Sans", "PT Serif", "Libre Franklin", "Bebas Neue", "Cabin", "Titillium Web", "Heebo", "Noto Serif", "Jost", "Source Code Pro", "Josefin Sans", "Dosis", "Fira Sans Condensed", "Archivo", "Noto Serif JP", "Crimson Text", "Cairo", "Pacifico", "Red Hat Display", "Assistant", "Comfortaa", "Lexend", "Fjalla One", "Caveat", "Arvo", "Lobster", "Schibsted Grotesk", "EB Garamond", "Sora", "Kalam", "Onest", "Space Grotesk", "Outfit", "Plus Jakarta Sans"];
3
+ const systemFonts = ["Monaco", "Helvetica", "Georgia", "Times New Roman", "Courier New", "Impact"];
4
+ export const googleFontList = [...mostUsedGoogleFonts, ...otherFonts];
5
+ const fontList = [...mostUsedGoogleFonts, ...otherFonts, ...systemFonts];
6
+ export const defaultFontFamilies = {
7
+ id: 1,
8
+ format: "fontFamily",
9
+ type: "fontfamilydropdown",
10
+ options: fontList || []
11
+ };
@@ -1,7 +1,11 @@
1
- import { useEffect } from "react";
1
+ import { useEffect, useState } from "react";
2
2
  import WebFont from "webfontloader";
3
3
  import { useEditorContext } from "../../hooks/useMouseMove";
4
- import { defaultFonts, googleFontList, otherFonts } from "./FontList";
4
+ import { googleFontList } from "./FontList";
5
+ import CircularProgress from "@mui/material/CircularProgress";
6
+ import Box from "@mui/material/Box";
7
+ import { jsx as _jsx } from "react/jsx-runtime";
8
+ import { Fragment as _Fragment } from "react/jsx-runtime";
5
9
  const FontLoader = props => {
6
10
  const {
7
11
  otherProps,
@@ -10,69 +14,74 @@ const FontLoader = props => {
10
14
  const {
11
15
  setFontFamilies
12
16
  } = useEditorContext();
17
+ const [loading, setLoading] = useState(true);
13
18
  const loadFontsInBatches = (families, batchSize = 5, maxRetries = 3) => {
14
19
  let currentIndex = 0;
15
20
  let retryCount = 0;
16
- function loadNextBatch() {
17
- if (currentIndex >= families?.length) {
18
- // console.log("All fonts have been loaded");
19
- return;
20
- }
21
- const batch = families?.slice(currentIndex, currentIndex + batchSize);
22
- const batchWithWeights = batch.map(font => `${font}:300,400,600,700`);
23
- WebFont.load({
24
- google: {
25
- families: [...batchWithWeights]
26
- },
27
- classes: false,
28
- timeout: 2000,
29
- active: () => {
30
- // console.log(`Fonts loaded successfully: ${batch}`);
31
- currentIndex += batchSize;
32
- retryCount = 0; // Reset retry count for the next batch
33
- loadNextBatch();
34
- },
35
- inactive: () => {
36
- // console.log(`Font loading failed for: ${batch}`);
37
-
38
- if (retryCount < maxRetries) {
39
- retryCount++;
40
- // console.log(`Retrying batch (${retryCount}/${maxRetries})...`);
41
- // Retry loading the same batch
42
- loadNextBatch();
43
- } else {
44
- // console.log(
45
- // `Max retries reached for batch: ${batch}. Moving to the next batch.`
46
- // );
21
+ const loadNextBatch = () => {
22
+ try {
23
+ if (currentIndex >= families?.length) {
24
+ // console.log("All fonts have been loaded");
25
+ setLoading(false);
26
+ return;
27
+ }
28
+ const batch = families?.slice(currentIndex, currentIndex + batchSize);
29
+ const batchWithWeights = batch?.map(font => `${font}:300,400,600,700`);
30
+ WebFont.load({
31
+ google: {
32
+ families: [...batchWithWeights]
33
+ },
34
+ classes: false,
35
+ timeout: 2000,
36
+ active: () => {
37
+ // console.log(`Fonts loaded successfully: ${batch}`);
47
38
  currentIndex += batchSize;
48
39
  retryCount = 0; // Reset retry count for the next batch
49
40
  loadNextBatch();
41
+ },
42
+ inactive: () => {
43
+ // console.log(`Font loading failed for: ${batch}`);
44
+ if (retryCount < maxRetries) {
45
+ retryCount++;
46
+ // console.log(`Retrying batch (${retryCount}/${maxRetries})...`);
47
+ // Retry loading the same batch
48
+ loadNextBatch();
49
+ } else {
50
+ // console.log(
51
+ // `Max retries reached for batch: ${batch}. Moving to the next batch.`
52
+ // );
53
+ currentIndex += batchSize;
54
+ retryCount = 0;
55
+ loadNextBatch();
56
+ }
50
57
  }
51
- }
52
- });
53
- }
58
+ });
59
+ } catch (err) {
60
+ setLoading(false);
61
+ }
62
+ };
54
63
  loadNextBatch();
55
64
  };
56
65
  useEffect(() => {
57
- let families = [...otherFonts, ...defaultFonts];
66
+ let families = [...googleFontList];
58
67
  if (!readOnly) {
59
68
  otherProps?.services("listGoogleFont", []).then(data => {
60
- families = [...families, ...(data?.data || [])];
61
- const filteredfamilies = families?.filter(font => !font?.includes("Material"));
69
+ families = [...(data?.data || [])];
62
70
  setFontFamilies({
63
71
  id: 1,
64
72
  format: "fontFamily",
65
73
  type: "fontfamilydropdown",
66
- options: filteredfamilies || []
74
+ options: families || []
67
75
  });
68
76
  loadFontsInBatches(families);
69
77
  }).catch(err => {
70
78
  // console.log(err);
79
+ setLoading(false);
71
80
  });
72
81
  } else {
73
82
  function correctFontArray(fontString) {
74
- let fontsArray = fontString.split(",");
75
- let cleanedFontsArray = [...new Set(fontsArray.map(font => font.trim()))];
83
+ let fontsArray = fontString?.split(",");
84
+ let cleanedFontsArray = [...new Set(fontsArray?.map(font => font.trim()))];
76
85
  return cleanedFontsArray;
77
86
  }
78
87
  function sanitizeFontFamily(fontFamily) {
@@ -88,11 +97,32 @@ const FontLoader = props => {
88
97
  let families = Array.from(fontSet);
89
98
  families = correctFontArray(families.join(", "));
90
99
  families = families?.map(font => font?.replace(/\"/g, ""));
91
- families = families?.map(font => font?.replace(", sans-serif", "")); //This is temporary fix for patch
92
- families = families.filter(font => googleFontList.includes(font));
100
+ families = families?.map(font => font?.replace(", sans-serif", ""));
101
+ families = families?.filter(font => googleFontList?.includes(font));
93
102
  loadFontsInBatches(families);
94
103
  }
104
+
105
+ // Set timeout to hide loader after 5 seconds
106
+ const timeoutId = setTimeout(() => {
107
+ setLoading(false);
108
+ }, 5000);
109
+ return () => clearTimeout(timeoutId);
95
110
  }, []);
96
- return null;
111
+ return /*#__PURE__*/_jsx(_Fragment, {
112
+ children: loading ? /*#__PURE__*/_jsx(Box, {
113
+ sx: {
114
+ position: "absolute",
115
+ top: 0,
116
+ left: 0,
117
+ right: 0,
118
+ bottom: 0,
119
+ zIndex: 99999,
120
+ display: "flex",
121
+ justifyContent: "center",
122
+ alignItems: "center"
123
+ },
124
+ children: /*#__PURE__*/_jsx(CircularProgress, {})
125
+ }) : null
126
+ });
97
127
  };
98
128
  export default FontLoader;
@@ -18,7 +18,7 @@ const Upload = props => {
18
18
  item: true,
19
19
  xs: 12,
20
20
  sx: {
21
- padding: '10px',
21
+ padding: 0,
22
22
  height: '100%'
23
23
  },
24
24
  className: "ims-right",
@@ -6,8 +6,7 @@ const UploadStyles = theme => ({
6
6
  boxShadow: "0px 4px 10px rgba(0, 0, 0, 0.16)",
7
7
  background: theme?.palette?.editor?.uploadFileBg,
8
8
  height: '100%',
9
- minHeight: '150px',
10
- height: "inherit"
9
+ minHeight: '150px'
11
10
  },
12
11
  uploadField: {
13
12
  width: "100%",