@flozy/editor 4.9.3 → 4.9.5
Sign up to get free protection for your applications and to get access to all the features.
- package/dist/Editor/Editor.css +21 -11
- package/dist/Editor/Elements/AI/PopoverAIInput.js +3 -3
- package/dist/Editor/Elements/AI/Styles.js +7 -7
- package/dist/Editor/Elements/Carousel/Carousel.js +3 -0
- package/dist/Editor/Elements/Divider/Divider.js +4 -2
- package/dist/Editor/Elements/Link/LinkButton.js +1 -1
- package/dist/Editor/Elements/Search/SearchAttachment.js +6 -9
- package/dist/Editor/Elements/Search/SearchButton.js +4 -4
- package/dist/Editor/Elements/Search/SearchList.js +7 -5
- package/dist/Editor/Elements/Signature/SignaturePopup.js +2 -1
- package/dist/Editor/Elements/Table/AddRowCol.js +3 -2
- package/dist/Editor/Elements/Table/DragButton.js +6 -2
- package/dist/Editor/Elements/Table/DragStyles.js +62 -36
- package/dist/Editor/Elements/Table/Styles.js +1 -1
- package/dist/Editor/Elements/Table/Table.js +8 -3
- package/dist/Editor/Elements/Table/TableCell.js +24 -10
- package/dist/Editor/Elements/Table/tableHelper.js +83 -0
- package/dist/Editor/Toolbar/PopupTool/MiniTextFormat/index.js +3 -3
- package/dist/Editor/Toolbar/PopupTool/PopupToolStyle.js +26 -22
- package/dist/Editor/Toolbar/PopupTool/index.js +13 -11
- package/dist/Editor/common/MentionsPopup/Styles.js +1 -1
- package/dist/Editor/common/RnD/ElementSettings/Settings/FormSettings.js +10 -35
- package/dist/Editor/common/StyleBuilder/fieldTypes/backgroundImage.js +5 -0
- package/dist/Editor/common/StyleBuilder/fieldTypes/card.js +10 -2
- package/dist/Editor/common/StyleBuilder/formStyle.js +101 -69
- package/dist/Editor/common/StyleBuilder/index.js +8 -34
- package/dist/Editor/common/Uploader.js +8 -0
- package/dist/Editor/common/iconListV2.js +2 -0
- package/dist/Editor/common/iconslist.js +1 -0
- package/dist/Editor/helper/deserialize/index.js +5 -11
- package/dist/Editor/hooks/useEditorScroll.js +1 -1
- package/dist/Editor/hooks/useTable.js +37 -30
- package/dist/Editor/utils/helper.js +11 -0
- package/package.json +1 -1
package/dist/Editor/Editor.css
CHANGED
@@ -622,7 +622,21 @@ blockquote {
|
|
622
622
|
}
|
623
623
|
|
624
624
|
.MuiIconButton-root.btnActive {
|
625
|
-
|
625
|
+
svg path {
|
626
|
+
stroke: #2563EB;
|
627
|
+
}
|
628
|
+
|
629
|
+
svg text,
|
630
|
+
svg circle,
|
631
|
+
.fill-svg,
|
632
|
+
.fill-path,
|
633
|
+
.fill-path path {
|
634
|
+
fill: #2563EB;
|
635
|
+
}
|
636
|
+
|
637
|
+
path.fill-path {
|
638
|
+
stroke: none;
|
639
|
+
}
|
626
640
|
}
|
627
641
|
|
628
642
|
.embed .element-toolbar {
|
@@ -1214,14 +1228,6 @@ blockquote {
|
|
1214
1228
|
position: absolute;
|
1215
1229
|
}
|
1216
1230
|
|
1217
|
-
.dividerComponent:hover {
|
1218
|
-
padding: 10px 0;
|
1219
|
-
}
|
1220
|
-
|
1221
|
-
.dividerComponent.readonlyDivider:hover {
|
1222
|
-
padding: 0;
|
1223
|
-
}
|
1224
|
-
|
1225
1231
|
.dividerComponent:hover .divider-settings {
|
1226
1232
|
display: block;
|
1227
1233
|
}
|
@@ -1229,7 +1235,10 @@ blockquote {
|
|
1229
1235
|
@media (max-width: 899px) {
|
1230
1236
|
.MuiPopover-root {
|
1231
1237
|
z-index: 1302 !important;
|
1232
|
-
}
|
1238
|
+
}
|
1239
|
+
canvas {
|
1240
|
+
max-width: 100% !important;
|
1241
|
+
}
|
1233
1242
|
}
|
1234
1243
|
|
1235
1244
|
.settingsHeader {
|
@@ -1250,4 +1259,5 @@ blockquote {
|
|
1250
1259
|
|
1251
1260
|
.hideScroll::-webkit-scrollbar-thumb:hover {
|
1252
1261
|
background: none !important;
|
1253
|
-
}
|
1262
|
+
}
|
1263
|
+
|
@@ -1,4 +1,4 @@
|
|
1
|
-
import { useEffect, useRef, useState } from "react";
|
1
|
+
import { useCallback, useEffect, useRef, useState } from "react";
|
2
2
|
import { useEditorContext } from "../../hooks/useMouseMove";
|
3
3
|
import Styles from "./Styles";
|
4
4
|
import { Fade, Paper, Popper } from "@mui/material";
|
@@ -178,9 +178,9 @@ function PopoverAIInput({
|
|
178
178
|
const selectedEleRef = useRef({});
|
179
179
|
const classes = Styles();
|
180
180
|
const editor = useSlate();
|
181
|
-
const updateAnchor = () => {
|
181
|
+
const updateAnchor = useCallback(() => {
|
182
182
|
updateAnchorEl(setAnchorEl, editor, openAI, selectedEleRef.current);
|
183
|
-
};
|
183
|
+
}, [setAnchorEl, editor, openAI, selectedEleRef.current]);
|
184
184
|
useEditorScroll(editorWrapper, updateAnchor);
|
185
185
|
const onClickOutside = () => {
|
186
186
|
setAnchorEl(null);
|
@@ -142,13 +142,13 @@ const Styles = theme => ({
|
|
142
142
|
gap: "8px"
|
143
143
|
},
|
144
144
|
"&:hover": {
|
145
|
-
backgroundColor: `${theme?.palette?.editor?.menuOptionSelectedOption} !important
|
146
|
-
|
147
|
-
|
148
|
-
}
|
149
|
-
|
150
|
-
|
151
|
-
}
|
145
|
+
backgroundColor: `${theme?.palette?.editor?.menuOptionSelectedOption} !important`
|
146
|
+
},
|
147
|
+
"& svg path": {
|
148
|
+
stroke: `${theme?.palette?.editor?.menuOptionTextColor} !important`
|
149
|
+
},
|
150
|
+
"& svg": {
|
151
|
+
color: `${theme?.palette?.editor?.menuOptionTextColor} !important`
|
152
152
|
},
|
153
153
|
"&.active": {
|
154
154
|
background: `${theme?.palette?.containers?.bg3 || "#E9F3FE"}`,
|
@@ -52,10 +52,13 @@ const Carousel = props => {
|
|
52
52
|
useEffect(() => {
|
53
53
|
setRefresh(new Date().getTime());
|
54
54
|
}, []);
|
55
|
+
|
56
|
+
//comment this for carosul selection on insert
|
55
57
|
useEffect(() => {
|
56
58
|
if (!edit) {
|
57
59
|
ReactEditor.focus(editor);
|
58
60
|
Transforms.select(editor, ReactEditor.findPath(editor, element));
|
61
|
+
Transforms.deselect(editor);
|
59
62
|
}
|
60
63
|
}, [edit]);
|
61
64
|
const onAddSlide = () => {
|
@@ -100,11 +100,12 @@ const Divider = props => {
|
|
100
100
|
};
|
101
101
|
return /*#__PURE__*/_jsxs("div", {
|
102
102
|
...attributes,
|
103
|
-
className: `dividerComponent
|
103
|
+
className: `dividerComponent`,
|
104
104
|
style: {
|
105
105
|
userSelect: "none",
|
106
106
|
position: 'relative'
|
107
107
|
},
|
108
|
+
contentEditable: false,
|
108
109
|
children: [!readOnly && /*#__PURE__*/_jsx("div", {
|
109
110
|
className: `element-root element-selector`,
|
110
111
|
contentEditable: false,
|
@@ -124,7 +125,8 @@ const Divider = props => {
|
|
124
125
|
userSelect: "none",
|
125
126
|
borderTop: !borderColor?.includes("linear") ? `${width} ${borderStyle} ${borderColor}` : `transparent`,
|
126
127
|
backgroundImage: borderColor?.includes("linear") ? borderColor : "none",
|
127
|
-
height: borderColor?.includes("linear") ? borderWidth : undefined
|
128
|
+
height: borderColor?.includes("linear") ? borderWidth : undefined,
|
129
|
+
marginTop: '15px'
|
128
130
|
}
|
129
131
|
}), /*#__PURE__*/_jsx("span", {
|
130
132
|
style: {
|
@@ -64,7 +64,7 @@ const LinkButton = props => {
|
|
64
64
|
title: "Link",
|
65
65
|
arrow: true,
|
66
66
|
children: /*#__PURE__*/_jsx(IconButton, {
|
67
|
-
className: `${showInput ? "clicked" : ""} ${isActive ? "btnActive" : ""}`,
|
67
|
+
className: `${showInput ? "clicked btnActive" : ""} ${isActive ? "btnActive" : ""}`,
|
68
68
|
format: "link",
|
69
69
|
onClick: toggleLink,
|
70
70
|
children: /*#__PURE__*/_jsx(Icon, {
|
@@ -27,7 +27,7 @@ const SearchAttachment = props => {
|
|
27
27
|
metadata?.actionHandler(type, element);
|
28
28
|
}
|
29
29
|
};
|
30
|
-
return /*#__PURE__*/
|
30
|
+
return /*#__PURE__*/_jsx(Box, {
|
31
31
|
component: "div",
|
32
32
|
className: "attachment-wrpr-ev2",
|
33
33
|
...attributes,
|
@@ -35,7 +35,7 @@ const SearchAttachment = props => {
|
|
35
35
|
style: {
|
36
36
|
display: "block"
|
37
37
|
},
|
38
|
-
children:
|
38
|
+
children: /*#__PURE__*/_jsxs(Card, {
|
39
39
|
style: {
|
40
40
|
display: "flex",
|
41
41
|
justifyContent: "flex-start",
|
@@ -45,7 +45,7 @@ const SearchAttachment = props => {
|
|
45
45
|
padding: "0px 10px",
|
46
46
|
boxShadow: "none",
|
47
47
|
border: `1px solid ${theme?.palette?.primary?.slashBrainBorder}`,
|
48
|
-
borderRadius: "7px",
|
48
|
+
borderRadius: "7px !important",
|
49
49
|
background: theme?.palette?.containers?.slashBrainCardBg,
|
50
50
|
cursor: 'pointer',
|
51
51
|
"& *::selection": {
|
@@ -76,7 +76,7 @@ const SearchAttachment = props => {
|
|
76
76
|
paddingBottom: '3px'
|
77
77
|
}
|
78
78
|
},
|
79
|
-
children: /*#__PURE__*/
|
79
|
+
children: /*#__PURE__*/_jsxs(Typography, {
|
80
80
|
sx: {
|
81
81
|
fontWeight: "500",
|
82
82
|
background: theme?.palette?.text?.slashBrainText,
|
@@ -95,13 +95,10 @@ const SearchAttachment = props => {
|
|
95
95
|
},
|
96
96
|
component: "div",
|
97
97
|
variant: "subtitle1",
|
98
|
-
children: label
|
98
|
+
children: [label, children]
|
99
99
|
})
|
100
100
|
})]
|
101
|
-
})
|
102
|
-
contentEditable: false,
|
103
|
-
children: children
|
104
|
-
})]
|
101
|
+
})
|
105
102
|
});
|
106
103
|
};
|
107
104
|
export default SearchAttachment;
|
@@ -110,8 +110,8 @@ const SearchButton = /*#__PURE__*/forwardRef((props, ref) => {
|
|
110
110
|
children: /*#__PURE__*/_jsx(Paper, {
|
111
111
|
sx: {
|
112
112
|
width: '100%',
|
113
|
-
background: theme?.palette?.
|
114
|
-
borderColor: theme?.palette?.type === 'dark' ? theme?.palette?.
|
113
|
+
background: theme?.palette?.editor?.miniToolBarBackground,
|
114
|
+
borderColor: theme?.palette?.type === 'dark' ? theme?.palette?.editor?.popUpBorderColor : 'transparent'
|
115
115
|
},
|
116
116
|
children: /*#__PURE__*/_jsx(SearchAndDocList, {
|
117
117
|
mapData: mapData,
|
@@ -143,9 +143,9 @@ const SearchButton = /*#__PURE__*/forwardRef((props, ref) => {
|
|
143
143
|
sx: {
|
144
144
|
padding: 0,
|
145
145
|
width: '330px',
|
146
|
-
background: theme?.palette?.
|
146
|
+
background: theme?.palette?.editor?.miniToolBarBackground,
|
147
147
|
border: '1px solid',
|
148
|
-
borderColor: theme?.palette?.type === 'dark' ? theme?.palette?.
|
148
|
+
borderColor: theme?.palette?.type === 'dark' ? theme?.palette?.editor?.popUpBorderColor : 'transparent',
|
149
149
|
borderRadius: '12px',
|
150
150
|
'&.MuiPaper-root-MuiPopover-paper': {
|
151
151
|
borderRadius: '12px !important'
|
@@ -36,7 +36,7 @@ const SearchAndDocList = ({
|
|
36
36
|
sx: {
|
37
37
|
borderRadius: "6px",
|
38
38
|
backgroundColor: theme?.palette?.containers?.bg7,
|
39
|
-
border: theme?.palette?.type === 'dark' ? `1px solid ${theme?.palette?.
|
39
|
+
border: theme?.palette?.type === 'dark' ? `1px solid ${theme?.palette?.editor?.popUpBorderColor}` : '',
|
40
40
|
padding: "5px",
|
41
41
|
"&:hover": {
|
42
42
|
backgroundColor: theme?.palette?.containers?.bg8,
|
@@ -111,24 +111,27 @@ const SearchAndDocList = ({
|
|
111
111
|
maxHeight: '400px',
|
112
112
|
minWidth: "275px",
|
113
113
|
overflowY: 'auto',
|
114
|
+
overflowX: 'hidden',
|
114
115
|
padding: '0px 16px 8px',
|
115
116
|
marginBottom: '20px',
|
116
117
|
scrollbarWidth: "thin",
|
117
118
|
scrollbarColor: `${theme?.palette?.primary?.slashBrainBorder} transparent`,
|
118
119
|
"&::-webkit-scrollbar": {
|
119
120
|
width: "3px",
|
120
|
-
height: "3px !important"
|
121
|
+
height: "3px !important",
|
122
|
+
borderRadius: "10px"
|
121
123
|
},
|
122
124
|
"&::-webkit-scrollbar-thumb": {
|
123
125
|
backgroundColor: theme?.palette?.primary?.slashBrainBorder,
|
124
|
-
borderRadius: "
|
126
|
+
borderRadius: "10px",
|
125
127
|
width: "3px !important"
|
126
128
|
},
|
127
129
|
"&::-webkit-scrollbar-thumb:hover": {
|
128
130
|
backgroundColor: theme?.palette?.primary?.slashBrainBorder
|
129
131
|
},
|
130
132
|
"&::-webkit-scrollbar-track": {
|
131
|
-
background: "transparent"
|
133
|
+
background: "transparent",
|
134
|
+
borderRadius: "10px"
|
132
135
|
}
|
133
136
|
},
|
134
137
|
children: [mapData?.map((doc, index) => {
|
@@ -206,7 +209,6 @@ const SearchAndDocList = ({
|
|
206
209
|
justifyContent: "center",
|
207
210
|
alignItems: 'center',
|
208
211
|
sx: {
|
209
|
-
minWidth: "330px",
|
210
212
|
minHeight: '400px',
|
211
213
|
padding: '0px 16px 8px',
|
212
214
|
position: 'absolute'
|
@@ -59,11 +59,12 @@ function AddRowCol(props) {
|
|
59
59
|
children: /*#__PURE__*/_jsx(Button, {
|
60
60
|
sx: {
|
61
61
|
fontSize: "14px",
|
62
|
-
border: "1px
|
63
|
-
color: "#2563EB",
|
62
|
+
border: "1px dashed #8DA8E3",
|
63
|
+
color: "#2563EB !important",
|
64
64
|
padding: "0px 4px",
|
65
65
|
minWidth: "unset",
|
66
66
|
lineHeight: "18px",
|
67
|
+
fontWeight: "lighter !important",
|
67
68
|
...buttonStyle,
|
68
69
|
opacity: showBtn ? 1 : 0
|
69
70
|
},
|
@@ -73,7 +73,7 @@ function DragButton({
|
|
73
73
|
modifiers: [{
|
74
74
|
name: "offset",
|
75
75
|
options: {
|
76
|
-
offset: [0, -
|
76
|
+
offset: [0, -12]
|
77
77
|
}
|
78
78
|
}, {
|
79
79
|
name: "flip",
|
@@ -81,7 +81,7 @@ function DragButton({
|
|
81
81
|
}],
|
82
82
|
|
83
83
|
disablePortal: dragType !== "row",
|
84
|
-
className: className
|
84
|
+
className: `${className}`,
|
85
85
|
children: ({
|
86
86
|
TransitionProps
|
87
87
|
}) => /*#__PURE__*/_jsx(Fade, {
|
@@ -94,6 +94,10 @@ function DragButton({
|
|
94
94
|
sx: dragType === "row" ? {
|
95
95
|
transform: "rotate(90deg)"
|
96
96
|
} : {},
|
97
|
+
className: `${showTool ? "active" : ""}`,
|
98
|
+
style: {
|
99
|
+
lineHeight: 0
|
100
|
+
},
|
97
101
|
children: /*#__PURE__*/_jsx(IconButton, {
|
98
102
|
onClick: () => {
|
99
103
|
onDragClick();
|
@@ -1,43 +1,69 @@
|
|
1
|
-
const DragStyles = theme =>
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
1
|
+
const DragStyles = theme => {
|
2
|
+
const {
|
3
|
+
containers,
|
4
|
+
editor
|
5
|
+
} = theme?.palette || {};
|
6
|
+
const {
|
7
|
+
buttonBorder,
|
8
|
+
background,
|
9
|
+
activeColor,
|
10
|
+
signaturePopUpTabButtonSelectedBg,
|
11
|
+
signaturePopUpTabButtonSelectedSvg
|
12
|
+
} = editor || {};
|
13
|
+
const onDragActive = {
|
14
|
+
outline: `1.5px solid ${activeColor || "#2563EB"}`,
|
15
|
+
background: `${signaturePopUpTabButtonSelectedBg} !important`,
|
16
|
+
"& svg ellipse": {
|
17
|
+
fill: `${signaturePopUpTabButtonSelectedSvg}`
|
18
|
+
}
|
19
|
+
};
|
20
|
+
return {
|
21
|
+
popper: {
|
22
|
+
zIndex: 1000,
|
23
|
+
"& .MuiPaper-root": {
|
24
|
+
borderRadius: "3px !important",
|
25
|
+
outline: `1.5px solid ${buttonBorder}`,
|
26
|
+
backgroundColor: `${background}`,
|
27
|
+
"&:hover": onDragActive,
|
28
|
+
"&.active": onDragActive
|
29
|
+
},
|
30
|
+
"& .MuiIconButton-root": {
|
31
|
+
padding: "4px 6px",
|
32
|
+
borderRadius: "none",
|
33
|
+
"& .dragIcon": {
|
34
|
+
width: "14px",
|
35
|
+
height: "10px"
|
36
|
+
},
|
37
|
+
"&:hover": {
|
38
|
+
background: "none"
|
39
|
+
}
|
8
40
|
}
|
9
41
|
},
|
10
|
-
|
11
|
-
|
12
|
-
"
|
13
|
-
|
42
|
+
toolPopper: {
|
43
|
+
zIndex: 4001,
|
44
|
+
"& .MuiPaper-root": {
|
45
|
+
borderRadius: "8px"
|
14
46
|
}
|
15
|
-
}
|
16
|
-
},
|
17
|
-
toolPopper: {
|
18
|
-
zIndex: 4001,
|
19
|
-
"& .MuiPaper-root": {
|
20
|
-
borderRadius: "8px"
|
21
|
-
}
|
22
|
-
},
|
23
|
-
mobileToolDrawer: {
|
24
|
-
"& .customSelectContainer": {
|
25
|
-
border: "none !important",
|
26
|
-
padding: "0px !important"
|
27
|
-
}
|
28
|
-
},
|
29
|
-
drawerContainer: {
|
30
|
-
"&.MuiDrawer-root": {
|
31
|
-
zIndex: 1301
|
32
47
|
},
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
48
|
+
mobileToolDrawer: {
|
49
|
+
"& .customSelectContainer": {
|
50
|
+
border: "none !important",
|
51
|
+
padding: "0px !important"
|
52
|
+
}
|
37
53
|
},
|
38
|
-
|
39
|
-
|
54
|
+
drawerContainer: {
|
55
|
+
"&.MuiDrawer-root": {
|
56
|
+
zIndex: 1301
|
57
|
+
},
|
58
|
+
"& .MuiDrawer-paper": {
|
59
|
+
borderTopLeftRadius: 8,
|
60
|
+
borderTopRightRadius: 8,
|
61
|
+
backgroundColor: containers?.card
|
62
|
+
},
|
63
|
+
"& .customSelectContainer": {
|
64
|
+
border: "none"
|
65
|
+
}
|
40
66
|
}
|
41
|
-
}
|
42
|
-
}
|
67
|
+
};
|
68
|
+
};
|
43
69
|
export default DragStyles;
|
@@ -8,7 +8,7 @@ import { useEditorContext, useEditorSelection } from "../../hooks/useMouseMove";
|
|
8
8
|
import TableStyles from "./Styles";
|
9
9
|
import "./table.css";
|
10
10
|
import { groupByBreakpoint } from "../../helper/theme";
|
11
|
-
import { TableProvider } from "../../hooks/useTable";
|
11
|
+
import useTable, { TableProvider } from "../../hooks/useTable";
|
12
12
|
import AddRowCol from "./AddRowCol";
|
13
13
|
import TableTool from "./TableTool";
|
14
14
|
import { useDebouncedCallback } from "use-debounce";
|
@@ -30,7 +30,11 @@ const ToolBar = props => {
|
|
30
30
|
handleAction,
|
31
31
|
exandTools
|
32
32
|
} = props;
|
33
|
-
|
33
|
+
const {
|
34
|
+
getSelectedCells
|
35
|
+
} = useTable();
|
36
|
+
const viewTool = selected && !showTool && getSelectedCells()?.length <= 1;
|
37
|
+
return viewTool ? /*#__PURE__*/_jsxs(Box, {
|
34
38
|
component: "div",
|
35
39
|
contentEditable: false,
|
36
40
|
className: `tableToolBar ${exandTools ? "active" : ""}`,
|
@@ -185,7 +189,8 @@ const Table = props => {
|
|
185
189
|
return /*#__PURE__*/_jsxs(TableProvider, {
|
186
190
|
editor: editor,
|
187
191
|
otherProps: {
|
188
|
-
dragRowBtnCls
|
192
|
+
dragRowBtnCls,
|
193
|
+
tablePath: path
|
189
194
|
},
|
190
195
|
children: [/*#__PURE__*/_jsxs("div", {
|
191
196
|
style: {
|
@@ -1,4 +1,4 @@
|
|
1
|
-
import React, { useState, useEffect } from "react";
|
1
|
+
import React, { useState, useEffect, useMemo } from "react";
|
2
2
|
import { Editor, Element, Path, Transforms } from "slate";
|
3
3
|
import { Box } from "@mui/material";
|
4
4
|
import { useSlateStatic, ReactEditor } from "slate-react";
|
@@ -190,11 +190,19 @@ const TableCell = props => {
|
|
190
190
|
if (!contentEditable) {
|
191
191
|
e.preventDefault();
|
192
192
|
}
|
193
|
-
|
194
|
-
|
195
|
-
|
196
|
-
|
197
|
-
|
193
|
+
if (
|
194
|
+
// for shift selection
|
195
|
+
e.shiftKey && startCellPath?.length && startCellPath.toString() !== path.toString()) {
|
196
|
+
updateTableSelection({
|
197
|
+
endCellPath: path
|
198
|
+
});
|
199
|
+
} else {
|
200
|
+
updateTableSelection({
|
201
|
+
startCellPath: path,
|
202
|
+
endCellPath: [],
|
203
|
+
isDragging: true
|
204
|
+
});
|
205
|
+
}
|
198
206
|
};
|
199
207
|
const onMouseUp = e => {
|
200
208
|
if (startCellPath?.length) {
|
@@ -211,6 +219,7 @@ const TableCell = props => {
|
|
211
219
|
const isCellSelected = selectionPath?.length && Path.equals(selectionPath, path);
|
212
220
|
if (!isCellSelected) {
|
213
221
|
// focus the clicked cell
|
222
|
+
ReactEditor.focus(editor);
|
214
223
|
Transforms.select(editor, {
|
215
224
|
anchor: Editor.end(editor, path),
|
216
225
|
focus: Editor.end(editor, path)
|
@@ -225,10 +234,15 @@ const TableCell = props => {
|
|
225
234
|
const cellId = path.toString() + "table-cell";
|
226
235
|
const cellRef = document.getElementById(cellId);
|
227
236
|
const contentEditable = !readOnly && isCellEditable(startCellPath, path);
|
228
|
-
const commonTdProps = {
|
229
|
-
|
230
|
-
|
231
|
-
|
237
|
+
const commonTdProps = useMemo(() => {
|
238
|
+
const props = {
|
239
|
+
id: cellId
|
240
|
+
};
|
241
|
+
if (!contentEditable) {
|
242
|
+
props.contentEditable = false;
|
243
|
+
}
|
244
|
+
return props;
|
245
|
+
}, [contentEditable, cellId]);
|
232
246
|
const handleTouchMove = e => {
|
233
247
|
const touch = e.touches[0]; // Get the current touch point
|
234
248
|
const element = document.elementFromPoint(touch.clientX, touch.clientY);
|
@@ -0,0 +1,83 @@
|
|
1
|
+
import { getNode } from "../../utils/helper";
|
2
|
+
import { serializeToText } from "../../utils/serializeToText";
|
3
|
+
export const getRectangleBounds = tableSelection => {
|
4
|
+
const {
|
5
|
+
startCellPath,
|
6
|
+
endCellPath
|
7
|
+
} = tableSelection;
|
8
|
+
if (!startCellPath?.length) return [];
|
9
|
+
const startPath = startCellPath.slice(0, -2);
|
10
|
+
const startCell = startCellPath.slice(-2);
|
11
|
+
const endCell = endCellPath.slice(-2);
|
12
|
+
const [startRow, startCol] = startCell;
|
13
|
+
const [endRow, endCol] = endCell?.length ? endCell : startCell;
|
14
|
+
const minRow = Math.min(startRow, endRow);
|
15
|
+
const maxRow = Math.max(startRow, endRow);
|
16
|
+
const minCol = Math.min(startCol, endCol);
|
17
|
+
const maxCol = Math.max(startCol, endCol);
|
18
|
+
const selectedPaths = [];
|
19
|
+
for (let row = minRow; row <= maxRow; row++) {
|
20
|
+
for (let col = minCol; col <= maxCol; col++) {
|
21
|
+
selectedPaths.push([...startPath, row, col]);
|
22
|
+
}
|
23
|
+
}
|
24
|
+
return selectedPaths;
|
25
|
+
};
|
26
|
+
export const createCopiedTableStructure = (editor, tableSelection, currentTableNode, tablePath, selectedText) => {
|
27
|
+
const selectedCells = getRectangleBounds(tableSelection);
|
28
|
+
const formattedCells = selectedCells.map(cell => cell.slice(-2));
|
29
|
+
const tableChild = [];
|
30
|
+
const rowIndexes = [...new Set(formattedCells.map(cell => cell[0]))];
|
31
|
+
rowIndexes.forEach((rowIndex, row_i) => {
|
32
|
+
const row = {
|
33
|
+
type: "table-row",
|
34
|
+
children: []
|
35
|
+
};
|
36
|
+
|
37
|
+
// Filter cells that belong to the current row
|
38
|
+
const cellsInRow = formattedCells.filter(cell => cell[0] === rowIndex);
|
39
|
+
|
40
|
+
// Iterate over the columns of the row to create table cells
|
41
|
+
const columnIndexes = [...new Set(cellsInRow.map(cell => cell[1]))];
|
42
|
+
columnIndexes.forEach((columnIndex, col_i) => {
|
43
|
+
const cellPath = [...tablePath, rowIndex, columnIndex];
|
44
|
+
const columnNode = getNode(editor, cellPath);
|
45
|
+
const cellNode = selectedText // we can select text in only one column
|
46
|
+
? {
|
47
|
+
...columnNode,
|
48
|
+
type: "table-cell",
|
49
|
+
children: [{
|
50
|
+
type: "paragraph",
|
51
|
+
children: [{
|
52
|
+
text: selectedText
|
53
|
+
}],
|
54
|
+
cellBgColor: "#FFFFFF"
|
55
|
+
}]
|
56
|
+
} : columnNode;
|
57
|
+
row.children.push(cellNode);
|
58
|
+
});
|
59
|
+
tableChild.push(row);
|
60
|
+
});
|
61
|
+
const table = {
|
62
|
+
...currentTableNode,
|
63
|
+
children: tableChild,
|
64
|
+
rows: rowIndexes?.length,
|
65
|
+
columns: tableChild[0]?.children?.length // first row's children length
|
66
|
+
};
|
67
|
+
|
68
|
+
return table;
|
69
|
+
};
|
70
|
+
export const tableNodeToDom = (tableNode, selectedText) => {
|
71
|
+
const tableEle = document.createElement("table");
|
72
|
+
tableNode.children?.forEach(row => {
|
73
|
+
const rowEle = document.createElement("tr");
|
74
|
+
row?.children?.forEach(cell => {
|
75
|
+
const cellEle = document.createElement("td");
|
76
|
+
const cellText = selectedText || serializeToText(cell);
|
77
|
+
cellEle.innerHTML = cellText;
|
78
|
+
rowEle.appendChild(cellEle);
|
79
|
+
});
|
80
|
+
tableEle.appendChild(rowEle);
|
81
|
+
});
|
82
|
+
return tableEle;
|
83
|
+
};
|
@@ -1,4 +1,4 @@
|
|
1
|
-
import {
|
1
|
+
import { Fade, Grid, IconButton, Paper, Popper } from "@mui/material";
|
2
2
|
import SelectTypography from "./SelectTypography";
|
3
3
|
import SelectList from "./SelectList";
|
4
4
|
import { toolbarGroups } from "../../toolbarGroups";
|
@@ -95,9 +95,9 @@ const MiniTextFormat = props => {
|
|
95
95
|
active: isBlockActive(editor, link.format),
|
96
96
|
editor: editor,
|
97
97
|
customProps: customProps
|
98
|
-
}, link.id), /*#__PURE__*/_jsx(
|
98
|
+
}, link.id), /*#__PURE__*/_jsx(IconButton, {
|
99
99
|
onClick: e => setAnchorEl(document.getElementById("mini-text-editor-wrapper")),
|
100
|
-
className:
|
100
|
+
className: `textSettingsIcon ${open ? "btnActive" : ""}`,
|
101
101
|
children: /*#__PURE__*/_jsx(TextToolIcon, {})
|
102
102
|
}), /*#__PURE__*/_jsx(Popper, {
|
103
103
|
id: id,
|