@flozy/editor 5.8.3 → 5.8.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.
- package/dist/Editor/ChatEditor.js +3 -6
- package/dist/Editor/CommonEditor.js +6 -11
- package/dist/Editor/Editor.css +15 -23
- package/dist/Editor/Elements/AI/PopoverAIInput.js +12 -2
- package/dist/Editor/Elements/Button/EditorButton.js +1 -3
- package/dist/Editor/Elements/DataView/DataView.js +3 -4
- package/dist/Editor/Elements/DataView/Layouts/DataTypes/NumberType.js +1 -5
- package/dist/Editor/Elements/DataView/Layouts/DataTypes/TextType.js +1 -5
- package/dist/Editor/Elements/DataView/Layouts/FilterView.js +19 -23
- package/dist/Editor/Elements/Form/Form.js +0 -1
- package/dist/Editor/Elements/FreeGrid/styles.js +0 -1
- package/dist/Editor/Elements/List/CheckList.js +1 -2
- package/dist/Editor/Elements/Search/SearchAttachment.js +0 -1
- package/dist/Editor/Elements/Search/SearchList.js +1 -8
- package/dist/Editor/Elements/SimpleText/index.js +1 -8
- package/dist/Editor/Elements/SimpleText/style.js +1 -5
- package/dist/Editor/Elements/Table/Table.js +3 -3
- package/dist/Editor/Elements/Table/TableCell.js +9 -14
- package/dist/Editor/Elements/Title/title.js +1 -13
- package/dist/Editor/Elements/Variables/Style.js +2 -21
- package/dist/Editor/Elements/Variables/VariableButton.js +4 -17
- package/dist/Editor/MiniEditor.js +2 -4
- package/dist/Editor/Toolbar/PopupTool/AddTemplates.js +28 -37
- package/dist/Editor/Toolbar/PopupTool/MiniTextFormat/SelectAlignment.js +1 -3
- package/dist/Editor/Toolbar/PopupTool/MiniTextFormat/SelectFontSize.js +1 -1
- package/dist/Editor/Toolbar/PopupTool/MiniTextFormat/SelectList.js +1 -3
- package/dist/Editor/Toolbar/PopupTool/MiniTextFormat/SelectTypography.js +1 -1
- package/dist/Editor/Toolbar/PopupTool/MiniTextFormat/index.js +3 -9
- package/dist/Editor/Toolbar/PopupTool/PopupToolStyle.js +0 -5
- package/dist/Editor/Toolbar/PopupTool/TemplateCard.js +1 -1
- package/dist/Editor/Toolbar/PopupTool/TextFormat.js +0 -45
- package/dist/Editor/Toolbar/PopupTool/index.js +0 -2
- package/dist/Editor/common/FontLoader/FontList.js +11 -3
- package/dist/Editor/common/FontLoader/FontLoader.js +11 -37
- package/dist/Editor/common/RnD/ElementSettings/Settings/FormSettings.js +0 -1
- package/dist/Editor/common/RnD/SwitchViewport/SwitchViewport.js +2 -14
- package/dist/Editor/common/Section/index.js +29 -39
- package/dist/Editor/common/StyleBuilder/fieldTypes/backgroundImage.js +0 -5
- package/dist/Editor/common/StyleBuilder/fieldTypes/card.js +2 -10
- package/dist/Editor/common/StyleBuilder/fieldTypes/index.js +1 -3
- package/dist/Editor/common/StyleBuilder/pageSettingsStyle.js +0 -4
- package/dist/Editor/common/Uploader.js +0 -8
- package/dist/Editor/commonStyle.js +12 -13
- package/dist/Editor/helper/deserialize/index.js +5 -18
- package/dist/Editor/helper/index.js +2 -2
- package/dist/Editor/helper/theme.js +1 -24
- package/dist/Editor/hooks/useMouseMove.js +2 -5
- package/dist/Editor/plugins/withHTML.js +1 -8
- package/dist/Editor/plugins/withLayout.js +1 -1
- package/dist/Editor/utils/SlateUtilityFunctions.js +4 -41
- package/dist/Editor/utils/button.js +4 -4
- package/dist/Editor/utils/customHooks/useTableResize.js +1 -2
- package/dist/Editor/utils/draftToSlate.js +2 -3
- package/dist/Editor/utils/helper.js +19 -60
- package/dist/Editor/utils/pageSettings.js +2 -14
- package/dist/Editor/utils/table.js +0 -21
- package/package.json +2 -3
- package/dist/Editor/common/StyleBuilder/fieldTypes/lineSpacing.js +0 -79
- package/dist/Editor/helper/ensureWrappedVariables.js +0 -28
- package/dist/Editor/helper/markdown.js +0 -45
@@ -3,15 +3,11 @@ import { useSlateStatic } from "slate-react";
|
|
3
3
|
import { MenuItem, Select } from "@mui/material";
|
4
4
|
import { insertVariables } from "../../utils/variables";
|
5
5
|
import VariableStyles from "./Style";
|
6
|
-
import
|
7
|
-
import { useEditorContext } from "../../hooks/useMouseMove";
|
6
|
+
import KeyboardArrowDownIcon from "@mui/icons-material/KeyboardArrowDown";
|
8
7
|
import { jsx as _jsx } from "react/jsx-runtime";
|
9
8
|
import { jsxs as _jsxs } from "react/jsx-runtime";
|
10
9
|
const VariableButton = props => {
|
11
|
-
const
|
12
|
-
theme
|
13
|
-
} = useEditorContext();
|
14
|
-
const classes = VariableStyles(theme);
|
10
|
+
const classes = VariableStyles();
|
15
11
|
const editor = useSlateStatic();
|
16
12
|
const {
|
17
13
|
options
|
@@ -28,14 +24,13 @@ const VariableButton = props => {
|
|
28
24
|
value: "",
|
29
25
|
sx: classes.variableBtn,
|
30
26
|
onChange: updateVariable,
|
31
|
-
IconComponent: () => /*#__PURE__*/_jsx(
|
27
|
+
IconComponent: () => /*#__PURE__*/_jsx(KeyboardArrowDownIcon, {}),
|
32
28
|
MenuProps: {
|
33
29
|
sx: classes.variableMenuItem,
|
34
30
|
PaperProps: {
|
35
31
|
style: {
|
36
32
|
maxHeight: 300,
|
37
|
-
overflowY: "auto"
|
38
|
-
transformOrigin: 'top left'
|
33
|
+
overflowY: "auto"
|
39
34
|
},
|
40
35
|
sx: {
|
41
36
|
"&::-webkit-scrollbar-track": {
|
@@ -45,14 +40,6 @@ const VariableButton = props => {
|
|
45
40
|
borderRadius: "16px"
|
46
41
|
}
|
47
42
|
}
|
48
|
-
},
|
49
|
-
anchorOrigin: {
|
50
|
-
vertical: 'bottom',
|
51
|
-
horizontal: 'right'
|
52
|
-
},
|
53
|
-
transformOrigin: {
|
54
|
-
vertical: 'top',
|
55
|
-
horizontal: 'right'
|
56
43
|
}
|
57
44
|
},
|
58
45
|
children: [/*#__PURE__*/_jsx(MenuItem, {
|
@@ -11,7 +11,6 @@ import withCommon from "./hooks/withCommon";
|
|
11
11
|
import { serializeToText } from "./utils/serializeToText";
|
12
12
|
import "./Editor.css";
|
13
13
|
import { EditorProvider } from "./hooks/useMouseMove";
|
14
|
-
import { ensureWrappedVariables } from "./helper/ensureWrappedVariables";
|
15
14
|
import { jsx as _jsx } from "react/jsx-runtime";
|
16
15
|
import { jsxs as _jsxs } from "react/jsx-runtime";
|
17
16
|
const MiniEditor = props => {
|
@@ -37,8 +36,7 @@ const MiniEditor = props => {
|
|
37
36
|
needLayout: false
|
38
37
|
}));
|
39
38
|
const [isInteracted, setIsInteracted] = useState(false);
|
40
|
-
const
|
41
|
-
const [value, setValue] = useState(ensureWrappedVariables(updatedContent));
|
39
|
+
const [value, setValue] = useState(content);
|
42
40
|
const [deboundedValue] = useDebounce(value, 500);
|
43
41
|
const isReadOnly = readOnly === "readonly";
|
44
42
|
const customProps = {
|
@@ -151,7 +149,7 @@ const MiniEditor = props => {
|
|
151
149
|
theme: theme,
|
152
150
|
children: /*#__PURE__*/_jsxs(Slate, {
|
153
151
|
editor: editor,
|
154
|
-
initialValue:
|
152
|
+
initialValue: content,
|
155
153
|
onChange: onChange,
|
156
154
|
children: [/*#__PURE__*/_jsx(BasicToolbar, {
|
157
155
|
...props,
|
@@ -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: "
|
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
|
-
|
74
|
+
getTemplatesList();
|
75
75
|
}, []);
|
76
|
-
const
|
77
|
-
|
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
|
79
|
+
const getTemplatesList = async () => {
|
87
80
|
setLoading(true);
|
88
|
-
const result = await services("listTemplates", {
|
89
|
-
|
90
|
-
|
91
|
-
|
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
|
-
|
99
|
+
setFilteredTemplates(templates.filter(f => f.category === newValue));
|
99
100
|
};
|
100
|
-
const onSelectTemplate = card =>
|
101
|
+
const onSelectTemplate = card => () => {
|
101
102
|
try {
|
102
|
-
|
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(
|
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__*/
|
176
|
+
}), /*#__PURE__*/_jsxs(Grid, {
|
186
177
|
container: true,
|
187
178
|
spacing: 0,
|
188
179
|
className: `${fullScreen ? "fullscreen" : ""}`,
|
189
180
|
sx: classes.templateCardsWrpr,
|
190
|
-
children:
|
181
|
+
children: [/*#__PURE__*/_jsx(ProgressBar, {
|
191
182
|
loading: loading
|
192
|
-
})
|
193
|
-
|
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, {
|
@@ -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 => {
|
@@ -166,7 +167,6 @@ function SelectTypography({
|
|
166
167
|
const [sizeInNumber] = size.split("px");
|
167
168
|
updateMarkData(Number(sizeInNumber));
|
168
169
|
}
|
169
|
-
closeMainPopup();
|
170
170
|
};
|
171
171
|
return /*#__PURE__*/_jsx(CustomSelectTool, {
|
172
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, {
|
@@ -416,11 +416,6 @@ const usePopupStyle = theme => ({
|
|
416
416
|
"& .MuiOutlinedInput-notchedOutline": {
|
417
417
|
border: `1px solid ${theme?.palette?.editor?.inputFieldBorder} !important`
|
418
418
|
},
|
419
|
-
'& .MuiInputBase-root': {
|
420
|
-
'& input': {
|
421
|
-
border: "none !important"
|
422
|
-
}
|
423
|
-
},
|
424
419
|
"& svg": {
|
425
420
|
width: "20px",
|
426
421
|
height: "24px"
|
@@ -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?.
|
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,
|
@@ -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 {
|
@@ -84,7 +83,6 @@ const PopupTool = props => {
|
|
84
83
|
setAnchorEl(null);
|
85
84
|
} else {
|
86
85
|
updateAnchorEl();
|
87
|
-
hideSlateSelection(); // removes slate selection background, when there is no selection
|
88
86
|
}
|
89
87
|
}, [selection]);
|
90
88
|
useEffect(() => {
|
@@ -1,3 +1,11 @@
|
|
1
|
-
const
|
2
|
-
|
3
|
-
|
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
|
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,20 +10,14 @@ const FontLoader = props => {
|
|
14
10
|
const {
|
15
11
|
setFontFamilies
|
16
12
|
} = useEditorContext();
|
17
|
-
const [loading, setLoading] = useState(false);
|
18
13
|
const loadFontsInBatches = (families, batchSize = 5, maxRetries = 3) => {
|
19
14
|
let currentIndex = 0;
|
20
15
|
let retryCount = 0;
|
21
|
-
let hideLoaderOn = 30;
|
22
16
|
function loadNextBatch() {
|
23
17
|
if (currentIndex >= families?.length) {
|
24
18
|
// console.log("All fonts have been loaded");
|
25
|
-
setLoading(false);
|
26
19
|
return;
|
27
20
|
}
|
28
|
-
if (currentIndex >= hideLoaderOn) {
|
29
|
-
setLoading(false);
|
30
|
-
}
|
31
21
|
const batch = families?.slice(currentIndex, currentIndex + batchSize);
|
32
22
|
const batchWithWeights = batch.map(font => `${font}:300,400,600,700`);
|
33
23
|
WebFont.load({
|
@@ -51,9 +41,9 @@ const FontLoader = props => {
|
|
51
41
|
// Retry loading the same batch
|
52
42
|
loadNextBatch();
|
53
43
|
} else {
|
54
|
-
|
55
|
-
|
56
|
-
|
44
|
+
console.log(
|
45
|
+
// `Max retries reached for batch: ${batch}. Moving to the next batch.`
|
46
|
+
);
|
57
47
|
currentIndex += batchSize;
|
58
48
|
retryCount = 0; // Reset retry count for the next batch
|
59
49
|
loadNextBatch();
|
@@ -64,21 +54,21 @@ const FontLoader = props => {
|
|
64
54
|
loadNextBatch();
|
65
55
|
};
|
66
56
|
useEffect(() => {
|
67
|
-
let families = [...
|
57
|
+
let families = [...otherFonts, ...defaultFonts];
|
68
58
|
if (!readOnly) {
|
69
59
|
otherProps?.services("listGoogleFont", []).then(data => {
|
70
|
-
families = [...(data?.data || [])];
|
60
|
+
families = [...families, ...(data?.data || [])];
|
61
|
+
const filteredfamilies = families?.filter(font => !font?.includes("Material"));
|
71
62
|
setFontFamilies({
|
72
63
|
id: 1,
|
73
64
|
format: "fontFamily",
|
74
65
|
type: "fontfamilydropdown",
|
75
|
-
options:
|
66
|
+
options: filteredfamilies || []
|
76
67
|
});
|
77
68
|
loadFontsInBatches(families);
|
78
69
|
}).catch(err => {
|
79
|
-
|
70
|
+
console.log(err);
|
80
71
|
});
|
81
|
-
// setLoading(true);
|
82
72
|
} else {
|
83
73
|
function correctFontArray(fontString) {
|
84
74
|
let fontsArray = fontString.split(",");
|
@@ -100,25 +90,9 @@ const FontLoader = props => {
|
|
100
90
|
families = families?.map(font => font?.replace(/\"/g, ""));
|
101
91
|
families = families?.map(font => font?.replace(", sans-serif", "")); //This is temporary fix for patch
|
102
92
|
families = families.filter(font => googleFontList.includes(font));
|
103
|
-
// setLoading(true);
|
104
93
|
loadFontsInBatches(families);
|
105
94
|
}
|
106
95
|
}, []);
|
107
|
-
return
|
108
|
-
children: loading ? /*#__PURE__*/_jsx(Box, {
|
109
|
-
sx: {
|
110
|
-
position: 'absolute',
|
111
|
-
top: 0,
|
112
|
-
left: 0,
|
113
|
-
right: 0,
|
114
|
-
bottom: 0,
|
115
|
-
zIndex: 99999,
|
116
|
-
display: 'flex',
|
117
|
-
justifyContent: 'center',
|
118
|
-
alignItems: 'center'
|
119
|
-
},
|
120
|
-
children: /*#__PURE__*/_jsx(CircularProgress, {})
|
121
|
-
}) : null
|
122
|
-
});
|
96
|
+
return null;
|
123
97
|
};
|
124
98
|
export default FontLoader;
|
@@ -3,35 +3,24 @@ import PersonalVideoIcon from "@mui/icons-material/PersonalVideo";
|
|
3
3
|
import PhoneIphoneIcon from "@mui/icons-material/PhoneIphone";
|
4
4
|
import useSwitchViewport from "./styles";
|
5
5
|
import { useEffect } from "react";
|
6
|
-
import { useEditorContext } from "../../../hooks/useMouseMove";
|
7
6
|
import { jsx as _jsx } from "react/jsx-runtime";
|
8
7
|
import { jsxs as _jsxs } from "react/jsx-runtime";
|
9
8
|
const SwitchViewport = props => {
|
10
9
|
const {
|
11
10
|
breakpoint,
|
12
|
-
onChange
|
13
|
-
show
|
11
|
+
onChange
|
14
12
|
} = props;
|
15
13
|
const classes = useSwitchViewport();
|
16
|
-
const {
|
17
|
-
setSelectedElement,
|
18
|
-
setActiveBreakPoint
|
19
|
-
} = useEditorContext();
|
20
14
|
useEffect(() => {
|
21
|
-
|
22
|
-
setSelectedElement({});
|
15
|
+
console.log(breakpoint);
|
23
16
|
}, [breakpoint]);
|
24
17
|
return /*#__PURE__*/_jsxs(Box, {
|
25
18
|
sx: classes.root,
|
26
|
-
style: {
|
27
|
-
display: show ? "block" : "none"
|
28
|
-
},
|
29
19
|
children: [/*#__PURE__*/_jsx(Tooltip, {
|
30
20
|
title: "Desktop View",
|
31
21
|
children: /*#__PURE__*/_jsx(IconButton, {
|
32
22
|
className: `${!breakpoint || breakpoint === "lg" ? "active" : ""}`,
|
33
23
|
onClick: () => {
|
34
|
-
setActiveBreakPoint("");
|
35
24
|
onChange("");
|
36
25
|
},
|
37
26
|
children: /*#__PURE__*/_jsx(PersonalVideoIcon, {})
|
@@ -41,7 +30,6 @@ const SwitchViewport = props => {
|
|
41
30
|
children: /*#__PURE__*/_jsx(IconButton, {
|
42
31
|
className: `${breakpoint === "xs" ? "active" : ""}`,
|
43
32
|
onClick: () => {
|
44
|
-
setActiveBreakPoint("xs");
|
45
33
|
onChange("xs");
|
46
34
|
},
|
47
35
|
children: /*#__PURE__*/_jsx(PhoneIphoneIcon, {})
|