@flozy/editor 11.0.3 → 11.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.
- package/dist/Editor/ChatEditor.js +17 -16
- package/dist/Editor/CommonEditor.js +129 -16
- package/dist/Editor/DialogWrapper.js +31 -25
- package/dist/Editor/Editor.css +36 -8
- package/dist/Editor/Elements/AI/PopoverAIInput.js +11 -3
- package/dist/Editor/Elements/AI/Styles.js +1 -0
- package/dist/Editor/Elements/Accordion/Accordion.js +28 -22
- package/dist/Editor/Elements/Accordion/AccordionButton.js +12 -3
- package/dist/Editor/Elements/AppHeader/AppHeader.js +3 -3
- package/dist/Editor/Elements/Attachments/AttachmentStyles.js +16 -0
- package/dist/Editor/Elements/Attachments/Attachments.js +153 -11
- package/dist/Editor/Elements/Attachments/AttachmentsButton.js +8 -3
- package/dist/Editor/Elements/Button/EditorButton.js +23 -7
- package/dist/Editor/Elements/Color Picker/ColorButtons.js +61 -14
- package/dist/Editor/Elements/Color Picker/ColorPicker.css +25 -1
- package/dist/Editor/Elements/Color Picker/ColorPicker.js +10 -7
- package/dist/Editor/Elements/Color Picker/Styles.js +15 -13
- package/dist/Editor/Elements/Embed/Embed.js +36 -43
- package/dist/Editor/Elements/Embed/Image.js +236 -23
- package/dist/Editor/Elements/Embed/Video.js +245 -15
- package/dist/Editor/Elements/Form/Form.js +16 -10
- package/dist/Editor/Elements/Form/FormField.js +1 -1
- package/dist/Editor/Elements/Form/Workflow/Styles.js +24 -22
- package/dist/Editor/Elements/Form/Workflow/constant.js +25 -1
- package/dist/Editor/Elements/FreeGrid/FreeGrid.js +31 -74
- package/dist/Editor/Elements/FreeGrid/FreeGridBox.js +9 -5
- package/dist/Editor/Elements/FreeGrid/FreeGridItem.js +3 -1
- package/dist/Editor/Elements/FreeGrid/Options/More.js +7 -7
- package/dist/Editor/Elements/FreeGrid/helper.js +194 -0
- package/dist/Editor/Elements/FreeGrid/styles.js +15 -0
- package/dist/Editor/Elements/Grid/GridItem.js +1 -1
- package/dist/Editor/Elements/PageSettings/PageSettingsButton.js +2 -1
- package/dist/Editor/Elements/Signature/SignatureOptions/TypeSignature.js +3 -2
- package/dist/Editor/Elements/Signature/SignaturePopup.js +24 -6
- package/dist/Editor/Elements/SimpleText/style.js +2 -2
- package/dist/Editor/Elements/Table/Table.js +3 -3
- package/dist/Editor/Elements/Title/title.js +6 -6
- package/dist/Editor/Elements/TopBanner/TopBanner.js +4 -2
- package/dist/Editor/Elements/TopBanner/TopBannerButton.js +5 -3
- package/dist/Editor/Elements/Variables/VariableButton.js +10 -1
- package/dist/Editor/MiniEditor.js +2 -1
- package/dist/Editor/Styles/EditorStyles.js +19 -4
- package/dist/Editor/Toolbar/FormatTools/Dropdown.js +27 -3
- package/dist/Editor/Toolbar/FormatTools/FontFamilyAutocomplete.js +4 -3
- package/dist/Editor/Toolbar/FormatTools/MarkButton.js +2 -2
- package/dist/Editor/Toolbar/FormatTools/TextSize.js +33 -29
- package/dist/Editor/Toolbar/Mini/MiniToolbar.js +2 -1
- package/dist/Editor/Toolbar/PopupTool/MiniTextFormat/MiniColorPicker.js +4 -2
- package/dist/Editor/Toolbar/PopupTool/MiniTextFormat/SelectFontSize.js +25 -23
- package/dist/Editor/Toolbar/PopupTool/MiniTextFormat/SelectList.js +25 -7
- package/dist/Editor/Toolbar/PopupTool/MiniTextFormat/SelectTypography.js +167 -42
- package/dist/Editor/Toolbar/PopupTool/MiniTextFormat/index.js +24 -8
- package/dist/Editor/Toolbar/PopupTool/PopperHeader.js +2 -1
- package/dist/Editor/Toolbar/PopupTool/PopupToolStyle.js +70 -10
- package/dist/Editor/Toolbar/PopupTool/TextFormat.js +73 -14
- package/dist/Editor/Toolbar/PopupTool/ThemeTextFormat.js +439 -0
- package/dist/Editor/Toolbar/PopupTool/index.js +4 -3
- package/dist/Editor/Toolbar/toolbarGroups.js +56 -10
- package/dist/Editor/assets/svg/BackIcon.js +18 -0
- package/dist/Editor/assets/svg/ThemeIcons.js +293 -0
- package/dist/Editor/common/ColorPickerButton.js +38 -16
- package/dist/Editor/common/CustomColorPicker/index.js +130 -0
- package/dist/Editor/common/CustomColorPicker/style.js +53 -0
- package/dist/Editor/common/CustomDialog2/index.js +94 -0
- package/dist/Editor/common/CustomDialog2/style.js +67 -0
- package/dist/Editor/common/CustomSelect.js +43 -0
- package/dist/Editor/common/DnD/DragHandleButton.js +1 -1
- package/dist/Editor/common/FontLoader/FontLoader.js +4 -0
- package/dist/Editor/common/Icon.js +28 -0
- package/dist/Editor/common/ImageSelector/ImageSelector.js +45 -7
- package/dist/Editor/common/ImageSelector/Options/Upload.js +26 -11
- package/dist/Editor/common/ImageSelector/Styles.js +3 -9
- package/dist/Editor/common/LinkSettings/NavComponents.js +6 -2
- package/dist/Editor/common/MentionsPopup/index.js +9 -1
- package/dist/Editor/common/RnD/ElementSettings/OtherSettings/Settings.js +2 -1
- package/dist/Editor/common/RnD/ElementSettings/Settings/AppHeaderSettings.js +3 -2
- package/dist/Editor/common/RnD/ElementSettings/Settings/BoxSettings.js +3 -2
- package/dist/Editor/common/RnD/ElementSettings/Settings/ButtonSettings.js +3 -2
- package/dist/Editor/common/RnD/ElementSettings/Settings/CodeSettings.js +3 -2
- package/dist/Editor/common/RnD/ElementSettings/Settings/FormSettings.js +4 -2
- package/dist/Editor/common/RnD/ElementSettings/Settings/ImageSettings.js +20 -7
- package/dist/Editor/common/RnD/ElementSettings/Settings/TableSettings.js +3 -2
- package/dist/Editor/common/RnD/ElementSettings/Settings/TextSettings.js +9 -1
- package/dist/Editor/common/RnD/ElementSettings/Settings/VideoSettings.js +20 -7
- package/dist/Editor/common/RnD/SwitchViewport/SwitchViewport.js +11 -2
- package/dist/Editor/common/RnD/Theme/MainThemeProvider.js +17 -0
- package/dist/Editor/common/RnD/Theme/ViewportStimulator.js +6 -3
- package/dist/Editor/common/RnD/Utils/gridDropItem.js +28 -11
- package/dist/Editor/common/RnD/Utils/index.js +3 -1
- package/dist/Editor/common/RnD/VirtualElement/VirtualTextElement.js +52 -63
- package/dist/Editor/common/RnD/VirtualElement/helper.js +320 -130
- package/dist/Editor/common/RnD/VirtualElement/styles.js +22 -0
- package/dist/Editor/common/RnD/index.js +61 -14
- package/dist/Editor/common/Shorthands/elements.js +62 -4
- package/dist/Editor/common/StyleBuilder/buttonStyle.js +4 -2
- package/dist/Editor/common/StyleBuilder/embedVideoStyle.js +4 -0
- package/dist/Editor/common/StyleBuilder/fieldTypes/backgroundImage.js +15 -2
- package/dist/Editor/common/StyleBuilder/fieldTypes/bannerSpacing.js +12 -2
- package/dist/Editor/common/StyleBuilder/fieldTypes/borderRadius.js +15 -7
- package/dist/Editor/common/StyleBuilder/fieldTypes/card.js +16 -8
- package/dist/Editor/common/StyleBuilder/fieldTypes/color.js +36 -10
- package/dist/Editor/common/StyleBuilder/fieldTypes/embedUpload.js +115 -0
- package/dist/Editor/common/StyleBuilder/fieldTypes/fontSize.js +16 -7
- package/dist/Editor/common/StyleBuilder/fieldTypes/index.js +3 -1
- package/dist/Editor/common/StyleBuilder/fieldTypes/textOptions.js +15 -7
- package/dist/Editor/common/StyleBuilder/index.js +8 -4
- package/dist/Editor/common/Uploader.js +125 -17
- package/dist/Editor/common/UploaderWithProgress.js +183 -0
- package/dist/Editor/common/iconslist.js +21 -0
- package/dist/Editor/commonStyle.js +67 -18
- package/dist/Editor/helper/index.js +10 -2
- package/dist/Editor/helper/textIndeces.js +58 -0
- package/dist/Editor/helper/theme.js +203 -2
- package/dist/Editor/hooks/useEditorTheme.js +153 -0
- package/dist/Editor/hooks/useMouseMove.js +9 -3
- package/dist/Editor/hooks/useThemeValues.js +63 -0
- package/dist/Editor/plugins/withEmbeds.js +12 -1
- package/dist/Editor/plugins/withHTML.js +3 -1
- package/dist/Editor/plugins/withTable.js +1 -1
- package/dist/Editor/service/fileupload.js +70 -0
- package/dist/Editor/theme/ThemeList.js +50 -173
- package/dist/Editor/theme/index.js +149 -0
- package/dist/Editor/themeSettings/ActiveTheme.js +82 -0
- package/dist/Editor/themeSettings/buttons/index.js +300 -0
- package/dist/Editor/themeSettings/buttons/style.js +23 -0
- package/dist/Editor/themeSettings/colorTheme/index.js +310 -0
- package/dist/Editor/themeSettings/colorTheme/style.js +81 -0
- package/dist/Editor/themeSettings/fonts/PreviewElement.js +121 -0
- package/dist/Editor/themeSettings/fonts/index.js +240 -0
- package/dist/Editor/themeSettings/fonts/style.js +62 -0
- package/dist/Editor/themeSettings/icons.js +60 -0
- package/dist/Editor/themeSettings/index.js +380 -0
- package/dist/Editor/themeSettings/style.js +299 -0
- package/dist/Editor/themeSettingsAI/icons.js +96 -0
- package/dist/Editor/themeSettingsAI/index.js +355 -0
- package/dist/Editor/themeSettingsAI/saveTheme.js +202 -0
- package/dist/Editor/themeSettingsAI/style.js +332 -0
- package/dist/Editor/utils/SlateUtilityFunctions.js +191 -40
- package/dist/Editor/utils/accordion.js +67 -39
- package/dist/Editor/utils/button.js +1 -17
- package/dist/Editor/utils/draftToSlate.js +3 -2
- package/dist/Editor/utils/events.js +94 -89
- package/dist/Editor/utils/font.js +40 -37
- package/dist/Editor/utils/helper.js +98 -22
- package/package.json +4 -4
- package/dist/Editor/Elements/DataView/Layouts/DataTypes/Components/MultiSelect.js +0 -454
@@ -17,7 +17,8 @@ export const StyleContent = props => {
|
|
17
17
|
element: propsElement,
|
18
18
|
customProps,
|
19
19
|
handleClose,
|
20
|
-
customElement
|
20
|
+
customElement,
|
21
|
+
title
|
21
22
|
} = props;
|
22
23
|
const element = customElement ? customElement : propsElement;
|
23
24
|
const {
|
@@ -49,7 +50,8 @@ export const StyleContent = props => {
|
|
49
50
|
customProps: customProps,
|
50
51
|
handleClose: handleClose,
|
51
52
|
classes: classes,
|
52
|
-
translation: translation
|
53
|
+
translation: translation,
|
54
|
+
title: title
|
53
55
|
}, `ei_stt_tab_${value}_${m.key}_${i}`) : null;
|
54
56
|
})
|
55
57
|
}, value);
|
@@ -217,7 +219,8 @@ const StyleBuilder = props => {
|
|
217
219
|
element: elementProps,
|
218
220
|
onChange: onElementPropsChange,
|
219
221
|
customProps: customProps,
|
220
|
-
handleClose: handleClose
|
222
|
+
handleClose: handleClose,
|
223
|
+
title: title
|
221
224
|
}, `tab_${field.value}_${index}`);
|
222
225
|
})
|
223
226
|
})]
|
@@ -230,7 +233,8 @@ const StyleBuilder = props => {
|
|
230
233
|
element: elementProps,
|
231
234
|
onChange: onElementPropsChange,
|
232
235
|
customProps: customProps,
|
233
|
-
handleClose: handleClose
|
236
|
+
handleClose: handleClose,
|
237
|
+
title: title
|
234
238
|
}, `tab_${m.value}_$${i}`);
|
235
239
|
}
|
236
240
|
})
|
@@ -1,9 +1,13 @@
|
|
1
|
-
import React, { useState } from "react";
|
2
|
-
import
|
1
|
+
import React, { useRef, useState } from "react";
|
2
|
+
import Grid from "@mui/material/Grid";
|
3
|
+
import Button from "@mui/material/Button";
|
4
|
+
import Typography from "@mui/material/Typography";
|
5
|
+
import Box from "@mui/material/Box";
|
6
|
+
import CircularProgress from "@mui/material/CircularProgress";
|
3
7
|
import { convertBase64 } from "../utils/helper";
|
4
|
-
import { uploadFile } from "../service/fileupload";
|
5
8
|
import Icon from "./Icon";
|
6
9
|
import UploadStyles from "../common/ImageSelector/UploadStyles";
|
10
|
+
import { allowedTypes, extensionMap } from "../Elements/Form/Workflow/constant";
|
7
11
|
import { jsx as _jsx } from "react/jsx-runtime";
|
8
12
|
import { Fragment as _Fragment } from "react/jsx-runtime";
|
9
13
|
import { jsxs as _jsxs } from "react/jsx-runtime";
|
@@ -12,35 +16,94 @@ const Uploader = props => {
|
|
12
16
|
value,
|
13
17
|
onUploaded,
|
14
18
|
customProps,
|
15
|
-
title
|
19
|
+
title,
|
20
|
+
setS3UploadProp,
|
21
|
+
setUniqueId,
|
22
|
+
uniqueId
|
16
23
|
} = props;
|
17
24
|
const classes = UploadStyles();
|
18
25
|
const [base64, setBase64] = useState(value?.url);
|
19
26
|
const [fileName, setFileName] = useState("");
|
20
|
-
const
|
27
|
+
const allowedFormat = {
|
28
|
+
Document: ".pdf,.doc,.docx,.xls,.xlsx,.ppt,.pptx,.txt,.rtf",
|
29
|
+
Image: "image/*",
|
30
|
+
Video: "video/*",
|
31
|
+
Embed: "*"
|
32
|
+
};
|
33
|
+
const {
|
34
|
+
uploadFile,
|
35
|
+
services,
|
36
|
+
uploadTerminator
|
37
|
+
} = customProps;
|
38
|
+
const [uploadStatus, setUploadStatus] = useState({
|
39
|
+
isUploading: false,
|
40
|
+
uploadPercentage: 0
|
41
|
+
});
|
42
|
+
const [error, setError] = useState(null);
|
43
|
+
const xhrRef = useRef(null);
|
21
44
|
const handleChange = async e => {
|
45
|
+
setError("");
|
22
46
|
const uFile = e.target.files[0];
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
47
|
+
if (!uFile) return;
|
48
|
+
const maxAllowedSize = 5 * 1024 * 1024;
|
49
|
+
|
50
|
+
// ✅ Check file size
|
51
|
+
if (uFile.size > maxAllowedSize) {
|
52
|
+
const sizeInMB = Math.round(maxAllowedSize / (1024 * 1024));
|
53
|
+
setError(`File size exceeds ${sizeInMB}MB for ${uFile.name.toLowerCase()}.`);
|
54
|
+
return;
|
55
|
+
}
|
56
|
+
|
57
|
+
// ✅ File type check with fallback to extension
|
58
|
+
const validTypes = allowedTypes["Image"];
|
59
|
+
const fileType = uFile.type;
|
60
|
+
const fileName = uFile.name.toLowerCase();
|
61
|
+
const fileExtension = fileName.split(".").pop();
|
62
|
+
const isValid = title === "Embed" || validTypes.includes(fileType) || extensionMap["Image"]?.includes(fileExtension);
|
63
|
+
if (!isValid) {
|
64
|
+
setError(`Invalid file format. Please upload a valid ${title.toLowerCase()}.`);
|
65
|
+
return;
|
66
|
+
}
|
67
|
+
try {
|
68
|
+
const strImage = await convertBase64(uFile);
|
69
|
+
setBase64(strImage);
|
70
|
+
setFileName(uFile?.name);
|
71
|
+
doUpload(strImage, e.target.files[0]);
|
72
|
+
} catch (error) {
|
73
|
+
setError("Failed to read file.");
|
74
|
+
}
|
75
|
+
};
|
76
|
+
const onSave = url => {
|
77
|
+
if (!uploadStatus?.isUploading) {
|
78
|
+
setS3UploadProp({
|
79
|
+
file: true
|
80
|
+
});
|
81
|
+
}
|
82
|
+
onUploaded(url);
|
27
83
|
};
|
28
84
|
const doUpload = async (strImage, file) => {
|
29
|
-
setUploading(true);
|
30
85
|
const formData = new FormData();
|
31
86
|
formData.set("file", file);
|
32
87
|
formData.set("resource_type", "pages");
|
33
88
|
formData.set("resource_id", customProps?.page_id);
|
34
|
-
const
|
35
|
-
|
36
|
-
|
37
|
-
|
89
|
+
const id = crypto?.randomUUID();
|
90
|
+
setUniqueId(id);
|
91
|
+
const result = await services("uploadFile", file);
|
92
|
+
if (result?.data?.[0]) {
|
93
|
+
const fileEntry = {
|
94
|
+
file: file,
|
95
|
+
xhrRef,
|
96
|
+
presidnedURL: result.data?.[0],
|
97
|
+
status: "uploading"
|
98
|
+
};
|
99
|
+
uploadFile(id, fileEntry, setUploadStatus, onSave, "image");
|
38
100
|
}
|
39
101
|
};
|
40
102
|
const {
|
41
103
|
translation
|
42
104
|
} = customProps;
|
43
105
|
const onRemoveBG = () => {
|
106
|
+
uploadTerminator(uniqueId, setUploadStatus);
|
44
107
|
setBase64(null);
|
45
108
|
onUploaded("none");
|
46
109
|
};
|
@@ -59,6 +122,7 @@ const Uploader = props => {
|
|
59
122
|
const renderThumb = () => {
|
60
123
|
switch (title) {
|
61
124
|
case "Document":
|
125
|
+
case "Video":
|
62
126
|
return /*#__PURE__*/_jsxs(_Fragment, {
|
63
127
|
children: [/*#__PURE__*/_jsx(Typography, {
|
64
128
|
style: {
|
@@ -82,11 +146,54 @@ const Uploader = props => {
|
|
82
146
|
});
|
83
147
|
}
|
84
148
|
};
|
149
|
+
const UploadingProgress = () => {
|
150
|
+
return /*#__PURE__*/_jsx(Grid, {
|
151
|
+
container: true,
|
152
|
+
direction: "row",
|
153
|
+
justifyContent: "space-between",
|
154
|
+
alignItems: "center",
|
155
|
+
children: /*#__PURE__*/_jsx(Box, {
|
156
|
+
display: "flex",
|
157
|
+
flexDirection: "column",
|
158
|
+
alignItems: "flex-start",
|
159
|
+
justifyContent: "space-between",
|
160
|
+
sx: {
|
161
|
+
gap: 1,
|
162
|
+
mb: 1,
|
163
|
+
mt: 1
|
164
|
+
},
|
165
|
+
children: /*#__PURE__*/_jsxs(Box, {
|
166
|
+
display: "flex",
|
167
|
+
alignItems: "center",
|
168
|
+
gap: 1,
|
169
|
+
children: [/*#__PURE__*/_jsx(Typography, {
|
170
|
+
variant: "body",
|
171
|
+
children: `Uploading ${uploadStatus?.fileSize}`
|
172
|
+
}), /*#__PURE__*/_jsx(CircularProgress, {
|
173
|
+
variant: "determinate",
|
174
|
+
value: uploadStatus?.uploadPercentage ?? 0,
|
175
|
+
className: "circularProgress-cls",
|
176
|
+
size: 15,
|
177
|
+
thickness: 8
|
178
|
+
}), /*#__PURE__*/_jsx(Typography, {
|
179
|
+
variant: "body",
|
180
|
+
children: `${uploadStatus?.uploadPercentage?.toFixed(0) ?? 0}%`
|
181
|
+
})]
|
182
|
+
})
|
183
|
+
})
|
184
|
+
});
|
185
|
+
};
|
85
186
|
return /*#__PURE__*/_jsxs(_Fragment, {
|
86
|
-
children: [/*#__PURE__*/
|
187
|
+
children: [/*#__PURE__*/_jsxs(Grid, {
|
87
188
|
item: true,
|
88
189
|
xs: 12,
|
89
|
-
children:
|
190
|
+
children: [!error && uploadStatus?.isUploading ? /*#__PURE__*/_jsx(UploadingProgress, {}) : "", error && /*#__PURE__*/_jsx(Typography, {
|
191
|
+
style: {
|
192
|
+
color: "red",
|
193
|
+
marginBottom: "8px"
|
194
|
+
},
|
195
|
+
children: error
|
196
|
+
})]
|
90
197
|
}), /*#__PURE__*/_jsx(Grid, {
|
91
198
|
container: true,
|
92
199
|
sx: classes.uploadContainer,
|
@@ -98,7 +205,7 @@ const Uploader = props => {
|
|
98
205
|
...getBackground()
|
99
206
|
},
|
100
207
|
sx: classes.uploadField,
|
101
|
-
children: !
|
208
|
+
children: !uploadStatus?.isUploading ? /*#__PURE__*/_jsx(Grid, {
|
102
209
|
className: "uploadImageSection",
|
103
210
|
children: base64 ? renderThumb() : /*#__PURE__*/_jsx(Grid, {
|
104
211
|
className: "uploadImageText",
|
@@ -112,6 +219,7 @@ const Uploader = props => {
|
|
112
219
|
sx: classes.uploadIcon,
|
113
220
|
children: [/*#__PURE__*/_jsx("input", {
|
114
221
|
type: "file",
|
222
|
+
accept: allowedFormat["Image"],
|
115
223
|
style: {
|
116
224
|
opacity: 0,
|
117
225
|
width: "0px"
|
@@ -0,0 +1,183 @@
|
|
1
|
+
import React, { useState } from "react";
|
2
|
+
import { Grid, Button, Typography } from "@mui/material";
|
3
|
+
import { convertBase64 } from "../utils/helper";
|
4
|
+
import Icon from "./Icon";
|
5
|
+
import UploadStyles from "../common/ImageSelector/UploadStyles";
|
6
|
+
import { allowedFormat, maxSizeMap, allowedTypes, extensionMap } from "../Elements/Form/Workflow/constant";
|
7
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
8
|
+
import { Fragment as _Fragment } from "react/jsx-runtime";
|
9
|
+
import { jsxs as _jsxs } from "react/jsx-runtime";
|
10
|
+
const UploaderWithProgress = props => {
|
11
|
+
const {
|
12
|
+
value,
|
13
|
+
onUploaded,
|
14
|
+
customProps,
|
15
|
+
setS3UploadProp,
|
16
|
+
s3UploadProp
|
17
|
+
} = props;
|
18
|
+
const title = props.title || "Image";
|
19
|
+
const classes = UploadStyles();
|
20
|
+
const [base64, setBase64] = useState(value?.url);
|
21
|
+
const [fileName, setFileName] = useState("");
|
22
|
+
const [uploading, setUploading] = useState(false);
|
23
|
+
const [error, setError] = useState("");
|
24
|
+
const handleChange = async e => {
|
25
|
+
setError("");
|
26
|
+
const uFile = e.target.files[0];
|
27
|
+
if (!uFile) return;
|
28
|
+
const maxAllowedSize = maxSizeMap[title] || 5 * 1024 * 1024;
|
29
|
+
|
30
|
+
// ✅ Check file size
|
31
|
+
if (uFile.size > maxAllowedSize) {
|
32
|
+
const sizeInMB = Math.round(maxAllowedSize / (1024 * 1024));
|
33
|
+
setError(`File size exceeds ${sizeInMB}MB for ${title.toLowerCase()}.`);
|
34
|
+
return;
|
35
|
+
}
|
36
|
+
|
37
|
+
// ✅ File type check with fallback to extension
|
38
|
+
const validTypes = allowedTypes[title];
|
39
|
+
const fileType = uFile.type;
|
40
|
+
const fileName = uFile.name.toLowerCase();
|
41
|
+
const fileExtension = fileName.split(".").pop();
|
42
|
+
const isValid = title === "Embed" || validTypes.includes(fileType) || extensionMap[title]?.includes(fileExtension);
|
43
|
+
if (!isValid) {
|
44
|
+
setError(`Invalid file format. Please upload a valid ${title.toLowerCase()}.`);
|
45
|
+
return;
|
46
|
+
}
|
47
|
+
try {
|
48
|
+
const strImage = await convertBase64(uFile);
|
49
|
+
setBase64(strImage);
|
50
|
+
setFileName(uFile?.name);
|
51
|
+
doUpload(strImage, uFile);
|
52
|
+
} catch (err) {
|
53
|
+
setError("Failed to read file.");
|
54
|
+
}
|
55
|
+
};
|
56
|
+
const doUpload = async (strImage, file) => {
|
57
|
+
setUploading(true);
|
58
|
+
setS3UploadProp({
|
59
|
+
...s3UploadProp,
|
60
|
+
file: file,
|
61
|
+
pageId: customProps?.page_id,
|
62
|
+
services: customProps?.services
|
63
|
+
});
|
64
|
+
setUploading(false);
|
65
|
+
};
|
66
|
+
const {
|
67
|
+
translation
|
68
|
+
} = customProps;
|
69
|
+
const onRemoveBG = () => {
|
70
|
+
setBase64(null);
|
71
|
+
onUploaded("");
|
72
|
+
setS3UploadProp({
|
73
|
+
...s3UploadProp,
|
74
|
+
file: null
|
75
|
+
});
|
76
|
+
};
|
77
|
+
const getBackground = () => {
|
78
|
+
switch (title) {
|
79
|
+
case "Document":
|
80
|
+
return {
|
81
|
+
backgroundImage: `url()`
|
82
|
+
};
|
83
|
+
default:
|
84
|
+
return {
|
85
|
+
backgroundImage: base64 ? `url(${base64})` : "none"
|
86
|
+
};
|
87
|
+
}
|
88
|
+
};
|
89
|
+
const renderThumb = () => {
|
90
|
+
switch (title) {
|
91
|
+
case "Video":
|
92
|
+
case "Document":
|
93
|
+
return /*#__PURE__*/_jsxs(_Fragment, {
|
94
|
+
children: [/*#__PURE__*/_jsx(Typography, {
|
95
|
+
style: {
|
96
|
+
padding: "8px",
|
97
|
+
fontSize: "12px",
|
98
|
+
color: "#2563eb",
|
99
|
+
textAlign: "center"
|
100
|
+
},
|
101
|
+
children: fileName
|
102
|
+
}), /*#__PURE__*/_jsx(Grid, {
|
103
|
+
className: "removeImageText",
|
104
|
+
onClick: onRemoveBG,
|
105
|
+
children: translation("Remove")
|
106
|
+
})]
|
107
|
+
});
|
108
|
+
default:
|
109
|
+
return /*#__PURE__*/_jsx(Grid, {
|
110
|
+
className: "removeImageText",
|
111
|
+
onClick: onRemoveBG,
|
112
|
+
children: translation("Remove")
|
113
|
+
});
|
114
|
+
}
|
115
|
+
};
|
116
|
+
return /*#__PURE__*/_jsx(_Fragment, {
|
117
|
+
children: /*#__PURE__*/_jsxs(Grid, {
|
118
|
+
style: {
|
119
|
+
height: error ? "fit-content" : "inherit"
|
120
|
+
},
|
121
|
+
className: "uploaderRoot",
|
122
|
+
children: [/*#__PURE__*/_jsx(Grid, {
|
123
|
+
item: true,
|
124
|
+
xs: 12,
|
125
|
+
children: error && /*#__PURE__*/_jsx(Typography, {
|
126
|
+
style: {
|
127
|
+
color: "red",
|
128
|
+
marginBottom: "8px"
|
129
|
+
},
|
130
|
+
children: error
|
131
|
+
})
|
132
|
+
}), /*#__PURE__*/_jsx(Grid, {
|
133
|
+
container: true,
|
134
|
+
sx: classes.uploadContainer,
|
135
|
+
style: {
|
136
|
+
minHeight: error ? "250px" : "none"
|
137
|
+
},
|
138
|
+
className: "uploaderDragPlace",
|
139
|
+
children: /*#__PURE__*/_jsx(Grid, {
|
140
|
+
item: true,
|
141
|
+
xs: 12,
|
142
|
+
className: "btn--wrpr",
|
143
|
+
style: {
|
144
|
+
...getBackground()
|
145
|
+
},
|
146
|
+
sx: classes.uploadField,
|
147
|
+
children: !uploading ? /*#__PURE__*/_jsx(Grid, {
|
148
|
+
className: "uploadImageSection",
|
149
|
+
children: base64 ? renderThumb() : /*#__PURE__*/_jsx(Grid, {
|
150
|
+
className: "uploadImageText",
|
151
|
+
children: /*#__PURE__*/_jsxs(Button, {
|
152
|
+
component: "label",
|
153
|
+
variant: "text",
|
154
|
+
style: {
|
155
|
+
background: "none",
|
156
|
+
width: "100%"
|
157
|
+
},
|
158
|
+
sx: classes.uploadIcon,
|
159
|
+
children: [/*#__PURE__*/_jsx("input", {
|
160
|
+
type: "file",
|
161
|
+
accept: allowedFormat[title],
|
162
|
+
style: {
|
163
|
+
opacity: 0,
|
164
|
+
width: "0px"
|
165
|
+
},
|
166
|
+
onChange: handleChange
|
167
|
+
}), /*#__PURE__*/_jsx(Icon, {
|
168
|
+
icon: "fileUpload"
|
169
|
+
}), /*#__PURE__*/_jsx("span", {
|
170
|
+
style: {
|
171
|
+
paddingLeft: "8px"
|
172
|
+
},
|
173
|
+
children: `${translation("upload")} ${translation(title) || translation("image")}`
|
174
|
+
})]
|
175
|
+
})
|
176
|
+
})
|
177
|
+
}) : null
|
178
|
+
})
|
179
|
+
})]
|
180
|
+
})
|
181
|
+
});
|
182
|
+
};
|
183
|
+
export default UploaderWithProgress;
|
@@ -1677,6 +1677,27 @@ export const CloseIcon = props => /*#__PURE__*/_jsxs("svg", {
|
|
1677
1677
|
strokeLinejoin: "round"
|
1678
1678
|
})]
|
1679
1679
|
});
|
1680
|
+
export const CloseIcon2 = props => /*#__PURE__*/_jsxs("svg", {
|
1681
|
+
width: "10",
|
1682
|
+
height: "10",
|
1683
|
+
viewBox: "0 0 10 10",
|
1684
|
+
fill: "none",
|
1685
|
+
xmlns: "http://www.w3.org/2000/svg",
|
1686
|
+
...(props || {}),
|
1687
|
+
children: [/*#__PURE__*/_jsx("path", {
|
1688
|
+
d: "M9.12476 0.875L0.875176 9.12458",
|
1689
|
+
stroke: "#8F9CAE",
|
1690
|
+
strokeWidth: "1.5",
|
1691
|
+
strokeLinecap: "round",
|
1692
|
+
strokeLinejoin: "round"
|
1693
|
+
}), /*#__PURE__*/_jsx("path", {
|
1694
|
+
d: "M0.875183 0.875L9.12476 9.12458",
|
1695
|
+
stroke: "#8F9CAE",
|
1696
|
+
strokeWidth: "1.5",
|
1697
|
+
strokeLinecap: "round",
|
1698
|
+
strokeLinejoin: "round"
|
1699
|
+
})]
|
1700
|
+
});
|
1680
1701
|
export const SearchIcon = () => /*#__PURE__*/_jsxs("svg", {
|
1681
1702
|
width: "18",
|
1682
1703
|
height: "18",
|
@@ -49,6 +49,12 @@ const useCommonStyle = theme => ({
|
|
49
49
|
fontWeight: "500",
|
50
50
|
fontFamily: "Inter, sans-serif"
|
51
51
|
},
|
52
|
+
"& .MuiPaper-root": {
|
53
|
+
border: `unset !important`,
|
54
|
+
borderRadius: "0px",
|
55
|
+
height: "fit-content",
|
56
|
+
padding: "2px"
|
57
|
+
},
|
52
58
|
"& p": {
|
53
59
|
marginBottom: "7px",
|
54
60
|
marginTop: "4px"
|
@@ -65,9 +71,6 @@ const useCommonStyle = theme => ({
|
|
65
71
|
},
|
66
72
|
"&::-webkit-scrollbar-thumb": {
|
67
73
|
background: `${theme?.palette?.editor?.brainPopupScroll} !important`
|
68
|
-
},
|
69
|
-
"&::-webkit-scrollbar-track": {
|
70
|
-
visibility: "hidden"
|
71
74
|
}
|
72
75
|
},
|
73
76
|
"& .MuiGrid-root>.MuiGrid-item": {
|
@@ -211,16 +214,16 @@ const useCommonStyle = theme => ({
|
|
211
214
|
backgroundColor: theme?.palette?.editor?.miniToolBarBackground
|
212
215
|
},
|
213
216
|
"& .popup_tabs": {
|
214
|
-
backgroundColor: theme?.palette?.editor?.
|
217
|
+
backgroundColor: theme?.palette?.editor?.miniToolBarBackground,
|
215
218
|
"@media only screen and (max-width: 899px)": {
|
216
219
|
width: "100% !important"
|
217
220
|
}
|
218
221
|
},
|
219
222
|
"& .popup_tabs-header": {
|
220
|
-
backgroundColor: theme?.palette?.editor?.
|
223
|
+
backgroundColor: theme?.palette?.editor?.miniToolBarBackground,
|
221
224
|
"& .popup_tabs-header-label-active": {
|
222
225
|
color: theme?.palette?.editor?.activeColor,
|
223
|
-
backgroundColor: theme?.palette?.editor?.
|
226
|
+
backgroundColor: theme?.palette?.editor?.miniToolBarBackground
|
224
227
|
}
|
225
228
|
},
|
226
229
|
"& .colorpicker": {
|
@@ -249,6 +252,40 @@ const useCommonStyle = theme => ({
|
|
249
252
|
backgroundColor: theme?.palette?.editor?.miniToolBarBackground,
|
250
253
|
color: theme?.palette?.editor?.textColor
|
251
254
|
}
|
255
|
+
},
|
256
|
+
"& .colorPickerActionBtns": {
|
257
|
+
backgroundColor: theme?.palette?.editor?.miniToolBarBackground,
|
258
|
+
display: "flex",
|
259
|
+
justifyContent: "end",
|
260
|
+
padding: "10px",
|
261
|
+
position: "sticky",
|
262
|
+
bottom: 0,
|
263
|
+
right: 0,
|
264
|
+
boxShadow: `0px -3px 12px 0px ${theme?.palette?.editor?.cardShadow}`,
|
265
|
+
gap: "8px",
|
266
|
+
"& button": {
|
267
|
+
fontWeight: 600,
|
268
|
+
fontSize: "14px",
|
269
|
+
opacity: 1,
|
270
|
+
borderRadius: "8px",
|
271
|
+
textTransform: "math-auto",
|
272
|
+
padding: "4px 20px",
|
273
|
+
height: "fit-content",
|
274
|
+
minWidth: "90px",
|
275
|
+
"@media only screen and (max-width: 899px)": {
|
276
|
+
width: "50%"
|
277
|
+
},
|
278
|
+
"&.confirmBtn": {
|
279
|
+
backgroundColor: "#2563EB",
|
280
|
+
color: "#ffffff",
|
281
|
+
border: `1px solid #2563EB`
|
282
|
+
},
|
283
|
+
"&.cancelBtn": {
|
284
|
+
backgroundColor: theme?.palette?.editor?.closeButtonBackground,
|
285
|
+
color: theme?.palette?.editor?.customDialogueCloseBtnColor,
|
286
|
+
border: `1px solid ${theme?.palette?.editor?.customDialogueCloseBtnBorder}`
|
287
|
+
}
|
288
|
+
}
|
252
289
|
}
|
253
290
|
},
|
254
291
|
colorPickerBtnBorder: {
|
@@ -528,6 +565,18 @@ const useCommonStyle = theme => ({
|
|
528
565
|
}
|
529
566
|
}
|
530
567
|
},
|
568
|
+
buttonMoreOption: {
|
569
|
+
background: `${theme?.palette?.editor?.aiInputBackground} !important`,
|
570
|
+
border: `1px solid ${theme?.palette?.editor?.buttonBorder1} !important`,
|
571
|
+
padding: "4px !important",
|
572
|
+
"& svg": {
|
573
|
+
width: "18px !important",
|
574
|
+
height: "18px !important",
|
575
|
+
"& path": {
|
576
|
+
stroke: `${theme?.palette?.editor?.closeButtonSvgStroke} !important`
|
577
|
+
}
|
578
|
+
}
|
579
|
+
},
|
531
580
|
pageSettingPopUpRoot: {
|
532
581
|
padding: "16px 8px 16px 10px!important",
|
533
582
|
height: "100%",
|
@@ -555,18 +604,18 @@ const useCommonStyle = theme => ({
|
|
555
604
|
right: -40,
|
556
605
|
transform: "translateY(-50%)"
|
557
606
|
},
|
558
|
-
buttonMoreOption: {
|
559
|
-
|
560
|
-
|
561
|
-
|
562
|
-
|
563
|
-
|
564
|
-
|
565
|
-
|
566
|
-
|
567
|
-
|
568
|
-
|
569
|
-
},
|
607
|
+
// buttonMoreOption: {
|
608
|
+
// background: `${theme?.palette?.editor?.aiInputBackground} !important`,
|
609
|
+
// border: `1px solid ${theme?.palette?.editor?.buttonBorder1} !important`,
|
610
|
+
// padding: "4px !important",
|
611
|
+
// "& svg": {
|
612
|
+
// width: "18px !important",
|
613
|
+
// height: "18px !important",
|
614
|
+
// "& path": {
|
615
|
+
// stroke: `${theme?.palette?.editor?.closeButtonSvgStroke} !important`,
|
616
|
+
// },
|
617
|
+
// },
|
618
|
+
// },
|
570
619
|
buttonMoreOption2: {
|
571
620
|
background: `${theme?.palette?.editor?.aiInputBackground} !important`,
|
572
621
|
border: `1px solid ${theme?.palette?.editor?.buttonBorder1} !important`,
|
@@ -7,14 +7,14 @@ import { Node } from "slate";
|
|
7
7
|
const HIDE_PLACHOLDERS = ["grid", "grid-item", "table"];
|
8
8
|
const TEXT_NODES = ["paragraph", "headingOne", "headingTwo", "headingThree"];
|
9
9
|
const PREVIEW_IMAGE_HIDE_CLASS = ["grid-container-toolbar", "grid-item-toolbar", "element-toolbar", "mini-tool-wrpr-ei", "element-selector", "element-selector-ctrl"];
|
10
|
-
const RND_ITEMS = ["freegridItem", "freegridBox"];
|
10
|
+
export const RND_ITEMS = ["freegridItem", "freegridBox"];
|
11
11
|
export const getThumbnailImage = async (dom, options = {}) => {
|
12
12
|
try {
|
13
13
|
const canvas = await html2canvas(dom, {
|
14
14
|
windowWidth: 1440,
|
15
15
|
windowHeight: 768,
|
16
16
|
...options,
|
17
|
-
backgroundColor:
|
17
|
+
backgroundColor: 'white',
|
18
18
|
allowTaint: true,
|
19
19
|
useCORS: false,
|
20
20
|
scale: 0.5,
|
@@ -23,6 +23,11 @@ export const getThumbnailImage = async (dom, options = {}) => {
|
|
23
23
|
// hide class
|
24
24
|
const sw = document.getElementById("slate-wrapper-scroll-container");
|
25
25
|
sw.style.minHeight = "2000px";
|
26
|
+
if (options?.fromBrains) {
|
27
|
+
const textbox = document.querySelector(".innert-editor-textbox");
|
28
|
+
textbox.style.padding = "24px";
|
29
|
+
textbox.style.background = options?.pageColor || '#fffff';
|
30
|
+
}
|
26
31
|
const svgFrames = document.querySelectorAll(".image-frame svg");
|
27
32
|
for (let i = 0; i < svgFrames.length; i++) {
|
28
33
|
svgFrames[i].style.width = "100%";
|
@@ -99,6 +104,9 @@ function padZero(str, len) {
|
|
99
104
|
return (zeros + str).slice(-len);
|
100
105
|
}
|
101
106
|
export function getEmbedURL(element, needType = false) {
|
107
|
+
if (typeof element?.href !== "string" && typeof element?.url !== "string") {
|
108
|
+
return null;
|
109
|
+
}
|
102
110
|
let refUrl = element.href ? element.href : element.url;
|
103
111
|
refUrl = refUrl ? refUrl.includes("http") ? refUrl : `//${refUrl}` : "Link";
|
104
112
|
let embedUrl = refUrl;
|
@@ -0,0 +1,58 @@
|
|
1
|
+
export function extractTextWithPath(data, path = []) {
|
2
|
+
let result = [];
|
3
|
+
data.forEach((item, index) => {
|
4
|
+
const currentPath = [...path, index];
|
5
|
+
if (item.text) {
|
6
|
+
result.push({
|
7
|
+
path_id: currentPath.join(","),
|
8
|
+
text: item.text
|
9
|
+
});
|
10
|
+
}
|
11
|
+
if (item.children) {
|
12
|
+
result = result.concat(extractTextWithPath(item.children, currentPath));
|
13
|
+
}
|
14
|
+
});
|
15
|
+
return result;
|
16
|
+
}
|
17
|
+
export function replaceTextPath(nestedJson, pathIdJson) {
|
18
|
+
// Create a map from path_id JSON for quick lookup
|
19
|
+
const pathIdMap = new Map(pathIdJson.map(item => [item.path_id, item.text]));
|
20
|
+
console.log(pathIdMap);
|
21
|
+
function extractTextWithPath(data, path = []) {
|
22
|
+
data.forEach((item, index) => {
|
23
|
+
const currentPath = [...path, index];
|
24
|
+
if (item.text) {
|
25
|
+
if (pathIdMap.has(currentPath?.join(","))) {
|
26
|
+
item.text = pathIdMap.get(currentPath?.join(","));
|
27
|
+
}
|
28
|
+
}
|
29
|
+
if (item.children) {
|
30
|
+
extractTextWithPath(item.children, currentPath);
|
31
|
+
}
|
32
|
+
});
|
33
|
+
}
|
34
|
+
extractTextWithPath(nestedJson, []);
|
35
|
+
return nestedJson;
|
36
|
+
}
|
37
|
+
|
38
|
+
// export function replaceTextPath(nestedJson, pathIdJson) {
|
39
|
+
// // Create a map from path_id JSON for quick lookup
|
40
|
+
// const pathIdMap = new Map(
|
41
|
+
// pathIdJson.map((item) => [item.path_id, item.text])
|
42
|
+
// );
|
43
|
+
|
44
|
+
// function traverseAndReplace(node) {
|
45
|
+
// if (Array.isArray(node)) {
|
46
|
+
// node.forEach(traverseAndReplace);
|
47
|
+
// } else if (typeof node === "object" && node !== null) {
|
48
|
+
// console.log(node);
|
49
|
+
// if (node.text && pathIdMap.has(node.text)) {
|
50
|
+
// node.text = pathIdMap.get(node.path_id);
|
51
|
+
// }
|
52
|
+
// Object.values(node).forEach(traverseAndReplace);
|
53
|
+
// }
|
54
|
+
// }
|
55
|
+
|
56
|
+
// traverseAndReplace(nestedJson);
|
57
|
+
// return nestedJson;
|
58
|
+
// }
|