@flozy/editor 7.0.7 → 7.0.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 (52) hide show
  1. package/dist/Editor/CommonEditor.js +19 -19
  2. package/dist/Editor/Editor.css +5 -4
  3. package/dist/Editor/Elements/AI/PopoverAIInput.js +2 -12
  4. package/dist/Editor/Elements/Button/EditorButton.js +1 -0
  5. package/dist/Editor/Elements/DataView/DataView.js +4 -3
  6. package/dist/Editor/Elements/DataView/Layouts/DataTypes/NumberType.js +5 -1
  7. package/dist/Editor/Elements/DataView/Layouts/DataTypes/TextType.js +5 -1
  8. package/dist/Editor/Elements/DataView/Layouts/FilterView.js +23 -19
  9. package/dist/Editor/Elements/Form/Form.js +1 -0
  10. package/dist/Editor/Elements/FreeGrid/styles.js +1 -0
  11. package/dist/Editor/Elements/List/CheckList.js +2 -1
  12. package/dist/Editor/Elements/Search/SearchAttachment.js +1 -0
  13. package/dist/Editor/Elements/Search/SearchList.js +8 -1
  14. package/dist/Editor/Elements/SimpleText/index.js +19 -7
  15. package/dist/Editor/Elements/SimpleText/style.js +5 -1
  16. package/dist/Editor/Elements/Table/Table.js +15 -15
  17. package/dist/Editor/Elements/Table/TableCell.js +14 -9
  18. package/dist/Editor/MiniEditor.js +4 -2
  19. package/dist/Editor/Styles/EditorStyles.js +291 -287
  20. package/dist/Editor/Toolbar/PopupTool/AddTemplates.js +37 -28
  21. package/dist/Editor/Toolbar/PopupTool/MiniTextFormat/SelectAlignment.js +3 -1
  22. package/dist/Editor/Toolbar/PopupTool/MiniTextFormat/SelectFontSize.js +1 -1
  23. package/dist/Editor/Toolbar/PopupTool/MiniTextFormat/SelectList.js +3 -1
  24. package/dist/Editor/Toolbar/PopupTool/MiniTextFormat/SelectTypography.js +3 -8
  25. package/dist/Editor/Toolbar/PopupTool/MiniTextFormat/index.js +9 -3
  26. package/dist/Editor/Toolbar/PopupTool/TemplateCard.js +1 -1
  27. package/dist/Editor/Toolbar/PopupTool/TextFormat.js +45 -0
  28. package/dist/Editor/Toolbar/PopupTool/index.js +39 -29
  29. package/dist/Editor/common/FontLoader/FontList.js +11 -11
  30. package/dist/Editor/common/FontLoader/FontLoader.js +45 -75
  31. package/dist/Editor/common/ImageSelector/Options/Upload.js +1 -1
  32. package/dist/Editor/common/ImageSelector/UploadStyles.js +2 -1
  33. package/dist/Editor/common/MentionsPopup/index.js +0 -1
  34. package/dist/Editor/common/RnD/ElementSettings/styles.js +1 -0
  35. package/dist/Editor/common/RnD/SwitchViewport/SwitchViewport.js +6 -0
  36. package/dist/Editor/common/Section/index.js +89 -60
  37. package/dist/Editor/common/StyleBuilder/fieldTypes/index.js +3 -1
  38. package/dist/Editor/common/StyleBuilder/fieldTypes/lineSpacing.js +79 -0
  39. package/dist/Editor/common/StyleBuilder/pageSettingsStyle.js +4 -0
  40. package/dist/Editor/commonStyle.js +5 -0
  41. package/dist/Editor/helper/deserialize/index.js +1 -1
  42. package/dist/Editor/helper/ensureWrappedVariables.js +28 -0
  43. package/dist/Editor/helper/theme.js +24 -1
  44. package/dist/Editor/hooks/useEditorScroll.js +1 -1
  45. package/dist/Editor/hooks/useMouseMove.js +6 -4
  46. package/dist/Editor/plugins/withHTML.js +7 -1
  47. package/dist/Editor/utils/SlateUtilityFunctions.js +23 -12
  48. package/dist/Editor/utils/customHooks/useTableResize.js +2 -1
  49. package/dist/Editor/utils/helper.js +41 -0
  50. package/dist/Editor/utils/pageSettings.js +14 -2
  51. package/dist/Editor/utils/table.js +21 -0
  52. package/package.json +2 -2
@@ -4,6 +4,7 @@ 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";
7
8
  import { jsxs as _jsxs } from "react/jsx-runtime";
