@flozy/editor 5.8.8 → 5.8.9

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 (34) hide show
  1. package/dist/Editor/CommonEditor.js +17 -13
  2. package/dist/Editor/Editor.css +29 -14
  3. package/dist/Editor/Elements/Button/EditorButton.js +2 -1
  4. package/dist/Editor/Elements/DataView/Layouts/DataTypes/Components/Select.js +8 -12
  5. package/dist/Editor/Elements/Grid/GridItem.js +1 -2
  6. package/dist/Editor/Elements/Link/Link.js +42 -31
  7. package/dist/Editor/Elements/SimpleText/index.js +7 -12
  8. package/dist/Editor/Elements/SimpleText/style.js +2 -2
  9. package/dist/Editor/Elements/Title/title.js +13 -1
  10. package/dist/Editor/Elements/Variables/Style.js +28 -2
  11. package/dist/Editor/Elements/Variables/VariableButton.js +17 -4
  12. package/dist/Editor/Toolbar/PopupTool/PopupToolStyle.js +5 -0
  13. package/dist/Editor/Toolbar/PopupTool/index.js +28 -31
  14. package/dist/Editor/common/FontLoader/FontList.js +3 -11
  15. package/dist/Editor/common/FontLoader/FontLoader.js +24 -7
  16. package/dist/Editor/common/RnD/ElementSettings/Settings/FormSettings.js +1 -0
  17. package/dist/Editor/common/RnD/SwitchViewport/SwitchViewport.js +8 -2
  18. package/dist/Editor/common/Section/index.js +60 -89
  19. package/dist/Editor/common/StyleBuilder/fieldTypes/backgroundImage.js +5 -0
  20. package/dist/Editor/common/StyleBuilder/fieldTypes/card.js +10 -2
  21. package/dist/Editor/common/Uploader.js +8 -0
  22. package/dist/Editor/common/iconslist.js +1 -2
  23. package/dist/Editor/commonStyle.js +55 -59
  24. package/dist/Editor/helper/deserialize/index.js +18 -5
  25. package/dist/Editor/helper/index.js +2 -2
  26. package/dist/Editor/helper/markdown.js +45 -0
  27. package/dist/Editor/hooks/useEditorScroll.js +1 -1
  28. package/dist/Editor/plugins/withHTML.js +8 -1
  29. package/dist/Editor/plugins/withLayout.js +1 -1
  30. package/dist/Editor/utils/SlateUtilityFunctions.js +36 -0
  31. package/dist/Editor/utils/button.js +4 -4
  32. package/dist/Editor/utils/draftToSlate.js +3 -2
  33. package/dist/Editor/utils/helper.js +20 -20
  34. package/package.json +3 -2
@@ -54,13 +54,14 @@ const Item = /*#__PURE__*/forwardRef(({
54
54
  });
55
55
  });
56
56
  Item.displayName = "Item";
