@flozy/editor 5.9.2 → 5.9.4
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.
@@ -493,7 +493,7 @@ const CommonEditor = /*#__PURE__*/forwardRef((props, ref) => {
|
|
493
493
|
...props,
|
494
494
|
fullScreen: fullScreen,
|
495
495
|
footer: footer || "",
|
496
|
-
children: /*#__PURE__*/
|
496
|
+
children: /*#__PURE__*/_jsxs(Box, {
|
497
497
|
component: "div",
|
498
498
|
className: `et-wrpr stimulate-${breakpoint} ${editorClass || ""} ${isIframe ? "iframe-editor" : ""}`,
|
499
499
|
sx: classes.root,
|
@@ -503,7 +503,7 @@ const CommonEditor = /*#__PURE__*/forwardRef((props, ref) => {
|
|
503
503
|
"data-breakpoint": breakpoint
|
504
504
|
// onContextMenu={handleContextMenu}
|
505
505
|
,
|
506
|
-
children: /*#__PURE__*/_jsxs(Slate, {
|
506
|
+
children: [/*#__PURE__*/_jsxs(Slate, {
|
507
507
|
editor: editor,
|
508
508
|
initialValue: getInitialValue(debouncedValue?.current, readOnly),
|
509
509
|
onChange: handleEditorChange,
|
@@ -603,10 +603,13 @@ const CommonEditor = /*#__PURE__*/forwardRef((props, ref) => {
|
|
603
603
|
}), htmlAction.showInput && /*#__PURE__*/_jsx(CodeToText, {
|
604
604
|
...htmlAction,
|
605
605
|
handleCodeToText: handleCodeToText
|
606
|
-
}), /*#__PURE__*/_jsx(FontLoader, {
|
607
|
-
...props
|
608
606
|
})]
|
609
|
-
}, id)
|
607
|
+
}, id), /*#__PURE__*/_jsx(FontLoader, {
|
608
|
+
otherProps: {
|
609
|
+
services: otherProps?.services
|
610
|
+
},
|
611
|
+
readOnly: readOnly
|
612
|
+
})]
|
610
613
|
})
|
611
614
|
})
|
612
615
|
});
|
@@ -1,11 +1,3 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
|
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
|
+
export const googleFontList = [...mostUsedGoogleFonts, ...otherFonts];
|
@@ -1,9 +1,11 @@
|
|
1
1
|
import { useEffect, useState } from "react";
|
2
2
|
import WebFont from "webfontloader";
|
3
|
-
import { Backdrop, CircularProgress } from "@mui/material";
|
4
3
|
import { useEditorContext } from "../../hooks/useMouseMove";
|
5
|
-
import {
|
4
|
+
import { googleFontList } from "./FontList";
|
5
|
+
import CircularProgress from "@mui/material/CircularProgress";
|
6
|
+
import Box from "@mui/material/Box";
|
6
7
|
import { jsx as _jsx } from "react/jsx-runtime";
|
8
|
+
import { Fragment as _Fragment } from "react/jsx-runtime";
|
7
9
|
const FontLoader = props => {
|
8
10
|
const {
|
9
11
|
otherProps,
|
@@ -12,66 +14,69 @@ const FontLoader = props => {
|
|
12
14
|
const {
|
13
15
|
setFontFamilies
|
14
16
|
} = useEditorContext();
|
15
|
-
const [
|
17
|
+
const [loading, setLoading] = useState(true);
|
16
18
|
const loadFontsInBatches = (families, batchSize = 5, maxRetries = 3) => {
|
17
19
|
let currentIndex = 0;
|
18
20
|
let retryCount = 0;
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
retryCount = 0; // Reset retry count for the next batch
|
37
|
-
loadNextBatch();
|
38
|
-
},
|
39
|
-
inactive: () => {
|
40
|
-
// console.log(`Font loading failed for: ${batch}`);
|
41
|
-
|
42
|
-
if (retryCount < maxRetries) {
|
43
|
-
retryCount++;
|
44
|
-
// console.log(`Retrying batch (${retryCount}/${maxRetries})...`);
|
45
|
-
// Retry loading the same batch
|
46
|
-
loadNextBatch();
|
47
|
-
} else {
|
48
|
-
console.log(
|
49
|
-
// `Max retries reached for batch: ${batch}. Moving to the next batch.`
|
50
|
-
);
|
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}`);
|
51
38
|
currentIndex += batchSize;
|
52
39
|
retryCount = 0; // Reset retry count for the next batch
|
53
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
|
+
}
|
54
57
|
}
|
55
|
-
}
|
56
|
-
})
|
57
|
-
|
58
|
+
});
|
59
|
+
} catch (err) {
|
60
|
+
setLoading(false);
|
61
|
+
}
|
62
|
+
};
|
58
63
|
loadNextBatch();
|
59
64
|
};
|
60
65
|
useEffect(() => {
|
61
|
-
let families = [...
|
66
|
+
let families = [...googleFontList];
|
62
67
|
if (!readOnly) {
|
63
68
|
otherProps?.services("listGoogleFont", []).then(data => {
|
64
|
-
families = [...
|
65
|
-
const filteredfamilies = families?.filter(font => !font?.includes("Material"));
|
69
|
+
families = [...(data?.data || [])];
|
66
70
|
setFontFamilies({
|
67
71
|
id: 1,
|
68
72
|
format: "fontFamily",
|
69
73
|
type: "fontfamilydropdown",
|
70
|
-
options:
|
74
|
+
options: families || []
|
71
75
|
});
|
72
76
|
loadFontsInBatches(families);
|
73
77
|
}).catch(err => {
|
74
|
-
console.log(err);
|
78
|
+
// console.log(err);
|
79
|
+
setLoading(false);
|
75
80
|
});
|
76
81
|
} else {
|
77
82
|
function correctFontArray(fontString) {
|
@@ -92,20 +97,32 @@ const FontLoader = props => {
|
|
92
97
|
let families = Array.from(fontSet);
|
93
98
|
families = correctFontArray(families.join(", "));
|
94
99
|
families = families?.map(font => font?.replace(/\"/g, ""));
|
95
|
-
families = families?.map(font => font?.replace(", sans-serif", ""));
|
100
|
+
families = families?.map(font => font?.replace(", sans-serif", ""));
|
96
101
|
families = families.filter(font => googleFontList.includes(font));
|
97
102
|
loadFontsInBatches(families);
|
98
103
|
}
|
104
|
+
|
105
|
+
// Set timeout to hide loader after 5 seconds
|
106
|
+
const timeoutId = setTimeout(() => {
|
107
|
+
setLoading(false);
|
108
|
+
}, 5000);
|
109
|
+
return () => clearTimeout(timeoutId);
|
99
110
|
}, []);
|
100
|
-
return /*#__PURE__*/_jsx(
|
101
|
-
|
102
|
-
|
103
|
-
|
104
|
-
|
105
|
-
|
106
|
-
|
107
|
-
|
108
|
-
|
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
|
109
126
|
});
|
110
127
|
};
|
111
128
|
export default FontLoader;
|