8
9
  const CATEGORIES_SORT_INDEX = {
9
10
  Brief: 1,
@@ -46,7 +47,7 @@ const ProgressBar = ({
46
47
  alignItems: "center",
47
48
  margin: 0,
48
49
  padding: 0,
49
- height: "50px",
50
+ height: "300px",
50
51
  overflow: "hidden"
51
52
  },
52
53
  children: /*#__PURE__*/_jsx(CircularProgress, {})
@@ -69,41 +70,49 @@ const AddTemplates = props => {
69
70
  const [categories, setCategories] = useState([]);
70
71
  const [category, setCategory] = useState("");
71
72
  const [templates, setTemplates] = useState([]);
72
- const [filteredTemplates, setFilteredTemplates] = useState([]);
73
73
  useEffect(() => {
74
- getTemplatesList();
74
+ getCategoryList();
75
75
  }, []);
76
- const sortCategory = (a, b) => {
77
- return (CATEGORIES_SORT_INDEX[a] || Infinity) - (CATEGORIES_SORT_INDEX[b] || Infinity);
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);
78
85
  };
79
- const getTemplatesList = async () => {
86
+ const getTemplatesList = async selectedCategory => {
80
87
  setLoading(true);
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);
88
+ const result = await services("listTemplates", {
89
+ category: selectedCategory
90
+ });
91
+ setTemplates(result?.data || []);
94
92
  setLoading(false);
95
93
  };
96
94
  const handleChange = (event, newValue) => {
95
+ setTemplates([]);
97
96
  onSearch("");
98
97
  setCategory(newValue);
99
- setFilteredTemplates(templates.filter(f => f.category === newValue));
98
+ getTemplatesList(newValue);
100
99
  };
101
- const onSelectTemplate = card => () => {
100
+ const onSelectTemplate = card => async () => {
102
101
  try {
103
- editor.insertNode(JSON.parse(card.content));
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
+ }
104
113
  onClose();
105
114
  } catch (err) {
106
- console.log(err);
115
+ console.log("Error inserting template content into editor:", err);
107
116
  }
108
117
  };
109
118
  const filterByTitle = f => {
@@ -173,16 +182,16 @@ const AddTemplates = props => {
173
182
  data: categories,
174
183
  handleChange: handleChange
175
184
  })
176
- }), /*#__PURE__*/_jsxs(Grid, {
185
+ }), /*#__PURE__*/_jsx(Grid, {
177
186
  container: true,
178
187
  spacing: 0,
179
188
  className: `${fullScreen ? "fullscreen" : ""}`,
180
189
  sx: classes.templateCardsWrpr,
181
- children: [/*#__PURE__*/_jsx(ProgressBar, {
190
+ children: loading ? /*#__PURE__*/_jsx(ProgressBar, {
182
191
  loading: loading
183
- }), filteredTemplates.filter(filterByTitle).map(m => {
184
- return renderTemplate(m);
185
- })]
192
+ }) : /*#__PURE__*/_jsx(_Fragment, {
193
+ children: templates.filter(filterByTitle).map(renderTemplate)
194
+ })
186
195
  })]
187
196
  });
188
197
  };
@@ -51,7 +51,8 @@ const alignmentOptions = [{
51
51
  }];