57
- const Element = props => {
57
+ const Element = /*#__PURE__*/React.memo(props => {
58
58
  return /*#__PURE__*/_jsx(Section, {
59
59
  ...props,
60
60
  children: getBlock(props)
61
61
  });
62
- };
63
- const Leaf = ({
62
+ });
63
+ Element.displayName = "Element";
64
+ const Leaf = /*#__PURE__*/React.memo(({
64
65
  attributes,
65
66
  children,
66
67
  leaf
@@ -71,12 +72,13 @@ const Leaf = ({
71
72
  ...attributes,
72
73
  children: children
73
74
  });
74
- };
75
+ });
76
+ Leaf.displayName = "Leaf";
75
77
  const updateTopBanner = (content = [], setTopBanner) => {
76
- setTopBanner(() => {
77
- const firstNode = content ? content[0] : {};
78
- return firstNode?.type === "topbanner" ? firstNode : null;
79
- });
78
+ // setTopBanner(() => {
79
+ // const firstNode = content ? content[0] : {};
80
+ // return firstNode?.type === "topbanner" ? firstNode : null;
81
+ // });
80
82
  };
81
83
  const CommonEditor = /*#__PURE__*/forwardRef((props, ref) => {
82
84
  const {
@@ -96,7 +98,8 @@ const CommonEditor = /*#__PURE__*/forwardRef((props, ref) => {
96
98
  const editorWrapper = useRef();
97
99
  const mentionsRef = useRef();
98
100
  const convertedContent = draftToSlate({
99
- data: content
101
+ data: content,
102
+ needLayout: otherProps?.needLayout
100
103
  });
101
104
  const [value, setValue] = useState(convertedContent);
102
105
  const [isInteracted, setIsInteracted] = useState(false);
@@ -167,11 +170,11 @@ const CommonEditor = /*#__PURE__*/forwardRef((props, ref) => {
167
170
  const debounced = useDebouncedCallback(
168
171
  // function
169
172
  value => {
173
+ debouncedValue.current = value;
170
174
  const {
171
175
  value: strVal,
172
176
  ...restVal
173
177
  } = getOnSaveData(value);
174
- debouncedValue.current = value;
175
178
  onSave(strVal, restVal);
176
179
  },
177
180
  // delay in ms
@@ -182,7 +185,7 @@ const CommonEditor = /*#__PURE__*/forwardRef((props, ref) => {
182
185
  return {
183
186
  value: JSON.stringify(val),
184
187
  text: text,
185
- title: serializeToText(title?.children) || "Untitled"
188
+ title: serializeToText(title?.children) || ""
186
189
  };
187
190
  };
188
191
  const getPreviewImage = async (needBackground = false, options = {}) => {
@@ -312,7 +315,7 @@ const CommonEditor = /*#__PURE__*/forwardRef((props, ref) => {
312
315
  updateTopBanner(newValue, setTopBanner);
313
316
  debounced(newValue);
314
317
  if (!isInteracted) {
315
- setIsInteracted(true);
318
+ // setIsInteracted(true);
316
319
  }
317
320
  }
318
321
  };
@@ -596,8 +599,9 @@ const CommonEditor = /*#__PURE__*/forwardRef((props, ref) => {
596
599
  setIsTextSelected: setIsTextSelected,
597
600
  customProps: customProps,
598
601
  editorWrapper: editorWrapper
599
- }) : null, !readOnly && showViewport ? /*#__PURE__*/_jsx(SwitchViewport, {
602
+ }) : null, !readOnly ? /*#__PURE__*/_jsx(SwitchViewport, {
600
603
  breakpoint: breakpoint,
604
+ show: showViewport,
601
605
  onChange: b => onSwitchBreakpoint(b)
602
606
  }) : null]
603
607
  })
@@ -1263,6 +1263,19 @@ blockquote {
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;
@@ -1330,3 +1329,19 @@ blockquote {
1330
1329
  background: linear-gradient(112.61deg, #2C63ED 19.3%, #8360FD 88.14%) !important;
1331
1330
  text-transform: math-auto !important;
1332
1331
  }
1332
+
1333
+ code.markcode {
1334
+ border-radius: 4px;
1335
+ padding: 6px 8px;
1336
+ margin: 8px 0px;
1337
+ display: block;
1338
+ background-color: #f3f3f3;
1339
+ font-family: 'Source Code Pro' !important;
1340
+ }
1341
+
1342
+ /* Hide the popper when the reference is hidden */
1343
+ .hide-popper-on-overlap[data-popper-escaped],
1344
+ .hide-popper-on-overlap[data-popper-reference-hidden] {
1345
+ visibility: hidden;
1346
+ pointer-events: none;
1347
+ }
@@ -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",
@@ -104,9 +104,9 @@ export default function Select(props) {
104
104
  return /*#__PURE__*/_jsx(Box, {
105
105
  className: "tv-ms-tag-wrpr",
106
106
  sx: {
107
- "& svg": {
108
- marginRight: "5px",
109
- "& path": {
107
+ '& svg': {
108
+ marginRight: '5px',
109
+ '& path': {
110
110
  stroke: "#000"
111
111
  }
112
112
  }
@@ -125,19 +125,15 @@ export default function Select(props) {
125
125
  sx: {
126
126
  background: option?.color || appTheme?.palette?.editor?.tv_border1,
127
127
  border: "none",
128
- "& .MuiChip-label": {
129
- paddingLeft: "12px !important"
128
+ '& .MuiChip-label': {
129
+ paddingLeft: '12px !important'
130
130
  }
131
131
  },
132
132
  avatar: /*#__PURE__*/_jsx(AvatarIcon, {
133
133
  option: option,
134
134
  avatar: optionAvatar
135
135
  }),
136
- deleteIcon: /*#__PURE__*/_jsx(CloseIcon, {
137
- style: {
138
- cursor: "pointer"
139
- }
140
- })
136
+ deleteIcon: /*#__PURE__*/_jsx(CloseIcon, {})
141
137
  }, key) : null;
142
138
  })
143
139
  });
@@ -153,8 +149,8 @@ export default function Select(props) {
153
149
  label: option.label || option.value || "",
154
150
  sx: {
155
151
  background: option.color || appTheme?.palette?.editor?.tv_border1,
156
- "& .MuiChip-label": {
157
- paddingLeft: "12px !important"
152
+ '& .MuiChip-label': {
153
+ paddingLeft: '12px !important'
158
154
  }
159
155
  },
160
156
  avatar: /*#__PURE__*/_jsx(AvatarIcon, {
@@ -50,8 +50,7 @@ const GridItemToolbar = props => {
50
50
  open: true,
51
51
  placement: "top-end",
52
52
  sx: classes.popTools,
53
- className: "gi-tool-pp",
54
- disablePortal: true,
53
+ className: "gi-tool-pp hide-popper-on-overlap",
55
54
  contentEditable: false,
56
55
  children: /*#__PURE__*/_jsxs(Box, {
57
56
  className: "ico-grp-ss",
@@ -1,7 +1,7 @@
1
- import React, { useState } from "react";
1
+ import React, { useRef, useState } from "react";
2
2
  import { Node, Transforms } from "slate";
3
3
  import { ReactEditor, useFocused, useSelected, useSlateStatic } from "slate-react";
4
- import { Box, IconButton, Tooltip } from "@mui/material";
4
+ import { Box, IconButton, Popper, Tooltip } from "@mui/material";
5
5
  import OpenInNewIcon from "@mui/icons-material/OpenInNew";
6
6
  import EditIcon from "@mui/icons-material/Edit";
7
7
  import LinkOffIcon from "@mui/icons-material/LinkOff";
@@ -53,6 +53,7 @@ const Link = props => {
53
53
  const showInNewTab = element?.showInNewTab || element?.target;
54
54
  const linkType = element?.linkType;
55
55
  const classes = linkStyles();
56
+ const linkRef = useRef(null);
56
57
  const updateLink = data => {
57
58
  Transforms.setNodes(editor, data, {
58
59
  at: path
@@ -81,43 +82,53 @@ const Link = props => {
81
82
  const btnProps = handleLinkType(urlPath, linkType, true, showInNewTab === "_blank");
82
83
  const navType = getLinkType(linkType, urlPath);
83
84
  const hideOpenLink = navType === "page" || !navType;
84
- return selected && focused ? /*#__PURE__*/_jsxs("div", {
85
- className: "element-toolbar hr",
85
+ return selected && focused ? /*#__PURE__*/_jsx(Popper, {
86
+ anchorEl: linkRef?.current,
87
+ open: true,
88
+ placement: "top-start",
89
+ className: "hide-popper-on-overlap",
86
90
  contentEditable: false,
87
91
  style: {
88
- width: "150px",
89
- top: "100%",
90
- left: "0px",
91
- display: "flex"
92
+ zIndex: 1
92
93
  },
93
- children: [hideOpenLink ? null : /*#__PURE__*/_jsx(Tooltip, {
94
- title: "Open",
95
- children: /*#__PURE__*/_jsx(Box, {
96
- sx: {
97
- display: "inline-flex",
98
- color: "rgba(0, 0, 0, 0.54)"
99
- },
100
- ...btnProps,
101
- children: /*#__PURE__*/_jsx(OpenInNewIcon, {})
102
- })
103
- }), /*#__PURE__*/_jsx(Tooltip, {
104
- title: "Edit",
105
- children: /*#__PURE__*/_jsx(IconButton, {
106
- onClick: onEditLink,
107
- children: /*#__PURE__*/_jsx(EditIcon, {})
108
- })
109
- }), /*#__PURE__*/_jsx(Tooltip, {
110
- title: "Remove",
111
- children: /*#__PURE__*/_jsx(IconButton, {
112
- onClick: () => removeLink(editor),
113
- children: /*#__PURE__*/_jsx(LinkOffIcon, {})
114
- })
115
- })]
94
+ children: /*#__PURE__*/_jsxs(Box, {
95
+ className: "element-toolbar hr",
96
+ style: {
97
+ width: "150px",
98
+ display: "flex",
99
+ position: "unset"
100
+ },
101
+ component: "div",
102
+ children: [hideOpenLink ? null : /*#__PURE__*/_jsx(Tooltip, {
103
+ title: "Open",
104
+ children: /*#__PURE__*/_jsx(Box, {
105
+ sx: {
106
+ display: "inline-flex",
107
+ color: "rgba(0, 0, 0, 0.54)"
108
+ },
109
+ ...btnProps,
110
+ children: /*#__PURE__*/_jsx(OpenInNewIcon, {})
111
+ })
112
+ }), /*#__PURE__*/_jsx(Tooltip, {
113
+ title: "Edit",
114
+ children: /*#__PURE__*/_jsx(IconButton, {
115
+ onClick: onEditLink,
116
+ children: /*#__PURE__*/_jsx(EditIcon, {})
117
+ })
118
+ }), /*#__PURE__*/_jsx(Tooltip, {
119
+ title: "Remove",
120
+ children: /*#__PURE__*/_jsx(IconButton, {
121
+ onClick: () => removeLink(editor),
122
+ children: /*#__PURE__*/_jsx(LinkOffIcon, {})
123
+ })
124
+ })]
125
+ })
116
126
  }) : null;
117
127
  };
118
128
  const buttonProps = handleLinkType(urlPath, linkType, readOnly, showInNewTab === "_blank");
119
129
  return /*#__PURE__*/_jsxs("div", {
120
130
  className: "link",
131
+ ref: linkRef,
121
132
  children: [/*#__PURE__*/_jsx(Box, {
122
133
  ...attributes,
123
134
  ...element.attr,
@@ -1,7 +1,7 @@
1
1
  import React from "react";
2
2
  import { useSlateStatic, useSelected, ReactEditor } from "slate-react";
3
3
  import { Box } from "@mui/material";
4
- import { getPageSettings } from "../../utils/pageSettings";
4
+ // import { getPageSettings } from "../../utils/pageSettings";
5
5
  import { isTextSelected } from "../../utils/helper";
6
6
  import { useEditorContext } from "../../hooks/useMouseMove";
7
7
  import SimpleTextStyle from "./style";
@@ -12,7 +12,6 @@ import { jsxs as _jsxs } from "react/jsx-runtime";
12
12
  import { createElement as _createElement } from "react";
13
13
  const SimpleText = props => {
14
14
  const {
15
- theme,
16
15
  openAI
17
16
  } = useEditorContext() || {};
18
17
  const editor = useSlateStatic();
@@ -28,19 +27,15 @@ const SimpleText = props => {
28
27
  readOnly,
29
28
  editorPlaceholder
30
29
  } = customProps;
31
- const {
32
- element: pageSt
33
- } = getPageSettings(editor) || {};
34
- const {
35
- pageColor
36
- } = pageSt?.pageProps || {};
30
+ // const { element: pageSt } = getPageSettings(editor) || {};
31
+ // const { pageColor } = pageSt?.pageProps || {};
37
32
  const {
38
33
  activeBreakPoint
39
34
  } = useEditorContext();
40
35
  const lineHeight = element?.children[0]?.lineHeight;
41
36
  const lineH = getBreakpointLineSpacing(lineHeight, activeBreakPoint);
42
37
  const classes = SimpleTextStyle({
43
- pageColor: pageColor || theme?.palette?.editor?.background || "#FFFFFF",
38
+ pageColor: "#FFFFFF",
44
39
  lineHeight: lineH
45
40
  });
46
41
  const selected = useSelected();
@@ -59,14 +54,14 @@ const SimpleText = props => {
59
54
  contentEditable: false,
60
55
  className: "placeholder-simple-text",
61
56
  children: isEmptyEditor ? editorPlaceholder || "Write Something..." : showPlaceHolder ? opacity && selected ? /*#__PURE__*/_jsxs(_Fragment, {
62
- children: ["Type ", /*#__PURE__*/_jsx("span", {
57
+ children: ["Type", " ", /*#__PURE__*/_jsx("span", {
63
58
  style: {
64
- backgroundColor: '#F2F6FA',
59
+ backgroundColor: "#F2F6FA",
65
60
  padding: "0px 2px",
66
61
  borderRadius: "2px"
67
62
  },
68
63
  children: "/"
69
- }), " to browse elements"]
64
+ }), " ", "to browse elements"]
70
65
  }) : "" : ""
71
66
  }));
72
67
  };
@@ -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,34 @@ 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
+ marginTop: '5px',
44
+ "@media only screen and (max-width: 599px)": {
45
+ padding: '10px 0px'
46
+ }
47
+ },
48
+ "& .MuiList-root": {
49
+ padding: '0px'
50
+ },
51
+ "& .MuiButtonBase-root": {
52
+ margin: '6px',
53
+ borderRadius: '8px',
54
+ padding: '6px 14px',
55
+ fontSize: '14px',
56
+ fontWeight: '400',
57
+ color: theme?.palette?.editor?.deletePopUpButtonTextColor,
58
+ "&:hover": {
59
+ background: `${theme?.palette?.editor?.menuOptionHoverBackground} !important`
60
+ },
61
+ "@media only screen and (max-width: 599px)": {
62
+ minHeight: '30px',
63
+ margin: '0px 6px'
64
+ }
65
+ },
40
66
  "& .Mui-selected": {
41
- backgroundColor: "rgba(0, 0, 0, 0.04) !important"
67
+ backgroundColor: 'unset !important'
42
68
  }
43
69
  }
44
70
  });
@@ -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,13 +28,14 @@ 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: {
31
35
  style: {
32
36
  maxHeight: 300,
33
- overflowY: "auto"
37
+ overflowY: "auto",
38
+ transformOrigin: 'top left'
34
39
  },
35
40
  sx: {
36
41
  "&::-webkit-scrollbar-track": {
@@ -40,6 +45,14 @@ const VariableButton = props => {
40
45
  borderRadius: "16px"
41
46
  }
42
47
  }
48
+ },
49
+ anchorOrigin: {
50
+ vertical: 'bottom',
51
+ horizontal: 'right'
52
+ },
53
+ transformOrigin: {
54
+ vertical: 'top',
55
+ horizontal: 'right'
43
56
  }
44
57
  },
45
58
  children: [/*#__PURE__*/_jsx(MenuItem, {
@@ -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"
@@ -1,5 +1,5 @@
1
- import React, { useCallback, useEffect, useState } from "react";
2
- import { Popper, Fade, Paper, ClickAwayListener } from "@mui/material";
1
+ import React, { useEffect, useState } from "react";
2
+ import { Popper, Paper, ClickAwayListener } from "@mui/material";
3
3
  import { Editor, Range, Transforms } from "slate";
4
4
  import { ReactEditor, useSlate } from "slate-react";
5
5
  import useDrag from "../../hooks/useDrag";
@@ -21,7 +21,8 @@ const PopupTool = props => {
21
21
  const classes = usePopupStyles(theme);
22
22
  const {
23
23
  setPopupType,
24
- openAI
24
+ openAI,
25
+ selectedElement
25
26
  } = useEditorContext();
26
27
  const [anchorEl, setAnchorEl] = useState(null);
27
28
  const [open, setOpen] = useState(false);
@@ -32,13 +33,10 @@ const PopupTool = props => {
32
33
  const [event] = useDrag(anchorEl);
33
34
  const id = open ? "popup-edit-tool" : "";
34
35
  const [size] = useWindowResize();
35
- const {
36
- selectedElement
37
- } = useEditorContext();
38
- const updateAnchorEl = useCallback(() => {
36
+ const updateAnchorEl = isScroll => {
39
37
  try {
40
38
  const isHavingSelection = selection && !Range.isCollapsed(selection);
41
- if (isHavingSelection) {
39
+ if (isHavingSelection && event === "end") {
42
40
  const domRange = ReactEditor.toDOMRange(editor, editor.selection);
43
41
  const editorContainer = document.querySelector("#slate-wrapper-scroll-container")?.getBoundingClientRect();
44
42
  const rect = domRange.getBoundingClientRect();
@@ -47,16 +45,21 @@ const PopupTool = props => {
47
45
  rect.y = -500; // hide the popper
48
46
  }
49
47
 
50
- setAnchorEl({
51
- clientWidth: rect.width,
52
- clientHeight: rect.height,
53
- getBoundingClientRect: () => rect
54
- });
48
+ // Create a dummy anchor element to match Popper's requirements
49
+ const anchor = document.createElement("div");
50
+ anchor.style.position = "absolute";
51
+ anchor.style.top = `${rect.top + window.scrollY}px`;
52
+ anchor.style.left = `${rect.left + window.scrollX}px`;
53
+ document.body.appendChild(anchor);
54
+ if (!anchorEl || isScroll === "scroll") {
55
+ setAnchorEl(anchor);
56
+ setOpen(true);
57
+ }
55
58
  }
56
59
  } catch (err) {
57
60
  console.log(err);
58
61
  }
59
- }, [selection]);
62
+ };
60
63
  useEditorScroll(editorWrapper, updateAnchorEl);
61
64
  useEffect(() => {
62
65
  const userStoppedSelection = size?.device === "xs" ? true : event === "end"; // for mobile, when user starts the selection, we are gonna show the popup tool
@@ -86,7 +89,7 @@ const PopupTool = props => {
86
89
  updateAnchorEl();
87
90
  hideSlateSelection(); // removes slate selection background, when there is no selection
88
91
  }
89
- }, [selection]);
92
+ }, [selection, event]);
90
93
  useEffect(() => {
91
94
  if (selectedElement?.enable === 1) {
92
95
  setAnchorEl(null);
@@ -117,24 +120,18 @@ const PopupTool = props => {
117
120
  id: id,
118
121
  open: open,
119
122
  anchorEl: anchorEl,
120
- transition: true,
121
123
  sx: classes.popupWrapper,
122
124
  placement: "top-start",
123
- children: ({
124
- TransitionProps
125
- }) => /*#__PURE__*/_jsx(Fade, {
126
- ...TransitionProps,
127
- children: /*#__PURE__*/_jsx(Paper, {
128
- style: {
129
- borderRadius: "6px",
130
- border: "1px solid #8360FD"
131
- },
132
- children: /*#__PURE__*/_jsx(MiniTextFormat, {
133
- editor: editor,
134
- classes: classes,
135
- closeMainPopup: handleClose,
136
- customProps: customProps
137
- })
125
+ children: /*#__PURE__*/_jsx(Paper, {
126
+ style: {
127
+ borderRadius: "6px",
128
+ border: "1px solid #8360FD"
129
+ },
130
+ children: /*#__PURE__*/_jsx(MiniTextFormat, {
131
+ editor: editor,
132
+ classes: classes,
133
+ closeMainPopup: handleClose,
134
+ customProps: customProps
138
135
  })
139
136
  })
140
137
  })
@@ -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];