@flozy/editor 1.1.1 → 1.1.4
Sign up to get free protection for your applications and to get access to all the features.
- package/dist/Editor/CollaborativeEditor.js +7 -2
- package/dist/Editor/CommonEditor.js +59 -37
- package/dist/Editor/Editor.css +209 -12
- package/dist/Editor/Elements/Accordion/Accordion.js +100 -0
- package/dist/Editor/Elements/Accordion/AccordionBtnPopup.js +20 -0
- package/dist/Editor/Elements/Accordion/AccordionButton.js +22 -0
- package/dist/Editor/Elements/Accordion/AccordionDetails.js +18 -0
- package/dist/Editor/Elements/Accordion/AccordionSummary.js +69 -0
- package/dist/Editor/Elements/Accordion/AccordionTitlePopup.js +20 -0
- package/dist/Editor/Elements/Button/ButtonPopup.js +20 -0
- package/dist/Editor/Elements/Button/ButtonToolIcon.js +19 -0
- package/dist/Editor/Elements/Button/EditorButton.js +124 -0
- package/dist/Editor/Elements/Carousel/Arrows.js +39 -0
- package/dist/Editor/Elements/Carousel/Carousel.js +82 -0
- package/dist/Editor/Elements/Carousel/CarouselButton.js +19 -0
- package/dist/Editor/Elements/Carousel/CarouselItem.js +13 -0
- package/dist/Editor/Elements/Carousel/slick-theme.min.css +143 -0
- package/dist/Editor/Elements/Carousel/slick.min.css +83 -0
- package/dist/Editor/Elements/Color Picker/ColorPicker.js +1 -1
- package/dist/Editor/Elements/Embed/Embed.css +22 -2
- package/dist/Editor/Elements/Embed/Embed.js +89 -74
- package/dist/Editor/Elements/Embed/EmbedPopup.js +23 -0
- package/dist/Editor/Elements/Embed/Image.js +92 -10
- package/dist/Editor/Elements/Embed/Video.js +31 -5
- package/dist/Editor/Elements/Equation/EquationButton.js +12 -12
- package/dist/Editor/Elements/Grid/Grid.js +64 -8
- package/dist/Editor/Elements/Grid/GridButton.js +2 -4
- package/dist/Editor/Elements/Grid/GridItem.js +59 -5
- package/dist/Editor/Elements/Grid/GridItemPopup.js +20 -0
- package/dist/Editor/Elements/Grid/GridPopup.js +22 -0
- package/dist/Editor/Elements/ID/Id.js +1 -1
- package/dist/Editor/Elements/ImageText/ImageText.js +14 -0
- package/dist/Editor/Elements/ImageText/ImageTextWrapper.js +14 -0
- package/dist/Editor/Elements/Link/LinkButton.js +1 -1
- package/dist/Editor/Elements/NewLine/NewLineButton.js +2 -1
- package/dist/Editor/Elements/PageSettings/PageSettingsButton.js +88 -0
- package/dist/Editor/Elements/PageSettings/PageSettingsPopup.js +22 -0
- package/dist/Editor/Elements/Signature/Signature.js +50 -0
- package/dist/Editor/Elements/Signature/SignatureButton.js +19 -0
- package/dist/Editor/Elements/Signature/SignatureOptions/DrawSignature.js +39 -0
- package/dist/Editor/Elements/Signature/SignatureOptions/TypeSignature.js +84 -0
- package/dist/Editor/Elements/Signature/SignatureOptions/UploadSignature.js +50 -0
- package/dist/Editor/Elements/Signature/SignatureOptions/index.js +5 -0
- package/dist/Editor/Elements/Signature/SignaturePopup.js +243 -0
- package/dist/Editor/Elements/Signature/Signed.js +80 -0
- package/dist/Editor/Elements/Table/DeleteCellIcon.js +24 -0
- package/dist/Editor/Elements/Table/DeleteRowIcon.js +24 -0
- package/dist/Editor/Elements/Table/Table.js +9 -1
- package/dist/Editor/Elements/Table/TableCell.js +181 -0
- package/dist/Editor/Elements/Table/TablePopup.js +22 -0
- package/dist/Editor/Elements/Table/TableRow.js +31 -0
- package/dist/Editor/Elements/Table/TableSelector.js +62 -68
- package/dist/Editor/Toolbar/Toolbar.js +47 -10
- package/dist/Editor/Toolbar/styles.css +20 -11
- package/dist/Editor/Toolbar/toolbarGroups.js +17 -19
- package/dist/Editor/common/Button.js +4 -8
- package/dist/Editor/common/StyleBuilder/accordionTitleBtnStyle.js +23 -0
- package/dist/Editor/common/StyleBuilder/accordionTitleStyle.js +35 -0
- package/dist/Editor/common/StyleBuilder/buttonStyle.js +47 -0
- package/dist/Editor/common/StyleBuilder/embedImageStyle.js +63 -0
- package/dist/Editor/common/StyleBuilder/fieldTypes/alignment.js +88 -0
- package/dist/Editor/common/StyleBuilder/fieldTypes/backgroundImage.js +87 -0
- package/dist/Editor/common/StyleBuilder/fieldTypes/bannerSpacing.js +136 -0
- package/dist/Editor/common/StyleBuilder/fieldTypes/borderRadius.js +126 -0
- package/dist/Editor/common/StyleBuilder/fieldTypes/color.js +89 -0
- package/dist/Editor/common/StyleBuilder/fieldTypes/elementSize.js +110 -0
- package/dist/Editor/common/StyleBuilder/fieldTypes/gridSize.js +42 -0
- package/dist/Editor/common/StyleBuilder/fieldTypes/imageTexts.js +75 -0
- package/dist/Editor/common/StyleBuilder/fieldTypes/index.js +21 -0
- package/dist/Editor/common/StyleBuilder/fieldTypes/text.js +46 -0
- package/dist/Editor/common/StyleBuilder/gridItemStyle.js +51 -0
- package/dist/Editor/common/StyleBuilder/gridStyle.js +51 -0
- package/dist/Editor/common/StyleBuilder/index.js +114 -0
- package/dist/Editor/common/StyleBuilder/pageSettingsStyle.js +10 -0
- package/dist/Editor/common/StyleBuilder/tableStyle.js +38 -0
- package/dist/Editor/common/Uploader.js +87 -0
- package/dist/Editor/plugins/withEmbeds.js +12 -5
- package/dist/Editor/plugins/withTable.js +5 -4
- package/dist/Editor/service/fileupload.js +17 -0
- package/dist/Editor/utils/SlateUtilityFunctions.js +72 -23
- package/dist/Editor/utils/accordion.js +25 -0
- package/dist/Editor/utils/button.js +11 -0
- package/dist/Editor/utils/carousel.js +13 -0
- package/dist/Editor/utils/carouselItem.js +19 -0
- package/dist/Editor/utils/customHooks/useContextMenu.js +8 -8
- package/dist/Editor/utils/customHooks/useResize.js +1 -1
- package/dist/Editor/utils/font.js +59 -0
- package/dist/Editor/utils/helper.js +32 -0
- package/dist/Editor/utils/imageText.js +19 -0
- package/dist/Editor/utils/signature.js +23 -0
- package/dist/Editor/utils/table.js +172 -0
- package/package.json +11 -3
@@ -0,0 +1,243 @@
|
|
1
|
+
import React, { useState } from "react";
|
2
|
+
import { Dialog, DialogTitle, DialogContent, DialogActions, Button, IconButton, Grid, TextField } from "@mui/material";
|
3
|
+
import CloseIcon from "@mui/icons-material/Close";
|
4
|
+
import BrushIcon from "@mui/icons-material/Brush";
|
5
|
+
import DatePicker from "react-datepicker";
|
6
|
+
import "react-datepicker/dist/react-datepicker.css";
|
7
|
+
import SignatureOptions from "./SignatureOptions";
|
8
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
9
|
+
import { jsxs as _jsxs } from "react/jsx-runtime";
|
10
|
+
import { Fragment as _Fragment } from "react/jsx-runtime";
|
11
|
+
const BrushSizes = [1, 3, 5];
|
12
|
+
const SignaturePopup = props => {
|
13
|
+
const {
|
14
|
+
onSave,
|
15
|
+
onClear,
|
16
|
+
customProps
|
17
|
+
} = props;
|
18
|
+
const [open, setOpen] = useState(false);
|
19
|
+
const [tab, setTab] = useState(0);
|
20
|
+
const SeletectedTab = SignatureOptions[tab];
|
21
|
+
const [signedData, setSignedData] = useState({});
|
22
|
+
const [brush, setBrush] = useState({
|
23
|
+
size: 1,
|
24
|
+
color: "#000000"
|
25
|
+
});
|
26
|
+
const handleOpen = () => {
|
27
|
+
setOpen(true);
|
28
|
+
};
|
29
|
+
const handleClose = () => {
|
30
|
+
setOpen(false);
|
31
|
+
};
|
32
|
+
const handleSave = () => {
|
33
|
+
onSave(signedData);
|
34
|
+
handleClose();
|
35
|
+
};
|
36
|
+
const handleClear = () => {
|
37
|
+
onClear();
|
38
|
+
handleClose();
|
39
|
+
};
|
40
|
+
const onDataChange = data => {
|
41
|
+
setSignedData({
|
42
|
+
...signedData,
|
43
|
+
...data
|
44
|
+
});
|
45
|
+
};
|
46
|
+
const onChange = e => {
|
47
|
+
setSignedData({
|
48
|
+
...signedData,
|
49
|
+
[e.target.name]: e.target.value
|
50
|
+
});
|
51
|
+
};
|
52
|
+
const onBrushSize = val => () => {
|
53
|
+
setBrush({
|
54
|
+
...brush,
|
55
|
+
size: val
|
56
|
+
});
|
57
|
+
};
|
58
|
+
const onBrushColor = e => {
|
59
|
+
setBrush({
|
60
|
+
...brush,
|
61
|
+
color: e.target.value
|
62
|
+
});
|
63
|
+
};
|
64
|
+
const onUploadDone = data => {
|
65
|
+
setSignedData({
|
66
|
+
...signedData,
|
67
|
+
...data
|
68
|
+
});
|
69
|
+
handleSave();
|
70
|
+
setOpen(false);
|
71
|
+
};
|
72
|
+
return /*#__PURE__*/_jsxs(_Fragment, {
|
73
|
+
children: [/*#__PURE__*/_jsx("div", {
|
74
|
+
className: `signature-btn-container`,
|
75
|
+
children: /*#__PURE__*/_jsx("button", {
|
76
|
+
contentEditable: false,
|
77
|
+
onClick: handleOpen,
|
78
|
+
children: "Sign Here"
|
79
|
+
})
|
80
|
+
}), /*#__PURE__*/_jsxs(Dialog, {
|
81
|
+
open: open,
|
82
|
+
onClose: handleClose,
|
83
|
+
fullWidth: true,
|
84
|
+
children: [/*#__PURE__*/_jsx(DialogTitle, {
|
85
|
+
children: /*#__PURE__*/_jsxs("div", {
|
86
|
+
style: {
|
87
|
+
display: "flex",
|
88
|
+
justifyContent: "space-between"
|
89
|
+
},
|
90
|
+
children: [/*#__PURE__*/_jsx("div", {
|
91
|
+
style: {
|
92
|
+
display: "flex"
|
93
|
+
},
|
94
|
+
children: "Signature"
|
95
|
+
}), /*#__PURE__*/_jsx("div", {
|
96
|
+
style: {
|
97
|
+
display: "flex"
|
98
|
+
},
|
99
|
+
children: /*#__PURE__*/_jsx(IconButton, {
|
100
|
+
onClick: handleClose,
|
101
|
+
children: /*#__PURE__*/_jsx(CloseIcon, {})
|
102
|
+
})
|
103
|
+
})]
|
104
|
+
})
|
105
|
+
}), /*#__PURE__*/_jsxs(DialogContent, {
|
106
|
+
children: [/*#__PURE__*/_jsxs("div", {
|
107
|
+
className: "signature-btn-grps",
|
108
|
+
children: [/*#__PURE__*/_jsx(Button, {
|
109
|
+
onClick: () => setTab(0),
|
110
|
+
className: tab === 0 ? "active" : "",
|
111
|
+
children: "Draw Signature"
|
112
|
+
}), /*#__PURE__*/_jsx(Button, {
|
113
|
+
onClick: () => setTab(1),
|
114
|
+
className: tab === 1 ? "active" : "",
|
115
|
+
children: "Type Signature"
|
116
|
+
}), /*#__PURE__*/_jsx(Button, {
|
117
|
+
onClick: () => setTab(2),
|
118
|
+
className: tab === 2 ? "active" : "",
|
119
|
+
children: "Upload Signature"
|
120
|
+
})]
|
121
|
+
}), /*#__PURE__*/_jsx("div", {
|
122
|
+
className: "signature-tab-content",
|
123
|
+
children: SeletectedTab ? /*#__PURE__*/_jsx(SeletectedTab, {
|
124
|
+
onDataChange: onDataChange,
|
125
|
+
customProps: {
|
126
|
+
...(customProps || {}),
|
127
|
+
brush: brush
|
128
|
+
},
|
129
|
+
onUploadDone: onUploadDone
|
130
|
+
}) : null
|
131
|
+
}), /*#__PURE__*/_jsxs(Grid, {
|
132
|
+
container: true,
|
133
|
+
padding: 2,
|
134
|
+
style: {
|
135
|
+
display: "flex",
|
136
|
+
justifyContent: "space-between"
|
137
|
+
},
|
138
|
+
children: [/*#__PURE__*/_jsxs(Grid, {
|
139
|
+
item: true,
|
140
|
+
xs: 5,
|
141
|
+
style: {
|
142
|
+
display: "flex",
|
143
|
+
alignItems: "center"
|
144
|
+
},
|
145
|
+
children: [/*#__PURE__*/_jsx(Grid, {
|
146
|
+
style: {
|
147
|
+
marginRight: "8px"
|
148
|
+
},
|
149
|
+
children: /*#__PURE__*/_jsx("label", {
|
150
|
+
htmlFor: "signedBy",
|
151
|
+
children: "Name:"
|
152
|
+
})
|
153
|
+
}), /*#__PURE__*/_jsx(Grid, {
|
154
|
+
children: /*#__PURE__*/_jsx(TextField, {
|
155
|
+
id: "signedBy",
|
156
|
+
name: "signedBy",
|
157
|
+
placeholder: "Enter Name",
|
158
|
+
size: "small",
|
159
|
+
onChange: onChange
|
160
|
+
})
|
161
|
+
})]
|
162
|
+
}), /*#__PURE__*/_jsxs(Grid, {
|
163
|
+
item: true,
|
164
|
+
xs: 5,
|
165
|
+
style: {
|
166
|
+
display: "flex",
|
167
|
+
alignItems: "center"
|
168
|
+
},
|
169
|
+
children: [/*#__PURE__*/_jsx(Grid, {
|
170
|
+
style: {
|
171
|
+
marginRight: "8px"
|
172
|
+
},
|
173
|
+
children: /*#__PURE__*/_jsx("label", {
|
174
|
+
htmlFor: "signedOn",
|
175
|
+
children: "Date:"
|
176
|
+
})
|
177
|
+
}), /*#__PURE__*/_jsx(Grid, {
|
178
|
+
children: /*#__PURE__*/_jsx(DatePicker, {
|
179
|
+
showIcon: true,
|
180
|
+
id: "signedOn",
|
181
|
+
selected: signedData?.signedOn ? new Date(signedData?.signedOn) : new Date(),
|
182
|
+
dateFormat: "MM/dd/yyyy",
|
183
|
+
onChange: date => {
|
184
|
+
setSignedData({
|
185
|
+
...signedData,
|
186
|
+
signedOn: new Date(date).toISOString().split("T")[0]
|
187
|
+
});
|
188
|
+
}
|
189
|
+
})
|
190
|
+
})]
|
191
|
+
})]
|
192
|
+
})]
|
193
|
+
}), /*#__PURE__*/_jsxs(DialogActions, {
|
194
|
+
className: "dialog-actions-si",
|
195
|
+
children: [tab === 0 ? /*#__PURE__*/_jsxs(Grid, {
|
196
|
+
container: true,
|
197
|
+
padding: 2,
|
198
|
+
style: {
|
199
|
+
display: "flex",
|
200
|
+
alignItems: "center"
|
201
|
+
},
|
202
|
+
children: [/*#__PURE__*/_jsx(Grid, {
|
203
|
+
item: true,
|
204
|
+
children: /*#__PURE__*/_jsx("input", {
|
205
|
+
type: "color",
|
206
|
+
className: "brushcolorpic",
|
207
|
+
onChange: onBrushColor,
|
208
|
+
size: "4",
|
209
|
+
value: brush?.color
|
210
|
+
})
|
211
|
+
}), /*#__PURE__*/_jsx(Grid, {
|
212
|
+
item: true,
|
213
|
+
children: /*#__PURE__*/_jsx(Grid, {
|
214
|
+
className: "dflex alignCenter sizeIcons",
|
215
|
+
children: BrushSizes.map(m => {
|
216
|
+
return /*#__PURE__*/_jsx(IconButton, {
|
217
|
+
onClick: onBrushSize(m),
|
218
|
+
disableRipple: true,
|
219
|
+
className: brush.size === m ? "active" : "",
|
220
|
+
children: /*#__PURE__*/_jsx(BrushIcon, {
|
221
|
+
style: {
|
222
|
+
width: 24 + m,
|
223
|
+
height: 24 + m
|
224
|
+
}
|
225
|
+
})
|
226
|
+
}, `sit-bs-${m}`);
|
227
|
+
})
|
228
|
+
})
|
229
|
+
})]
|
230
|
+
}) : null, tab !== 2 ? /*#__PURE__*/_jsxs(_Fragment, {
|
231
|
+
children: [/*#__PURE__*/_jsx(Button, {
|
232
|
+
onClick: handleClear,
|
233
|
+
children: "Clear"
|
234
|
+
}), /*#__PURE__*/_jsx(Button, {
|
235
|
+
onClick: handleSave,
|
236
|
+
children: "Save"
|
237
|
+
})]
|
238
|
+
}) : null]
|
239
|
+
})]
|
240
|
+
})]
|
241
|
+
});
|
242
|
+
};
|
243
|
+
export default SignaturePopup;
|
@@ -0,0 +1,80 @@
|
|
1
|
+
import React, { useState } from "react";
|
2
|
+
import DeleteIcon from "@mui/icons-material/Delete";
|
3
|
+
import { IconButton } from "@mui/material";
|
4
|
+
import { Transforms } from "slate";
|
5
|
+
import { useSlateStatic, ReactEditor } from "slate-react";
|
6
|
+
import { fontFamilyMap } from "../../utils/font";
|
7
|
+
import { formatDate } from "../../utils/helper";
|
8
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
9
|
+
import { jsxs as _jsxs } from "react/jsx-runtime";
|
10
|
+
const Signed = props => {
|
11
|
+
const editor = useSlateStatic();
|
12
|
+
const {
|
13
|
+
attributes,
|
14
|
+
element,
|
15
|
+
children
|
16
|
+
} = props;
|
17
|
+
const {
|
18
|
+
signature,
|
19
|
+
signedBy,
|
20
|
+
signedOn,
|
21
|
+
signedText,
|
22
|
+
fontFamily
|
23
|
+
} = element;
|
24
|
+
const [selected, setSelected] = useState(false);
|
25
|
+
const onSelect = () => {
|
26
|
+
setSelected(!selected);
|
27
|
+
};
|
28
|
+
const onDelete = () => {
|
29
|
+
const path = ReactEditor.findPath(editor, element);
|
30
|
+
Transforms.removeNodes(editor, {
|
31
|
+
at: path
|
32
|
+
});
|
33
|
+
};
|
34
|
+
const renderSign = () => {
|
35
|
+
if (signature) {
|
36
|
+
return /*#__PURE__*/_jsx("img", {
|
37
|
+
src: signature,
|
38
|
+
alt: "signature",
|
39
|
+
style: {
|
40
|
+
width: "150px",
|
41
|
+
height: "auto"
|
42
|
+
}
|
43
|
+
});
|
44
|
+
} else if (signedText) {
|
45
|
+
return /*#__PURE__*/_jsx("span", {
|
46
|
+
className: "signed-text",
|
47
|
+
style: {
|
48
|
+
fontFamily: fontFamilyMap[fontFamily]
|
49
|
+
},
|
50
|
+
children: signedText
|
51
|
+
});
|
52
|
+
}
|
53
|
+
return null;
|
54
|
+
};
|
55
|
+
return /*#__PURE__*/_jsxs("div", {
|
56
|
+
className: "signature-signed-wrapper",
|
57
|
+
...attributes,
|
58
|
+
children: [/*#__PURE__*/_jsxs("span", {
|
59
|
+
className: "signature-signed-span",
|
60
|
+
contentEditable: false,
|
61
|
+
children: [selected ? /*#__PURE__*/_jsx(IconButton, {
|
62
|
+
className: "signed-btn-del",
|
63
|
+
onClick: onDelete,
|
64
|
+
children: /*#__PURE__*/_jsx(DeleteIcon, {})
|
65
|
+
}) : null, /*#__PURE__*/_jsxs("button", {
|
66
|
+
className: "signed-btn",
|
67
|
+
onClick: onSelect,
|
68
|
+
children: [renderSign(), /*#__PURE__*/_jsx("div", {
|
69
|
+
style: {
|
70
|
+
fontWeight: "bold"
|
71
|
+
},
|
72
|
+
children: signedBy || ""
|
73
|
+
}), /*#__PURE__*/_jsx("div", {
|
74
|
+
children: formatDate(signedOn, "MM/DD/YYYY")
|
75
|
+
})]
|
76
|
+
})]
|
77
|
+
}), children]
|
78
|
+
});
|
79
|
+
};
|
80
|
+
export default Signed;
|
@@ -0,0 +1,24 @@
|
|
1
|
+
import React from "react";
|
2
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
3
|
+
import { jsxs as _jsxs } from "react/jsx-runtime";
|
4
|
+
const DeleteCell = () => {
|
5
|
+
return /*#__PURE__*/_jsxs("svg", {
|
6
|
+
width: "24px",
|
7
|
+
height: "24px",
|
8
|
+
viewBox: "0 0 24 24",
|
9
|
+
fill: "none",
|
10
|
+
xmlns: "http://www.w3.org/2000/svg",
|
11
|
+
children: [/*#__PURE__*/_jsx("path", {
|
12
|
+
fillRule: "evenodd",
|
13
|
+
clipRule: "evenodd",
|
14
|
+
d: "M20 16V20L4 20V4H20V8H18.5V5.5H15V18.5L18.5 18.5V16H20ZM5.5 16.5V18.5H8.5V16.5L5.5 16.5ZM10 16.5V18.5L13.5 18.5V16.5L10 16.5ZM13.5 8.01957V5.5H10V8.01958L13.5 8.01957ZM8.5 8.01958V5.5H5.5V8.01959L8.5 8.01958ZM8.5 9.51958L5.5 9.51959V11.5L8.5 11.5V9.51958ZM8.5 13L5.5 13V15L8.5 15V13ZM10 13V15L13.5 15V13L10 13ZM10 11.5L13.5 11.5V9.51957L10 9.51958V11.5Z",
|
15
|
+
fill: "#1F2328"
|
16
|
+
}), /*#__PURE__*/_jsx("path", {
|
17
|
+
fillRule: "evenodd",
|
18
|
+
clipRule: "evenodd",
|
19
|
+
d: "M18.7176 13.0606L19.9373 14.2803L20.9979 13.2197L19.7782 12L20.9979 10.7803L19.9372 9.71967L18.7176 10.9393L17.4979 9.71968L16.4373 10.7803L17.6569 12L16.4373 13.2196L17.4979 14.2803L18.7176 13.0606Z",
|
20
|
+
fill: "#1F2328"
|
21
|
+
})]
|
22
|
+
});
|
23
|
+
};
|
24
|
+
export default DeleteCell;
|
@@ -0,0 +1,24 @@
|
|
1
|
+
import React from "react";
|
2
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
3
|
+
import { jsxs as _jsxs } from "react/jsx-runtime";
|
4
|
+
const DeleteCell = () => {
|
5
|
+
return /*#__PURE__*/_jsxs("svg", {
|
6
|
+
width: "24px",
|
7
|
+
height: "24px",
|
8
|
+
viewBox: "0 0 24 24",
|
9
|
+
fill: "none",
|
10
|
+
xmlns: "http://www.w3.org/2000/svg",
|
11
|
+
children: [/*#__PURE__*/_jsx("path", {
|
12
|
+
fillRule: "evenodd",
|
13
|
+
clipRule: "evenodd",
|
14
|
+
d: "M20 4H4V20H8V18.5H5.5V13H18.5V18.5H16V20H20V4ZM5.5 8V5.5H8.5V8H5.5ZM10 8V5.5H14L13.9999 8H10ZM15.4999 8L15.5 5.5H18.5V8H15.4999ZM15.4999 9.5H18.5V11.5H15.4998L15.4999 9.5ZM8.5 11.5H5.5V9.5H8.5V11.5ZM10 11.5V9.5H13.9999L13.9998 11.5H10Z",
|
15
|
+
fill: "#1F2328"
|
16
|
+
}), /*#__PURE__*/_jsx("path", {
|
17
|
+
fillRule: "evenodd",
|
18
|
+
clipRule: "evenodd",
|
19
|
+
d: "M12 18.7804L13.2197 20.0001L14.2803 18.9395L13.0606 17.7197L14.2802 16.5001L13.2196 15.4395L12 16.6591L10.7803 15.4395L9.71968 16.5001L10.9393 17.7197L9.71967 18.9394L10.7803 20.0001L12 18.7804Z",
|
20
|
+
fill: "#1F2328"
|
21
|
+
})]
|
22
|
+
});
|
23
|
+
};
|
24
|
+
export default DeleteCell;
|
@@ -5,13 +5,21 @@ const Table = ({
|
|
5
5
|
children,
|
6
6
|
element
|
7
7
|
}) => {
|
8
|
+
const {
|
9
|
+
bgColor,
|
10
|
+
borderColor
|
11
|
+
} = element;
|
8
12
|
return /*#__PURE__*/_jsx("div", {
|
9
13
|
style: {
|
10
14
|
minWidth: "100%",
|
11
15
|
maxWidth: "100%",
|
12
|
-
|
16
|
+
position: "relative"
|
13
17
|
},
|
14
18
|
children: /*#__PURE__*/_jsx("table", {
|
19
|
+
style: {
|
20
|
+
backgroundColor: bgColor,
|
21
|
+
border: `1px solid ${borderColor}`
|
22
|
+
},
|
15
23
|
children: /*#__PURE__*/_jsx("tbody", {
|
16
24
|
...attributes,
|
17
25
|
children: children
|
@@ -0,0 +1,181 @@
|
|
1
|
+
import React, { useState } from "react";
|
2
|
+
import { Transforms, Editor, Element } from "slate";
|
3
|
+
import { useSelected, useSlateStatic, ReactEditor } from "slate-react";
|
4
|
+
import { IconButton } from "@mui/material";
|
5
|
+
import AlignHorizontalLeftIcon from "@mui/icons-material/AlignHorizontalLeft";
|
6
|
+
import AlignHorizontalRightIcon from "@mui/icons-material/AlignHorizontalRight";
|
7
|
+
import AlignVerticalTopIcon from "@mui/icons-material/AlignVerticalTop";
|
8
|
+
import AlignVerticalBottomIcon from "@mui/icons-material/AlignVerticalBottom";
|
9
|
+
import DeleteForeverIcon from "@mui/icons-material/DeleteForever";
|
10
|
+
import SettingsIcon from "@mui/icons-material/Settings";
|
11
|
+
import DeleteCellIcon from "./DeleteCellIcon";
|
12
|
+
import DeleteRowIcon from "./DeleteRowIcon";
|
13
|
+
import { TableUtil } from "../../utils/table";
|
14
|
+
import TablePopup from "./TablePopup";
|
15
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
16
|
+
import { jsxs as _jsxs } from "react/jsx-runtime";
|
17
|
+
const TABLE_MENUS = [{
|
18
|
+
Icon: AlignHorizontalRightIcon,
|
19
|
+
text: "Insert Columns to the Right",
|
20
|
+
action: {
|
21
|
+
type: "insertColumn",
|
22
|
+
position: "after"
|
23
|
+
}
|
24
|
+
}, {
|
25
|
+
Icon: AlignHorizontalLeftIcon,
|
26
|
+
text: "Insert Columns to the Left",
|
27
|
+
action: {
|
28
|
+
type: "insertColumn",
|
29
|
+
position: "at"
|
30
|
+
}
|
31
|
+
}, {
|
32
|
+
Icon: AlignVerticalTopIcon,
|
33
|
+
text: "Insert Row Above",
|
34
|
+
action: {
|
35
|
+
type: "insertRow",
|
36
|
+
positon: "at"
|
37
|
+
}
|
38
|
+
}, {
|
39
|
+
Icon: AlignVerticalBottomIcon,
|
40
|
+
text: "Insert Row Below",
|
41
|
+
action: {
|
42
|
+
type: "insertRow",
|
43
|
+
position: "after"
|
44
|
+
}
|
45
|
+
}, {
|
46
|
+
Icon: DeleteRowIcon,
|
47
|
+
text: "Delete Row",
|
48
|
+
action: {
|
49
|
+
type: "deleteRow"
|
50
|
+
}
|
51
|
+
}, {
|
52
|
+
Icon: DeleteCellIcon,
|
53
|
+
text: "Delete Column",
|
54
|
+
action: {
|
55
|
+
type: "deleteColumn"
|
56
|
+
}
|
57
|
+
}, {
|
58
|
+
Icon: SettingsIcon,
|
59
|
+
text: "Settings",
|
60
|
+
action: {
|
61
|
+
type: "settings"
|
62
|
+
}
|
63
|
+
}, {
|
64
|
+
Icon: DeleteForeverIcon,
|
65
|
+
text: "Remove Table",
|
66
|
+
action: {
|
67
|
+
type: "remove"
|
68
|
+
}
|
69
|
+
}];
|
70
|
+
const TableCell = props => {
|
71
|
+
const {
|
72
|
+
element,
|
73
|
+
attributes,
|
74
|
+
children,
|
75
|
+
customProps
|
76
|
+
} = props;
|
77
|
+
const [openSetttings, setOpenSettings] = useState(false);
|
78
|
+
const {
|
79
|
+
bgColor,
|
80
|
+
borderColor
|
81
|
+
} = element;
|
82
|
+
const editor = useSlateStatic();
|
83
|
+
const selected = useSelected();
|
84
|
+
const table = new TableUtil(editor);
|
85
|
+
const tableProps = table.getTableProps();
|
86
|
+
const path = ReactEditor.findPath(editor, element);
|
87
|
+
const [tableNode] = Editor.nodes(editor, {
|
88
|
+
at: path,
|
89
|
+
match: n => !Editor.isEditor(n) && Element.isElement(n) && n.type === "table"
|
90
|
+
});
|
91
|
+
const [rowNode] = Editor.nodes(editor, {
|
92
|
+
at: path,
|
93
|
+
match: n => !Editor.isEditor(n) && Element.isElement(n) && n.type === "table-row"
|
94
|
+
});
|
95
|
+
const [parentProps] = tableNode || [{}];
|
96
|
+
const [rowProps] = rowNode || [{}];
|
97
|
+
const handleInsert = ({
|
98
|
+
type,
|
99
|
+
position
|
100
|
+
}) => () => {
|
101
|
+
Transforms.select(editor, editor.selection);
|
102
|
+
switch (type) {
|
103
|
+
case "insertRow":
|
104
|
+
table.insertRow(position);
|
105
|
+
break;
|
106
|
+
case "insertColumn":
|
107
|
+
table.insertColumn(position);
|
108
|
+
break;
|
109
|
+
case "deleteRow":
|
110
|
+
table.deleteRow();
|
111
|
+
break;
|
112
|
+
case "deleteColumn":
|
113
|
+
table.deleteColumn();
|
114
|
+
break;
|
115
|
+
case "remove":
|
116
|
+
table.removeTable();
|
117
|
+
break;
|
118
|
+
case "settings":
|
119
|
+
if (tableProps) {
|
120
|
+
onSettings(true);
|
121
|
+
}
|
122
|
+
break;
|
123
|
+
default:
|
124
|
+
return;
|
125
|
+
}
|
126
|
+
};
|
127
|
+
const ToolBar = () => {
|
128
|
+
return selected ? /*#__PURE__*/_jsx("div", {
|
129
|
+
contentEditable: false,
|
130
|
+
style: {
|
131
|
+
position: "absolute",
|
132
|
+
top: "-40px",
|
133
|
+
left: 0,
|
134
|
+
backgroundColor: "#CCC"
|
135
|
+
},
|
136
|
+
children: TABLE_MENUS.map(({
|
137
|
+
Icon,
|
138
|
+
text,
|
139
|
+
action
|
140
|
+
}) => {
|
141
|
+
return /*#__PURE__*/_jsx(IconButton, {
|
142
|
+
title: text,
|
143
|
+
onClick: handleInsert(action),
|
144
|
+
children: /*#__PURE__*/_jsx(Icon, {})
|
145
|
+
}, text);
|
146
|
+
})
|
147
|
+
}) : null;
|
148
|
+
};
|
149
|
+
const onSettings = () => {
|
150
|
+
setOpenSettings(true);
|
151
|
+
};
|
152
|
+
const onSave = data => {
|
153
|
+
const updateData = {
|
154
|
+
...data
|
155
|
+
};
|
156
|
+
delete updateData.children;
|
157
|
+
delete updateData.type;
|
158
|
+
table.updateTableStyle(updateData, {
|
159
|
+
...tableProps
|
160
|
+
});
|
161
|
+
onClose();
|
162
|
+
};
|
163
|
+
const onClose = () => {
|
164
|
+
setOpenSettings(false);
|
165
|
+
};
|
166
|
+
return /*#__PURE__*/_jsxs("td", {
|
167
|
+
...element.attr,
|
168
|
+
...attributes,
|
169
|
+
style: {
|
170
|
+
backgroundColor: bgColor,
|
171
|
+
border: `3px solid ${borderColor || rowProps?.borderColor || parentProps?.borderColor}`
|
172
|
+
},
|
173
|
+
children: [/*#__PURE__*/_jsx(ToolBar, {}), children, openSetttings ? /*#__PURE__*/_jsx(TablePopup, {
|
174
|
+
element: tableProps?.styleProps || {},
|
175
|
+
onSave: onSave,
|
176
|
+
onClose: onClose,
|
177
|
+
customProps: customProps
|
178
|
+
}) : null]
|
179
|
+
});
|
180
|
+
};
|
181
|
+
export default TableCell;
|
@@ -0,0 +1,22 @@
|
|
1
|
+
import React from "react";
|
2
|
+
import StyleBuilder from "../../common/StyleBuilder";
|
3
|
+
import tableStyle from "../../common/StyleBuilder/tableStyle";
|
4
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
5
|
+
const TablePopup = props => {
|
6
|
+
const {
|
7
|
+
element,
|
8
|
+
onSave,
|
9
|
+
onClose,
|
10
|
+
customProps
|
11
|
+
} = props;
|
12
|
+
return /*#__PURE__*/_jsx(StyleBuilder, {
|
13
|
+
title: "Table",
|
14
|
+
type: "gridStyle",
|
15
|
+
element: element,
|
16
|
+
onSave: onSave,
|
17
|
+
onClose: onClose,
|
18
|
+
renderTabs: tableStyle,
|
19
|
+
customProps: customProps
|
20
|
+
});
|
21
|
+
};
|
22
|
+
export default TablePopup;
|
@@ -0,0 +1,31 @@
|
|
1
|
+
import React from "react";
|
2
|
+
import { Editor, Element } from "slate";
|
3
|
+
import { useSlateStatic, ReactEditor } from "slate-react";
|
4
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
5
|
+
const TableRow = props => {
|
6
|
+
const {
|
7
|
+
attributes,
|
8
|
+
children,
|
9
|
+
element
|
10
|
+
} = props;
|
11
|
+
const {
|
12
|
+
bgColor,
|
13
|
+
borderColor
|
14
|
+
} = element;
|
15
|
+
const editor = useSlateStatic();
|
16
|
+
const path = ReactEditor.findPath(editor, element);
|
17
|
+
const [tableNode] = Editor.nodes(editor, {
|
18
|
+
at: path,
|
19
|
+
match: n => !Editor.isEditor(n) && Element.isElement(n) && n.type === "table"
|
20
|
+
});
|
21
|
+
const [tableProps] = tableNode || [{}];
|
22
|
+
return /*#__PURE__*/_jsx("tr", {
|
23
|
+
...attributes,
|
24
|
+
style: {
|
25
|
+
backgroundColor: bgColor,
|
26
|
+
border: `1px solid ${borderColor || tableProps?.borderColor}`
|
27
|
+
},
|
28
|
+
children: children
|
29
|
+
});
|
30
|
+
};
|
31
|
+
export default TableRow;
|