@flozy/editor 9.2.1 → 9.2.2

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.
@@ -1280,8 +1280,8 @@ blockquote {
1280
1280
  }
1281
1281
  @media (max-width: 899px) {
1282
1282
  /* Qa validation required */
1283
- /* .MuiPopover-root {
1284
- z-index: 1302 !important;
1283
+ /* .MuiPopover-root {
1284
+ z-index: 1302 !important;
1285
1285
  } */
1286
1286
 
1287
1287
  canvas {
@@ -5,7 +5,7 @@ import { Box } from "@mui/material";
5
5
  import { isTextSelected } from "../../utils/helper";
6
6
  import { useEditorContext } from "../../hooks/useMouseMove";
7
7
  import SimpleTextStyle from "./style";
8
- // import { getBreakpointLineSpacing } from "../../helper/theme";
8
+ import { getBreakpointLineSpacing } from "../../helper/theme";
9
9
  import { jsx as _jsx } from "react/jsx-runtime";
10
10
  import { Fragment as _Fragment } from "react/jsx-runtime";
11
11
  import { jsxs as _jsxs } from "react/jsx-runtime";
@@ -155,7 +155,7 @@ const TableCell = props => {
155
155
  };
156
156
  useEffect(() => {
157
157
  const currentPath = path?.toString();
158
- const timeoutId = setTimeout(() => {
158
+ setTimeout(() => {
159
159
  if (tableResizing === currentPath) {
160
160
  setTableResizing(null);
161
161
 
@@ -171,7 +171,6 @@ const TableCell = props => {
171
171
  if (resizing) {
172
172
  setTableResizing(currentPath);
173
173
  }
174
- return () => clearTimeout(timeoutId);
175
174
  }, [resizing]);
176
175
  const onMouseEnter = path => {
177
176
  setHoverPath(path);
@@ -33,14 +33,17 @@ const TextFormat = props => {
33
33
  const [anchorEl, setAnchorEl] = useState(null);
34
34
  const [type, setType] = useState(null);
35
35
  const open = Boolean(anchorEl);
36
-
37
- // const { element: pageSt } = getPageSettings(editor) || {};
36
+ const {
37
+ element: pageSt
38
+ } = getPageSettings(editor) || {};
38
39
  // const pageSettingLine = pageSt?.pageProps?.lineHeight;
39
40
  const {
40
41
  fontFamilies,
41
42
  theme
42
43
  } = useEditorContext();
43
- // const { activeBreakPoint } = useEditorContext();
44
+ const {
45
+ activeBreakPoint
46
+ } = useEditorContext();
44
47
  // const breakpoint = activeBreakPoint === "" ? "lg" : activeBreakPoint;
45
48
  const fontWeight = allTools.find(f => f.format === "fontWeight");
46
49
  const fontStyle = allTools.filter(f => f.type === "mark" && f.format !== "strikethrough" && f.format !== "superscript" && f.format !== "subscript");
@@ -14,6 +14,7 @@ import { jsx as _jsx } from "react/jsx-runtime";
14
14
  const PopupTool = props => {
15
15
  const {
16
16
  theme,
17
+ setIsTextSelected,
17
18
  customProps,
18
19
  editorWrapper
19
20
  } = props;
@@ -34,9 +35,6 @@ const PopupTool = props => {
34
35
  const [size] = useWindowResize();
35
36
  const updateAnchorEl = isScroll => {
36
37
  try {
37
- const {
38
- selection
39
- } = editor;
40
38
  const isHavingSelection = selection && !Range.isCollapsed(selection);
41
39
  if (isHavingSelection && event === "end") {
42
40
  const domRange = ReactEditor.toDOMRange(editor, editor.selection);
@@ -76,39 +74,29 @@ const PopupTool = props => {
76
74
  if (!isCarouselEdit) {
77
75
  setOpen(true);
78
76
  setPopupType("textFormat");
79
- // setIsTextSelected(true);
77
+ setIsTextSelected(true);
80
78
  }
81
79
  } else if (!anchorEl) {
82
80
  setOpen(false);
83
81
  setPopupType("");
84
- // setIsTextSelected(false);
82
+ setIsTextSelected(false);
85
83
  }
86
84
  }, [event, anchorEl]);
87
85
  useEffect(() => {
88
- console.log("Editor useEffect", selection);
89
- const {
90
- path,
91
- enable
92
- } = selectedElement || {};
93
- const isFreeGridElement = path && path.split("|").length > 2;
94
- const isFreeGridEnabled = enable === 1 && isFreeGridElement;
95
- if (!selection || Range.isCollapsed(selection) || Editor.string(editor, selection) === "" || isFreeGridEnabled) {
86
+ if (!selection || Range.isCollapsed(selection) || Editor.string(editor, selection) === "" || selectedElement?.enable === 1) {
96
87
  setAnchorEl(null);
97
88
  } else {
98
- console.log("Editor updateAnchorEl", selection);
99
89
  updateAnchorEl();
100
90
  hideSlateSelection(); // removes slate selection background, when there is no selection
101
91
  }
102
92
  }, [selection, event, selectedElement?.enable]);
103
93
  const handleClose = () => {
104
- console.log("Editor closing");
105
94
  // setAnchorEl(null);
106
95
  setOpen(false);
107
96
  setPopupType("");
108
97
  };
109
98
  return open && !openAI ? /*#__PURE__*/_jsx(ClickAwayListener, {
110
99
  onClickAway: e => {
111
- console.log("ClickAwayListener", e.target, document.body, e.target !== document.body);
112
100
  // close the mini toolbar, if user clicks outside the editor (in Flozy app.)
113
101
  if (e.target !== document.body) {
114
102
  // e.target returns body, if the user clicks material ui select popup inside the tool bar, on that time, we don't need to close
@@ -19,7 +19,7 @@ const Upload = props => {
19
19
  xs: 12,
20
20
  sx: {
21
21
  padding: "10px",
22
- height: "100%"
22
+ height: '100%'
23
23
  },
24
24
  className: "ims-right",
25
25
  children: /*#__PURE__*/_jsx(Uploader, {
@@ -5,9 +5,9 @@ const UploadStyles = theme => ({
5
5
  borderRadius: "11px",
6
6
  boxShadow: "0px 4px 10px rgba(0, 0, 0, 0.16)",
7
7
  background: theme?.palette?.editor?.uploadFileBg,
8
- height: "100%",
9
- minHeight: "150px",
10
- height: "inherit"
8
+ height: '100%',
9
+ minHeight: '150px',
10
+ height: 'inherit'
11
11
  },
12
12
  uploadField: {
13
13
  width: "100%",
@@ -19,21 +19,21 @@ const UploadStyles = theme => ({
19
19
  backgroundColor: theme?.palette?.editor?.uploadFileInnerBg,
20
20
  borderRadius: "9px",
21
21
  border: "1px dashed #2563EB",
22
- minHeight: "150px"
22
+ minHeight: '150px'
23
23
  },
24
24
  uploadIcon: {
25
25
  display: "grid !important",
26
26
  "& svg": {
27
- display: "flex",
28
- width: "100%",
27
+ display: 'flex',
28
+ width: '100%',
29
29
  "& path": {
30
30
  stroke: "#2563EB"
31
31
  }
32
32
  },
33
- "& span": {
34
- display: "flex",
35
- width: "100%",
36
- marginTop: "5px"
33
+ '& span': {
34
+ display: 'flex',
35
+ width: '100%',
36
+ marginTop: '5px'
37
37
  }
38
38
  }
39
39
  });
@@ -58,7 +58,6 @@ const useElementSettingsStyle = theme => ({
58
58
  maxHeight: "500px",
59
59
  overflowX: "hidden",
60
60
  overflowY: "auto",
61
- paddingLeft: "4px",
62
61
  background: theme?.palette?.editor?.background,
63
62
  paddingLeft: "4px",
64
63
  "& .MuiTypography-root, .MuiInputBase-root, input": {
@@ -75,13 +75,12 @@ const VirtualElement = props => {
75
75
  const virtualRef = useRef();
76
76
  useEffect(() => {
77
77
  if (virtualRef?.current) {
78
- const timeoutId = setTimeout(() => {
78
+ setTimeout(() => {
79
79
  const allData = calculateProps(path, virtualRef?.current, ROOT_ITEM_CLASS, []);
80
80
  const groupData = groupByPathAndCalculateHeight(allData);
81
81
  // it should trigger by auto alignment or on clicking mobile view change
82
82
  updateAutoProps(editor, allData, "xs", groupData);
83
83
  }, 100);
84
- return () => clearTimeout(timeoutId);
85
84
  }
86
85
  }, [updated_at, virtualRef?.current]);
87
86
  const calculateProps = (curPath, dom, domClass, allData) => {
@@ -287,22 +287,18 @@ export const bringItemToFB = (editor, {
287
287
  };
288
288
  export const debounce = function (func, wait, immediate) {
289
289
  let timeout;
290
- function debounced(...args) {
291
- const context = this;
292
- const later = function () {
293
- timeout = null;
294
- if (!immediate) func.apply(context, args);
295
- };
296
- const callNow = immediate && !timeout;
290
+ return function () {
291
+ const context = this,
292
+ args = arguments,
293
+ later = function () {
294
+ timeout = null;
295
+ if (!immediate) func.apply(context, args);
296
+ },
297
+ callNow = immediate && !timeout;
297
298
  clearTimeout(timeout);
298
299
  timeout = setTimeout(later, wait);
299
300
  if (callNow) func.apply(context, args);
300
- }
301
- debounced.cancel = function () {
302
- clearTimeout(timeout);
303
- timeout = null;
304
301
  };
305
- return debounced;
306
302
  };
307
303
  export const getTextColor = (color = "") => {
308
304
  return color?.indexOf("gradient") >= 0 ? {
@@ -341,14 +337,14 @@ export const isCarouselSelected = editor => {
341
337
  return false;
342
338
  }
343
339
  const [nodeEntry] = Editor.nodes(editor, {
344
- match: n => !Editor.isEditor(n) && Element.isElement(n) && n.type === "carousel"
340
+ match: n => !Editor.isEditor(n) && Element.isElement(n) && n.type === 'carousel'
345
341
  });
346
342
  if (!nodeEntry) {
347
343
  return false;
348
344
  }
349
345
  const [node] = nodeEntry;
350
346
  const carouselDom = ReactEditor.toDOMNode(editor, node);
351
- const isEdit = carouselDom.classList.contains("carousel_slider_edit");
347
+ const isEdit = carouselDom.classList.contains('carousel_slider_edit');
352
348
  return !isEdit;
353
349
  } catch (err) {
354
350
  console.log(err);
@@ -1,20 +1,26 @@
1
- import { useCallback, useEffect, useState } from "react";
1
+ import { useEffect, useState } from "react";
2
2
  const useDrag = () => {
3
3
  const [event, setEvent] = useState("");
4
4
  useEffect(() => {
5
- const onMouseDown = () => {
6
- setEvent("start");
7
- };
8
- const onMouseUp = () => {
9
- setEvent("end");
10
- };
11
- document.addEventListener("pointerdown", onMouseDown);
12
- document.addEventListener("pointerup", onMouseUp);
5
+ addListener();
13
6
  return () => {
14
- document.removeEventListener("pointerdown", onMouseDown);
15
- document.removeEventListener("pointerup", onMouseUp);
7
+ removeListener();
16
8
  };
17
9
  }, []);
10
+ const onMouseDown = () => {
11
+ setEvent("start");
12
+ };
13
+ const onMouseUp = () => {
14
+ setEvent("end");
15
+ };
16
+ const addListener = () => {
17
+ document.addEventListener("pointerdown", onMouseDown);
18
+ document.addEventListener("pointerup", onMouseUp);
19
+ };
20
+ const removeListener = () => {
21
+ document.removeEventListener("pointerdown", onMouseDown);
22
+ document.removeEventListener("pointerup", onMouseUp);
23
+ };
18
24
  return [event];
19
25
  };
20
26
  export default useDrag;
@@ -3,18 +3,22 @@ function useEditorScroll(editorWrapper = {
3
3
  current: null
4
4
  }, callback) {
5
5
  useEffect(() => {
6
- if (!editorWrapper?.current) return;
7
6
  const handleScroll = () => {
8
- console.log("Editor debug useEditorScroll ====>", editorWrapper, callback);
9
- callback("scroll");
7
+ if (editorWrapper.current) {
8
+ callback("scroll");
9
+ }
10
10
  };
11
11
  const currentEditorWrapper = editorWrapper.current;
12
- currentEditorWrapper.addEventListener("scroll", handleScroll);
12
+ if (currentEditorWrapper) {
13
+ currentEditorWrapper.addEventListener("scroll", handleScroll);
14
+ }
13
15
 
14
16
  // Cleanup the event listener on component unmount
15
17
  return () => {
16
- currentEditorWrapper.removeEventListener("scroll", handleScroll);
18
+ if (currentEditorWrapper) {
19
+ currentEditorWrapper.removeEventListener("scroll", handleScroll);
20
+ }
17
21
  };
18
- }, [editorWrapper, callback]);
22
+ }, [editorWrapper.current, callback]);
19
23
  }
20
24
  export default useEditorScroll;
@@ -1,4 +1,4 @@
1
- import { useEffect, useState, createContext, useContext, useMemo, useCallback } from "react";
1
+ import { useEffect, useState, createContext, useContext, useMemo } from "react";
2
2
  import { getSelectedText } from "../utils/helper";
3
3
  import { debounce } from "../helper";
4
4
  import { defaultFontFamilies } from "../common/FontLoader/FontList";
@@ -115,7 +115,13 @@ const useMouseMove = dragging => {
115
115
  const [event, setEvent] = useState({
116
116
  target: null
117
117
  });
118
- const onMouseMove = useCallback(debounce(e => {
118
+ useEffect(() => {
119
+ addListener();
120
+ return () => {
121
+ removeListener();
122
+ };
123
+ }, []);
124
+ const onMouseMove = e => {
119
125
  if (!dragging?.id) {
120
126
  const dpath = e?.target?.closest(".dpath");
121
127
  if (dpath) {
@@ -124,14 +130,14 @@ const useMouseMove = dragging => {
124
130
  });
125
131
  }
126
132
  }
127
- }, 100), [dragging]);
128
- useEffect(() => {
129
- document.addEventListener("mousemove", onMouseMove);
130
- return () => {
131
- document.removeEventListener("mousemove", onMouseMove);
132
- onMouseMove.cancel(); // Cancel any pending debounced calls
133
- };
134
- }, [onMouseMove]);
133
+ };
134
+ const debounceMouseMove = debounce(onMouseMove, 100);
135
+ const addListener = () => {
136
+ document.addEventListener("mousemove", debounceMouseMove);
137
+ };
138
+ const removeListener = () => {
139
+ document.removeEventListener("mousemove", debounceMouseMove);
140
+ };
135
141
  return [event];
136
142
  };
137
143
  export default useMouseMove;
@@ -184,7 +184,7 @@ export const TableProvider = ({
184
184
  window.removeEventListener("copy", handleCopy);
185
185
  window.removeEventListener("cut", handleCut);
186
186
  };
187
- }, [tableSelection, editor]);
187
+ }, [tableSelection, editor, tableSelection]);
188
188
 
189
189
  // useEffect(() => {
190
190
  // selectFirstCell(tablePath, editor, updateTableSelection);
@@ -149,7 +149,6 @@ const getFocusedNode = (editor, nodeType = "") => {
149
149
  console.log(err);
150
150
  }
151
151
  };
152
- const voidTypes = ["image", "page-settings"];
153
152
  const withHtml = editor => {
154
153
  const {
155
154
  insertData,
@@ -160,7 +159,7 @@ const withHtml = editor => {
160
159
  return element.type === "link" ? true : isInline(element);
161
160
  };
162
161
  editor.isVoid = element => {
163
- return voidTypes.includes(element.type) ? true : isVoid(element);
162
+ return element.type === "image" ? true : isVoid(element);
164
163
  };
165
164
  editor.insertData = data => {
166
165
  const slateHTML = data?.getData("application/x-slate-fragment");
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@flozy/editor",
3
- "version": "9.2.1",
3
+ "version": "9.2.2",
4
4
  "description": "An Editor for flozy app brain",
5
5
  "files": [
6
6
  "dist"
@@ -61,7 +61,7 @@
61
61
  "scripts": {
62
62
  "prepare": "husky install .husky",
63
63
  "analyze": "source-map-explorer build/static/js/*.js",
64
- "lint": "./node_modules/. bin/eslint --ignore-path .gitignore .",
64
+ "lint": "./node_modules/.bin/eslint --ignore-path .gitignore .",
65
65
  "start": "craco start",
66
66
  "build": "NODE_OPTIONS='--max_old_space_size=4096' craco build",
67
67
  "test": "craco test --passWithNoTests",