@flozy/editor 1.8.6 → 1.8.7
Sign up to get free protection for your applications and to get access to all the features.
- package/dist/Editor/Elements/Embed/Image.js +1 -1
- package/dist/Editor/Styles/EditorStyles.js +9 -1
- package/dist/Editor/common/DnD/DragHandle.js +2 -3
- package/dist/Editor/common/DnD/DragHandleButton.js +100 -0
- package/dist/Editor/common/DnD/Droppable.js +2 -2
- package/dist/Editor/common/Section/index.js +16 -2
- package/dist/Editor/utils/SlateUtilityFunctions.js +5 -0
- package/dist/Editor/utils/events.js +6 -1
- package/package.json +1 -1
@@ -63,7 +63,7 @@ const Image = ({
|
|
63
63
|
const selected = hoverPath === path.join(",");
|
64
64
|
useEffect(() => {
|
65
65
|
if (editor && ele && ele[1] !== undefined) {
|
66
|
-
const dom = ReactEditor.toDOMNode(editor,
|
66
|
+
const dom = ReactEditor.toDOMNode(editor, element);
|
67
67
|
setParentDOM(dom);
|
68
68
|
onLoad(element?.size || {});
|
69
69
|
}
|
@@ -103,7 +103,15 @@ const editorStyles = ({
|
|
103
103
|
display: "block",
|
104
104
|
left: "8px",
|
105
105
|
top: "8px",
|
106
|
-
width: "fit-content"
|
106
|
+
width: "fit-content",
|
107
|
+
"& button": {
|
108
|
+
boxShadow: "none",
|
109
|
+
color: "rgb(85, 85, 85)",
|
110
|
+
background: "rgb(221, 221, 221, 0.1)",
|
111
|
+
"&:hover": {
|
112
|
+
background: "rgb(221, 221, 221, 0.8)"
|
113
|
+
}
|
114
|
+
}
|
107
115
|
}
|
108
116
|
},
|
109
117
|
"&.hselect:before": {
|
@@ -12,7 +12,7 @@ const DragHandleStyle = () => ({
|
|
12
12
|
root: {
|
13
13
|
position: "relative",
|
14
14
|
"&:hover": {
|
15
|
-
"& > .dh-para:first-
|
15
|
+
"& > .dh-para:first-of-type": {
|
16
16
|
opacity: 1
|
17
17
|
}
|
18
18
|
},
|
@@ -74,7 +74,6 @@ const DragHandle = props => {
|
|
74
74
|
if (moved) {
|
75
75
|
const upPath = ReactEditor.findPath(editor, element);
|
76
76
|
try {
|
77
|
-
alert(upPath);
|
78
77
|
Transforms.removeNodes(editor, {
|
79
78
|
at: upPath
|
80
79
|
});
|
@@ -89,7 +88,7 @@ const DragHandle = props => {
|
|
89
88
|
return canDraggable ? /*#__PURE__*/_jsxs(Box, {
|
90
89
|
...attributes,
|
91
90
|
component: "div",
|
92
|
-
className:
|
91
|
+
className: `drag-wrpr ${dragging ? "dragging" : ""}`,
|
93
92
|
sx: classes.root,
|
94
93
|
children: [/*#__PURE__*/_jsx(Droppable, {
|
95
94
|
id: id,
|
@@ -0,0 +1,100 @@
|
|
1
|
+
import React, { useEffect, useState } from "react";
|
2
|
+
import { ReactEditor, useSlateStatic } from "slate-react";
|
3
|
+
import { Box } from "@mui/material";
|
4
|
+
import Draggable from "./Draggable";
|
5
|
+
import Droppable from "./Droppable";
|
6
|
+
import { useEditorContext } from "../../hooks/useMouseMove";
|
7
|
+
import { Transforms } from "slate";
|
8
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
9
|
+
import { jsxs as _jsxs } from "react/jsx-runtime";
|
10
|
+
const DRAGGABLE_TYPES = ["paragraph", "headingOne", "headinTwo", "headingThree", "grid"];
|
11
|
+
const DragHandleStyle = () => ({
|
12
|
+
dragHandle: {
|
13
|
+
opacity: 0,
|
14
|
+
content: '" "',
|
15
|
+
position: "absolute",
|
16
|
+
top: "2px",
|
17
|
+
left: "-52px",
|
18
|
+
borderRadius: "0px",
|
19
|
+
padding: "0px",
|
20
|
+
width: "20px",
|
21
|
+
height: "20px",
|
22
|
+
border: 0,
|
23
|
+
display: "flex",
|
24
|
+
alignItems: "center",
|
25
|
+
justifyContent: "center",
|
26
|
+
cursor: "grab",
|
27
|
+
color: "rgb(85, 85, 85)",
|
28
|
+
background: "rgb(221, 221, 221, 0.1)",
|
29
|
+
"& svg": {
|
30
|
+
width: "20px"
|
31
|
+
},
|
32
|
+
"&:hover": {
|
33
|
+
opacity: 1,
|
34
|
+
background: "rgb(221, 221, 221, 0.8)"
|
35
|
+
},
|
36
|
+
"&.active": {
|
37
|
+
opacity: 1,
|
38
|
+
cursor: "grabbing"
|
39
|
+
}
|
40
|
+
},
|
41
|
+
dropArea: {
|
42
|
+
position: "absolute",
|
43
|
+
left: 0,
|
44
|
+
top: 0,
|
45
|
+
width: "100%",
|
46
|
+
height: "100%",
|
47
|
+
"&.dragging": {
|
48
|
+
backgroundColor: "#def4ff"
|
49
|
+
}
|
50
|
+
},
|
51
|
+
dropAreaOver: {
|
52
|
+
height: "4px"
|
53
|
+
}
|
54
|
+
});
|
55
|
+
const DragHandle = props => {
|
56
|
+
const classes = DragHandleStyle();
|
57
|
+
const editor = useSlateStatic();
|
58
|
+
const [dragging, setDragging] = useState(false);
|
59
|
+
const {
|
60
|
+
element
|
61
|
+
} = props;
|
62
|
+
const path = ReactEditor.findPath(editor, element);
|
63
|
+
const canDraggable = DRAGGABLE_TYPES.indexOf(element?.type) > -1;
|
64
|
+
const id = `${element.type}_${[...path].join("|")}`;
|
65
|
+
const {
|
66
|
+
moved
|
67
|
+
} = element;
|
68
|
+
const {
|
69
|
+
drop
|
70
|
+
} = useEditorContext();
|
71
|
+
useEffect(() => {
|
72
|
+
if (moved) {
|
73
|
+
const upPath = ReactEditor.findPath(editor, element);
|
74
|
+
try {
|
75
|
+
Transforms.removeNodes(editor, {
|
76
|
+
at: upPath
|
77
|
+
});
|
78
|
+
} catch (err) {
|
79
|
+
console.log(err, upPath);
|
80
|
+
}
|
81
|
+
}
|
82
|
+
}, [moved]);
|
83
|
+
const handleOnDrag = isDragging => {
|
84
|
+
setDragging(isDragging);
|
85
|
+
};
|
86
|
+
return canDraggable ? /*#__PURE__*/_jsxs("div", {
|
87
|
+
children: [/*#__PURE__*/_jsx(Box, {
|
88
|
+
className: dragging ? "dragging" : "",
|
89
|
+
sx: classes.dropArea
|
90
|
+
}), /*#__PURE__*/_jsx(Droppable, {
|
91
|
+
id: id,
|
92
|
+
classes: classes
|
93
|
+
}), /*#__PURE__*/_jsx(Draggable, {
|
94
|
+
id: id,
|
95
|
+
classes: classes,
|
96
|
+
onDrag: handleOnDrag
|
97
|
+
})]
|
98
|
+
}, `${id}_${drop}`) : null;
|
99
|
+
};
|
100
|
+
export default DragHandle;
|
@@ -14,7 +14,7 @@ const Droppable = props => {
|
|
14
14
|
id: id
|
15
15
|
});
|
16
16
|
const dropStyle = {
|
17
|
-
backgroundColor: isOver ? "
|
17
|
+
backgroundColor: isOver ? "#47bbf5" : undefined
|
18
18
|
};
|
19
19
|
return /*#__PURE__*/_jsx(Box, {
|
20
20
|
ref: setNodeRef,
|
@@ -22,7 +22,7 @@ const Droppable = props => {
|
|
22
22
|
className: `droppable-para`,
|
23
23
|
contentEditable: false,
|
24
24
|
style: dropStyle,
|
25
|
-
sx: classes.
|
25
|
+
sx: classes.dropAreaOver
|
26
26
|
});
|
27
27
|
};
|
28
28
|
export default Droppable;
|
@@ -5,9 +5,20 @@ import { Box, IconButton, Tooltip } from "@mui/material";
|
|
5
5
|
import TuneIcon from "@mui/icons-material/Tune";
|
6
6
|
import SectionPopup from "../../Elements/Grid/SectionPopup";
|
7
7
|
import { getBreakPointsValue, getTRBLBreakPoints } from "../../helper/theme";
|
8
|
+
import DragHandle from "../DnD/DragHandleButton";
|
8
9
|
import { jsx as _jsx } from "react/jsx-runtime";
|
9
10
|
import { jsxs as _jsxs } from "react/jsx-runtime";
|
11
|
+
const SectionStyle = () => ({
|
12
|
+
root: {
|
13
|
+
"&:hover": {
|
14
|
+
"& .dh-para": {
|
15
|
+
opacity: 1
|
16
|
+
}
|
17
|
+
}
|
18
|
+
}
|
19
|
+
});
|
10
20
|
const Section = props => {
|
21
|
+
const classes = SectionStyle();
|
11
22
|
const {
|
12
23
|
children,
|
13
24
|
element,
|
@@ -47,7 +58,7 @@ const Section = props => {
|
|
47
58
|
className: "element-toolbar no-border-button ss hr section-tw",
|
48
59
|
style: {
|
49
60
|
left: "-28px",
|
50
|
-
top: "
|
61
|
+
top: "2px"
|
51
62
|
},
|
52
63
|
children: /*#__PURE__*/_jsx(Tooltip, {
|
53
64
|
title: "Section Settings",
|
@@ -86,6 +97,7 @@ const Section = props => {
|
|
86
97
|
component: "section",
|
87
98
|
className: `ed-section-wrapper ${readOnly ? "" : "hselect"} ${needHover}`,
|
88
99
|
sx: {
|
100
|
+
...classes.root,
|
89
101
|
background: sectionBgColor,
|
90
102
|
...sectionBgImage,
|
91
103
|
padding: {
|
@@ -104,7 +116,9 @@ const Section = props => {
|
|
104
116
|
...getBreakPointsValue(sectionGridSize || 8, null, "overrideGridSize", true)
|
105
117
|
}
|
106
118
|
},
|
107
|
-
children: [
|
119
|
+
children: [/*#__PURE__*/_jsx(DragHandle, {
|
120
|
+
...props
|
121
|
+
}), children, /*#__PURE__*/_jsx(Toolbar, {})]
|
108
122
|
}), openSetttings ? /*#__PURE__*/_jsx(SectionPopup, {
|
109
123
|
element: {
|
110
124
|
...element,
|
@@ -37,6 +37,7 @@ import { isEmptyTextNode } from "../helper";
|
|
37
37
|
import Attachments from "../Elements/Attachments/Attachments";
|
38
38
|
import { getBreakPointsValue } from "../helper/theme";
|
39
39
|
import Variables from "../Elements/Variables/Variable";
|
40
|
+
import insertNewLine from "./insertNewLine";
|
40
41
|
import { jsx as _jsx } from "react/jsx-runtime";
|
41
42
|
const alignment = ["alignLeft", "alignRight", "alignCenter"];
|
42
43
|
const list_types = ["orderedList", "unorderedList"];
|
@@ -44,6 +45,7 @@ const LIST_FORMAT_TYPE = {
|
|
44
45
|
orderedList: "list-item",
|
45
46
|
unorderedList: "list-item"
|
46
47
|
};
|
48
|
+
const NEWLINESAFTER = ["headingOne", "headingTwo", "headingThree"];
|
47
49
|
export const toggleBlock = (editor, format, selection = true, attr = {}) => {
|
48
50
|
const isActive = isBlockActive(editor, format);
|
49
51
|
const isList = list_types.includes(format);
|
@@ -86,6 +88,9 @@ export const toggleBlock = (editor, format, selection = true, attr = {}) => {
|
|
86
88
|
children: []
|
87
89
|
});
|
88
90
|
}
|
91
|
+
if (NEWLINESAFTER.indexOf(format) > -1) {
|
92
|
+
insertNewLine(editor);
|
93
|
+
}
|
89
94
|
};
|
90
95
|
export const addMarkData = (editor, data) => {
|
91
96
|
try {
|
@@ -127,7 +127,12 @@ export const escapeEvent = props => {
|
|
127
127
|
};
|
128
128
|
export const enterEvent = (e, editor, ele) => {
|
129
129
|
try {
|
130
|
-
|
130
|
+
// on shift enter break line in same node
|
131
|
+
if (e.shiftKey) {
|
132
|
+
console.log("shif enter");
|
133
|
+
e.preventDefault();
|
134
|
+
Transforms.insertText(editor, "\n");
|
135
|
+
} else if (ele && ele[0]) {
|
131
136
|
const {
|
132
137
|
type
|
133
138
|
} = ele[0];
|