@flozy/editor 9.0.1 → 9.0.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.
- package/dist/Editor/Editor.css +2 -2
- package/dist/Editor/Elements/Color Picker/ColorPicker.js +5 -3
- package/dist/Editor/Toolbar/PopupTool/index.js +21 -6
- package/dist/Editor/common/ImageSelector/Options/Upload.js +1 -1
- package/dist/Editor/common/ImageSelector/UploadStyles.js +10 -10
- package/dist/Editor/common/RnD/ElementSettings/styles.js +1 -0
- package/dist/Editor/hooks/useDrag.js +11 -17
- package/dist/Editor/hooks/useEditorScroll.js +1 -0
- package/package.json +2 -2
package/dist/Editor/Editor.css
CHANGED
@@ -43,19 +43,21 @@ const ColorPicker = props => {
|
|
43
43
|
};
|
44
44
|
const handleFormSubmit = color => {
|
45
45
|
if (!color) return;
|
46
|
-
selection && Transforms.select(editor, selection);
|
46
|
+
// selection && Transforms.select(editor, selection);
|
47
47
|
addMarkData(editor, {
|
48
48
|
format,
|
49
49
|
value: color
|
50
50
|
});
|
51
|
-
selection && ReactEditor.focus(editor);
|
52
|
-
handleClose();
|
51
|
+
// selection && ReactEditor.focus(editor);
|
52
|
+
// handleClose();
|
53
53
|
};
|
54
|
+
|
54
55
|
const onSelect = color => {
|
55
56
|
handleFormSubmit(color);
|
56
57
|
};
|
57
58
|
const handleClose = () => {
|
58
59
|
setAnchorEl(null);
|
60
|
+
setSelection(null);
|
59
61
|
};
|
60
62
|
const activeColor = activeMark(editor, format) || DEFAULT_COLOR[format];
|
61
63
|
return /*#__PURE__*/_jsxs(_Fragment, {
|
@@ -14,7 +14,6 @@ import { jsx as _jsx } from "react/jsx-runtime";
|
|
14
14
|
const PopupTool = props => {
|
15
15
|
const {
|
16
16
|
theme,
|
17
|
-
setIsTextSelected,
|
18
17
|
customProps,
|
19
18
|
editorWrapper
|
20
19
|
} = props;
|
@@ -35,9 +34,14 @@ const PopupTool = props => {
|
|
35
34
|
const {
|
36
35
|
selectedElement
|
37
36
|
} = useEditorContext();
|
37
|
+
console.log("Editor debug ====>", event, open, anchorEl, selection);
|
38
38
|
const updateAnchorEl = useCallback(() => {
|
39
39
|
try {
|
40
|
+
const {
|
41
|
+
selection
|
42
|
+
} = editor;
|
40
43
|
const isHavingSelection = selection && !Range.isCollapsed(selection);
|
44
|
+
console.log("Editor isHavingSelection", isHavingSelection, selection);
|
41
45
|
if (isHavingSelection) {
|
42
46
|
const domRange = ReactEditor.toDOMRange(editor, editor.selection);
|
43
47
|
const editorContainer = document.querySelector("#slate-wrapper-scroll-container")?.getBoundingClientRect();
|
@@ -47,6 +51,7 @@ const PopupTool = props => {
|
|
47
51
|
rect.y = -500; // hide the popper
|
48
52
|
}
|
49
53
|
|
54
|
+
console.log("Editor setAnchorEl", rect, domRange, editorContainer);
|
50
55
|
setAnchorEl({
|
51
56
|
clientWidth: rect.width,
|
52
57
|
clientHeight: rect.height,
|
@@ -56,7 +61,7 @@ const PopupTool = props => {
|
|
56
61
|
} catch (err) {
|
57
62
|
console.log(err);
|
58
63
|
}
|
59
|
-
}, [selection]);
|
64
|
+
}, [editor?.selection]);
|
60
65
|
useEditorScroll(editorWrapper, updateAnchorEl);
|
61
66
|
useEffect(() => {
|
62
67
|
const userStoppedSelection = size?.device === "xs" ? true : event === "end"; // for mobile, when user starts the selection, we are gonna show the popup tool
|
@@ -71,34 +76,44 @@ const PopupTool = props => {
|
|
71
76
|
if (!isCarouselEdit) {
|
72
77
|
setOpen(true);
|
73
78
|
setPopupType("textFormat");
|
74
|
-
setIsTextSelected(true);
|
79
|
+
// setIsTextSelected(true);
|
75
80
|
}
|
76
81
|
} else if (!anchorEl) {
|
77
82
|
setOpen(false);
|
78
83
|
setPopupType("");
|
79
|
-
setIsTextSelected(false);
|
84
|
+
// setIsTextSelected(false);
|
80
85
|
}
|
81
86
|
}, [event, anchorEl]);
|
82
87
|
useEffect(() => {
|
88
|
+
console.log("Editor useEffect", selection);
|
83
89
|
if (!selection || Range.isCollapsed(selection) || Editor.string(editor, selection) === "") {
|
84
90
|
setAnchorEl(null);
|
85
91
|
} else {
|
92
|
+
console.log("Editor updateAnchorEl", selection);
|
86
93
|
updateAnchorEl();
|
87
94
|
hideSlateSelection(); // removes slate selection background, when there is no selection
|
88
95
|
}
|
89
|
-
}, [selection]);
|
96
|
+
}, [editor?.selection]);
|
90
97
|
useEffect(() => {
|
91
|
-
|
98
|
+
const {
|
99
|
+
path,
|
100
|
+
enable
|
101
|
+
} = selectedElement || {};
|
102
|
+
const isFreeGridElement = path && path.split("|").length > 2;
|
103
|
+
if (enable === 1 && isFreeGridElement) {
|
104
|
+
console.log("Editor useEffect isFreeGridElement", selectedElement);
|
92
105
|
setAnchorEl(null);
|
93
106
|
}
|
94
107
|
}, [selection, selectedElement?.path, selectedElement?.enable]);
|
95
108
|
const handleClose = () => {
|
109
|
+
console.log("Editor closing");
|
96
110
|
// setAnchorEl(null);
|
97
111
|
setOpen(false);
|
98
112
|
setPopupType("");
|
99
113
|
};
|
100
114
|
return open && !openAI ? /*#__PURE__*/_jsx(ClickAwayListener, {
|
101
115
|
onClickAway: e => {
|
116
|
+
console.log("ClickAwayListener", e.target, document.body, e.target !== document.body);
|
102
117
|
// close the mini toolbar, if user clicks outside the editor (in Flozy app.)
|
103
118
|
if (e.target !== document.body) {
|
104
119
|
// 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
|
@@ -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:
|
9
|
-
minHeight:
|
10
|
-
height:
|
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:
|
22
|
+
minHeight: "150px"
|
23
23
|
},
|
24
24
|
uploadIcon: {
|
25
25
|
display: "grid !important",
|
26
26
|
"& svg": {
|
27
|
-
display:
|
28
|
-
width:
|
27
|
+
display: "flex",
|
28
|
+
width: "100%",
|
29
29
|
"& path": {
|
30
30
|
stroke: "#2563EB"
|
31
31
|
}
|
32
32
|
},
|
33
|
-
|
34
|
-
display:
|
35
|
-
width:
|
36
|
-
marginTop:
|
33
|
+
"& span": {
|
34
|
+
display: "flex",
|
35
|
+
width: "100%",
|
36
|
+
marginTop: "5px"
|
37
37
|
}
|
38
38
|
}
|
39
39
|
});
|
@@ -58,6 +58,7 @@ const useElementSettingsStyle = theme => ({
|
|
58
58
|
maxHeight: "500px",
|
59
59
|
overflowX: "hidden",
|
60
60
|
overflowY: "auto",
|
61
|
+
paddingLeft: "4px",
|
61
62
|
background: theme?.palette?.editor?.background,
|
62
63
|
paddingLeft: "4px",
|
63
64
|
"& .MuiTypography-root, .MuiInputBase-root, input": {
|
@@ -1,26 +1,20 @@
|
|
1
|
-
import { useEffect, useState } from "react";
|
1
|
+
import { useCallback, useEffect, useState } from "react";
|
2
2
|
const useDrag = () => {
|
3
3
|
const [event, setEvent] = useState("");
|
4
|
-
|
5
|
-
addListener();
|
6
|
-
return () => {
|
7
|
-
removeListener();
|
8
|
-
};
|
9
|
-
}, []);
|
10
|
-
const onMouseDown = () => {
|
4
|
+
const onMouseDown = useCallback(() => {
|
11
5
|
setEvent("start");
|
12
|
-
};
|
13
|
-
const onMouseUp = () => {
|
6
|
+
}, []);
|
7
|
+
const onMouseUp = useCallback(() => {
|
14
8
|
setEvent("end");
|
15
|
-
};
|
16
|
-
|
9
|
+
}, []);
|
10
|
+
useEffect(() => {
|
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;
|
package/package.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "@flozy/editor",
|
3
|
-
"version": "9.0.
|
3
|
+
"version": "9.0.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",
|