@flozy/editor 6.0.4 → 6.0.6
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.
@@ -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,8 +34,12 @@ 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);
|
41
44
|
if (isHavingSelection) {
|
42
45
|
const domRange = ReactEditor.toDOMRange(editor, editor.selection);
|
@@ -56,7 +59,7 @@ const PopupTool = props => {
|
|
56
59
|
} catch (err) {
|
57
60
|
console.log(err);
|
58
61
|
}
|
59
|
-
}, [selection]);
|
62
|
+
}, [editor?.selection]);
|
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
|
@@ -71,12 +74,12 @@ const PopupTool = props => {
|
|
71
74
|
if (!isCarouselEdit) {
|
72
75
|
setOpen(true);
|
73
76
|
setPopupType("textFormat");
|
74
|
-
setIsTextSelected(true);
|
77
|
+
// setIsTextSelected(true);
|
75
78
|
}
|
76
79
|
} else if (!anchorEl) {
|
77
80
|
setOpen(false);
|
78
81
|
setPopupType("");
|
79
|
-
setIsTextSelected(false);
|
82
|
+
// setIsTextSelected(false);
|
80
83
|
}
|
81
84
|
}, [event, anchorEl]);
|
82
85
|
useEffect(() => {
|
@@ -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;
|
@@ -1,4 +1,4 @@
|
|
1
|
-
import { Editor, Transforms, Element as SlateElement } from "slate";
|
1
|
+
import { Editor, Transforms, Element as SlateElement, Range } from "slate";
|
2
2
|
import { Box } from "@mui/material";
|
3
3
|
import { sizeMap } from "./font";
|
4
4
|
import Link from "../Elements/Link/Link";
|
@@ -38,7 +38,7 @@ import { getBreakPointsValue, groupByBreakpoint } from "../helper/theme";
|
|
38
38
|
import Variables from "../Elements/Variables/Variable";
|
39
39
|
import insertNewLine from "./insertNewLine";
|
40
40
|
import Divider from "../Elements/Divider/Divider";
|
41
|
-
import { getBorderColor } from "./helper";
|
41
|
+
import { getBorderColor, getSlateDom } from "./helper";
|
42
42
|
import Code from "../Elements/EmbedScript/Code";
|
43
43
|
import FreeGrid from "../Elements/FreeGrid/FreeGrid";
|
44
44
|
import FreeGridItem from "../Elements/FreeGrid/FreeGridItem";
|
@@ -155,13 +155,23 @@ export const activeMark = (editor, format) => {
|
|
155
155
|
const defaultMarkData = {
|
156
156
|
color: "#000000",
|
157
157
|
bgColor: "#FFFFFF",
|
158
|
-
fontSize: "
|
158
|
+
fontSize: "14px",
|
159
159
|
fontFamily: "PoppinsRegular",
|
160
160
|
fontWeight: "normal"
|
161
161
|
};
|
162
162
|
try {
|
163
163
|
const marks = Editor.marks(editor);
|
164
|
-
|
164
|
+
let defaultValue = defaultMarkData[format];
|
165
|
+
const {
|
166
|
+
selection
|
167
|
+
} = editor || {};
|
168
|
+
if (format === "fontSize" && selection && !Range.isCollapsed(selection)) {
|
169
|
+
const slateDom = getSlateDom(editor, editor?.selection);
|
170
|
+
if (slateDom) {
|
171
|
+
const parentElement = slateDom.commonAncestorContainer.parentElement;
|
172
|
+
defaultValue = window.getComputedStyle(parentElement).fontSize;
|
173
|
+
}
|
174
|
+
}
|
165
175
|
return marks?.[format] ?? defaultValue;
|
166
176
|
} catch (err) {
|
167
177
|
console.log(err);
|