52
52
  function SelectAlignment({
53
53
  editor,
54
- classes
54
+ classes,
55
+ closeMainPopup
55
56
  }) {
56
57
  const selected = useMemo(() => {
57
58
  return alignmentOptions.find(t => isBlockActive(editor, t.value));
@@ -59,6 +60,7 @@ function SelectAlignment({
59
60
  const onChange = (format, option) => {
60
61
  if (option.type === "block") {
61
62
  toggleBlock(editor, format);
63
+ closeMainPopup();
62
64
  }
63
65
  };
64
66
  return /*#__PURE__*/_jsx(CustomSelectTool, {
@@ -59,7 +59,7 @@ function SelectFontSize({
59
59
  size = value;
60
60
  }
61
61
  });
62
- return parseInt(size);
62
+ return isNaN(parseInt(size)) ? 14 : parseInt(size);
63
63
  } catch (err) {
64
64
  return "";
65
65
  }
@@ -68,7 +68,8 @@ const listOptions = [{
68
68
  }];
69
69
  function SelectList({
70
70
  editor,
71
- classes
71
+ classes,
72
+ closeMainPopup
72
73
  }) {
73
74
  const selectedList = useMemo(() => {
74
75
  return listOptions.find(t => isBlockActive(editor, t.value));
@@ -79,6 +80,7 @@ function SelectList({
79
80
  } else if (option.type === "accordion") {
80
81
  insertAccordion(editor);
81
82
  }
83
+ closeMainPopup();
82
84
  };
83
85
  return /*#__PURE__*/_jsx(CustomSelectTool, {
84
86
  options: listOptions,
@@ -125,7 +125,6 @@ function SelectTypography({
125
125
  ...upData
126
126
  }
127
127
  });
128
- closeMainPopup();
129
128
  };
130
129
  const selectedBlock = useMemo(() => {
131
130
  return typographyOptions.find(t => {
@@ -152,21 +151,17 @@ function SelectTypography({
152
151
  toggleBlock(editor, format);
153
152
  if (option.type === "block") {
154
153
  // reset old font size
155
- let updatedValue = !selectedBlock ? {} : {
156
- xs: "16px",
157
- sm: "16px",
158
- md: "16px",
159
- lg: "16px"
160
- };
154
+ // let updatedValue = !selectedBlock ? {} : { xs: "16px", sm: "16px", md: "16px", lg: "16px" }
161
155
  addMarkData(editor, {
162
156
  format: "fontSize",
163
- value: updatedValue
157
+ value: {}
164
158
  });
165
159
  } else if (option.type === "mark") {
166
160
  const size = sizeMap[option.value] || "";
167
161
  const [sizeInNumber] = size.split("px");
168
162
  updateMarkData(Number(sizeInNumber));
169
163
  }
164
+ closeMainPopup();
170
165
  };
171
166
  return /*#__PURE__*/_jsx(CustomSelectTool, {
172
167
  options: typographyOptions,
@@ -14,6 +14,7 @@ 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";
17
18
  import { jsx as _jsx } from "react/jsx-runtime";
18
19
  import { jsxs as _jsxs } from "react/jsx-runtime";
19
20
  const DEFAULT_COLOR = {
@@ -60,13 +61,15 @@ const MiniTextFormat = props => {
60
61
  className: "verticalLine"
61
62
  }), /*#__PURE__*/_jsx(SelectList, {
62
63
  classes: classes,
63
- editor: editor
64
+ editor: editor,
65
+ closeMainPopup: closeMainPopup
64
66
  }), /*#__PURE__*/_jsx("div", {
65
67
  className: "verticalLine mr-1"
66
68
  }), /*#__PURE__*/_jsx(SelectAlignment, {
67
69
  fontAlign: fontAlign,
68
70
  classes: classes,
69
- editor: editor
71
+ editor: editor,
72
+ closeMainPopup: closeMainPopup
70
73
  }), /*#__PURE__*/_jsx("div", {
71
74
  className: "verticalLine mr-1"
72
75
  }), /*#__PURE__*/_jsx(SelectFontSize, {
@@ -98,7 +101,10 @@ const MiniTextFormat = props => {
98
101
  editor: editor,
99
102
  customProps: customProps
100
103
  }, link.id), /*#__PURE__*/_jsx(IconButton, {
101
- onClick: e => setAnchorEl(document.getElementById("mini-text-editor-wrapper")),
104
+ onClick: e => {
105
+ viewSlateSelection();
106
+ setAnchorEl(document.getElementById("mini-text-editor-wrapper"));
107
+ },
102
108
  className: `textSettingsIcon ${open ? "btnActive" : ""}`,
103
109
  children: /*#__PURE__*/_jsx(TextToolIcon, {})
104
110
  }), /*#__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?.thumbnail,
50
+ image: m?.compressedThum || m?.thumbnail,
51
51
  alt: m?.title,
52
52
  sx: classes.templateCardMedia
53
53
  }), /*#__PURE__*/_jsx(PreviewAndSelect, {
@@ -14,6 +14,8 @@ 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";
17
19
  import { jsx as _jsx } from "react/jsx-runtime";
18
20
  import { jsxs as _jsxs } from "react/jsx-runtime";
19
21
  const allTools = toolbarGroups.flat();
@@ -31,10 +33,18 @@ const TextFormat = props => {
31
33
  const [anchorEl, setAnchorEl] = useState(null);
32
34
  const [type, setType] = useState(null);
33
35
  const open = Boolean(anchorEl);
36
+ const {
37
+ element: pageSt
38
+ } = getPageSettings(editor) || {};
39
+ const pageSettingLine = pageSt?.pageProps?.lineHeight;
34
40
  const {
35
41
  fontFamilies,
36
42
  theme
37
43
  } = useEditorContext();
44
+ const {
45
+ activeBreakPoint
46
+ } = useEditorContext();
47
+ const breakpoint = activeBreakPoint === "" ? "lg" : activeBreakPoint;
38
48
  const fontWeight = allTools.find(f => f.format === "fontWeight");
39
49
  const fontStyle = allTools.filter(f => f.type === "mark" && f.format !== "strikethrough" && f.format !== "superscript" && f.format !== "subscript");
40
50
  const fontAlign = allTools.filter(f => f.format?.indexOf("align") >= 0);
@@ -51,6 +61,8 @@ const TextFormat = props => {
51
61
  color: "",
52
62
  bgColor: ""
53
63
  };
64
+ let lineSpacingValue = activeMark(editor, 'lineHeight');
65
+ lineSpacingValue = lineSpacingValue?.[breakpoint] !== undefined ? lineSpacingValue : pageSettingLine;
54
66
  const handleColorPicker = type => e => {
55
67
  setType(type);
56
68
  setAnchorEl(e.currentTarget);
@@ -91,6 +103,13 @@ const TextFormat = props => {
91
103
  value
92
104
  });
93
105
  };
106
+ const handleLineSpacing = data => {
107
+ const [[format, value]] = Object.entries(data);
108
+ addMarkData(editor, {
109
+ format,
110
+ value
111
+ });
112
+ };
94
113
  return /*#__PURE__*/_jsxs(Grid, {
95
114
  container: true,
96
115
  sx: classes.textFormatWrapper,
@@ -360,6 +379,32 @@ const TextFormat = props => {
360
379
  xs: 12,
361
380
  sx: classes.dividerGrid,
362
381
  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, {})
363
408
  }), /*#__PURE__*/_jsx(Grid, {
364
409
  item: true,
365
410
  xs: 12,
@@ -1,5 +1,5 @@
1
- import React, { useEffect, useState } from "react";
2
- import { Popper, Paper, ClickAwayListener } from "@mui/material";
1
+ import React, { useCallback, useEffect, useState } from "react";
2
+ import { Popper, Fade, 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,6 +9,7 @@ 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";
12
13
  import { jsx as _jsx } from "react/jsx-runtime";
13
14
  const PopupTool = props => {
14
15
  const {
@@ -20,8 +21,7 @@ const PopupTool = props => {
20
21
  const classes = usePopupStyles(theme);
21
22
  const {
22
23
  setPopupType,
23
- openAI,
24
- selectedElement
24
+ openAI
25
25
  } = useEditorContext();
26
26
  const [anchorEl, setAnchorEl] = useState(null);
27
27
  const [open, setOpen] = useState(false);
@@ -32,10 +32,13 @@ const PopupTool = props => {
32
32
  const [event] = useDrag(anchorEl);
33
33
  const id = open ? "popup-edit-tool" : "";
34
34
  const [size] = useWindowResize();
35
- const updateAnchorEl = isScroll => {
35
+ const {
36
+ selectedElement
37
+ } = useEditorContext();
38
+ const updateAnchorEl = useCallback(() => {
36
39
  try {
37
40
  const isHavingSelection = selection && !Range.isCollapsed(selection);
38
- if (isHavingSelection && event === "end") {
41
+ if (isHavingSelection) {
39
42
  const domRange = ReactEditor.toDOMRange(editor, editor.selection);
40
43
  const editorContainer = document.querySelector("#slate-wrapper-scroll-container")?.getBoundingClientRect();
41
44
  const rect = domRange.getBoundingClientRect();
@@ -44,21 +47,16 @@ const PopupTool = props => {
44
47
  rect.y = -500; // hide the popper
45
48
  }
46
49
 
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
- }
50
+ setAnchorEl({
51
+ clientWidth: rect.width,
52
+ clientHeight: rect.height,
53
+ getBoundingClientRect: () => rect
54
+ });
57
55
  }
58
56
  } catch (err) {
59
57
  console.log(err);
60
58
  }
61
- };
59
+ }, [selection]);
62
60
  useEditorScroll(editorWrapper, updateAnchorEl);
63
61
  useEffect(() => {
64
62
  const userStoppedSelection = size?.device === "xs" ? true : event === "end"; // for mobile, when user starts the selection, we are gonna show the popup tool
@@ -82,12 +80,18 @@ const PopupTool = props => {
82
80
  }
83
81
  }, [event, anchorEl]);
84
82
  useEffect(() => {
85
- if (!selection || Range.isCollapsed(selection) || Editor.string(editor, selection) === "" || selectedElement?.enable === 1) {
83
+ if (!selection || Range.isCollapsed(selection) || Editor.string(editor, selection) === "") {
86
84
  setAnchorEl(null);
87
85
  } else {
88
86
  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);
89
93
  }
90
- }, [selection, event, selectedElement?.enable]);
94
+ }, [selection, selectedElement?.path, selectedElement?.enable]);
91
95
  const handleClose = () => {
92
96
  // setAnchorEl(null);
93
97
  setOpen(false);
@@ -113,18 +117,24 @@ const PopupTool = props => {
113
117
  id: id,
114
118
  open: open,
115
119
  anchorEl: anchorEl,
120
+ transition: true,
116
121
  sx: classes.popupWrapper,
117
122
  placement: "top-start",
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
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
+ })
128
138
  })
129
139
  })
130
140
  })
@@ -1,11 +1,11 @@
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
+ 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,11 +1,7 @@
1
- import { useEffect, useState } from "react";
1
+ import { useEffect } from "react";
2
2
  import WebFont from "webfontloader";
3
3
  import { useEditorContext } from "../../hooks/useMouseMove";
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";
4
+ import { defaultFonts, googleFontList, otherFonts } from "./FontList";
9
5
  const FontLoader = props => {
10
6
  const {
11
7
  otherProps,
@@ -14,74 +10,69 @@ const FontLoader = props => {
14
10
  const {
15
11
  setFontFamilies
16
12
  } = useEditorContext();
17
- const [loading, setLoading] = useState(true);
18
13
  const loadFontsInBatches = (families, batchSize = 5, maxRetries = 3) => {
19
14
  let currentIndex = 0;
20
15
  let retryCount = 0;
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}`);
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
+ // );
38
47
  currentIndex += batchSize;
39
48
  retryCount = 0; // Reset retry count for the next batch
40
49
  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
- }
57
50
  }
58
- });
59
- } catch (err) {
60
- setLoading(false);
61
- }
62
- };
51
+ }
52
+ });
53
+ }
63
54
  loadNextBatch();
64
55
  };
65
56
  useEffect(() => {
66
- let families = [...googleFontList];
57
+ let families = [...otherFonts, ...defaultFonts];
67
58
  if (!readOnly) {
68
59
  otherProps?.services("listGoogleFont", []).then(data => {
69
- families = [...(data?.data || [])];
60
+ families = [...families, ...(data?.data || [])];
61
+ const filteredfamilies = families?.filter(font => !font?.includes("Material"));
70
62
  setFontFamilies({
71
63
  id: 1,
72
64
  format: "fontFamily",
73
65
  type: "fontfamilydropdown",
74
- options: families || []
66
+ options: filteredfamilies || []
75
67
  });
76
68
  loadFontsInBatches(families);
77
69
  }).catch(err => {
78
70
  // console.log(err);
79
- setLoading(false);
80
71
  });
81
72
  } else {
82
73
  function correctFontArray(fontString) {
83
- let fontsArray = fontString?.split(",");
84
- let cleanedFontsArray = [...new Set(fontsArray?.map(font => font.trim()))];
74
+ let fontsArray = fontString.split(",");
75
+ let cleanedFontsArray = [...new Set(fontsArray.map(font => font.trim()))];
85
76
  return cleanedFontsArray;
86
77
  }
87
78
  function sanitizeFontFamily(fontFamily) {
@@ -97,32 +88,11 @@ const FontLoader = props => {
97
88
  let families = Array.from(fontSet);
98
89
  families = correctFontArray(families.join(", "));
99
90
  families = families?.map(font => font?.replace(/\"/g, ""));
100
- families = families?.map(font => font?.replace(", sans-serif", ""));
101
- families = families?.filter(font => googleFontList?.includes(font));
91
+ families = families?.map(font => font?.replace(", sans-serif", "")); //This is temporary fix for patch
92
+ families = families.filter(font => googleFontList.includes(font));
102
93
  loadFontsInBatches(families);
103
94
  }
104
-
105
- // Set timeout to hide loader after 5 seconds
106
- const timeoutId = setTimeout(() => {
107
- setLoading(false);
108
- }, 5000);
109
- return () => clearTimeout(timeoutId);
110
95
  }, []);
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
- });
96
+ return null;
127
97
  };
128
98
  export default FontLoader;
@@ -18,7 +18,7 @@ const Upload = props => {
18
18
  item: true,
19
19
  xs: 12,
20
20
  sx: {
21
- padding: 0,
21
+ padding: "10px",
22
22
  height: '100%'
23
23
  },
24
24
  className: "ims-right",
@@ -6,7 +6,8 @@ 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'
9
+ minHeight: '150px',
10
+ height: 'inherit'
10
11
  },
11
12
  uploadField: {
12
13
  width: "100%",