@flozy/editor 11.1.1 → 11.1.3

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 (143) hide show
  1. package/dist/Editor/ChatEditor.js +6 -6
  2. package/dist/Editor/CommonEditor.js +82 -21
  3. package/dist/Editor/DialogWrapper.js +31 -25
  4. package/dist/Editor/Editor.css +37 -4
  5. package/dist/Editor/Elements/AI/PopoverAIInput.js +11 -3
  6. package/dist/Editor/Elements/AppHeader/AppHeader.js +3 -3
  7. package/dist/Editor/Elements/Attachments/AttachmentStyles.js +16 -0
  8. package/dist/Editor/Elements/Attachments/Attachments.js +154 -11
  9. package/dist/Editor/Elements/Attachments/AttachmentsButton.js +8 -3
  10. package/dist/Editor/Elements/Button/EditorButton.js +22 -7
  11. package/dist/Editor/Elements/Color Picker/ColorButtons.js +61 -14
  12. package/dist/Editor/Elements/Color Picker/ColorPicker.css +25 -1
  13. package/dist/Editor/Elements/Color Picker/ColorPicker.js +10 -7
  14. package/dist/Editor/Elements/Color Picker/Styles.js +15 -13
  15. package/dist/Editor/Elements/DataView/Layouts/DataTypes/Components/Select.js +134 -55
  16. package/dist/Editor/Elements/DataView/Layouts/DataTypes/Components/SelectV1.js +7 -8
  17. package/dist/Editor/Elements/DataView/Layouts/DataTypes/PersonType.js +8 -3
  18. package/dist/Editor/Elements/DataView/Layouts/Options/EditProperty.js +1 -1
  19. package/dist/Editor/Elements/DataView/Layouts/TableStyles.js +1 -1
  20. package/dist/Editor/Elements/Embed/Embed.css +5 -0
  21. package/dist/Editor/Elements/Embed/Embed.js +37 -43
  22. package/dist/Editor/Elements/Embed/Image.js +242 -22
  23. package/dist/Editor/Elements/Embed/Video.js +277 -32
  24. package/dist/Editor/Elements/Form/Form.js +10 -35
  25. package/dist/Editor/Elements/Form/FormField.js +1 -1
  26. package/dist/Editor/Elements/Form/Workflow/Styles.js +24 -22
  27. package/dist/Editor/Elements/Form/Workflow/constant.js +25 -1
  28. package/dist/Editor/Elements/FreeGrid/FreeGrid.js +34 -75
  29. package/dist/Editor/Elements/FreeGrid/FreeGridBox.js +9 -5
  30. package/dist/Editor/Elements/FreeGrid/FreeGridItem.js +3 -1
  31. package/dist/Editor/Elements/FreeGrid/helper.js +194 -0
  32. package/dist/Editor/Elements/FreeGrid/styles.js +15 -0
  33. package/dist/Editor/Elements/Grid/GridItem.js +1 -1
  34. package/dist/Editor/Elements/PageSettings/PageSettingsButton.js +2 -1
  35. package/dist/Editor/Elements/Signature/SignatureOptions/TypeSignature.js +2 -3
  36. package/dist/Editor/Elements/Signature/SignaturePopup.js +2 -13
  37. package/dist/Editor/Elements/SimpleText/index.js +4 -1
  38. package/dist/Editor/Elements/Table/Table.js +2 -1
  39. package/dist/Editor/Elements/Table/TableCell.js +10 -3
  40. package/dist/Editor/Elements/Title/title.js +4 -5
  41. package/dist/Editor/Elements/TopBanner/TopBanner.js +4 -2
  42. package/dist/Editor/Elements/TopBanner/TopBannerButton.js +5 -3
  43. package/dist/Editor/Styles/EditorStyles.js +16 -5
  44. package/dist/Editor/Toolbar/FormatTools/Dropdown.js +27 -3
  45. package/dist/Editor/Toolbar/FormatTools/FontFamilyAutocomplete.js +4 -3
  46. package/dist/Editor/Toolbar/FormatTools/MarkButton.js +2 -2
  47. package/dist/Editor/Toolbar/FormatTools/TextSize.js +33 -29
  48. package/dist/Editor/Toolbar/Mini/MiniToolbar.js +2 -1
  49. package/dist/Editor/Toolbar/PopupTool/MiniTextFormat/MiniColorPicker.js +3 -1
  50. package/dist/Editor/Toolbar/PopupTool/MiniTextFormat/SelectFontSize.js +25 -23
  51. package/dist/Editor/Toolbar/PopupTool/MiniTextFormat/SelectTypography.js +167 -42
  52. package/dist/Editor/Toolbar/PopupTool/MiniTextFormat/index.js +15 -5
  53. package/dist/Editor/Toolbar/PopupTool/PopperHeader.js +2 -1
  54. package/dist/Editor/Toolbar/PopupTool/PopupToolStyle.js +65 -7
  55. package/dist/Editor/Toolbar/PopupTool/TextFormat.js +66 -12
  56. package/dist/Editor/Toolbar/PopupTool/ThemeTextFormat.js +439 -0
  57. package/dist/Editor/Toolbar/PopupTool/index.js +7 -4
  58. package/dist/Editor/Toolbar/toolbarGroups.js +48 -6
  59. package/dist/Editor/assets/svg/BackIcon.js +18 -0
  60. package/dist/Editor/assets/svg/ThemeIcons.js +293 -0
  61. package/dist/Editor/common/ColorPickerButton.js +38 -19
  62. package/dist/Editor/common/CustomColorPicker/index.js +130 -0
  63. package/dist/Editor/common/CustomColorPicker/style.js +53 -0
  64. package/dist/Editor/common/CustomDialog2/index.js +94 -0
  65. package/dist/Editor/common/CustomDialog2/style.js +67 -0
  66. package/dist/Editor/common/CustomSelect.js +43 -0
  67. package/dist/Editor/common/DnD/DragHandleButton.js +1 -1
  68. package/dist/Editor/common/FontLoader/FontLoader.js +1 -0
  69. package/dist/Editor/common/Icon.js +28 -0
  70. package/dist/Editor/common/ImageSelector/ImageSelector.js +45 -7
  71. package/dist/Editor/common/ImageSelector/Options/Upload.js +26 -11
  72. package/dist/Editor/common/ImageSelector/Styles.js +3 -9
  73. package/dist/Editor/common/RnD/ElementSettings/OtherSettings/Settings.js +2 -1
  74. package/dist/Editor/common/RnD/ElementSettings/Settings/AppHeaderSettings.js +3 -2
  75. package/dist/Editor/common/RnD/ElementSettings/Settings/BoxSettings.js +3 -2
  76. package/dist/Editor/common/RnD/ElementSettings/Settings/ButtonSettings.js +3 -2
  77. package/dist/Editor/common/RnD/ElementSettings/Settings/CodeSettings.js +3 -2
  78. package/dist/Editor/common/RnD/ElementSettings/Settings/FormSettings.js +3 -2
  79. package/dist/Editor/common/RnD/ElementSettings/Settings/ImageSettings.js +20 -7
  80. package/dist/Editor/common/RnD/ElementSettings/Settings/TableSettings.js +3 -2
  81. package/dist/Editor/common/RnD/ElementSettings/Settings/TextSettings.js +2 -0
  82. package/dist/Editor/common/RnD/ElementSettings/Settings/VideoSettings.js +20 -7
  83. package/dist/Editor/common/RnD/GuideLines/styles.js +1 -1
  84. package/dist/Editor/common/RnD/Theme/MainThemeProvider.js +17 -0
  85. package/dist/Editor/common/RnD/Theme/ViewportStimulator.js +6 -3
  86. package/dist/Editor/common/RnD/Utils/gridDropItem.js +28 -11
  87. package/dist/Editor/common/RnD/Utils/index.js +3 -1
  88. package/dist/Editor/common/RnD/VirtualElement/VirtualTextElement.js +52 -63
  89. package/dist/Editor/common/RnD/VirtualElement/helper.js +248 -68
  90. package/dist/Editor/common/RnD/VirtualElement/styles.js +22 -0
  91. package/dist/Editor/common/RnD/index.js +61 -14
  92. package/dist/Editor/common/Shorthands/elements.js +54 -0
  93. package/dist/Editor/common/StyleBuilder/buttonStyle.js +4 -2
  94. package/dist/Editor/common/StyleBuilder/embedVideoStyle.js +4 -0
  95. package/dist/Editor/common/StyleBuilder/fieldStyle.js +1 -0
  96. package/dist/Editor/common/StyleBuilder/fieldTypes/backgroundImage.js +18 -4
  97. package/dist/Editor/common/StyleBuilder/fieldTypes/bannerSpacing.js +12 -2
  98. package/dist/Editor/common/StyleBuilder/fieldTypes/borderRadius.js +15 -7
  99. package/dist/Editor/common/StyleBuilder/fieldTypes/color.js +36 -10
  100. package/dist/Editor/common/StyleBuilder/fieldTypes/fontSize.js +13 -4
  101. package/dist/Editor/common/StyleBuilder/fieldTypes/menusArray.js +2 -0
  102. package/dist/Editor/common/StyleBuilder/fieldTypes/text.js +15 -4
  103. package/dist/Editor/common/StyleBuilder/fieldTypes/textOptions.js +15 -7
  104. package/dist/Editor/common/StyleBuilder/formStyle.js +19 -13
  105. package/dist/Editor/common/StyleBuilder/index.js +8 -4
  106. package/dist/Editor/common/Uploader.js +118 -17
  107. package/dist/Editor/common/UploaderWithProgress.js +183 -0
  108. package/dist/Editor/common/iconslist.js +21 -0
  109. package/dist/Editor/commonStyle.js +37 -3
  110. package/dist/Editor/helper/index.js +4 -1
  111. package/dist/Editor/helper/theme.js +203 -2
  112. package/dist/Editor/hooks/useEditorTheme.js +153 -0
  113. package/dist/Editor/hooks/useMouseMove.js +12 -3
  114. package/dist/Editor/hooks/useTable.js +62 -1
  115. package/dist/Editor/hooks/useThemeValues.js +63 -0
  116. package/dist/Editor/plugins/withEmbeds.js +1 -1
  117. package/dist/Editor/plugins/withHTML.js +56 -3
  118. package/dist/Editor/plugins/withTable.js +1 -1
  119. package/dist/Editor/service/fileupload.js +70 -0
  120. package/dist/Editor/theme/ThemeList.js +50 -173
  121. package/dist/Editor/theme/index.js +149 -0
  122. package/dist/Editor/themeSettings/ActiveTheme.js +82 -0
  123. package/dist/Editor/themeSettings/buttons/index.js +300 -0
  124. package/dist/Editor/themeSettings/buttons/style.js +23 -0
  125. package/dist/Editor/themeSettings/colorTheme/index.js +310 -0
  126. package/dist/Editor/themeSettings/colorTheme/style.js +81 -0
  127. package/dist/Editor/themeSettings/fonts/PreviewElement.js +121 -0
  128. package/dist/Editor/themeSettings/fonts/index.js +240 -0
  129. package/dist/Editor/themeSettings/fonts/style.js +62 -0
  130. package/dist/Editor/themeSettings/icons.js +60 -0
  131. package/dist/Editor/themeSettings/index.js +380 -0
  132. package/dist/Editor/themeSettings/style.js +299 -0
  133. package/dist/Editor/themeSettingsAI/icons.js +96 -0
  134. package/dist/Editor/themeSettingsAI/index.js +355 -0
  135. package/dist/Editor/themeSettingsAI/saveTheme.js +202 -0
  136. package/dist/Editor/themeSettingsAI/style.js +332 -0
  137. package/dist/Editor/utils/SlateUtilityFunctions.js +162 -38
  138. package/dist/Editor/utils/accordion.js +1 -1
  139. package/dist/Editor/utils/button.js +1 -17
  140. package/dist/Editor/utils/font.js +40 -37
  141. package/dist/Editor/utils/helper.js +76 -3
  142. package/dist/Editor/utils/insertAppHeader.js +8 -4
  143. package/package.json +1 -1
