@flozy/editor 9.2.2 → 9.2.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.
- package/dist/Editor/Elements/Table/TableCell.js +2 -1
- package/dist/Editor/Toolbar/PopupTool/index.js +7 -1
- package/dist/Editor/common/RnD/VirtualElement/index.js +2 -1
- package/dist/Editor/helper/index.js +14 -10
- package/dist/Editor/hooks/useDrag.js +10 -16
- package/dist/Editor/hooks/useEditorScroll.js +5 -10
- package/dist/Editor/hooks/useMouseMove.js +10 -16
- package/dist/Editor/hooks/useTable.js +1 -1
- package/package.json +1 -1
@@ -155,7 +155,7 @@ const TableCell = props => {
|
|
155
155
|
};
|
156
156
|
useEffect(() => {
|
157
157
|
const currentPath = path?.toString();
|
158
|
-
setTimeout(() => {
|
158
|
+
const timeoutId = setTimeout(() => {
|
159
159
|
if (tableResizing === currentPath) {
|
160
160
|
setTableResizing(null);
|
161
161
|
|
@@ -171,6 +171,7 @@ const TableCell = props => {
|
|
171
171
|
if (resizing) {
|
172
172
|
setTableResizing(currentPath);
|
173
173
|
}
|
174
|
+
return () => clearTimeout(timeoutId);
|
174
175
|
}, [resizing]);
|
175
176
|
const onMouseEnter = path => {
|
176
177
|
setHoverPath(path);
|
@@ -83,7 +83,13 @@ const PopupTool = props => {
|
|
83
83
|
}
|
84
84
|
}, [event, anchorEl]);
|
85
85
|
useEffect(() => {
|
86
|
-
|
86
|
+
const {
|
87
|
+
path,
|
88
|
+
enable
|
89
|
+
} = selectedElement || {};
|
90
|
+
const isFreeGridElement = path && path.split("|").length > 2;
|
91
|
+
const isFreeGridEnabled = enable === 1 && isFreeGridElement;
|
92
|
+
if (!selection || Range.isCollapsed(selection) || Editor.string(editor, selection) === "" || isFreeGridEnabled) {
|
87
93
|
setAnchorEl(null);
|
88
94
|
} else {
|
89
95
|
updateAnchorEl();
|
@@ -75,12 +75,13 @@ const VirtualElement = props => {
|
|
75
75
|
const virtualRef = useRef();
|
76
76
|
useEffect(() => {
|
77
77
|
if (virtualRef?.current) {
|
78
|
-
setTimeout(() => {
|
78
|
+
const timeoutId = 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);
|
84
85
|
}
|
85
86
|
}, [updated_at, virtualRef?.current]);
|
86
87
|
const calculateProps = (curPath, dom, domClass, allData) => {
|
@@ -287,18 +287,22 @@ export const bringItemToFB = (editor, {
|
|
287
287
|
};
|
288
288
|
export const debounce = function (func, wait, immediate) {
|
289
289
|
let timeout;
|
290
|
-
|
291
|
-
const context = this
|
292
|
-
|
293
|
-
|
294
|
-
|
295
|
-
|
296
|
-
|
297
|
-
callNow = immediate && !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;
|
298
297
|
clearTimeout(timeout);
|
299
298
|
timeout = setTimeout(later, wait);
|
300
299
|
if (callNow) func.apply(context, args);
|
300
|
+
}
|
301
|
+
debounced.cancel = function () {
|
302
|
+
clearTimeout(timeout);
|
303
|
+
timeout = null;
|
301
304
|
};
|
305
|
+
return debounced;
|
302
306
|
};
|
303
307
|
export const getTextColor = (color = "") => {
|
304
308
|
return color?.indexOf("gradient") >= 0 ? {
|
@@ -337,14 +341,14 @@ export const isCarouselSelected = editor => {
|
|
337
341
|
return false;
|
338
342
|
}
|
339
343
|
const [nodeEntry] = Editor.nodes(editor, {
|
340
|
-
match: n => !Editor.isEditor(n) && Element.isElement(n) && n.type ===
|
344
|
+
match: n => !Editor.isEditor(n) && Element.isElement(n) && n.type === "carousel"
|
341
345
|
});
|
342
346
|
if (!nodeEntry) {
|
343
347
|
return false;
|
344
348
|
}
|
345
349
|
const [node] = nodeEntry;
|
346
350
|
const carouselDom = ReactEditor.toDOMNode(editor, node);
|
347
|
-
const isEdit = carouselDom.classList.contains(
|
351
|
+
const isEdit = carouselDom.classList.contains("carousel_slider_edit");
|
348
352
|
return !isEdit;
|
349
353
|
} catch (err) {
|
350
354
|
console.log(err);
|
@@ -2,25 +2,19 @@ import { useEffect, useState } from "react";
|
|
2
2
|
const useDrag = () => {
|
3
3
|
const [event, setEvent] = useState("");
|
4
4
|
useEffect(() => {
|
5
|
-
|
6
|
-
|
7
|
-
|
5
|
+
const onMouseDown = () => {
|
6
|
+
setEvent("start");
|
7
|
+
};
|
8
|
+
const onMouseUp = () => {
|
9
|
+
setEvent("end");
|
8
10
|
};
|
9
|
-
}, []);
|
10
|
-
const onMouseDown = () => {
|
11
|
-
setEvent("start");
|
12
|
-
};
|
13
|
-
const onMouseUp = () => {
|
14
|
-
setEvent("end");
|
15
|
-
};
|
16
|
-
const addListener = () => {
|
17
11
|
document.addEventListener("pointerdown", onMouseDown);
|
18
12
|
document.addEventListener("pointerup", onMouseUp);
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
};
|
13
|
+
return () => {
|
14
|
+
document.removeEventListener("pointerdown", onMouseDown);
|
15
|
+
document.removeEventListener("pointerup", onMouseUp);
|
16
|
+
};
|
17
|
+
}, []);
|
24
18
|
return [event];
|
25
19
|
};
|
26
20
|
export default useDrag;
|
@@ -3,22 +3,17 @@ function useEditorScroll(editorWrapper = {
|
|
3
3
|
current: null
|
4
4
|
}, callback) {
|
5
5
|
useEffect(() => {
|
6
|
+
if (!editorWrapper?.current) return;
|
6
7
|
const handleScroll = () => {
|
7
|
-
|
8
|
-
callback("scroll");
|
9
|
-
}
|
8
|
+
callback("scroll");
|
10
9
|
};
|
11
10
|
const currentEditorWrapper = editorWrapper.current;
|
12
|
-
|
13
|
-
currentEditorWrapper.addEventListener("scroll", handleScroll);
|
14
|
-
}
|
11
|
+
currentEditorWrapper.addEventListener("scroll", handleScroll);
|
15
12
|
|
16
13
|
// Cleanup the event listener on component unmount
|
17
14
|
return () => {
|
18
|
-
|
19
|
-
currentEditorWrapper.removeEventListener("scroll", handleScroll);
|
20
|
-
}
|
15
|
+
currentEditorWrapper.removeEventListener("scroll", handleScroll);
|
21
16
|
};
|
22
|
-
}, [editorWrapper
|
17
|
+
}, [editorWrapper, callback]);
|
23
18
|
}
|
24
19
|
export default useEditorScroll;
|
@@ -1,4 +1,4 @@
|
|
1
|
-
import { useEffect, useState, createContext, useContext, useMemo } from "react";
|
1
|
+
import { useEffect, useState, createContext, useContext, useMemo, useCallback } from "react";
|
2
2
|
import { getSelectedText } from "../utils/helper";
|
3
3
|
import { debounce } from "../helper";
|
4
4
|
import { defaultFontFamilies } from "../common/FontLoader/FontList";
|
@@ -115,13 +115,7 @@ const useMouseMove = dragging => {
|
|
115
115
|
const [event, setEvent] = useState({
|
116
116
|
target: null
|
117
117
|
});
|
118
|
-
|
119
|
-
addListener();
|
120
|
-
return () => {
|
121
|
-
removeListener();
|
122
|
-
};
|
123
|
-
}, []);
|
124
|
-
const onMouseMove = e => {
|
118
|
+
const onMouseMove = useCallback(debounce(e => {
|
125
119
|
if (!dragging?.id) {
|
126
120
|
const dpath = e?.target?.closest(".dpath");
|
127
121
|
if (dpath) {
|
@@ -130,14 +124,14 @@ const useMouseMove = dragging => {
|
|
130
124
|
});
|
131
125
|
}
|
132
126
|
}
|
133
|
-
};
|
134
|
-
|
135
|
-
|
136
|
-
|
137
|
-
|
138
|
-
|
139
|
-
|
140
|
-
};
|
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]);
|
141
135
|
return [event];
|
142
136
|
};
|
143
137
|
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]);
|
188
188
|
|
189
189
|
// useEffect(() => {
|
190
190
|
// selectFirstCell(tablePath, editor, updateTableSelection);
|