@flozy/editor 5.7.7 → 5.7.8

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 (38) hide show
  1. package/dist/Editor/CommonEditor.js +6 -4
  2. package/dist/Editor/Editor.css +14 -15
  3. package/dist/Editor/Elements/AI/PopoverAIInput.js +2 -12
  4. package/dist/Editor/Elements/Button/EditorButton.js +2 -1
  5. package/dist/Editor/Elements/DataView/DataView.js +4 -3
  6. package/dist/Editor/Elements/DataView/Layouts/DataTypes/NumberType.js +5 -1
  7. package/dist/Editor/Elements/DataView/Layouts/DataTypes/TextType.js +5 -1
  8. package/dist/Editor/Elements/DataView/Layouts/FilterView.js +23 -19
  9. package/dist/Editor/Elements/Divider/Divider.js +3 -3
  10. package/dist/Editor/Elements/Search/SearchList.js +8 -1
  11. package/dist/Editor/Elements/SimpleText/style.js +2 -2
  12. package/dist/Editor/Elements/Title/title.js +13 -1
  13. package/dist/Editor/Elements/Variables/Style.js +20 -2
  14. package/dist/Editor/Elements/Variables/VariableButton.js +7 -3
  15. package/dist/Editor/Toolbar/PopupTool/AddTemplates.js +24 -25
  16. package/dist/Editor/Toolbar/PopupTool/MiniTextFormat/SelectAlignment.js +3 -1
  17. package/dist/Editor/Toolbar/PopupTool/MiniTextFormat/SelectFontSize.js +1 -1
  18. package/dist/Editor/Toolbar/PopupTool/MiniTextFormat/SelectList.js +3 -1
  19. package/dist/Editor/Toolbar/PopupTool/MiniTextFormat/SelectTypography.js +1 -1
  20. package/dist/Editor/Toolbar/PopupTool/MiniTextFormat/index.js +9 -3
  21. package/dist/Editor/Toolbar/PopupTool/PopupToolStyle.js +5 -0
  22. package/dist/Editor/Toolbar/PopupTool/index.js +2 -0
  23. package/dist/Editor/common/FontLoader/FontList.js +3 -11
  24. package/dist/Editor/common/FontLoader/FontLoader.js +33 -7
  25. package/dist/Editor/common/RnD/ElementSettings/Settings/FormSettings.js +1 -0
  26. package/dist/Editor/common/RnD/SwitchViewport/SwitchViewport.js +8 -2
  27. package/dist/Editor/common/Section/styles.js +15 -0
  28. package/dist/Editor/common/StyleBuilder/fieldTypes/backgroundImage.js +5 -0
  29. package/dist/Editor/common/StyleBuilder/fieldTypes/card.js +10 -2
  30. package/dist/Editor/common/Uploader.js +8 -0
  31. package/dist/Editor/commonStyle.js +13 -12
  32. package/dist/Editor/helper/index.js +2 -2
  33. package/dist/Editor/plugins/withLayout.js +1 -1
  34. package/dist/Editor/utils/SlateUtilityFunctions.js +2 -3
  35. package/dist/Editor/utils/button.js +4 -4
  36. package/dist/Editor/utils/draftToSlate.js +3 -2
  37. package/dist/Editor/utils/helper.js +60 -19
  38. package/package.json +1 -1