@@ -3,13 +3,13 @@ import { Checkbox, FormControlLabel, Grid, Slider, Typography, Box, IconButton }
3
3
  import { squreStyle } from "./radiusStyle";
4
4
  import { getBreakPointsValue } from "../../../helper/theme";
5
5
  import useWindowResize from "../../../hooks/useWindowResize";
6
+ import { useEditorTheme } from "../../../hooks/useEditorTheme";
6
7
  import { CheckedBoxCheckIcon } from "../../iconListV2";
7
8
  import { jsx as _jsx } from "react/jsx-runtime";
8
9
  import { jsxs as _jsxs } from "react/jsx-runtime";
9
10
  const BANNER_SPACING_KEYS = ["top", "left", "right", "bottom"];
10
11
  const BannerSpacing = props => {
11
12
  const {
12
- value: val,
13
13
  data,
14
14
  onChange,
15
15
  elementProps,
@@ -23,7 +23,17 @@ const BannerSpacing = props => {
23
23
  key
24
24
  } = data;
25
25
  const lockKeyVal = `lock${key}`;
26
- let lockSpacing = elementProps[lockKeyVal];
26
+ const {
27
+ selectedTheme
28
+ } = useEditorTheme();
29
+ const {
30
+ bannerSpacing,
31
+ lockbannerSpacing
32
+ } = selectedTheme?.elementProps[elementProps?.type] || {};
33
+ const isUserValue = Object.keys(props?.value || {})?.length;
34
+ const isUserLockedSpacing = typeof elementProps[lockKeyVal] === "boolean";
35
+ const val = isUserValue ? props?.value : bannerSpacing;
36
+ let lockSpacing = isUserLockedSpacing ? elementProps[lockKeyVal] : lockbannerSpacing;
27
37
  if (lockSpacing === undefined) {
28
38
  lockSpacing = true;
29
39
  }
@@ -3,13 +3,13 @@ import { Grid, Typography, Slider, FormControlLabel, Checkbox, Box, IconButton }
3
3
  import { radiusStyle } from "./radiusStyle";
4
4
  import useWindowResize from "../../../hooks/useWindowResize";
5
5
  import { getBreakPointsValue, getCustomizationValue } from "../../../helper/theme";
6
+ import { useEditorTheme } from "../../../hooks/useEditorTheme";
6
7
  import { CheckedBoxCheckIcon } from "../../iconListV2";
7
8
  import { jsx as _jsx } from "react/jsx-runtime";
8
9
  import { jsxs as _jsxs } from "react/jsx-runtime";
9
10
  const BORDER_RADIUS_KEYS = ["topLeft", "topRight", "bottomLeft", "bottomRight"];
10
11
  const BorderRadius = props => {
11
12
  const {
12
- value: val,
13
13
  data,
14
14
  onChange,
15
15
  elementProps,
@@ -19,16 +19,24 @@ const BorderRadius = props => {
19
19
  const {
20
20
  translation
21
21
  } = customProps;
22
- let {
23
- lockRadius
24
- } = elementProps;
25
- if (lockRadius === undefined) {
26
- lockRadius = true;
27
- }
28
22
  const {
29
23
  key
30
24
  } = data;
31
25
  const [size] = useWindowResize();
26
+ const {
27
+ selectedTheme
28
+ } = useEditorTheme();
29
+ const {
30
+ borderRadius,
31
+ lockRadius: themeLockRadius
32
+ } = selectedTheme?.elementProps[elementProps?.type] || {};
33
+ const isUserValue = Object.keys(props?.value || {})?.length;
34
+ const isUserLockedRadius = typeof elementProps?.lockRadius === "boolean";
35
+ const val = isUserValue ? props?.value : borderRadius;
36
+ let lockRadius = isUserLockedRadius ? elementProps?.lockRadius : themeLockRadius;
37
+ if (lockRadius === undefined) {
38
+ lockRadius = true;
39
+ }
32
40
  const value = getBreakPointsValue(val, size?.device);
33
41
  const handleChange = e => {
34
42
  let changeAll = {};
@@ -1,14 +1,23 @@
1
- import React, { useEffect, useState } from "react";
1
+ import React, { useEffect, useMemo, useState } from "react";
2
2
  import { Grid, TextField, InputAdornment, Typography, Tooltip } from "@mui/material";
3
3
  import ColorPickerButton from "../../ColorPickerButton";
4
+ import { getVariableValue } from "../../../helper/theme";
5
+ import { useButtonStyle } from "../../../hooks/useThemeValues";
6
+
7
+ // const MAP_STYLE_PROPS = {
8
+ // bgColor: "background-color",
9
+ // textColor: "color",
10
+ // };
4
11
  import { jsx as _jsx } from "react/jsx-runtime";
5
12
  import { jsxs as _jsxs } from "react/jsx-runtime";
6
13
  const Color = props => {
7
14
  const {
8
- value,
15
+ value: val,
9
16
  data,
10
17
  onChange,
11
18
  classes,
19
+ elementProps,
20
+ handleClose,
12
21
  customProps
13
22
  } = props;
14
23
  const {
@@ -20,7 +29,22 @@ const Color = props => {
20
29
  translation
21
30
  } = customProps;
22
31
  const [recentColors, setRecentColors] = useState({});
23
- const getLable = label === 'Text' ? translation("selectTextColor") : label === 'Background' ? translation("selectBgColor") : translation(label);
32
+ const {
33
+ buttonStyle
34
+ } = useButtonStyle(val, key, elementProps);
35
+ const newValue = buttonStyle?.color;
36
+ const {
37
+ value,
38
+ inputValue
39
+ } = useMemo(() => {
40
+ const isVariable = newValue && newValue.startsWith("var");
41
+ const inputValue = isVariable ? getVariableValue(newValue) : newValue;
42
+ return {
43
+ value: newValue,
44
+ inputValue: inputValue
45
+ };
46
+ }, [buttonStyle?.color]);
47
+ const getLable = label === "Text" ? translation("selectTextColor") : label === "Background" ? translation("selectBgColor") : translation(label);
24
48
  useEffect(() => {
25
49
  const storedColors = JSON.parse(localStorage.getItem("recentColors"));
26
50
  if (storedColors) {
@@ -58,11 +82,11 @@ const Color = props => {
58
82
  fontSize: "14px",
59
83
  fontWeight: 500,
60
84
  marginBottom: "5px",
61
- display: 'flex',
62
- alignItems: 'center',
63
- '& svg': {
64
- width: '20px',
65
- height: '20px'
85
+ display: "flex",
86
+ alignItems: "center",
87
+ "& svg": {
88
+ width: "20px",
89
+ height: "20px"
66
90
  }
67
91
  },
68
92
  children: [translation(label), data?.infoIcon ? /*#__PURE__*/_jsx(Tooltip, {
@@ -70,14 +94,14 @@ const Color = props => {
70
94
  title: translation("noteText"),
71
95
  children: /*#__PURE__*/_jsx("span", {
72
96
  style: {
73
- display: 'inline-block'
97
+ display: "inline-block"
74
98
  },
75
99
  children: data?.infoIcon
76
100
  })
77
101
  }) : null]
78
102
  }), /*#__PURE__*/_jsx(TextField, {
79
103
  fullWidth: true,
80
- value: value,
104
+ value: inputValue,
81
105
  placeholder: getLable || `${label} ${translation("color code")}`,
82
106
  InputLabelProps: {
83
107
  shrink: true
@@ -90,6 +114,8 @@ const Color = props => {
90
114
  value: value,
91
115
  onSave: onSave,
92
116
  recentColors: recentColors[key],
117
+ handleClose: handleClose,
118
+ disableEditTheme: customProps?.disableEditTheme,
93
119
  hideGradient: hideGradient
94
120
  })
95
121
  })
@@ -1,14 +1,17 @@
1
- import React from "react";
1
+ import React, { useMemo } from "react";
2
2
  import { TextField, IconButton, Grid, Typography } from "@mui/material";
3
3
  import { sizeMap } from "../../../utils/font.js";
4
4
  import { TextMinusIcon, TextPlusIcon } from "../../../common/iconslist.js";
5
+ import { getElementStyle } from "../../../helper/theme.js";
6
+ import { useSlateStatic } from "slate-react";
5
7
  import { jsx as _jsx } from "react/jsx-runtime";
6
8
  import { jsxs as _jsxs } from "react/jsx-runtime";
7
9
  const FontSize = props => {
8
10
  const {
9
- value,
11
+ value: val,
10
12
  data,
11
13
  onChange,
14
+ elementProps,
12
15
  customProps
13
16
  } = props;
14
17
  const {
@@ -18,6 +21,10 @@ const FontSize = props => {
18
21
  key,
19
22
  width
20
23
  } = data;
24
+ const editor = useSlateStatic();
25
+ const value = useMemo(() => {
26
+ return val || getElementStyle(editor, elementProps, "font-size");
27
+ }, [editor, val]);
21
28
  const handleChange = e => {
22
29
  let inc = parseInt(e.target.value) || 16;
23
30
  inc = inc > 200 ? 200 : inc;
@@ -28,7 +35,9 @@ const FontSize = props => {
28
35
  const getSizeVal = () => {
29
36
  try {
30
37
  const size = `${value}`?.indexOf("px") >= 0 ? value : sizeMap[value] || value;
31
- return parseInt(size || 16);
38
+ const defaultSize = 16;
39
+ const val = parseInt(size || defaultSize);
40
+ return isNaN(val) ? defaultSize : val;
32
41
  } catch (err) {
33
42
  return "";
34
43
  }
@@ -77,7 +86,7 @@ const FontSize = props => {
77
86
  size: "small",
78
87
  inputProps: {
79
88
  style: {
80
- // textAlign: "center",
89
+ // textAlign: "center",
81
90
  padding: "11px"
82
91
  }
83
92
  },
@@ -129,6 +129,7 @@ const MenusArray = props => {
129
129
  className: "menu-item-app-header",
130
130
  children: [/*#__PURE__*/_jsx(TextField, {
131
131
  name: "text",
132
+ placeholder: m?.placeholder || "text",
132
133
  type: "text",
133
134
  value: m.text,
134
135
  onChange: handleChange(i),
@@ -140,6 +141,7 @@ const MenusArray = props => {
140
141
  }), /*#__PURE__*/_jsx(TextField, {
141
142
  name: "url",
142
143
  type: "text",
144
+ placeholder: m?.placeholder || "url",
143
145
  value: m.url,
144
146
  onChange: handleChange(i),
145
147
  size: "small",
@@ -1,4 +1,4 @@
1
- import React, { useState } from "react";
1
+ import React, { useEffect, useState } from "react";
2
2
  import { Grid, TextField, Typography } from "@mui/material";
3
3
  import { jsx as _jsx } from "react/jsx-runtime";
4
4
  import { jsxs as _jsxs } from "react/jsx-runtime";
@@ -20,6 +20,17 @@ const Text = props => {
20
20
  } = data;
21
21
  const [value, setValue] = useState(pro_value);
22
22
  const [error, setError] = useState(false);
23
+ useEffect(() => {
24
+ if (["sectionBackgroundImage", "pageBgImage"].includes(key)) {
25
+ let bgUrl = "";
26
+ if (typeof props?.value === "string" && props?.value !== "none") {
27
+ bgUrl = props.value;
28
+ } else if (props?.value?.embedURL) {
29
+ bgUrl = props.value.embedURL;
30
+ }
31
+ setValue(bgUrl);
32
+ }
33
+ }, [props?.value]);
23
34
  const handleChange = e => {
24
35
  const newValue = e.target.value;
25
36
  setValue(newValue);
@@ -55,10 +66,10 @@ const Text = props => {
55
66
  fullWidth: true,
56
67
  required: required,
57
68
  error: error,
58
- helperText: error ? translation("This field is required") : '',
69
+ helperText: error ? translation("This field is required") : "",
59
70
  sx: {
60
- '& .MuiFormHelperText-root': {
61
- color: '#d32f2f !important'
71
+ "& .MuiFormHelperText-root": {
72
+ color: "#d32f2f !important"
62
73
  }
63
74
  }
64
75
  })]
@@ -1,13 +1,13 @@
1
- import React from "react";
1
+ import React, { useMemo } from "react";
2
2
  import { FormControl, Grid, ListItemIcon, ListSubheader, MenuItem, Select, Typography } from "@mui/material";
3
- import { getBreakPointsValue } from "../../../helper/theme";
3
+ import { getBreakPointsValue, getElementStyle } from "../../../helper/theme";
4
4
  import useWindowResize from "../../../hooks/useWindowResize";
5
5
  import { useEditorContext } from "../../../hooks/useMouseMove";
6
6
  import FontFamilyAutocomplete from "../../../Toolbar/FormatTools/FontFamilyAutocomplete";
7
7
  import { useSlate } from "slate-react";
8
8
  import KeyboardArrowDownRoundedIcon from "@mui/icons-material/KeyboardArrowDownRounded";
9
9
 
10
- // hideMetaDataOptions -- pass true to hide metadata option in select field
10
+ // hideMetaDataOptions -- pass true to hide metadata option in select field
11
11
  import { jsx as _jsx } from "react/jsx-runtime";
12
12
  import { jsxs as _jsxs } from "react/jsx-runtime";
13
13
  import { Fragment as _Fragment } from "react/jsx-runtime";
@@ -31,14 +31,22 @@ const TextOptions = props => {
31
31
  renderOption,
32
32
  width,
33
33
  webFont = false,
34
- hideMetaDataOptions = false
34
+ hideMetaDataOptions = false,
35
+ themeEnabled
35
36
  } = data;
36
37
  const {
37
38
  fontFamilies
38
39
  } = useEditorContext();
39
- const editor = useSlate();
40
40
  const [size] = useWindowResize();
41
- const value = isBreakpoint ? getBreakPointsValue(val, size?.device) : val;
41
+ const editor = useSlate();
42
+ const value = useMemo(() => {
43
+ const userValue = isBreakpoint ? getBreakPointsValue(val, size?.device) : val;
44
+ if (themeEnabled) {
45
+ // editor takes a little amount of time to update the new style in element, in that case userValue will be returned
46
+ return getElementStyle(editor, elementProps, key) || userValue;
47
+ }
48
+ return userValue;
49
+ }, [editor, isBreakpoint, val, size?.device]);
42
50
  const metaDataMappingOptions = metaMappings?.boards || [];
43
51
  const updatedOption = !hideMetaDataOptions && elementProps?.metadatamapping ? [...options, ...metaDataMappingOptions] : webFont ? fontFamilies?.options : options;
44
52
  const handleChange = (e, d) => {
@@ -117,7 +125,7 @@ const TextOptions = props => {
117
125
  editor: editor,
118
126
  format: key,
119
127
  options: fontFamilies.options,
120
- width: '100%',
128
+ width: "100%",
121
129
  onChange: onChange,
122
130
  val: value,
123
131
  webFont: true
@@ -124,19 +124,25 @@ export const formStyle = [{
124
124
  key: "alignment",
125
125
  type: "alignment"
126
126
  }]
127
- }, {
128
- tab: "Background",
129
- value: "backgroundImage",
130
- fields: [{
131
- label: "URL",
132
- key: "backgroundImage",
133
- type: "text"
134
- }, {
135
- label: "Background Image",
136
- key: "backgroundImage",
137
- type: "backgroundImage"
138
- }]
139
- }, {
127
+ },
128
+ // Commented out because the background functionality for forms has not been implemented yet
129
+ // {
130
+ // tab: "Background",
131
+ // value: "backgroundImage",
132
+ // fields: [
133
+ // {
134
+ // label: "URL",
135
+ // key: "backgroundImage",
136
+ // type: "text",
137
+ // },
138
+ // {
139
+ // label: "Background Image",
140
+ // key: "backgroundImage",
141
+ // type: "backgroundImage",
142
+ // },
143
+ // ],
144
+ // },
145
+ {
140
146
  tab: "Add to Boards",
141
147
  value: "metadatamapping",
142
148
  fields: [{
@@ -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 { Grid, Button, Typography } from "@mui/material";
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 { allowedFormat, 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,88 @@ 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 [uploading, setUploading] = useState(false);
27
+ const {
28
+ uploadFile,
29
+ services,
30
+ uploadTerminator
31
+ } = customProps;
32
+ const [uploadStatus, setUploadStatus] = useState({
33
+ isUploading: false,
34
+ uploadPercentage: 0
35
+ });
36
+ const [error, setError] = useState(null);
37
+ const xhrRef = useRef(null);
21
38
  const handleChange = async e => {
39
+ setError("");
22
40
  const uFile = e.target.files[0];
23
- const strImage = await convertBase64(uFile);
24
- setBase64(strImage);
25
- setFileName(uFile?.name);
26
- doUpload(strImage, e.target.files[0]);
41
+ if (!uFile) return;
42
+ const maxAllowedSize = 5 * 1024 * 1024;
43
+
44
+ // ✅ Check file size
45
+ if (uFile.size > maxAllowedSize) {
46
+ const sizeInMB = Math.round(maxAllowedSize / (1024 * 1024));
47
+ setError(`File size exceeds ${sizeInMB}MB for ${uFile.name.toLowerCase()}.`);
48
+ return;
49
+ }
50
+
51
+ // ✅ File type check with fallback to extension
52
+ const validTypes = allowedTypes["Image"];
53
+ const fileType = uFile.type;
54
+ const fileName = uFile.name.toLowerCase();
55
+ const fileExtension = fileName.split(".").pop();
56
+ const isValid = title === "Embed" || validTypes.includes(fileType) || extensionMap["Image"]?.includes(fileExtension);
57
+ if (!isValid) {
58
+ setError(`Invalid file format. Please upload a valid ${title.toLowerCase()}.`);
59
+ return;
60
+ }
61
+ try {
62
+ const strImage = await convertBase64(uFile);
63
+ setBase64(strImage);
64
+ setFileName(uFile?.name);
65
+ doUpload(strImage, e.target.files[0]);
66
+ } catch (error) {
67
+ setError("Failed to read file.");
68
+ }
69
+ };
70
+ const onSave = url => {
71
+ if (!uploadStatus?.isUploading) {
72
+ setS3UploadProp({
73
+ file: true
74
+ });
75
+ }
76
+ onUploaded(url);
27
77
  };
28
78
  const doUpload = async (strImage, file) => {
29
- setUploading(true);
30
79
  const formData = new FormData();
31
80
  formData.set("file", file);
32
81
  formData.set("resource_type", "pages");
33
82
  formData.set("resource_id", customProps?.page_id);
34
- const result = await uploadFile(formData, customProps);
35
- setUploading(false);
36
- if (result && result?.imageURL) {
37
- onUploaded(result?.imageURL[0]);
83
+ const id = crypto?.randomUUID();
84
+ setUniqueId(id);
85
+ const result = await services("uploadFile", file);
86
+ if (result?.data?.[0]) {
87
+ const fileEntry = {
88
+ file: file,
89
+ xhrRef,
90
+ presidnedURL: result.data?.[0],
91
+ status: "uploading"
92
+ };
93
+ uploadFile(id, fileEntry, setUploadStatus, onSave, "image");
38
94
  }
39
95
  };
40
96
  const {
41
97
  translation
42
98
  } = customProps;
43
99
  const onRemoveBG = () => {
100
+ uploadTerminator(uniqueId, setUploadStatus);
44
101
  setBase64(null);
45
102
  onUploaded("none");
46
103
  };
@@ -82,11 +139,54 @@ const Uploader = props => {
82
139
  });
83
140
  }
84
141
  };
142
+ const UploadingProgress = () => {
143
+ return /*#__PURE__*/_jsx(Grid, {
144
+ container: true,
145
+ direction: "row",
146
+ justifyContent: "space-between",
147
+ alignItems: "center",
148
+ children: /*#__PURE__*/_jsx(Box, {
149
+ display: "flex",
150
+ flexDirection: "column",
151
+ alignItems: "flex-start",
152
+ justifyContent: "space-between",
153
+ sx: {
154
+ gap: 1,
155
+ mb: 1,
156
+ mt: 1
157
+ },
158
+ children: /*#__PURE__*/_jsxs(Box, {
159
+ display: "flex",
160
+ alignItems: "center",
161
+ gap: 1,
162
+ children: [/*#__PURE__*/_jsx(Typography, {
163
+ variant: "body",
164
+ children: `Uploading ${uploadStatus?.fileSize}`
165
+ }), /*#__PURE__*/_jsx(CircularProgress, {
166
+ variant: "determinate",
167
+ value: uploadStatus?.uploadPercentage ?? 0,
168
+ className: "circularProgress-cls",
169
+ size: 15,
170
+ thickness: 8
171
+ }), /*#__PURE__*/_jsx(Typography, {
172
+ variant: "body",
173
+ children: `${uploadStatus?.uploadPercentage?.toFixed(0) ?? 0}%`
174
+ })]
175
+ })
176
+ })
177
+ });
178
+ };
85
179
  return /*#__PURE__*/_jsxs(_Fragment, {
86
- children: [/*#__PURE__*/_jsx(Grid, {
180
+ children: [/*#__PURE__*/_jsxs(Grid, {
87
181
  item: true,
88
182
  xs: 12,
89
- children: uploading ? translation("uploadingText") : ""
183
+ children: [!error && uploadStatus?.isUploading ? /*#__PURE__*/_jsx(UploadingProgress, {}) : "", error && /*#__PURE__*/_jsx(Typography, {
184
+ style: {
185
+ color: "red",
186
+ marginBottom: "8px"
187
+ },
188
+ children: error
189
+ })]
90
190
  }), /*#__PURE__*/_jsx(Grid, {
91
191
  container: true,
92
192
  sx: classes.uploadContainer,
@@ -98,7 +198,7 @@ const Uploader = props => {
98
198
  ...getBackground()
99
199
  },
100
200
  sx: classes.uploadField,
101
- children: !uploading ? /*#__PURE__*/_jsx(Grid, {
201
+ children: !uploadStatus?.isUploading ? /*#__PURE__*/_jsx(Grid, {
102
202
  className: "uploadImageSection",
103
203
  children: base64 ? renderThumb() : /*#__PURE__*/_jsx(Grid, {
104
204
  className: "uploadImageText",
@@ -112,6 +212,7 @@ const Uploader = props => {
112
212
  sx: classes.uploadIcon,
113
213
  children: [/*#__PURE__*/_jsx("input", {
114
214
  type: "file",
215
+ accept: allowedFormat["Image"],
115
216
  style: {
116
217
  opacity: 0,
117
218
  width: "0px"