@flozy/editor 1.9.9 → 2.0.0
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/CommonEditor.js +2 -0
- package/dist/Editor/DialogWrapper.js +7 -2
- package/dist/Editor/Editor.css +1 -1
- package/dist/Editor/Elements/Accordion/Accordion.js +12 -4
- package/dist/Editor/Elements/Accordion/AccordionSummary.js +3 -1
- package/dist/Editor/Elements/Embed/Image.js +3 -2
- package/dist/Editor/Elements/Grid/Grid.js +4 -3
- package/dist/Editor/Elements/Grid/GridItem.js +3 -2
- package/dist/Editor/Elements/Table/Table.js +4 -2
- package/dist/Editor/Elements/Table/TableCell.js +3 -1
- package/dist/Editor/Elements/TopBanner/TopBanner.js +2 -1
- package/dist/Editor/Styles/EditorStyles.js +16 -0
- package/dist/Editor/common/Section/index.js +4 -2
- package/dist/Editor/commonStyle.js +5 -0
- package/dist/Editor/hooks/useMouseMove.js +17 -1
- package/package.json +1 -1
|
@@ -338,7 +338,9 @@ const CommonEditor = /*#__PURE__*/forwardRef((props, ref) => {
|
|
|
338
338
|
};
|
|
339
339
|
return /*#__PURE__*/_jsx(EditorProvider, {
|
|
340
340
|
theme: theme,
|
|
341
|
+
editor: editor,
|
|
341
342
|
children: /*#__PURE__*/_jsx(DialogWrapper, {
|
|
343
|
+
classes: classes,
|
|
342
344
|
...props,
|
|
343
345
|
fullScreen: fullScreen,
|
|
344
346
|
footer: footer || "",
|
|
@@ -9,7 +9,8 @@ const DialogWrapper = props => {
|
|
|
9
9
|
const {
|
|
10
10
|
fullScreen,
|
|
11
11
|
onClose,
|
|
12
|
-
children
|
|
12
|
+
children,
|
|
13
|
+
classes
|
|
13
14
|
} = props;
|
|
14
15
|
return fullScreen ? /*#__PURE__*/_jsxs(Dialog, {
|
|
15
16
|
className: `dialogComp`,
|
|
@@ -19,6 +20,7 @@ const DialogWrapper = props => {
|
|
|
19
20
|
style: {
|
|
20
21
|
zIndex: 1000
|
|
21
22
|
},
|
|
23
|
+
sx: classes.fullScreenWrapper,
|
|
22
24
|
children: [/*#__PURE__*/_jsx(DialogTitle, {
|
|
23
25
|
style: {
|
|
24
26
|
padding: "6px 8px"
|
|
@@ -31,13 +33,16 @@ const DialogWrapper = props => {
|
|
|
31
33
|
},
|
|
32
34
|
children: /*#__PURE__*/_jsx(IconButton, {
|
|
33
35
|
onClick: onClose,
|
|
36
|
+
style: {
|
|
37
|
+
background: "rgba(255,255,255,0.5)"
|
|
38
|
+
},
|
|
34
39
|
children: /*#__PURE__*/_jsx(CloseIcon, {})
|
|
35
40
|
})
|
|
36
41
|
})
|
|
37
42
|
})
|
|
38
43
|
}), /*#__PURE__*/_jsx(DialogContent, {
|
|
39
44
|
style: {
|
|
40
|
-
|
|
45
|
+
paddingTop: "12px"
|
|
41
46
|
},
|
|
42
47
|
children: children
|
|
43
48
|
})]
|
package/dist/Editor/Editor.css
CHANGED
|
@@ -2,10 +2,11 @@ import React, { useState } from "react";
|
|
|
2
2
|
import { Transforms } from "slate";
|
|
3
3
|
import { useSelected, useSlateStatic, ReactEditor } from "slate-react";
|
|
4
4
|
import AccordionBtnPopup from "./AccordionBtnPopup";
|
|
5
|
-
import { IconButton, Tooltip } from "@mui/material";
|
|
5
|
+
import { IconButton, Tooltip, Box } from "@mui/material";
|
|
6
6
|
import DeleteIcon from "@mui/icons-material/Delete";
|
|
7
7
|
import { GridSettingsIcon } from "../../common/iconslist";
|
|
8
8
|
import Icon from "../../common/Icon";
|
|
9
|
+
import { useEditorSelection } from "../../hooks/useMouseMove";
|
|
9
10
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
10
11
|
import { jsxs as _jsxs } from "react/jsx-runtime";
|
|
11
12
|
const Accordion = props => {
|
|
@@ -21,6 +22,7 @@ const Accordion = props => {
|
|
|
21
22
|
const [toggle, setToggle] = useState(false);
|
|
22
23
|
const [openSetttings, setOpenSettings] = useState(false);
|
|
23
24
|
const editor = useSlateStatic();
|
|
25
|
+
const [showTool] = useEditorSelection(editor);
|
|
24
26
|
const selected = useSelected();
|
|
25
27
|
const path = ReactEditor.findPath(editor, element);
|
|
26
28
|
const {
|
|
@@ -31,7 +33,7 @@ const Accordion = props => {
|
|
|
31
33
|
setToggle(!toggle);
|
|
32
34
|
};
|
|
33
35
|
const ToolBar = () => {
|
|
34
|
-
return selected ? /*#__PURE__*/_jsxs("div", {
|
|
36
|
+
return selected && !showTool ? /*#__PURE__*/_jsxs("div", {
|
|
35
37
|
className: "element-toolbar hr",
|
|
36
38
|
contentEditable: false,
|
|
37
39
|
style: {
|
|
@@ -94,13 +96,19 @@ const Accordion = props => {
|
|
|
94
96
|
backgroundColor: bgColor
|
|
95
97
|
},
|
|
96
98
|
onClick: onToggle,
|
|
97
|
-
children: [/*#__PURE__*/_jsx(
|
|
99
|
+
children: [/*#__PURE__*/_jsx(Box, {
|
|
100
|
+
role: "button",
|
|
98
101
|
className: "accordion-summary-collapse-btn",
|
|
99
102
|
contentEditable: false,
|
|
100
103
|
sx: {
|
|
104
|
+
display: "flex",
|
|
105
|
+
alignItems: "center",
|
|
106
|
+
justifyContent: "center",
|
|
107
|
+
userSelect: "none",
|
|
101
108
|
"& svg": {
|
|
102
109
|
fill: textColor
|
|
103
|
-
}
|
|
110
|
+
},
|
|
111
|
+
cursor: "pointer"
|
|
104
112
|
},
|
|
105
113
|
children: !toggle ? /*#__PURE__*/_jsx(Icon, {
|
|
106
114
|
icon: "accordionArrow"
|
|
@@ -4,6 +4,7 @@ import { useSelected, useSlateStatic, ReactEditor } from "slate-react";
|
|
|
4
4
|
import AccordionTitlePopup from "./AccordionTitlePopup";
|
|
5
5
|
import { IconButton, Tooltip } from "@mui/material";
|
|
6
6
|
import { GridSettingsIcon } from "../../common/iconslist";
|
|
7
|
+
import { useEditorSelection } from "../../hooks/useMouseMove";
|
|
7
8
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
8
9
|
import { jsxs as _jsxs } from "react/jsx-runtime";
|
|
9
10
|
const AccordionSummary = props => {
|
|
@@ -18,6 +19,7 @@ const AccordionSummary = props => {
|
|
|
18
19
|
} = customProps;
|
|
19
20
|
const [openSetttings, setOpenSettings] = useState(false);
|
|
20
21
|
const editor = useSlateStatic();
|
|
22
|
+
const [showTool] = useEditorSelection(editor);
|
|
21
23
|
const selected = useSelected();
|
|
22
24
|
const path = ReactEditor.findPath(editor, element);
|
|
23
25
|
const {
|
|
@@ -26,7 +28,7 @@ const AccordionSummary = props => {
|
|
|
26
28
|
borderColor
|
|
27
29
|
} = element;
|
|
28
30
|
const ToolBar = () => {
|
|
29
|
-
return selected ? /*#__PURE__*/_jsx("div", {
|
|
31
|
+
return selected && !showTool ? /*#__PURE__*/_jsx("div", {
|
|
30
32
|
className: "element-toolbar hr",
|
|
31
33
|
contentEditable: false,
|
|
32
34
|
style: {
|
|
@@ -6,7 +6,7 @@ import useResize from "../../utils/customHooks/useResize";
|
|
|
6
6
|
import EmbedPopup from "./EmbedPopup";
|
|
7
7
|
import { IconButton, Tooltip, Box } from "@mui/material";
|
|
8
8
|
import { GridSettingsIcon } from "../../common/iconslist";
|
|
9
|
-
import { useEditorContext } from "../../hooks/useMouseMove";
|
|
9
|
+
import { useEditorContext, useEditorSelection } from "../../hooks/useMouseMove";
|
|
10
10
|
import { getTRBLBreakPoints, getBreakPointsValue } from "../../helper/theme";
|
|
11
11
|
import Icon from "../../common/Icon";
|
|
12
12
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
@@ -48,6 +48,7 @@ const Image = ({
|
|
|
48
48
|
const [parentDOM, setParentDOM] = useState(null);
|
|
49
49
|
const [openSetttings, setOpenSettings] = useState(false);
|
|
50
50
|
const path = ReactEditor.findPath(editor, element);
|
|
51
|
+
const [showTool] = useEditorSelection(editor);
|
|
51
52
|
const getSize = () => {
|
|
52
53
|
if (element?.size === undefined) {
|
|
53
54
|
return {
|
|
@@ -111,7 +112,7 @@ const Image = ({
|
|
|
111
112
|
});
|
|
112
113
|
};
|
|
113
114
|
const ToolBar = () => {
|
|
114
|
-
return selected ? /*#__PURE__*/_jsx("div", {
|
|
115
|
+
return selected && !showTool ? /*#__PURE__*/_jsx("div", {
|
|
115
116
|
className: "element-toolbar visible-on-hover",
|
|
116
117
|
contentEditable: false,
|
|
117
118
|
children: /*#__PURE__*/_jsx(Tooltip, {
|
|
@@ -11,7 +11,7 @@ import { GridAddGridIcon, GridAddSectionIcon, GridSettingsIcon } from "../../com
|
|
|
11
11
|
import GridPopup from "./GridPopup";
|
|
12
12
|
import SectionPopup from "./SectionPopup";
|
|
13
13
|
import { gridItem } from "../../utils/gridItem";
|
|
14
|
-
import { useEditorContext } from "../../hooks/useMouseMove";
|
|
14
|
+
import { useEditorContext, useEditorSelection } from "../../hooks/useMouseMove";
|
|
15
15
|
import { getTRBLBreakPoints, getBreakPointsValue } from "../../helper/theme";
|
|
16
16
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
17
17
|
import { Fragment as _Fragment } from "react/jsx-runtime";
|
|
@@ -62,6 +62,7 @@ const Grid = props => {
|
|
|
62
62
|
hoverPath
|
|
63
63
|
} = useEditorContext();
|
|
64
64
|
const selected = hoverPath === path.join(",");
|
|
65
|
+
const [showTool] = useEditorSelection(editor);
|
|
65
66
|
const onAddGridItem = () => {
|
|
66
67
|
const currentPath = editor.selection?.anchor?.path;
|
|
67
68
|
const ancestorsPath = Path.ancestors(currentPath, {
|
|
@@ -174,7 +175,7 @@ const Grid = props => {
|
|
|
174
175
|
};
|
|
175
176
|
const PoupComp = GridSettingsPoupComp[openSetttings];
|
|
176
177
|
const NewLineButtons = () => {
|
|
177
|
-
return !readOnly && selected && path.length === 2 ? /*#__PURE__*/_jsxs(_Fragment, {
|
|
178
|
+
return !readOnly && selected && path.length === 2 && !showTool ? /*#__PURE__*/_jsxs(_Fragment, {
|
|
178
179
|
children: [/*#__PURE__*/_jsx("div", {
|
|
179
180
|
className: "element-selector-ctrl tc",
|
|
180
181
|
children: /*#__PURE__*/_jsx(Tooltip, {
|
|
@@ -199,7 +200,7 @@ const Grid = props => {
|
|
|
199
200
|
}) : null;
|
|
200
201
|
};
|
|
201
202
|
const GridToolBar = () => {
|
|
202
|
-
return selected ? /*#__PURE__*/_jsxs("div", {
|
|
203
|
+
return selected && !showTool ? /*#__PURE__*/_jsxs("div", {
|
|
203
204
|
className: "grid-container-toolbar",
|
|
204
205
|
contentEditable: false,
|
|
205
206
|
children: [/*#__PURE__*/_jsx(Tooltip, {
|
|
@@ -5,7 +5,7 @@ import { useSlateStatic, ReactEditor } from "slate-react";
|
|
|
5
5
|
import GridItemPopup from "./GridItemPopup";
|
|
6
6
|
import { IconButton, Tooltip, Box, Grid as Item } from "@mui/material";
|
|
7
7
|
import { GridSettingsIcon } from "../../common/iconslist";
|
|
8
|
-
import { useEditorContext } from "../../hooks/useMouseMove";
|
|
8
|
+
import { useEditorContext, useEditorSelection } from "../../hooks/useMouseMove";
|
|
9
9
|
import { getBreakPointsValue, getTRBLBreakPoints } from "../../helper/theme";
|
|
10
10
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
11
11
|
import { jsxs as _jsxs } from "react/jsx-runtime";
|
|
@@ -53,8 +53,9 @@ const GridItem = props => {
|
|
|
53
53
|
hoverPath
|
|
54
54
|
} = useEditorContext();
|
|
55
55
|
const selected = hoverPath === path.join(",");
|
|
56
|
+
const [showTool] = useEditorSelection(editor);
|
|
56
57
|
const GridItemToolbar = () => {
|
|
57
|
-
return selected ? /*#__PURE__*/_jsx("div", {
|
|
58
|
+
return selected && !showTool ? /*#__PURE__*/_jsx("div", {
|
|
58
59
|
contentEditable: false,
|
|
59
60
|
className: "grid-item-toolbar",
|
|
60
61
|
style: {
|
|
@@ -13,8 +13,9 @@ import DeleteCellIcon from "./DeleteCellIcon";
|
|
|
13
13
|
import DeleteRowIcon from "./DeleteRowIcon";
|
|
14
14
|
import { TableUtil } from "../../utils/table";
|
|
15
15
|
import TablePopup from "./TablePopup";
|
|
16
|
-
import "
|
|
16
|
+
import { useEditorSelection } from "../../hooks/useMouseMove";
|
|
17
17
|
import TableStyles from "./Styles";
|
|
18
|
+
import "./table.css";
|
|
18
19
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
19
20
|
import { jsxs as _jsxs } from "react/jsx-runtime";
|
|
20
21
|
const TABLE_MENUS = [{
|
|
@@ -91,6 +92,7 @@ const Table = props => {
|
|
|
91
92
|
const selected = useSelected();
|
|
92
93
|
const table = new TableUtil(editor);
|
|
93
94
|
const tableProps = table.getTableProps();
|
|
95
|
+
const [showTool] = useEditorSelection(editor);
|
|
94
96
|
const handleAction = ({
|
|
95
97
|
type,
|
|
96
98
|
position
|
|
@@ -125,7 +127,7 @@ const Table = props => {
|
|
|
125
127
|
setExpandTools(!exandTools);
|
|
126
128
|
};
|
|
127
129
|
const ToolBar = () => {
|
|
128
|
-
return selected ? /*#__PURE__*/_jsxs(Box, {
|
|
130
|
+
return selected && !showTool ? /*#__PURE__*/_jsxs(Box, {
|
|
129
131
|
component: "div",
|
|
130
132
|
contentEditable: false,
|
|
131
133
|
className: `tableToolBar ${exandTools ? "active" : ""}`,
|
|
@@ -5,6 +5,7 @@ import { useSlateStatic, ReactEditor } from "slate-react";
|
|
|
5
5
|
import useTableResize from "../../utils/customHooks/useTableResize";
|
|
6
6
|
import { TableUtil } from "../../utils/table";
|
|
7
7
|
import TableStyles from "./Styles";
|
|
8
|
+
import { useEditorSelection } from "../../hooks/useMouseMove";
|
|
8
9
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
9
10
|
import { Fragment as _Fragment } from "react/jsx-runtime";
|
|
10
11
|
import { jsxs as _jsxs } from "react/jsx-runtime";
|
|
@@ -45,6 +46,7 @@ const TableCell = props => {
|
|
|
45
46
|
} = element;
|
|
46
47
|
const [parentDOM, setParentDOM] = useState(null);
|
|
47
48
|
const editor = useSlateStatic();
|
|
49
|
+
const [showTool] = useEditorSelection(editor);
|
|
48
50
|
const path = ReactEditor.findPath(editor, element);
|
|
49
51
|
const isHeader = path.length >= 2 ? path[path.length - 2] === 0 : false;
|
|
50
52
|
const [size, onMouseDown, resizing, onLoad] = useTableResize({
|
|
@@ -119,7 +121,7 @@ const TableCell = props => {
|
|
|
119
121
|
border: `3px solid ${cellBorderColor}`,
|
|
120
122
|
...(sizeProps || {})
|
|
121
123
|
},
|
|
122
|
-
children: [children, isHeader && !readOnly && tableSize?.height ? /*#__PURE__*/_jsx(Resizer, {
|
|
124
|
+
children: [children, isHeader && !readOnly && tableSize?.height && !showTool ? /*#__PURE__*/_jsx(Resizer, {
|
|
123
125
|
classes: classes,
|
|
124
126
|
onMouseDown: onMouseDown,
|
|
125
127
|
height: tableSize?.height
|
|
@@ -73,7 +73,7 @@ const TopBanner = props => {
|
|
|
73
73
|
...attributes,
|
|
74
74
|
style: {
|
|
75
75
|
position: "relative",
|
|
76
|
-
height: "
|
|
76
|
+
height: "296px",
|
|
77
77
|
textAlign: "center"
|
|
78
78
|
},
|
|
79
79
|
contentEditable: false,
|
|
@@ -81,6 +81,7 @@ const TopBanner = props => {
|
|
|
81
81
|
children: [/*#__PURE__*/_jsx("img", {
|
|
82
82
|
src: url,
|
|
83
83
|
alt: "Top Banner",
|
|
84
|
+
className: "top-banner-wrpr-ele",
|
|
84
85
|
style: {
|
|
85
86
|
width: "100%",
|
|
86
87
|
height: "280px",
|
|
@@ -28,6 +28,11 @@ const editorStyles = ({
|
|
|
28
28
|
flexDirection: "column",
|
|
29
29
|
alignItems: "center",
|
|
30
30
|
color: "#0f172a",
|
|
31
|
+
"& .has-topbanner": {
|
|
32
|
+
"& .doc-title-ele-wrpr": {
|
|
33
|
+
marginTop: "12px"
|
|
34
|
+
}
|
|
35
|
+
},
|
|
31
36
|
"&.no-color": {
|
|
32
37
|
backgroundColor: theme?.palette?.editor?.background,
|
|
33
38
|
color: theme?.palette?.editor?.textColor,
|
|
@@ -206,6 +211,17 @@ const editorStyles = ({
|
|
|
206
211
|
textAlign: "center",
|
|
207
212
|
border: "1px solid #CFD8F5"
|
|
208
213
|
}
|
|
214
|
+
},
|
|
215
|
+
fullScreenWrapper: {
|
|
216
|
+
"& .MuiPaper-root": {
|
|
217
|
+
borderRadius: "0px !important",
|
|
218
|
+
"& .MuiDialogTitle-root": {
|
|
219
|
+
position: "absolute",
|
|
220
|
+
top: 0,
|
|
221
|
+
right: "12px",
|
|
222
|
+
zIndex: 100
|
|
223
|
+
}
|
|
224
|
+
}
|
|
209
225
|
}
|
|
210
226
|
});
|
|
211
227
|
export default editorStyles;
|
|
@@ -6,6 +6,7 @@ import TuneIcon from "@mui/icons-material/Tune";
|
|
|
6
6
|
import SectionPopup from "../../Elements/Grid/SectionPopup";
|
|
7
7
|
import { getBreakPointsValue, getTRBLBreakPoints } from "../../helper/theme";
|
|
8
8
|
import DragHandle from "../DnD/DragHandleButton";
|
|
9
|
+
import { useEditorSelection } from "../../hooks/useMouseMove";
|
|
9
10
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
10
11
|
import { jsxs as _jsxs } from "react/jsx-runtime";
|
|
11
12
|
const SectionStyle = () => ({
|
|
@@ -33,6 +34,7 @@ const Section = props => {
|
|
|
33
34
|
readOnly
|
|
34
35
|
} = customProps;
|
|
35
36
|
const editor = useSlateStatic();
|
|
37
|
+
const [showTool] = useEditorSelection(editor);
|
|
36
38
|
const [openSetttings, setOpenSettings] = useState(false);
|
|
37
39
|
const {
|
|
38
40
|
sectionBgColor,
|
|
@@ -58,7 +60,7 @@ const Section = props => {
|
|
|
58
60
|
setOpenSettings(true);
|
|
59
61
|
};
|
|
60
62
|
const Toolbar = () => {
|
|
61
|
-
return !readOnly ? /*#__PURE__*/_jsx(Box, {
|
|
63
|
+
return !readOnly && !showTool ? /*#__PURE__*/_jsx(Box, {
|
|
62
64
|
component: "div",
|
|
63
65
|
className: "element-toolbar no-border-button ss hr section-tw",
|
|
64
66
|
style: {
|
|
@@ -121,7 +123,7 @@ const Section = props => {
|
|
|
121
123
|
...getBreakPointsValue(sectionGridSize || 8, null, "overrideGridSize", true)
|
|
122
124
|
}
|
|
123
125
|
},
|
|
124
|
-
children: [!readOnly ? /*#__PURE__*/_jsx(DragHandle, {
|
|
126
|
+
children: [!readOnly && !showTool ? /*#__PURE__*/_jsx(DragHandle, {
|
|
125
127
|
...props
|
|
126
128
|
}) : null, children, /*#__PURE__*/_jsx(Toolbar, {})]
|
|
127
129
|
}), openSetttings ? /*#__PURE__*/_jsx(SectionPopup, {
|
|
@@ -1,7 +1,23 @@
|
|
|
1
1
|
import { useEffect, useState, createContext, useContext, useMemo } from "react";
|
|
2
|
+
import { getSelectedText } from "../utils/helper";
|
|
2
3
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
3
4
|
const EditorContext = /*#__PURE__*/createContext();
|
|
5
|
+
export const useEditorSelection = editor => {
|
|
6
|
+
const [textSelected, setTextSelected] = useState(false);
|
|
7
|
+
useEffect(() => {
|
|
8
|
+
if (editor?.selection) {
|
|
9
|
+
const text = getSelectedText(editor);
|
|
10
|
+
if (text?.length > 0) {
|
|
11
|
+
setTextSelected(true);
|
|
12
|
+
} else {
|
|
13
|
+
setTextSelected(false);
|
|
14
|
+
}
|
|
15
|
+
}
|
|
16
|
+
}, [editor?.selection]);
|
|
17
|
+
return [textSelected];
|
|
18
|
+
};
|
|
4
19
|
export const EditorProvider = ({
|
|
20
|
+
editor,
|
|
5
21
|
theme,
|
|
6
22
|
children
|
|
7
23
|
}) => {
|
|
@@ -23,7 +39,7 @@ export const EditorProvider = ({
|
|
|
23
39
|
hoverPath: previous
|
|
24
40
|
};
|
|
25
41
|
}
|
|
26
|
-
}, [path]);
|
|
42
|
+
}, [path, editor?.selection]);
|
|
27
43
|
return /*#__PURE__*/_jsx(EditorContext.Provider, {
|
|
28
44
|
value: {
|
|
29
45
|
...(value || {}),
|