@@ -96,7 +96,8 @@ const CommonEditor = /*#__PURE__*/forwardRef((props, ref) => {
96
96
  const editorWrapper = useRef();
97
97
  const mentionsRef = useRef();
98
98
  const convertedContent = draftToSlate({
99
- data: content
99
+ data: content,
100
+ needLayout: otherProps?.needLayout
100
101
  });
101
102
  const [value, setValue] = useState(convertedContent);
102
103
  const [isInteracted, setIsInteracted] = useState(false);
@@ -167,11 +168,11 @@ const CommonEditor = /*#__PURE__*/forwardRef((props, ref) => {
167
168
  const debounced = useDebouncedCallback(
168
169
  // function
169
170
  value => {
171
+ debouncedValue.current = value;
170
172
  const {
171
173
  value: strVal,
172
174
  ...restVal
173
175
  } = getOnSaveData(value);
174
- debouncedValue.current = value;
175
176
  onSave(strVal, restVal);
176
177
  },
177
178
  // delay in ms
@@ -182,7 +183,7 @@ const CommonEditor = /*#__PURE__*/forwardRef((props, ref) => {
182
183
  return {
183
184
  value: JSON.stringify(val),
184
185
  text: text,
185
- title: serializeToText(title?.children) || "Untitled"
186
+ title: serializeToText(title?.children) || ""
186
187
  };
187
188
  };
188
189
  const getPreviewImage = async (needBackground = false, options = {}) => {
@@ -596,8 +597,9 @@ const CommonEditor = /*#__PURE__*/forwardRef((props, ref) => {
596
597
  setIsTextSelected: setIsTextSelected,
597
598
  customProps: customProps,
598
599
  editorWrapper: editorWrapper
599
- }) : null, !readOnly && showViewport ? /*#__PURE__*/_jsx(SwitchViewport, {
600
+ }) : null, !readOnly ? /*#__PURE__*/_jsx(SwitchViewport, {
600
601
  breakpoint: breakpoint,
602
+ show: showViewport,
601
603
  onChange: b => onSwitchBreakpoint(b)
602
604
  }) : null]
603
605
  })
@@ -1258,11 +1258,24 @@ blockquote {
1258
1258
  }
1259
1259
 
1260
1260
  .dividerComponent:hover .divider-settings,
1261
- .dividerComponent:hover .element-selector {
1261
+ .dividerComponent:hover .sectionIcon button {
1262
1262
  display: block;
1263
1263
  pointer-events: auto;
1264
1264
  }
1265
1265
 
1266
+ @media (max-width: 899px) {
1267
+ .MuiPopover-root {
1268
+ z-index: 1302 !important;
1269
+ }
1270
+ canvas {
1271
+ max-width: 100% !important;
1272
+ }
1273
+ }
1274
+
1275
+ .settingsHeader {
1276
+ font-size: 14px !important;
1277
+ font-weight: 500 !important;
1278
+ }
1266
1279
  .hideScroll {
1267
1280
  overflow-anchor: none;
1268
1281
  }
@@ -1278,20 +1291,6 @@ blockquote {
1278
1291
  .hideScroll::-webkit-scrollbar-thumb:hover {
1279
1292
  background: none !important;
1280
1293
  }
1281
- @media (max-width: 899px) {
1282
- .MuiPopover-root {
1283
- z-index: 1302 !important;
1284
- }
1285
-
1286
- canvas {
1287
- max-width: 100% !important;
1288
- }
1289
- }
1290
-
1291
- .settingsHeader {
1292
- font-size: 14px !important;
1293
- font-weight: 500 !important;
1294
- }
1295
1294
 
1296
1295
  .custom-scroll::-webkit-scrollbar {
1297
1296
  height: .6rem;
@@ -6,7 +6,7 @@ import AIInput from "./AIInput";
6
6
  import { ReactEditor, useSlate } from "slate-react";
7
7
  import { Node, Range, Transforms } from "slate";
8
8
  import { MODES } from "./helper";
9
- import { getSelectedText, getSlateDom } from "../../utils/helper";
9
+ import { getSelectedText, getSlateDom, viewSlateSelection } from "../../utils/helper";
10
10
  import { VoiceToText } from "./VoiceToText";
11
11
  import deserialize from "../../helper/deserialize";
12
12
  import useEditorScroll from "../../hooks/useEditorScroll";
@@ -286,17 +286,7 @@ function PopoverAIInput({
286
286
  };
287
287
  useEffect(() => {
288
288
  if (openAI && getSelectedText(editor).trim()) {
289
- const customSelection = document.querySelectorAll(".slate-highlight");
290
- const selectionBg = "rgba(35, 131, 226, 0.35)";
291
- if (customSelection?.length) {
292
- customSelection?.forEach(el => el.style.background = selectionBg);
293
-
294
- // if ai is opened, remove the window selection class and open then slate selection, To resolve: focussing on the ai input removes window selection automatically
295
- const selection = window.getSelection();
296
- if (selection) {
297
- selection.removeAllRanges(); // Clears the selection
298
- }
299
- }
289
+ viewSlateSelection();
300
290
  }
301
291
  }, [editor.selection, openAI]);
302
292
  return /*#__PURE__*/_jsxs("div", {
@@ -162,6 +162,7 @@ const EditorButton = props => {
162
162
  display: "inline-flex",
163
163
  color: "rgba(0, 0, 0, 0.54)",
164
164
  marginBottom: "0px !important",
165
+ ...classes.buttonMoreOption,
165
166
  ...classes.buttonMoreOption3
166
167
  },
167
168
  ...btnProps,
@@ -264,7 +265,7 @@ const EditorButton = props => {
264
265
  ...btnSp,
265
266
  borderStyle: borderStyle || "solid",
266
267
  color: `${textColor || "#FFFFFF"}`,
267
- fontSize: textSize || "inherit",
268
+ fontSize: textSize || "12px",
268
269
  fontFamily: fontFamily || "PoppinsRegular",
269
270
  display: "inline-flex",
270
271
  alignItems: "center",
@@ -1,6 +1,6 @@
1
1
  import React from "react";
2
2
  import { Node, Path, Transforms } from "slate";
3
- import { ReactEditor, useSlateStatic } from "slate-react";
3
+ import { ReactEditor, useSlate } from "slate-react";
4
4
  import { Box, useTheme } from "@mui/material";
5
5
  import { DataViewProvider } from "./Providers/DataViewProvider";
6
6
  import useDataViewStyles from "./styles";
@@ -15,7 +15,7 @@ const DataView = props => {
15
15
  theme: appTheme
16
16
  } = useEditorContext();
17
17
  const theme = useTheme();
18
- const editor = useSlateStatic();
18
+ const editor = useSlate();
19
19
  const {
20
20
  attributes,
21
21
  children,
@@ -113,7 +113,8 @@ const DataView = props => {
113
113
  onDuplicate: onDuplicate,
114
114
  readOnly: readOnly,
115
115
  title: title,
116
- onTitleChange: onTitleChange
116
+ onTitleChange: onTitleChange,
117
+ path: path
117
118
  }), /*#__PURE__*/_jsx(LayoutView, {
118
119
  readOnly: readOnly,
119
120
  children: children
@@ -1,6 +1,7 @@
1
1
  import React from "react";
2
2
  import { TextField } from "@mui/material";
3
3
  import { useDataView } from "../../Providers/DataViewProvider";
4
+ import { focusDynamicTableInput } from "../../../../utils/helper";
4
5
  import { jsx as _jsx } from "react/jsx-runtime";
5
6
  const NumberType = props => {
6
7
  const {
@@ -16,6 +17,7 @@ const NumberType = props => {
16
17
  onChange(rowIndex, {
17
18
  [property]: e?.target?.value
18
19
  });
20
+ focusDynamicTableInput(e);
19
21
  };
20
22
  return /*#__PURE__*/_jsx(TextField, {
21
23
  type: "number",
@@ -24,7 +26,9 @@ const NumberType = props => {
24
26
  value: value,
25
27
  size: "small",
26
28
  onChange: handleChange,
27
- disabled: readOnly
29
+ disabled: readOnly,
30
+ id: `tv-number-input-${rowIndex}-${property}` // * should be unique
28
31
  });
29
32
  };
33
+
30
34
  export default NumberType;
@@ -1,6 +1,7 @@
1
1
  import React from "react";
2
2
  import { TextField } from "@mui/material";
3
3
  import { useDataView } from "../../Providers/DataViewProvider";
4
+ import { focusDynamicTableInput } from "../../../../utils/helper";
4
5
  import { jsx as _jsx } from "react/jsx-runtime";
5
6
  const TextType = props => {
6
7
  const {
@@ -16,6 +17,7 @@ const TextType = props => {
16
17
  onChange(rowIndex, {
17
18
  [property]: e?.target?.value
18
19
  });
20
+ focusDynamicTableInput(e);
19
21
  };
20
22
  const formatValue = () => {
21
23
  if (typeof value === "string") {
@@ -30,7 +32,9 @@ const TextType = props => {
30
32
  value: formatValue(value),
31
33
  size: "small",
32
34
  onChange: handleChange,
33
- disabled: readOnly
35
+ disabled: readOnly,
36
+ id: `tv-text-input-${rowIndex}-${property}` // * should be unique
34
37
  });
35
38
  };
39
+
36
40
  export default TextType;
@@ -5,6 +5,7 @@ import FilterSort from "./FilterSort";
5
5
  import MoreHorizIcon from "@mui/icons-material/MoreHoriz";
6
6
  import Icon from "../../../common/Icon";
7
7
  import { useEditorContext } from "../../../hooks/useMouseMove";
8
+ import { focusDynamicTableInput } from "../../../utils/helper";
8
9
  import { jsx as _jsx } from "react/jsx-runtime";
9
10
  import { jsxs as _jsxs } from "react/jsx-runtime";
10
11
  const FilterView = props => {
@@ -15,7 +16,8 @@ const FilterView = props => {
15
16
  onEnter,
16
17
  readOnly,
17
18
  title,
18
- onTitleChange
19
+ onTitleChange,
20
+ path
19
21
  } = props;
20
22
  const {
21
23
  sort,
@@ -70,6 +72,7 @@ const FilterView = props => {
70
72
  };
71
73
  const handleTitleChange = e => {
72
74
  onTitleChange(e?.target?.value);
75
+ focusDynamicTableInput(e);
73
76
  };
74
77
  const handleEnter = e => {
75
78
  if (e?.key === "Enter") {
@@ -96,24 +99,25 @@ const FilterView = props => {
96
99
  },
97
100
  value: title,
98
101
  onChange: handleTitleChange,
99
- onKeyUp: handleEnter
102
+ onKeyUp: handleEnter,
103
+ id: `tv-title-input-${path.join("|")}`
100
104
  }) : title || "Untitled"
101
105
  }), /*#__PURE__*/_jsxs(Box, {
102
106
  className: "tv-fi-wrpr",
103
107
  sx: {
104
- alignItems: 'center'
108
+ alignItems: "center"
105
109
  },
106
110
  children: [/*#__PURE__*/_jsxs(Box, {
107
111
  className: `tv-sb mr ${toggle ? "open" : ""}`,
108
112
  sx: {
109
- minHeight: '32px'
113
+ minHeight: "32px"
110
114
  },
111
115
  children: [/*#__PURE__*/_jsx(IconButton, {
112
116
  type: "button",
113
117
  sx: {
114
- '& svg': {
115
- width: '14px',
116
- height: '14px'
118
+ "& svg": {
119
+ width: "14px",
120
+ height: "14px"
117
121
  }
118
122
  },
119
123
  "aria-label": "search",
@@ -137,12 +141,12 @@ const FilterView = props => {
137
141
  className: ` ${sort?.length > 0 ? "active" : ""}`,
138
142
  onClick: handleSortClick,
139
143
  sx: {
140
- '& svg': {
144
+ "& svg": {
141
145
  strokeWidth: 1.2
142
146
  }
143
147
  },
144
148
  children: /*#__PURE__*/_jsx(Icon, {
145
- icon: 'sortBy'
149
+ icon: "sortBy"
146
150
  })
147
151
  }), /*#__PURE__*/_jsx(FilterSort, {
148
152
  open: open,
@@ -152,7 +156,7 @@ const FilterView = props => {
152
156
  }), !readOnly ? /*#__PURE__*/_jsx(IconButton, {
153
157
  className: "mr",
154
158
  sx: {
155
- '& svg': {
159
+ "& svg": {
156
160
  fill: theme?.palette?.editor?.tv_stroke
157
161
  }
158
162
  },
@@ -162,7 +166,7 @@ const FilterView = props => {
162
166
  className: "mr",
163
167
  onClick: handleDeleteRow,
164
168
  children: /*#__PURE__*/_jsx(Icon, {
165
- icon: 'trashIcon'
169
+ icon: "trashIcon"
166
170
  })
167
171
  }) : null, !readOnly ? /*#__PURE__*/_jsxs(Menu, {
168
172
  sx: classes.basicMenu,
@@ -185,24 +189,24 @@ const FilterView = props => {
185
189
  onClick: onMenuClick("Duplicate"),
186
190
  children: [" ", /*#__PURE__*/_jsx(Box, {
187
191
  sx: {
188
- marginRight: '5px',
189
- display: ' flex',
190
- alignItems: 'center'
192
+ marginRight: "5px",
193
+ display: " flex",
194
+ alignItems: "center"
191
195
  },
192
196
  children: /*#__PURE__*/_jsx(Icon, {
193
- icon: 'duplicateIcon'
197
+ icon: "duplicateIcon"
194
198
  })
195
199
  }), "Duplicate"]
196
200
  }), /*#__PURE__*/_jsxs(MenuItem, {
197
201
  onClick: onMenuClick("Delete"),
198
202
  children: [" ", /*#__PURE__*/_jsx(Box, {
199
203
  sx: {
200
- marginRight: '5px',
201
- display: ' flex',
202
- alignItems: 'center'
204
+ marginRight: "5px",
205
+ display: " flex",
206
+ alignItems: "center"
203
207
  },
204
208
  children: /*#__PURE__*/_jsx(Icon, {
205
- icon: 'trashIcon'
209
+ icon: "trashIcon"
206
210
  })
207
211
  }), "Delete"]
208
212
  })]
@@ -57,9 +57,9 @@ const Divider = props => {
57
57
  // : {};
58
58
  return /*#__PURE__*/_jsx("div", {
59
59
  contentEditable: false,
60
- className: "divider-settings",
60
+ className: "element-toolbar dividerIcon",
61
61
  style: {
62
- top: "-33px",
62
+ top: "3px",
63
63
  left: 0
64
64
  },
65
65
  children: /*#__PURE__*/_jsx(Tooltip, {
@@ -76,7 +76,7 @@ const Divider = props => {
76
76
  // theme?.palette?.type === "dark"
77
77
  // ? "1px solid #E4E8EB33"
78
78
  // : "none",
79
- boxShadow: "0px 0px 4px 0px #00000040",
79
+ boxShadow: "0px 0px 4px 0px #00000040 !important",
80
80
  borderRadius: "50%",
81
81
  "& svg": {
82
82
  width: '16px',
@@ -185,6 +185,9 @@ const SearchAndDocList = ({
185
185
  gap: 1,
186
186
  children: [/*#__PURE__*/_jsx(Grid, {
187
187
  item: true,
188
+ sx: {
189
+ maxWidth: 'calc(100% - 45px)'
190
+ },
188
191
  children: /*#__PURE__*/_jsxs(Grid, {
189
192
  container: true,
190
193
  alignItems: "center",
@@ -207,6 +210,9 @@ const SearchAndDocList = ({
207
210
  })
208
211
  }), /*#__PURE__*/_jsx(Grid, {
209
212
  item: true,
213
+ sx: {
214
+ maxWidth: '100%'
215
+ },
210
216
  children: /*#__PURE__*/_jsx(Typography, {
211
217
  sx: {
212
218
  fontSize: "12px",
@@ -219,7 +225,8 @@ const SearchAndDocList = ({
219
225
  maxWidth: '230px',
220
226
  textAlign: 'left',
221
227
  '@media only screen and (min-width: 350px) and (max-width: 899px)': {
222
- maxWidth: '100%'
228
+ maxWidth: '100%',
229
+ width: '100%'
223
230
  }
224
231
  },
225
232
  children: title
@@ -35,8 +35,8 @@ const SimpleTextStyle = ({
35
35
  height: "24px",
36
36
  overflow: "hidden",
37
37
  fontSize: "14px",
38
- display: 'inline-flex',
39
- alignItems: 'center',
38
+ display: "inline-flex",
39
+ alignItems: "center",
40
40
  "& .bg-pad-sl": {
41
41
  padding: "2px 4px 2px 4px",
42
42
  background: "transparent",
@@ -1,12 +1,24 @@
1
1
  import React from "react";
2
+ import { Text } from "slate";
2
3
  import { jsx as _jsx } from "react/jsx-runtime";
4
+ const isEmptyTextNode = node => {
5
+ if (Text.isText(node)) {
6
+ return !node.text.trim();
7
+ }
8
+ return false;
9
+ };
3
10
  const Title = props => {
4
11
  const {
12
+ element,
5
13
  attributes,
6
- children
14
+ children,
15
+ customProps
7
16
  } = props;
17
+ const isEmpty = !customProps?.readOnly && isEmptyTextNode(element?.children[0]) ? "empty" : "";
8
18
  return /*#__PURE__*/_jsx("div", {
9
19
  ...attributes,
20
+ placeholder: "Title",
21
+ className: `content-editable ${isEmpty}`,
10
22
  style: {
11
23
  fontWeight: "bold",
12
24
  fontSize: "20px"
@@ -1,4 +1,4 @@
1
- const VariableStyles = () => ({
1
+ const VariableStyles = theme => ({
2
2
  variablesItem: {
3
3
  color: "#2563EB",
4
4
  background: "#EEEEEE"
@@ -37,8 +37,26 @@ const VariableStyles = () => ({
37
37
  "& .MuiMenuItem-root": {
38
38
  color: "#64748B"
39
39
  },
40
+ "& .MuiPaper-root": {
41
+ borderRadius: '8px',
42
+ backgroundColor: `${theme?.palette?.editor?.miniToolBarBackground} !important`
43
+ },
44
+ "& .MuiList-root": {
45
+ padding: '0px'
46
+ },
47
+ "& .MuiButtonBase-root": {
48
+ margin: '6px',
49
+ borderRadius: '8px',
50
+ padding: '6px 14px',
51
+ fontSize: '14px',
52
+ fontWeight: '400',
53
+ color: theme?.palette?.editor?.deletePopUpButtonTextColor,
54
+ "&:hover": {
55
+ background: `${theme?.palette?.editor?.menuOptionHoverBackground} !important`
56
+ }
57
+ },
40
58
  "& .Mui-selected": {
41
- backgroundColor: "rgba(0, 0, 0, 0.04) !important"
59
+ backgroundColor: 'unset !important'
42
60
  }
43
61
  }
44
62
  });
@@ -3,11 +3,15 @@ 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 KeyboardArrowDownIcon from "@mui/icons-material/KeyboardArrowDown";
6
+ import KeyboardArrowDownRoundedIcon from '@mui/icons-material/KeyboardArrowDownRounded';
7
+ import { useEditorContext } from "../../hooks/useMouseMove";
7
8
  import { jsx as _jsx } from "react/jsx-runtime";
8
9
  import { jsxs as _jsxs } from "react/jsx-runtime";
9
10
  const VariableButton = props => {
10
- const classes = VariableStyles();
11
+ const {
12
+ theme
13
+ } = useEditorContext();
14
+ const classes = VariableStyles(theme);
11
15
  const editor = useSlateStatic();
12
16
  const {
13
17
  options
@@ -24,7 +28,7 @@ const VariableButton = props => {
24
28
  value: "",
25
29
  sx: classes.variableBtn,
26
30
  onChange: updateVariable,
27
- IconComponent: () => /*#__PURE__*/_jsx(KeyboardArrowDownIcon, {}),
31
+ IconComponent: () => /*#__PURE__*/_jsx(KeyboardArrowDownRoundedIcon, {}),
28
32
  MenuProps: {
29
33
  sx: classes.variableMenuItem,
30
34
  PaperProps: {
@@ -4,6 +4,7 @@ import TemplateCard from "./TemplateCard";
4
4
  import FullViewCard from "./FullViewCard";
5
5
  import ButtonTemplateCard from "./ButtonTemplatesCard";
6
6
  import { jsx as _jsx } from "react/jsx-runtime";
7
+ import { Fragment as _Fragment } from "react/jsx-runtime";
7
8
  import { jsxs as _jsxs } from "react/jsx-runtime";
8
9
  const CATEGORIES_SORT_INDEX = {
9
10
  Brief: 1,
@@ -46,7 +47,7 @@ const ProgressBar = ({
46
47
  alignItems: "center",
47
48
  margin: 0,
48
49
  padding: 0,
49
- height: "50px",
50
+ height: "300px",
50
51
  overflow: "hidden"
51
52
  },
52
53
  children: /*#__PURE__*/_jsx(CircularProgress, {})
@@ -69,34 +70,32 @@ const AddTemplates = props => {
69
70
  const [categories, setCategories] = useState([]);
70
71
  const [category, setCategory] = useState("");
71
72
  const [templates, setTemplates] = useState([]);
72
- const [filteredTemplates, setFilteredTemplates] = useState([]);
73
73
  useEffect(() => {
74
- getTemplatesList();
74
+ getCategoryList();
75
75
  }, []);
76
- const sortCategory = (a, b) => {
77
- return (CATEGORIES_SORT_INDEX[a] || Infinity) - (CATEGORIES_SORT_INDEX[b] || Infinity);
76
+ const getCategoryList = async () => {
77
+ setLoading(true);
78
+ const categoryDB = await services("listCategory");
79
+ if (categoryDB?.data?.Template?.length > 0) {
80
+ setCategories(categoryDB.data.Template);
81
+ setCategory(categoryDB.data.Template[0]);
82
+ getTemplatesList(categoryDB.data.Template[0]);
83
+ }
84
+ setLoading(false);
78
85
  };
79
- const getTemplatesList = async () => {
86
+ const getTemplatesList = async selectedCategory => {
80
87
  setLoading(true);
81
- const result = await services("listTemplates", {});
82
- const tempList = result?.data?.filter(f => f.type === "Template");
83
- const lic = tempList?.reduce((a, b) => {
84
- if (a.indexOf(b.category) < 0) {
85
- a.push(b.category);
86
- }
87
- return a;
88
- }, []).sort(sortCategory);
89
- const ft = tempList?.filter(f => f.category === lic[0]);
90
- setTemplates(tempList);
91
- setCategories(lic);
92
- setCategory(lic[0]);
93
- setFilteredTemplates(ft);
88
+ const result = await services("listTemplates", {
89
+ category: selectedCategory
90
+ });
91
+ setTemplates(result?.data || []);
94
92
  setLoading(false);
95
93
  };
96
94
  const handleChange = (event, newValue) => {
95
+ setTemplates([]);
97
96
  onSearch("");
98
97
  setCategory(newValue);
99
- setFilteredTemplates(templates.filter(f => f.category === newValue));
98
+ getTemplatesList(newValue);
100
99
  };
101
100
  const onSelectTemplate = card => async () => {
102
101
  try {
@@ -183,16 +182,16 @@ const AddTemplates = props => {
183
182
  data: categories,
184
183
  handleChange: handleChange
185
184
  })
186
- }), /*#__PURE__*/_jsxs(Grid, {
185
+ }), /*#__PURE__*/_jsx(Grid, {
187
186
  container: true,
188
187
  spacing: 0,
189
188
  className: `${fullScreen ? "fullscreen" : ""}`,
190
189
  sx: classes.templateCardsWrpr,
191
- children: [/*#__PURE__*/_jsx(ProgressBar, {
190
+ children: loading ? /*#__PURE__*/_jsx(ProgressBar, {
192
191
  loading: loading
193
- }), filteredTemplates.filter(filterByTitle).map(m => {
194
- return renderTemplate(m);
195
- })]
192
+ }) : /*#__PURE__*/_jsx(_Fragment, {
193
+ children: templates.filter(filterByTitle).map(renderTemplate)
194
+ })
196
195
  })]
197
196
  });
198
197
  };
@@ -51,7 +51,8 @@ const alignmentOptions = [{
51
51
  }];
52
52
  function SelectAlignment({
53
53
  editor,
54
- classes
54
+ classes,
55
+ closeMainPopup
55
56
  }) {
56
57
  const selected = useMemo(() => {
57
58
  return alignmentOptions.find(t => isBlockActive(editor, t.value));
@@ -59,6 +60,7 @@ function SelectAlignment({
59
60
  const onChange = (format, option) => {
60
61
  if (option.type === "block") {
61
62
  toggleBlock(editor, format);
63
+ closeMainPopup();
62
64
  }
63
65
  };
64
66
  return /*#__PURE__*/_jsx(CustomSelectTool, {
@@ -59,7 +59,7 @@ function SelectFontSize({
59
59
  size = value;
60
60
  }
61
61
  });
62
- return parseInt(size);
62
+ return isNaN(parseInt(size)) ? 14 : parseInt(size);
63
63
  } catch (err) {
64
64
  return "";
65
65
  }
@@ -68,7 +68,8 @@ const listOptions = [{
68
68
  }];
69
69
  function SelectList({
70
70
  editor,
71
- classes
71
+ classes,
72
+ closeMainPopup
72
73
  }) {
73
74
  const selectedList = useMemo(() => {
74
75
  return listOptions.find(t => isBlockActive(editor, t.value));
@@ -79,6 +80,7 @@ function SelectList({
79
80
  } else if (option.type === "accordion") {
80
81
  insertAccordion(editor);
81
82
  }
83
+ closeMainPopup();
82
84
  };
83
85
  return /*#__PURE__*/_jsx(CustomSelectTool, {
84
86
  options: listOptions,
@@ -125,7 +125,6 @@ function SelectTypography({
125
125
  ...upData
126
126
  }
127
127
  });
128
- closeMainPopup();
129
128
  };
130
129
  const selectedBlock = useMemo(() => {
131
130
  return typographyOptions.find(t => {
@@ -167,6 +166,7 @@ function SelectTypography({
167
166
  const [sizeInNumber] = size.split("px");
168
167
  updateMarkData(Number(sizeInNumber));
169
168
  }
169
+ closeMainPopup();
170
170
  };
171
171
  return /*#__PURE__*/_jsx(CustomSelectTool, {
172
172
  options: typographyOptions,
@@ -14,6 +14,7 @@ import MiniColorPicker from "./MiniColorPicker";
14
14
  import SelectAlignment from "./SelectAlignment";
15
15
  import SelectFontSize from "./SelectFontSize";
16
16
  import InfinityAITool from "./InfinityAITool";
17
+ import { viewSlateSelection } from "../../../utils/helper";
17
18
  import { jsx as _jsx } from "react/jsx-runtime";
18
19
  import { jsxs as _jsxs } from "react/jsx-runtime";
19
20
  const DEFAULT_COLOR = {
@@ -60,13 +61,15 @@ const MiniTextFormat = props => {
60
61
  className: "verticalLine"
61
62
  }), /*#__PURE__*/_jsx(SelectList, {
62
63
  classes: classes,
63
- editor: editor
64
+ editor: editor,
65
+ closeMainPopup: closeMainPopup
64
66
  }), /*#__PURE__*/_jsx("div", {
65
67
  className: "verticalLine mr-1"
66
68
  }), /*#__PURE__*/_jsx(SelectAlignment, {
67
69
  fontAlign: fontAlign,
68
70
  classes: classes,
69
- editor: editor
71
+ editor: editor,
72
+ closeMainPopup: closeMainPopup
70
73
  }), /*#__PURE__*/_jsx("div", {
71
74
  className: "verticalLine mr-1"
72
75
  }), /*#__PURE__*/_jsx(SelectFontSize, {
@@ -98,7 +101,10 @@ const MiniTextFormat = props => {
98
101
  editor: editor,
99
102
  customProps: customProps
100
103
  }, link.id), /*#__PURE__*/_jsx(IconButton, {
101
- onClick: e => setAnchorEl(document.getElementById("mini-text-editor-wrapper")),
104
+ onClick: e => {
105
+ viewSlateSelection();
106
+ setAnchorEl(document.getElementById("mini-text-editor-wrapper"));
107
+ },
102
108
  className: `textSettingsIcon ${open ? "btnActive" : ""}`,
103
109
  children: /*#__PURE__*/_jsx(TextToolIcon, {})
104
110
  }), /*#__PURE__*/_jsx(Popper, {
@@ -416,6 +416,11 @@ 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
+ },
419
424
  "& svg": {
420
425
  width: "20px",
421
426
  height: "24px"
@@ -9,6 +9,7 @@ import { useEditorContext } from "../../hooks/useMouseMove";
9
9
  import usePopupStyles from "../PopupTool/PopupToolStyle";
10
10
  import useEditorScroll from "../../hooks/useEditorScroll";
11
11
  import { isCarouselSelected } from "../../helper";
12
+ import { hideSlateSelection } from "../../utils/helper";
12
13
  import { jsx as _jsx } from "react/jsx-runtime";
13
14
  const PopupTool = props => {
14
15
  const {
@@ -83,6 +84,7 @@ const PopupTool = props => {
83
84
  setAnchorEl(null);
84
85
  } else {
85
86
  updateAnchorEl();
87
+ hideSlateSelection(); // removes slate selection background, when there is no selection
86
88
  }
87
89
  }, [selection]);
88
90
  useEffect(() => {
@@ -1,11 +1,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
+ 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,7 +1,11 @@
1
- import { useEffect } from "react";
1
+ import { useEffect, useState } from "react";
2
2
  import WebFont from "webfontloader";
3
3
  import { useEditorContext } from "../../hooks/useMouseMove";
4
- import { defaultFonts, googleFontList, otherFonts } from "./FontList";
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";
5
9
  const FontLoader = props => {
6
10
  const {
7
11
  otherProps,
@@ -10,14 +14,20 @@ const FontLoader = props => {
10
14
  const {
11
15
  setFontFamilies
12
16
  } = useEditorContext();
17
+ const [loading, setLoading] = useState(false);
13
18
  const loadFontsInBatches = (families, batchSize = 5, maxRetries = 3) => {
14
19
  let currentIndex = 0;
15
20
  let retryCount = 0;
21
+ let hideLoaderOn = 30;
16
22
  function loadNextBatch() {
17
23
  if (currentIndex >= families?.length) {
18
24
  // console.log("All fonts have been loaded");
25
+ setLoading(false);
19
26
  return;
20
27
  }
28
+ if (currentIndex >= hideLoaderOn) {
29
+ setLoading(false);
30
+ }
21
31
  const batch = families?.slice(currentIndex, currentIndex + batchSize);
22
32
  const batchWithWeights = batch.map(font => `${font}:300,400,600,700`);
23
33
  WebFont.load({
@@ -54,21 +64,21 @@ const FontLoader = props => {
54
64
  loadNextBatch();
55
65
  };
56
66
  useEffect(() => {
57
- let families = [...otherFonts, ...defaultFonts];
67
+ let families = [...googleFontList];
58
68
  if (!readOnly) {
59
69
  otherProps?.services("listGoogleFont", []).then(data => {
60
- families = [...families, ...(data?.data || [])];
61
- const filteredfamilies = families?.filter(font => !font?.includes("Material"));
70
+ families = [...(data?.data || [])];
62
71
  setFontFamilies({
63
72
  id: 1,
64
73
  format: "fontFamily",
65
74
  type: "fontfamilydropdown",
66
- options: filteredfamilies || []
75
+ options: families || []
67
76
  });
68
77
  loadFontsInBatches(families);
69
78
  }).catch(err => {
70
79
  // console.log(err);
71
80
  });
81
+ // setLoading(true);
72
82
  } else {
73
83
  function correctFontArray(fontString) {
74
84
  let fontsArray = fontString.split(",");
@@ -90,9 +100,25 @@ const FontLoader = props => {
90
100
  families = families?.map(font => font?.replace(/\"/g, ""));
91
101
  families = families?.map(font => font?.replace(", sans-serif", "")); //This is temporary fix for patch
92
102
  families = families.filter(font => googleFontList.includes(font));
103
+ // setLoading(true);
93
104
  loadFontsInBatches(families);
94
105
  }
95
106
  }, []);
96
- return null;
107
+ return /*#__PURE__*/_jsx(_Fragment, {
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
+ });
97
123
  };
98
124
  export default FontLoader;
@@ -62,6 +62,7 @@ const FormSettings = props => {
62
62
  MuiAccordion: {
63
63
  styleOverrides: {
64
64
  root: {
65
+ background: theme?.palette?.editor?.miniToolBarBackground,
65
66
  "& .MuiAccordionSummary-root": {
66
67
  flexDirection: "row-reverse",
67
68
  "& .MuiSvgIcon-root": {
@@ -9,17 +9,23 @@ import { jsxs as _jsxs } from "react/jsx-runtime";
9
9
  const SwitchViewport = props => {
10
10
  const {
11
11
  breakpoint,
12
- onChange
12
+ onChange,
13
+ show
13
14
  } = props;
14
15
  const classes = useSwitchViewport();
15
16
  const {
17
+ setSelectedElement,
16
18
  setActiveBreakPoint
17
19
  } = useEditorContext();
18
20
  useEffect(() => {
19
- console.log(breakpoint);
21
+ // to reset selection on viewport changes - FS-6589
22
+ setSelectedElement({});
20
23
  }, [breakpoint]);
21
24
  return /*#__PURE__*/_jsxs(Box, {
22
25
  sx: classes.root,
26
+ style: {
27
+ display: show ? "block" : "none"
28
+ },
23
29
  children: [/*#__PURE__*/_jsx(Tooltip, {
24
30
  title: "Desktop View",
25
31
  children: /*#__PURE__*/_jsx(IconButton, {
@@ -11,6 +11,9 @@ const SectionStyle = (themeReact, theme) => ({
11
11
  "& .sectionIcon": {
12
12
  opacity: 1
13
13
  },
14
+ '& .dividerIcon': {
15
+ opacity: 1
16
+ },
14
17
  "& .sectionPopper": {
15
18
  opacity: 1
16
19
  }
@@ -52,6 +55,18 @@ const SectionStyle = (themeReact, theme) => ({
52
55
  opacity: 1
53
56
  }
54
57
  },
58
+ "& .dividerIcon": {
59
+ opacity: 0,
60
+ padding: "0px",
61
+ background: "transparent",
62
+ border: "none",
63
+ width: "20px",
64
+ height: "20px",
65
+ "& button": {
66
+ boxShadow: "none",
67
+ background: "transparent"
68
+ }
69
+ },
55
70
  "& .ed-section-inner": {
56
71
  [themeReact.breakpoints.between("xs", "md")]: {
57
72
  maxWidth: `320px !important`,
@@ -73,6 +73,11 @@ const BackgroundImage = props => {
73
73
  children: "REMOVE"
74
74
  }) : /*#__PURE__*/_jsx(Grid, {
75
75
  className: "uploadImageText",
76
+ sx: {
77
+ padding: 0,
78
+ background: `${theme?.palette?.editor?.inputFieldBgColor}`,
79
+ border: `1px solid ${theme?.palette?.editor?.inputFieldBorder}`
80
+ },
76
81
  children: /*#__PURE__*/_jsxs(Button, {
77
82
  component: "label",
78
83
  variant: "text",
@@ -1,6 +1,7 @@
1
1
  import { Box, Card, Checkbox, FormControlLabel, Grid, Tooltip, Typography } from "@mui/material";
2
2
  import React from "react";
3
3
  import Icon from "../../Icon";
4
+ import { useEditorContext } from "../../../hooks/useMouseMove";
4
5
  import { jsx as _jsx } from "react/jsx-runtime";
5
6
  import { Fragment as _Fragment } from "react/jsx-runtime";
6
7
  import { jsxs as _jsxs } from "react/jsx-runtime";
@@ -15,7 +16,10 @@ const RenderCard = ({
15
16
  return /*#__PURE__*/_jsx(Card, {
16
17
  sx: {
17
18
  position: 'relative',
18
- padding: "10px"
19
+ padding: "10px",
20
+ '& .MuiCheckbox-root svg': {
21
+ fill: 'unset !important'
22
+ }
19
23
  },
20
24
  children: /*#__PURE__*/_jsx(FormControlLabel, {
21
25
  control: /*#__PURE__*/_jsx(Checkbox, {
@@ -81,6 +85,9 @@ const CardsMapping = props => {
81
85
  selectedCard,
82
86
  infoIcon
83
87
  } = data;
88
+ const {
89
+ theme
90
+ } = useEditorContext();
84
91
  const activeCard = value === selectedCard;
85
92
  const handleChange = e => {
86
93
  if (selectedCard === data?.value) {
@@ -99,7 +106,8 @@ const CardsMapping = props => {
99
106
  sx: {
100
107
  marginBottom: "12px",
101
108
  "& .MuiPaper-root": {
102
- border: activeCard ? "1px solid #2563EB" : "1px solid #C8D8FA",
109
+ background: theme?.palette?.editor?.miniToolBarBackground,
110
+ border: activeCard ? "1px solid #2563EB" : `1px solid ${theme?.palette?.editor?.inputFieldBorder}`,
103
111
  borderRadius: "8px",
104
112
  boxShadow: activeCard ? "0px 4px 16px 0px #2563EB40" : "unset"
105
113
  }
@@ -4,6 +4,7 @@ import { convertBase64 } from "../utils/helper";
4
4
  import { uploadFile } from "../service/fileupload";
5
5
  import Icon from "./Icon";
6
6
  import UploadStyles from "../common/ImageSelector/UploadStyles";
7
+ import { useEditorContext } from "../hooks/useMouseMove";
7
8
  import { jsx as _jsx } from "react/jsx-runtime";
8
9
  import { Fragment as _Fragment } from "react/jsx-runtime";
9
10
  import { jsxs as _jsxs } from "react/jsx-runtime";
@@ -18,6 +19,9 @@ const Uploader = props => {
18
19
  const [base64, setBase64] = useState(value?.url);
19
20
  const [fileName, setFileName] = useState("");
20
21
  const [uploading, setUploading] = useState(false);
22
+ const {
23
+ theme
24
+ } = useEditorContext();
21
25
  const handleChange = async e => {
22
26
  const uFile = e.target.files[0];
23
27
  const strImage = await convertBase64(uFile);
@@ -99,6 +103,10 @@ const Uploader = props => {
99
103
  className: "uploadImageSection",
100
104
  children: base64 ? renderThumb() : /*#__PURE__*/_jsx(Grid, {
101
105
  className: "uploadImageText",
106
+ sx: {
107
+ background: `${theme?.palette?.editor?.inputFieldBgColor}`,
108
+ border: `1px solid ${theme?.palette?.editor?.inputFieldBorder}`
109
+ },
102
110
  children: /*#__PURE__*/_jsxs(Button, {
103
111
  component: "label",
104
112
  variant: "text",
@@ -49,16 +49,20 @@ const useCommonStyle = theme => ({
49
49
  fontWeight: "500",
50
50
  fontFamily: "Inter, sans-serif"
51
51
  },
52
- "& p": {
53
- marginBottom: "7px",
54
- marginTop: "4px"
55
- },
56
52
  "& .MuiPaper-root": {
57
- border: 'unset !important',
53
+ border: `unset !important`,
58
54
  borderRadius: '0px',
59
55
  height: 'fit-content',
60
56
  padding: '2px'
61
57
  },
58
+ "& p": {
59
+ marginBottom: "7px",
60
+ marginTop: "4px"
61
+ },
62
+ "& p": {
63
+ marginBottom: "7px",
64
+ marginTop: "4px"
65
+ },
62
66
  "& .muiIconsListParent": {
63
67
  "& svg": {
64
68
  color: `${theme?.palette?.editor?.svgTextAlignStrokeColor} !important`
@@ -71,9 +75,6 @@ const useCommonStyle = theme => ({
71
75
  },
72
76
  "&::-webkit-scrollbar-thumb": {
73
77
  background: `${theme?.palette?.editor?.brainPopupScroll} !important`
74
- },
75
- "&::-webkit-scrollbar-track": {
76
- visibility: "hidden"
77
78
  }
78
79
  },
79
80
  "& .MuiGrid-root>.MuiGrid-item": {
@@ -470,10 +471,6 @@ const useCommonStyle = theme => ({
470
471
  }
471
472
  }
472
473
  },
473
- pageSettingPopUpRoot: {
474
- padding: "16px 8px 16px 10px!important",
475
- height: "100%"
476
- },
477
474
  buttonMoreOption: {
478
475
  background: `${theme?.palette?.editor?.aiInputBackground} !important`,
479
476
  border: `1px solid ${theme?.palette?.editor?.buttonBorder1} !important`,
@@ -486,6 +483,10 @@ const useCommonStyle = theme => ({
486
483
  }
487
484
  }
488
485
  },
486
+ pageSettingPopUpRoot: {
487
+ padding: "16px 8px 16px 10px!important",
488
+ height: "100%"
489
+ },
489
490
  buttonMoreOption2: {
490
491
  background: `${theme?.palette?.editor?.aiInputBackground} !important`,
491
492
  border: `1px solid ${theme?.palette?.editor?.buttonBorder1} !important`,
@@ -337,14 +337,14 @@ export const isCarouselSelected = editor => {
337
337
  return false;
338
338
  }
339
339
  const [nodeEntry] = Editor.nodes(editor, {
340
- match: n => !Editor.isEditor(n) && Element.isElement(n) && n.type === 'carousel'
340
+ match: n => !Editor.isEditor(n) && Element.isElement(n) && n.type === "carousel"
341
341
  });
342
342
  if (!nodeEntry) {
343
343
  return false;
344
344
  }
345
345
  const [node] = nodeEntry;
346
346
  const carouselDom = ReactEditor.toDOMNode(editor, node);
347
- const isEdit = carouselDom.classList.contains('carousel_slider_edit');
347
+ const isEdit = carouselDom.classList.contains("carousel_slider_edit");
348
348
  return !isEdit;
349
349
  } catch (err) {
350
350
  console.log(err);
@@ -39,7 +39,7 @@ const withLayout = editor => {
39
39
  const title = {
40
40
  type: "title",
41
41
  children: [{
42
- text: "Untitled"
42
+ text: ""
43
43
  }]
44
44
  };
45
45
  Transforms.insertNodes(editor, title, {
@@ -173,10 +173,9 @@ export const getMarked = (leaf, children, theme) => {
173
173
  if (leaf.highlight) {
174
174
  children = /*#__PURE__*/_jsx("span", {
175
175
  style: {
176
- color: "inherit"
176
+ color: "inherit",
177
+ background: "var(--slate-highlight-bg)"
177
178
  },
178
- className: "slate-highlight" // while opening AI, we will use this element to highlight the selection. (PopoverAIInput.js)
179
- ,
180
179
  children: children
181
180
  });
182
181
  }
@@ -20,10 +20,10 @@ export const insertButton = editor => {
20
20
  bottomRight: 30
21
21
  },
22
22
  bannerSpacing: {
23
- left: 16,
24
- top: 8,
25
- right: 16,
26
- bottom: 8
23
+ left: 24,
24
+ top: 10,
25
+ right: 24,
26
+ bottom: 10
27
27
  },
28
28
  ...(windowVar.lastButtonProps || {})
29
29
  };
@@ -82,7 +82,8 @@ const splitInlineStyleRanges = (text, inlineStyleRanges, data) => {
82
82
  };
83
83
  export const draftToSlate = props => {
84
84
  const {
85
- data
85
+ data,
86
+ needLayout
86
87
  } = props;
87
88
  if (data?.blocks && data?.blocks?.length > 0) {
88
89
  const converted = data?.blocks?.reduce((a, b) => {
@@ -104,7 +105,7 @@ export const draftToSlate = props => {
104
105
  return data;
105
106
  } else {
106
107
  return [{
107
- type: "paragraph",
108
+ type: needLayout ? "title" : "paragraph",
108
109
  children: [{
109
110
  text: ""
110
111
  }]
@@ -625,6 +625,10 @@ export const isRestrictedNode = (event, editor) => {
625
625
  return isNodeRestricted;
626
626
  }
627
627
  };
628
+ export function capitalizeFirstLetter(str) {
629
+ if (!str) return str;
630
+ return str.charAt(0).toUpperCase() + str.slice(1);
631
+ }
628
632
  export const insertLineBreakAtEndOfPath = (editor, path) => {
629
633
  try {
630
634
  const [node, nodePath] = Editor.node(editor, path); // Get the node at the specified path
@@ -643,6 +647,13 @@ export const insertLineBreakAtEndOfPath = (editor, path) => {
643
647
  console.log(err);
644
648
  }
645
649
  };
650
+ export function isHavingSelection(editor) {
651
+ try {
652
+ return editor?.selection && !Range.isCollapsed(editor.selection);
653
+ } catch (err) {
654
+ console.log(err);
655
+ }
656
+ }
646
657
  const omitNodes = ["site-settings", "page-settings"];
647
658
  export function getInitialValue(value = [], readOnly) {
648
659
  if (readOnly === "readonly" && value?.length) {
@@ -673,20 +684,17 @@ export function getInitialValue(value = [], readOnly) {
673
684
  }
674
685
  return value;
675
686
  }
676
- export function capitalizeFirstLetter(str) {
677
- if (!str) return str;
678
- return str.charAt(0).toUpperCase() + str.slice(1);
679
- }
680
- export function isHavingSelection(editor) {
681
- try {
682
- return editor?.selection && !Range.isCollapsed(editor.selection);
683
- } catch (err) {
684
- console.log(err);
685
- }
686
- }
687
687
  export function getSelectedCls(defaultCls = "", selected, selectedClsName = "selected") {
688
688
  return `${defaultCls} ${selected ? selectedClsName : ""}`;
689
689
  }
690
+ export function handleNegativeInteger(val) {
691
+ return val < 0 ? 0 : val;
692
+ }
693
+ export const containsSurrogatePair = text => {
694
+ // Match surrogate pairs (high and low surrogate)
695
+ const surrogatePairRegex = /[\uD800-\uDBFF][\uDC00-\uDFFF]/;
696
+ return surrogatePairRegex.test(text);
697
+ };
690
698
  export const getNodeWithType = (editor, nodeType = "", otherOptions) => {
691
699
  try {
692
700
  const options = {
@@ -700,11 +708,6 @@ export const getNodeWithType = (editor, nodeType = "", otherOptions) => {
700
708
  return [];
701
709
  }
702
710
  };
703
- export const containsSurrogatePair = text => {
704
- // Match surrogate pairs (high and low surrogate)
705
- const surrogatePairRegex = /[\uD800-\uDBFF][\uDC00-\uDFFF]/;
706
- return surrogatePairRegex.test(text);
707
- };
708
711
  export const getSlateDom = (editor, range) => {
709
712
  try {
710
713
  const slateDom = ReactEditor.toDOMRange(editor, range);
@@ -713,6 +716,44 @@ export const getSlateDom = (editor, range) => {
713
716
  console.log(err);
714
717
  }
715
718
  };
716
- export function handleNegativeInteger(val) {
717
- return val < 0 ? 0 : val;
718
- }
719
+
720
+ // The inputs inside the dynamic table lose focus after calling `setNodes` on the first `onChange` event.
721
+ // To replicate this issue, insert some paragraph nodes above the dynamic table, then type something in the title.
722
+ // After typing the first word, the input loses focus.
723
+ export const focusDynamicTableInput = e => {
724
+ setTimeout(() => {
725
+ const input = document.getElementById(e.target.id);
726
+ if (input) {
727
+ // Check if the input is not already focused
728
+ if (document.activeElement !== input) {
729
+ const length = input.value.length;
730
+ // Focus on the input
731
+ input.focus();
732
+
733
+ // number input not supports selection
734
+ if (e.target.type !== "number") {
735
+ // Set the cursor to the end
736
+ input.setSelectionRange(length, length);
737
+ }
738
+ }
739
+ }
740
+ }, 0);
741
+ };
742
+ export const clearWindowSelection = () => {
743
+ const selection = window.getSelection();
744
+ if (selection) {
745
+ selection.removeAllRanges(); // Clears the selection
746
+ }
747
+ };
748
+
749
+ export const viewSlateSelection = () => {
750
+ // if ai is opened, remove the window selection class and open then slate selection, To resolve: focussing on the ai input removes window selection automatically
751
+ clearWindowSelection();
752
+ const selectionBg = "rgba(35, 131, 226, 0.35)";
753
+ const root = document.documentElement;
754
+ root.style.setProperty("--slate-highlight-bg", selectionBg);
755
+ };
756
+ export const hideSlateSelection = () => {
757
+ const root = document.documentElement;
758
+ root.style.setProperty("--slate-highlight-bg", "none");
759
+ };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@flozy/editor",
3
- "version": "5.7.7",
3
+ "version": "5.7.8",
4
4
  "description": "An Editor for flozy app brain",
5
5
  "files": [
6
6
  "dist"