@flozy/editor 5.0.0 → 5.0.2
Sign up to get free protection for your applications and to get access to all the features.
- package/dist/Editor/CommonEditor.js +5 -3
- package/dist/Editor/Editor.css +14 -3
- package/dist/Editor/Elements/Carousel/Carousel.js +2 -1
- package/dist/Editor/Elements/Carousel/slick.min.css +1 -1
- package/dist/Editor/Elements/Color Picker/ColorButtons.js +2 -2
- package/dist/Editor/Elements/Embed/Image.js +3 -2
- package/dist/Editor/Elements/Grid/Grid.js +1 -1
- package/dist/Editor/Elements/Grid/GridItem.js +4 -1
- package/dist/Editor/Elements/Grid/Styles.js +2 -2
- package/dist/Editor/Elements/Table/Table.js +7 -4
- package/dist/Editor/Elements/Table/TableCell.js +7 -6
- package/dist/Editor/Elements/TopBanner/Styles.js +18 -12
- package/dist/Editor/Elements/TopBanner/TopBanner.js +15 -6
- package/dist/Editor/Toolbar/PopupTool/PopupToolStyle.js +14 -8
- package/dist/Editor/Toolbar/PopupTool/index.js +10 -4
- package/dist/Editor/common/Icon.js +5 -1
- package/dist/Editor/common/Section/index.js +1 -1
- package/dist/Editor/common/StyleBuilder/fieldTypes/alignment.js +45 -27
- package/dist/Editor/helper/deserialize/index.js +4 -1
- package/dist/Editor/helper/index.js +21 -1
- package/dist/Editor/hooks/useTable.js +5 -4
- package/dist/Editor/plugins/withEmbeds.js +27 -1
- package/dist/Editor/utils/helper.js +32 -0
- package/dist/Editor/utils/table.js +34 -13
- package/package.json +4 -2
@@ -298,9 +298,11 @@ const CommonEditor = /*#__PURE__*/forwardRef((props, ref) => {
|
|
298
298
|
hideTools: updatedHideTools || []
|
299
299
|
}) : [];
|
300
300
|
const handleEditorChange = newValue => {
|
301
|
-
|
302
|
-
|
303
|
-
|
301
|
+
if (JSON.stringify(newValue) !== JSON.stringify(debouncedValue?.current)) {
|
302
|
+
debounced(newValue);
|
303
|
+
if (!isInteracted) {
|
304
|
+
setIsInteracted(true);
|
305
|
+
}
|
304
306
|
}
|
305
307
|
};
|
306
308
|
const onDrawerOpen = status => {
|
package/dist/Editor/Editor.css
CHANGED
@@ -648,9 +648,12 @@ blockquote {
|
|
648
648
|
height: fit-content;
|
649
649
|
margin-left: auto;
|
650
650
|
margin-right: auto;
|
651
|
-
|
652
|
-
|
653
|
-
|
651
|
+
padding: 4px;
|
652
|
+
border-radius: 8px;
|
653
|
+
}
|
654
|
+
|
655
|
+
.embed .element-toolbar .last-btn {
|
656
|
+
margin-right: 0px
|
654
657
|
}
|
655
658
|
|
656
659
|
.embed-code .element-toolbar {
|
@@ -667,6 +670,13 @@ blockquote {
|
|
667
670
|
position: absolute !important;
|
668
671
|
bottom: 2px;
|
669
672
|
right: 2px;
|
673
|
+
border-radius: 7px !important;
|
674
|
+
padding: 2px !important;
|
675
|
+
color: #64748B !important;
|
676
|
+
}
|
677
|
+
|
678
|
+
.resize-br.img-resizer {
|
679
|
+
bottom: 8px;
|
670
680
|
}
|
671
681
|
|
672
682
|
.visible-on-hover {
|
@@ -814,6 +824,7 @@ blockquote {
|
|
814
824
|
|
815
825
|
.element-toolbar button {
|
816
826
|
margin-right: 4px;
|
827
|
+
margin-bottom: 0px;
|
817
828
|
}
|
818
829
|
|
819
830
|
.empty-carousel-wrapper .element-selector {
|
@@ -121,7 +121,7 @@ const Carousel = props => {
|
|
121
121
|
};
|
122
122
|
return /*#__PURE__*/_jsxs("div", {
|
123
123
|
...attributes,
|
124
|
-
className:
|
124
|
+
className: `sliderBg ${edit ? "carousel_slider_edit" : ""}`,
|
125
125
|
style: {
|
126
126
|
backgroundColor: "transparent",
|
127
127
|
position: "relative"
|
@@ -136,6 +136,7 @@ const Carousel = props => {
|
|
136
136
|
style: {
|
137
137
|
padding: "12px"
|
138
138
|
},
|
139
|
+
contentEditable: false,
|
139
140
|
children: /*#__PURE__*/_jsx(Slider, {
|
140
141
|
...settings,
|
141
142
|
children: children.map((m, i) => {
|
@@ -13,9 +13,9 @@
|
|
13
13
|
-webkit-user-select: none;
|
14
14
|
-moz-user-select: none;
|
15
15
|
-ms-user-select: none;
|
16
|
-
user-select: none;
|
17
16
|
-webkit-touch-callout: none;
|
18
17
|
-khtml-user-select: none;
|
18
|
+
user-select: none;
|
19
19
|
-ms-touch-action: pan-y;
|
20
20
|
touch-action: pan-y;
|
21
21
|
-webkit-tap-highlight-color: transparent;
|
@@ -1,6 +1,6 @@
|
|
1
1
|
import React, { useState } from "react";
|
2
2
|
import { Box, IconButton, Popover } from "@mui/material";
|
3
|
-
import
|
3
|
+
import KeyboardArrowDownRoundedIcon from "@mui/icons-material/KeyboardArrowDownRounded";
|
4
4
|
import Button from "../../common/Button";
|
5
5
|
import { colors } from "./defaultColors";
|
6
6
|
import ColorPicker from "./colorPicker.svg";
|
@@ -46,7 +46,7 @@ const SingleColorButton = ({
|
|
46
46
|
id: `in_${id}`,
|
47
47
|
onClick: handleMore,
|
48
48
|
className: "more-btn-cbs",
|
49
|
-
children: /*#__PURE__*/_jsx(
|
49
|
+
children: /*#__PURE__*/_jsx(KeyboardArrowDownRoundedIcon, {})
|
50
50
|
}) : null]
|
51
51
|
}, `ci_bs_row_${index}}`);
|
52
52
|
};
|
@@ -41,6 +41,7 @@ const ToolBar = ({
|
|
41
41
|
title: "Link Settings",
|
42
42
|
arrow: true,
|
43
43
|
children: /*#__PURE__*/_jsx(IconButton, {
|
44
|
+
className: "last-btn",
|
44
45
|
onClick: () => setOpenNav(true),
|
45
46
|
children: /*#__PURE__*/_jsx(LinkIcon, {})
|
46
47
|
})
|
@@ -299,13 +300,13 @@ const Image = props => {
|
|
299
300
|
editor: editor,
|
300
301
|
handleImageClick: handleImageClick
|
301
302
|
})
|
302
|
-
}) : null, selected && !readOnly && /*#__PURE__*/_jsx(IconButton, {
|
303
|
+
}) : null, selected && !readOnly && url && /*#__PURE__*/_jsx(IconButton, {
|
303
304
|
onPointerDown: onMouseDown,
|
304
305
|
style: {
|
305
306
|
opacity: 1,
|
306
307
|
background: "#FFF"
|
307
308
|
},
|
308
|
-
className: "resize-br visible-on-hover",
|
309
|
+
className: "resize-br visible-on-hover img-resizer",
|
309
310
|
children: /*#__PURE__*/_jsx(AspectRatioIcon, {})
|
310
311
|
})]
|
311
312
|
}), /*#__PURE__*/_jsx("span", {
|
@@ -312,7 +312,7 @@ const Grid = props => {
|
|
312
312
|
return /*#__PURE__*/_jsx(GridProvider, {
|
313
313
|
children: /*#__PURE__*/_jsxs(GridContainer, {
|
314
314
|
container: true,
|
315
|
-
className: `grid-container ${grid}
|
315
|
+
className: `grid-container ${grid} element-root dpath ${equalItems ? "equal-cols" : ""} cc-${element?.children?.length}`,
|
316
316
|
...attributes,
|
317
317
|
...sectionId,
|
318
318
|
sx: {
|
@@ -125,6 +125,7 @@ const GridItem = props => {
|
|
125
125
|
const [parentDOM, setParentDOM] = useState({});
|
126
126
|
const [alert, setAlert] = useState(null);
|
127
127
|
const childCount = getChildCount(editor, path);
|
128
|
+
const lastChild = childCount - 1 === [...path].pop();
|
128
129
|
const [size, onMouseDown, resizing, onLoad, isDone] = useTableResize({
|
129
130
|
...parentDOM
|
130
131
|
});
|
@@ -283,6 +284,7 @@ const GridItem = props => {
|
|
283
284
|
}
|
284
285
|
},
|
285
286
|
"data-path": path.join(","),
|
287
|
+
"data-info": "handle-outside-editor-click",
|
286
288
|
children: [!readOnly && /*#__PURE__*/_jsxs("div", {
|
287
289
|
className: `element-selector ${selected ? "selected" : ""}`,
|
288
290
|
contentEditable: false,
|
@@ -327,6 +329,7 @@ const GridItem = props => {
|
|
327
329
|
}
|
328
330
|
},
|
329
331
|
placeholder: "Column",
|
332
|
+
"data-info": "handle-outside-editor-click",
|
330
333
|
children: children
|
331
334
|
}), openSetttings ? /*#__PURE__*/_jsx(GridItemPopup, {
|
332
335
|
element: element,
|
@@ -336,7 +339,7 @@ const GridItem = props => {
|
|
336
339
|
customProps: customProps
|
337
340
|
}) : null, !readOnly ? /*#__PURE__*/_jsx(Resizer, {
|
338
341
|
classes: classes,
|
339
|
-
className: resizing ? "resizing" : ""
|
342
|
+
className: `${lastChild ? "last-resize" : ""} ${resizing ? "resizing" : ""}`,
|
340
343
|
onMouseDown: onMouseDown,
|
341
344
|
height: "auto"
|
342
345
|
}) : null, /*#__PURE__*/_jsxs(Dialog, {
|
@@ -172,15 +172,18 @@ const Table = props => {
|
|
172
172
|
table.insertColumn("after");
|
173
173
|
Transforms.deselect(editor);
|
174
174
|
};
|
175
|
-
const
|
176
|
-
containerRef?.current?.classList.add("hideScroll");
|
177
|
-
}, 200);
|
178
|
-
const handleScroll = () => {
|
175
|
+
const handleRowDragBtns = () => {
|
179
176
|
if (containerRef?.current?.scrollLeft > 0) {
|
180
177
|
hideRowDragBtns("none", dragRowBtnCls);
|
181
178
|
} else {
|
182
179
|
hideRowDragBtns("", dragRowBtnCls);
|
183
180
|
}
|
181
|
+
};
|
182
|
+
const handleScrollStop = useDebouncedCallback(() => {
|
183
|
+
containerRef?.current?.classList.add("hideScroll");
|
184
|
+
}, 200);
|
185
|
+
const handleScroll = () => {
|
186
|
+
handleRowDragBtns();
|
184
187
|
containerRef?.current?.classList.remove("hideScroll");
|
185
188
|
handleScrollStop();
|
186
189
|
};
|
@@ -113,6 +113,7 @@ const TableCell = props => {
|
|
113
113
|
const tableDOM = table.getDOMNode(path, true);
|
114
114
|
const isCellSelected = getSelectedCells();
|
115
115
|
const hasSelected = (isCellSelected || [])?.findIndex(f => f.join(",") === path.join(",")) > -1;
|
116
|
+
const containerEle = tableDOM?.parentNode?.parentNode;
|
116
117
|
useEffect(() => {
|
117
118
|
if (tableDOM) {
|
118
119
|
const {
|
@@ -165,7 +166,7 @@ const TableCell = props => {
|
|
165
166
|
if (!resizing && tableResizing) {
|
166
167
|
table.resizeTableCell({
|
167
168
|
"col.size": size
|
168
|
-
},
|
169
|
+
}, path);
|
169
170
|
}
|
170
171
|
if (resizing) {
|
171
172
|
setTableResizing(currentPath);
|
@@ -204,9 +205,8 @@ const TableCell = props => {
|
|
204
205
|
});
|
205
206
|
}
|
206
207
|
};
|
207
|
-
const onMouseUp =
|
208
|
+
const onMouseUp = () => {
|
208
209
|
if (startCellPath?.length) {
|
209
|
-
e.preventDefault();
|
210
210
|
updateTableSelection({
|
211
211
|
endCellPath: path,
|
212
212
|
isDragging: false
|
@@ -231,7 +231,7 @@ const TableCell = props => {
|
|
231
231
|
});
|
232
232
|
}
|
233
233
|
};
|
234
|
-
const cellId = path.toString()
|
234
|
+
const cellId = "table-cell" + path.toString();
|
235
235
|
const cellRef = document.getElementById(cellId);
|
236
236
|
const contentEditable = !readOnly && isCellEditable(startCellPath, path);
|
237
237
|
const commonTdProps = useMemo(() => {
|
@@ -280,7 +280,7 @@ const TableCell = props => {
|
|
280
280
|
const isCellDragging = active?.id && active?.id === cellId;
|
281
281
|
const isRowDragging = isCellDragging && currentDraggingType === "row";
|
282
282
|
const isColDragging = isCellDragging && currentDraggingType === "col";
|
283
|
-
const width = size?.width || tableSize?.cellWidth;
|
283
|
+
const width = isHeader ? size?.width || tableSize?.cellWidth : "0px";
|
284
284
|
const sizeProps = {
|
285
285
|
minWidth: width,
|
286
286
|
maxWidth: width
|
@@ -390,6 +390,7 @@ const TableCell = props => {
|
|
390
390
|
dndProps,
|
391
391
|
resetSelection
|
392
392
|
};
|
393
|
+
const showRowDragBtn = (showRowDrag || isRowDragging) && containerEle?.scrollLeft <= 0;
|
393
394
|
return /*#__PURE__*/_jsxs(_Fragment, {
|
394
395
|
children: [/*#__PURE__*/_jsxs("td", {
|
395
396
|
...element.attr,
|
@@ -429,7 +430,7 @@ const TableCell = props => {
|
|
429
430
|
dragType: "col",
|
430
431
|
onDrag: onColDrag,
|
431
432
|
hideDelete: rowProps?.children?.length <= 1
|
432
|
-
}) : null,
|
433
|
+
}) : null, showRowDragBtn ? /*#__PURE__*/_jsx(DragButton, {
|
433
434
|
...commonDragBtnProps,
|
434
435
|
dragType: "row",
|
435
436
|
onDrag: onRowDrag,
|
@@ -1,4 +1,4 @@
|
|
1
|
-
const TopBannerStyles =
|
1
|
+
const TopBannerStyles = theme => ({
|
2
2
|
root: {
|
3
3
|
"&:hover": {
|
4
4
|
"& .tb-toolbar": {
|
@@ -9,23 +9,29 @@ const TopBannerStyles = () => ({
|
|
9
9
|
toolbar: {
|
10
10
|
position: "absolute",
|
11
11
|
width: "auto",
|
12
|
-
bottom: "
|
13
|
-
left: 0,
|
12
|
+
bottom: "23px",
|
14
13
|
right: 0,
|
15
14
|
margin: "auto",
|
16
15
|
display: "none",
|
17
16
|
"& button": {
|
18
|
-
background:
|
19
|
-
border:
|
20
|
-
borderRadius: "
|
21
|
-
color: "#
|
17
|
+
background: theme?.palette?.editor?.background,
|
18
|
+
border: `1px solid ${theme?.palette?.editor?.popUpBorderColor}`,
|
19
|
+
borderRadius: "50%",
|
20
|
+
color: "#000",
|
22
21
|
marginRight: "8px",
|
23
|
-
padding: "4px
|
24
|
-
|
25
|
-
fontSize: "14px",
|
22
|
+
padding: "4px",
|
23
|
+
boxShadow: '0px 0px 32px rgba(255, 255, 255, 0.12)',
|
26
24
|
"&:hover": {
|
27
|
-
background:
|
28
|
-
|
25
|
+
background: theme?.palette?.editor?.background,
|
26
|
+
border: `1px solid ${theme?.palette?.editor?.activeColor}`,
|
27
|
+
"& svg": {
|
28
|
+
fill: theme?.palette?.editor?.activeColor
|
29
|
+
}
|
30
|
+
},
|
31
|
+
"& svg": {
|
32
|
+
width: '20px',
|
33
|
+
height: '20px',
|
34
|
+
fill: theme?.palette?.editor?.menuOptionTextColor
|
29
35
|
}
|
30
36
|
}
|
31
37
|
}
|
@@ -1,8 +1,10 @@
|
|
1
1
|
import React, { useState } from "react";
|
2
|
-
import { Box,
|
2
|
+
import { Box, IconButton } from "@mui/material";
|
3
3
|
import { updateTopBanner, removeTopBanner } from "../../utils/topBanner";
|
4
4
|
import ImageSelector from "../../common/ImageSelector/ImageSelector";
|
5
5
|
import TopBannerStyles from "./Styles";
|
6
|
+
import Icon from "../../common/Icon";
|
7
|
+
import { useEditorContext } from "../../hooks/useMouseMove";
|
6
8
|
import { jsx as _jsx } from "react/jsx-runtime";
|
7
9
|
import { jsxs as _jsxs } from "react/jsx-runtime";
|
8
10
|
import { Fragment as _Fragment } from "react/jsx-runtime";
|
@@ -39,12 +41,16 @@ export const TopBannerToolbar = props => {
|
|
39
41
|
component: "div",
|
40
42
|
className: "tb-toolbar",
|
41
43
|
sx: classes.toolbar,
|
42
|
-
children: [/*#__PURE__*/_jsx(
|
44
|
+
children: [/*#__PURE__*/_jsx(IconButton, {
|
43
45
|
onClick: handleClick("change"),
|
44
|
-
children:
|
45
|
-
|
46
|
+
children: /*#__PURE__*/_jsx(Icon, {
|
47
|
+
icon: "editIcon"
|
48
|
+
})
|
49
|
+
}), /*#__PURE__*/_jsx(IconButton, {
|
46
50
|
onClick: handleClick("remove"),
|
47
|
-
children:
|
51
|
+
children: /*#__PURE__*/_jsx(Icon, {
|
52
|
+
icon: "deleteIcon"
|
53
|
+
})
|
48
54
|
})]
|
49
55
|
}), /*#__PURE__*/_jsx(ImageSelector, {
|
50
56
|
open: open,
|
@@ -67,7 +73,10 @@ const TopBanner = props => {
|
|
67
73
|
const {
|
68
74
|
url
|
69
75
|
} = element;
|
70
|
-
const
|
76
|
+
const {
|
77
|
+
theme
|
78
|
+
} = useEditorContext();
|
79
|
+
const classes = TopBannerStyles(theme);
|
71
80
|
return /*#__PURE__*/_jsxs(Box, {
|
72
81
|
component: "div",
|
73
82
|
...attributes,
|
@@ -25,17 +25,23 @@ const usePopupStyle = theme => ({
|
|
25
25
|
borderRadius: "0px !important"
|
26
26
|
},
|
27
27
|
"& .inputField": {
|
28
|
-
height:
|
29
|
-
|
30
|
-
padding:
|
28
|
+
height: "29px",
|
29
|
+
"& .MuiIconButton-root": {
|
30
|
+
padding: "5px"
|
31
|
+
},
|
32
|
+
"& .MuiOutlinedInput-root ": {
|
33
|
+
background: `${theme?.palette?.editor?.inputFieldBgColor}`,
|
34
|
+
borderRadius: "8px",
|
35
|
+
border: `1px solid ${theme?.palette?.editor?.inputFieldBorder}`
|
31
36
|
},
|
32
37
|
"& .MuiFormControl-root": {
|
33
|
-
background: theme?.palette?.editor?.inputFieldBgColor
|
34
|
-
borderRadius: "8px"
|
38
|
+
background: `${theme?.palette?.editor?.inputFieldBgColor} !important`,
|
39
|
+
borderRadius: "8px",
|
40
|
+
height: "29px"
|
35
41
|
},
|
36
42
|
"& .MuiOutlinedInput-notchedOutline": {
|
37
43
|
borderRadius: "8px",
|
38
|
-
border: `1px solid
|
44
|
+
border: `1px solid transparent`
|
39
45
|
},
|
40
46
|
"& .MuiOutlinedInput-input": {
|
41
47
|
padding: "3px 35px 4px 2px !important"
|
@@ -43,8 +49,8 @@ const usePopupStyle = theme => ({
|
|
43
49
|
"& .MuiInputBase-adornedStart": {
|
44
50
|
padding: "0px 0px 0px 9px"
|
45
51
|
},
|
46
|
-
|
47
|
-
|
52
|
+
"& svg": {
|
53
|
+
"& path": {
|
48
54
|
stroke: `${theme?.palette?.editor?.closeButtonSvgStroke} !important`
|
49
55
|
}
|
50
56
|
}
|
@@ -1,6 +1,6 @@
|
|
1
1
|
import React, { useCallback, useEffect, useState } from "react";
|
2
2
|
import { Popper, Fade, Paper, ClickAwayListener } from "@mui/material";
|
3
|
-
import { Editor, Range } from "slate";
|
3
|
+
import { Editor, Range, Transforms } from "slate";
|
4
4
|
import { ReactEditor, useSlate } from "slate-react";
|
5
5
|
import useDrag from "../../hooks/useDrag";
|
6
6
|
import useWindowResize from "../../hooks/useWindowResize";
|
@@ -8,6 +8,7 @@ import MiniTextFormat from "./MiniTextFormat";
|
|
8
8
|
import { useEditorContext } from "../../hooks/useMouseMove";
|
9
9
|
import usePopupStyles from "../PopupTool/PopupToolStyle";
|
10
10
|
import useEditorScroll from "../../hooks/useEditorScroll";
|
11
|
+
import { isCarouselSelected } from "../../helper";
|
11
12
|
import { jsx as _jsx } from "react/jsx-runtime";
|
12
13
|
const PopupTool = props => {
|
13
14
|
const {
|
@@ -63,10 +64,15 @@ const PopupTool = props => {
|
|
63
64
|
// for table cell selection
|
64
65
|
// const isCellsSelected = table.isCellSelected(editor.selection);
|
65
66
|
// if (!isCellsSelected) {
|
66
|
-
setOpen(true);
|
67
|
-
setPopupType("textFormat");
|
68
|
-
setIsTextSelected(true);
|
69
67
|
// }
|
68
|
+
const isCarouselEdit = isCarouselSelected(editor);
|
69
|
+
if (isCarouselEdit) {
|
70
|
+
Transforms.deselect(editor);
|
71
|
+
} else {
|
72
|
+
setOpen(true);
|
73
|
+
setPopupType("textFormat");
|
74
|
+
setIsTextSelected(true);
|
75
|
+
}
|
70
76
|
} else if (!anchorEl) {
|
71
77
|
setOpen(false);
|
72
78
|
setPopupType("");
|
@@ -23,6 +23,8 @@ import OpenLinkIcon from "../assets/svg/OpenLinkIcon";
|
|
23
23
|
import { BrainIcon } from "../assets/svg/BrainIcon";
|
24
24
|
import DocsIcon from "../assets/svg/DocsIcon";
|
25
25
|
import UserIcon from "../assets/svg/UserIcon";
|
26
|
+
import EditIcon from "@mui/icons-material/Edit";
|
27
|
+
import DeleteIcon from '@mui/icons-material/Delete';
|
26
28
|
import { jsx as _jsx } from "react/jsx-runtime";
|
27
29
|
import { jsxs as _jsxs } from "react/jsx-runtime";
|
28
30
|
const iconList = {
|
@@ -270,7 +272,9 @@ const iconList = {
|
|
270
272
|
openLinkIcon: /*#__PURE__*/_jsx(OpenLinkIcon, {}),
|
271
273
|
brain: /*#__PURE__*/_jsx(BrainIcon, {}),
|
272
274
|
docsIcon: /*#__PURE__*/_jsx(DocsIcon, {}),
|
273
|
-
userIcon: /*#__PURE__*/_jsx(UserIcon, {})
|
275
|
+
userIcon: /*#__PURE__*/_jsx(UserIcon, {}),
|
276
|
+
editIcon: /*#__PURE__*/_jsx(EditIcon, {}),
|
277
|
+
deleteIcon: /*#__PURE__*/_jsx(DeleteIcon, {})
|
274
278
|
};
|
275
279
|
export const icons = {
|
276
280
|
...iconList
|
@@ -104,7 +104,7 @@ const Section = props => {
|
|
104
104
|
});
|
105
105
|
};
|
106
106
|
const isFreeGrid = element?.children?.find(f => f.type === "freegrid");
|
107
|
-
const needHover = element?.children?.find(f => f.type === "grid" && !list_types.includes(element.type)) ? "
|
107
|
+
const needHover = element?.children?.find(f => f.type === "grid" && !list_types.includes(element.type)) ? "" : "";
|
108
108
|
let tempProps = {};
|
109
109
|
if (element?.type === "temp") {
|
110
110
|
tempProps = {
|
@@ -1,5 +1,5 @@
|
|
1
1
|
import React from "react";
|
2
|
-
import { Grid, Radio, RadioGroup, FormControl, FormLabel, FormControlLabel, Typography } from "@mui/material";
|
2
|
+
import { Grid, Radio, RadioGroup, FormControl, FormLabel, FormControlLabel, Typography, Tooltip } from "@mui/material";
|
3
3
|
import { JustifyStartIcon, JustifyCenterIcon, JustifyEndIcon, AlignEndIcon, AlignCenterIcon, AlignStartIcon, DirectionRowIcon, DirectionColumIcon, DirectionReverseIcon } from "../../iconslist";
|
4
4
|
import { jsx as _jsx } from "react/jsx-runtime";
|
5
5
|
import { jsxs as _jsxs } from "react/jsx-runtime";
|
@@ -44,7 +44,7 @@ const Alignment = props => {
|
|
44
44
|
},
|
45
45
|
children: [/*#__PURE__*/_jsxs(RadioGroup, {
|
46
46
|
row: true,
|
47
|
-
"aria-labelledby": "pos-
|
47
|
+
"aria-labelledby": "pos-jc",
|
48
48
|
name: "horizantal",
|
49
49
|
value: value?.horizantal || "start",
|
50
50
|
onChange: handleChange,
|
@@ -52,22 +52,31 @@ const Alignment = props => {
|
|
52
52
|
style: {
|
53
53
|
display: "flex"
|
54
54
|
},
|
55
|
-
children: [/*#__PURE__*/_jsx(
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
55
|
+
children: [/*#__PURE__*/_jsx(Tooltip, {
|
56
|
+
title: "Align Left",
|
57
|
+
children: /*#__PURE__*/_jsx(FormControlLabel, {
|
58
|
+
value: "start",
|
59
|
+
control: /*#__PURE__*/_jsx(Radio, {}),
|
60
|
+
label: /*#__PURE__*/_jsx(JustifyStartIcon, {})
|
61
|
+
})
|
62
|
+
}), /*#__PURE__*/_jsx(Tooltip, {
|
63
|
+
title: "Align Center",
|
64
|
+
children: /*#__PURE__*/_jsx(FormControlLabel, {
|
65
|
+
value: "center",
|
66
|
+
control: /*#__PURE__*/_jsx(Radio, {}),
|
67
|
+
label: /*#__PURE__*/_jsx(JustifyCenterIcon, {})
|
68
|
+
})
|
69
|
+
}), /*#__PURE__*/_jsx(Tooltip, {
|
70
|
+
title: "Align Right",
|
71
|
+
children: /*#__PURE__*/_jsx(FormControlLabel, {
|
72
|
+
value: "end",
|
73
|
+
control: /*#__PURE__*/_jsx(Radio, {}),
|
74
|
+
label: /*#__PURE__*/_jsx(JustifyEndIcon, {})
|
75
|
+
})
|
67
76
|
})]
|
68
77
|
}), /*#__PURE__*/_jsxs(RadioGroup, {
|
69
78
|
row: true,
|
70
|
-
"aria-labelledby": "pos-
|
79
|
+
"aria-labelledby": "pos-align-tems",
|
71
80
|
name: "vertical",
|
72
81
|
value: value?.vertical || "start",
|
73
82
|
onChange: handleChange,
|
@@ -75,18 +84,27 @@ const Alignment = props => {
|
|
75
84
|
style: {
|
76
85
|
display: "flex"
|
77
86
|
},
|
78
|
-
children: [/*#__PURE__*/_jsx(
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
|
87
|
+
children: [/*#__PURE__*/_jsx(Tooltip, {
|
88
|
+
title: "Align Top",
|
89
|
+
children: /*#__PURE__*/_jsx(FormControlLabel, {
|
90
|
+
value: "start",
|
91
|
+
control: /*#__PURE__*/_jsx(Radio, {}),
|
92
|
+
label: /*#__PURE__*/_jsx(AlignStartIcon, {})
|
93
|
+
})
|
94
|
+
}), /*#__PURE__*/_jsx(Tooltip, {
|
95
|
+
title: "Align Middle",
|
96
|
+
children: /*#__PURE__*/_jsx(FormControlLabel, {
|
97
|
+
value: "center",
|
98
|
+
control: /*#__PURE__*/_jsx(Radio, {}),
|
99
|
+
label: /*#__PURE__*/_jsx(AlignCenterIcon, {})
|
100
|
+
})
|
101
|
+
}), /*#__PURE__*/_jsx(Tooltip, {
|
102
|
+
title: "Align Bottom",
|
103
|
+
children: /*#__PURE__*/_jsx(FormControlLabel, {
|
104
|
+
value: "end",
|
105
|
+
control: /*#__PURE__*/_jsx(Radio, {}),
|
106
|
+
label: /*#__PURE__*/_jsx(AlignEndIcon, {})
|
107
|
+
})
|
90
108
|
})]
|
91
109
|
})]
|
92
110
|
})]
|
@@ -1,4 +1,4 @@
|
|
1
|
-
import { Editor, Transforms, Path } from "slate";
|
1
|
+
import { Editor, Transforms, Path, Element } from "slate";
|
2
2
|
import { ReactEditor } from "slate-react";
|
3
3
|
import html2canvas from "html2canvas";
|
4
4
|
import { rectIntersection, closestCenter } from "@dnd-kit/core";
|
@@ -322,4 +322,24 @@ export const getBorderColor = (borderColor = "") => {
|
|
322
322
|
borderStyle.borderColor = borderColor;
|
323
323
|
}
|
324
324
|
return borderStyle;
|
325
|
+
};
|
326
|
+
export const isCarouselSelected = editor => {
|
327
|
+
try {
|
328
|
+
if (!editor.selection) {
|
329
|
+
return false;
|
330
|
+
}
|
331
|
+
const [nodeEntry] = Editor.nodes(editor, {
|
332
|
+
match: n => !Editor.isEditor(n) && Element.isElement(n) && n.type === 'carousel'
|
333
|
+
});
|
334
|
+
if (!nodeEntry) {
|
335
|
+
return false;
|
336
|
+
}
|
337
|
+
const [node] = nodeEntry;
|
338
|
+
const carouselDom = ReactEditor.toDOMNode(editor, node);
|
339
|
+
const isEdit = carouselDom.classList.contains('carousel_slider_edit');
|
340
|
+
return !isEdit;
|
341
|
+
} catch (err) {
|
342
|
+
console.log(err);
|
343
|
+
return false;
|
344
|
+
}
|
325
345
|
};
|
@@ -2,11 +2,12 @@ import { ClickAwayListener } from "@mui/material";
|
|
2
2
|
import { createContext, useContext, useEffect, useMemo, useState } from "react";
|
3
3
|
import { clearCellText } from "../utils/table";
|
4
4
|
import { Editor, Element, Transforms, Range } from "slate";
|
5
|
-
import { DndContext, PointerSensor, useSensor, useSensors } from "@dnd-kit/core";
|
5
|
+
import { DndContext, DragOverlay, PointerSensor, useSensor, useSensors } from "@dnd-kit/core";
|
6
6
|
import { encodeToBase64 } from "../utils/helper";
|
7
7
|
import { serializeToText } from "../utils/serializeToText";
|
8
8
|
import { createCopiedTableStructure, getRectangleBounds, tableNodeToDom } from "../Elements/Table/tableHelper";
|
9
9
|
import { jsx as _jsx } from "react/jsx-runtime";
|
10
|
+
import { jsxs as _jsxs } from "react/jsx-runtime";
|
10
11
|
const handleDragEnd = (dragData, editor, resetAll) => {
|
11
12
|
const {
|
12
13
|
active,
|
@@ -157,15 +158,15 @@ export const TableProvider = ({
|
|
157
158
|
}, [openSetttings]);
|
158
159
|
return /*#__PURE__*/_jsx(TableContext.Provider, {
|
159
160
|
value: values,
|
160
|
-
children: /*#__PURE__*/
|
161
|
+
children: /*#__PURE__*/_jsxs(DndContext, {
|
161
162
|
sensors: sensors,
|
162
163
|
onDragEnd: data => handleDragEnd(data, editor, resetAll),
|
163
|
-
children: /*#__PURE__*/_jsx(ClickAwayListener, {
|
164
|
+
children: [/*#__PURE__*/_jsx(ClickAwayListener, {
|
164
165
|
onClickAway: () => setTableSelection(getDefaultTableSelection()),
|
165
166
|
children: /*#__PURE__*/_jsx("div", {
|
166
167
|
children: children
|
167
168
|
})
|
168
|
-
})
|
169
|
+
}), /*#__PURE__*/_jsx(DragOverlay, {})]
|
169
170
|
})
|
170
171
|
});
|
171
172
|
};
|
@@ -1,9 +1,11 @@
|
|
1
1
|
import { Transforms, Path, Node } from "slate";
|
2
2
|
const AvoidCopying = ["headingOne", "headingTwo", "headingThree", "blockquote"];
|
3
|
+
const BlockTypes = ["grid"];
|
3
4
|
const withEmbeds = editor => {
|
4
5
|
const {
|
5
6
|
isVoid,
|
6
|
-
insertBreak
|
7
|
+
insertBreak,
|
8
|
+
insertNodes
|
7
9
|
} = editor;
|
8
10
|
editor.isVoid = element => {
|
9
11
|
if (["video", "htmlCode"].includes(element.type)) {
|
@@ -14,6 +16,30 @@ const withEmbeds = editor => {
|
|
14
16
|
return isVoid(element);
|
15
17
|
}
|
16
18
|
};
|
19
|
+
editor.insertNodes = (...args) => {
|
20
|
+
try {
|
21
|
+
const parentPath = Path.parent(editor.selection.focus.path);
|
22
|
+
const parentNode = Node.get(editor, parentPath);
|
23
|
+
const previousPath = Path.previous(parentPath);
|
24
|
+
const previousNode = Node.get(editor, previousPath);
|
25
|
+
if (BlockTypes.includes(previousNode?.children[0]?.type) && parentNode?.type?.indexOf("heading") >= 0) {
|
26
|
+
console.log("grid is in previous", parentPath, previousPath, [...args]);
|
27
|
+
insertNodes(...[{
|
28
|
+
type: "paragraph",
|
29
|
+
children: [{
|
30
|
+
text: ""
|
31
|
+
}]
|
32
|
+
}, {
|
33
|
+
at: parentPath
|
34
|
+
}]);
|
35
|
+
} else {
|
36
|
+
insertNodes(...args);
|
37
|
+
}
|
38
|
+
} catch (err) {
|
39
|
+
console.log(err);
|
40
|
+
insertNodes(...args);
|
41
|
+
}
|
42
|
+
};
|
17
43
|
editor.insertBreak = (...args) => {
|
18
44
|
const parentPath = Path.parent(editor.selection.focus.path);
|
19
45
|
const parentNode = Node.get(editor, parentPath);
|
@@ -110,10 +110,31 @@ export const isEmptyNode = (editor, children, path) => {
|
|
110
110
|
}
|
111
111
|
};
|
112
112
|
export const outsideEditorClickLabel = "handle-outside-editor-click";
|
113
|
+
const insertNewLineOnColumn = (editor, pathStr) => {
|
114
|
+
try {
|
115
|
+
const path = pathStr.split(",").map(m => parseInt(m));
|
116
|
+
const colNode = Node.get(editor, path);
|
117
|
+
if (colNode?.type === "grid-item") {
|
118
|
+
const newPath = [...path, colNode?.children.length];
|
119
|
+
Transforms.insertNodes(editor, [{
|
120
|
+
type: "paragraph",
|
121
|
+
children: [{
|
122
|
+
text: ""
|
123
|
+
}]
|
124
|
+
}], {
|
125
|
+
at: newPath,
|
126
|
+
select: true
|
127
|
+
});
|
128
|
+
}
|
129
|
+
} catch (err) {
|
130
|
+
console.log(err);
|
131
|
+
}
|
132
|
+
};
|
113
133
|
export const handleInsertLastElement = (event, editor) => {
|
114
134
|
if (event.target.dataset.info !== outsideEditorClickLabel) {
|
115
135
|
return;
|
116
136
|
}
|
137
|
+
const hasPath = event.target.dataset.path;
|
117
138
|
const lastElement = editor.children[editor.children?.length - 1];
|
118
139
|
const isFreeGrid = lastElement?.type === "freegrid" || lastElement?.children[0]?.type === "freegrid";
|
119
140
|
if (isFreeGrid) {
|
@@ -122,6 +143,10 @@ export const handleInsertLastElement = (event, editor) => {
|
|
122
143
|
const isLastElementEmpty = lastElement.type === "paragraph" && !lastElement.children[0]?.text && !lastElement.children?.some(c => c.type === "grid");
|
123
144
|
if (!ReactEditor.isFocused(editor)) {
|
124
145
|
if (isLastElementEmpty) {
|
146
|
+
if (hasPath) {
|
147
|
+
insertNewLineOnColumn(editor, hasPath);
|
148
|
+
return;
|
149
|
+
}
|
125
150
|
// just focus on the last empty element
|
126
151
|
const path = [editor.children.length - 1, 0];
|
127
152
|
const move = {
|
@@ -136,6 +161,11 @@ export const handleInsertLastElement = (event, editor) => {
|
|
136
161
|
Transforms.move(editor, move);
|
137
162
|
Transforms.select(editor, move);
|
138
163
|
} else {
|
164
|
+
// if dataset has path insert new line on the path (for columns / grid)
|
165
|
+
if (hasPath) {
|
166
|
+
insertNewLineOnColumn(editor, hasPath);
|
167
|
+
return;
|
168
|
+
}
|
139
169
|
// insert an new empty element and focus
|
140
170
|
Transforms.insertNodes(editor, [{
|
141
171
|
type: "paragraph",
|
@@ -148,6 +178,8 @@ export const handleInsertLastElement = (event, editor) => {
|
|
148
178
|
});
|
149
179
|
}
|
150
180
|
ReactEditor.focus(editor);
|
181
|
+
} else if (hasPath) {
|
182
|
+
insertNewLineOnColumn(editor, hasPath);
|
151
183
|
}
|
152
184
|
};
|
153
185
|
export const isListItem = editor => {
|
@@ -246,7 +246,7 @@ export class TableUtil {
|
|
246
246
|
const isDuplicate = action === "duplicate";
|
247
247
|
const isInsertNext = action === "after" || isDuplicate;
|
248
248
|
const path = isInsertNext ? Path.next(currentRow) : currentRow;
|
249
|
-
const insertData = isDuplicate ? JSON.parse(JSON.stringify(currentRowData)) :
|
249
|
+
const insertData = isDuplicate ? JSON.parse(JSON.stringify(currentRowData)) : createRowOnInsertAbove(currentRowData, currentRow, this.editor);
|
250
250
|
Transforms.insertNodes(this.editor, insertData, {
|
251
251
|
at: path
|
252
252
|
});
|
@@ -492,16 +492,12 @@ export class TableUtil {
|
|
492
492
|
console.log(err);
|
493
493
|
}
|
494
494
|
};
|
495
|
-
resizeTableCell = (styleProps,
|
495
|
+
resizeTableCell = (styleProps, path) => {
|
496
496
|
const cellProps = parseByPrefixKey(styleProps, "col.");
|
497
|
-
|
498
|
-
|
499
|
-
|
500
|
-
|
501
|
-
...cellProps
|
502
|
-
}, {
|
503
|
-
at: cellPath
|
504
|
-
});
|
497
|
+
Transforms.setNodes(this.editor, {
|
498
|
+
...cellProps
|
499
|
+
}, {
|
500
|
+
at: path
|
505
501
|
});
|
506
502
|
};
|
507
503
|
getTableProps = () => {
|
@@ -626,14 +622,14 @@ export class TableUtil {
|
|
626
622
|
}
|
627
623
|
};
|
628
624
|
}
|
629
|
-
const createRow = cellText => {
|
630
|
-
const newRow = Array.from(cellText, value => createTableCell(value));
|
625
|
+
const createRow = (cellText, other) => {
|
626
|
+
const newRow = Array.from(cellText, value => createTableCell(value, other));
|
631
627
|
return {
|
632
628
|
type: "table-row",
|
633
629
|
children: newRow
|
634
630
|
};
|
635
631
|
};
|
636
|
-
export const createTableCell = text => {
|
632
|
+
export const createTableCell = (text, other = {}) => {
|
637
633
|
return {
|
638
634
|
type: "table-cell",
|
639
635
|
children: [{
|
@@ -644,7 +640,32 @@ export const createTableCell = text => {
|
|
644
640
|
}],
|
645
641
|
size: {
|
646
642
|
width: 120
|
643
|
+
},
|
644
|
+
...other
|
645
|
+
};
|
646
|
+
};
|
647
|
+
const createRowOnInsertAbove = (currentRow, currRowPath, editor) => {
|
648
|
+
const isFirstRow = currRowPath[currRowPath?.length - 1] === 0;
|
649
|
+
const rowChild = currentRow?.children?.map((cell, i) => {
|
650
|
+
let other = {};
|
651
|
+
|
652
|
+
// remove the current row's size and add it on the currently inserting cell
|
653
|
+
if (isFirstRow) {
|
654
|
+
const cellPath = [...currRowPath, i];
|
655
|
+
Transforms.setNodes(editor, {
|
656
|
+
size: null
|
657
|
+
}, {
|
658
|
+
at: cellPath
|
659
|
+
});
|
660
|
+
other = {
|
661
|
+
size: cell?.size
|
662
|
+
};
|
647
663
|
}
|
664
|
+
return createTableCell("", other);
|
665
|
+
});
|
666
|
+
return {
|
667
|
+
type: "table-row",
|
668
|
+
children: rowChild
|
648
669
|
};
|
649
670
|
};
|
650
671
|
|
package/package.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "@flozy/editor",
|
3
|
-
"version": "5.0.
|
3
|
+
"version": "5.0.2",
|
4
4
|
"description": "An Editor for flozy app brain",
|
5
5
|
"files": [
|
6
6
|
"dist"
|
@@ -68,7 +68,9 @@
|
|
68
68
|
"storybook": "storybook dev -p 6006",
|
69
69
|
"build-storybook": "NODE_OPTIONS='--max_old_space_size=4096' storybook build",
|
70
70
|
"publish:npm": "rm -rf dist && mkdir dist && babel src/components -d dist --copy-files",
|
71
|
-
"publish:local": "rm -rf /Users/agmac03/flozy/client/node_modules/@flozy/editor/dist && babel src/components -d /Users/agmac03/flozy/client/node_modules/@flozy/editor/dist --copy-files"
|
71
|
+
"publish:local": "rm -rf /Users/agmac03/flozy/client/node_modules/@flozy/editor/dist && babel src/components -d /Users/agmac03/flozy/client/node_modules/@flozy/editor/dist --copy-files",
|
72
|
+
"publish:local2": "rm -rf /Users/agmac23/Desktop/surya/sweetpsocial-2.0/client/node_modules/@flozy/editor/dist && babel src/components -d /Users/agmac23/Desktop/surya/sweetpsocial-2.0/client/node_modules/@flozy/editor/dist --copy-files",
|
73
|
+
"publish:local3": "rm -rf /Users/agmac23/Desktop/surya/flozy_v2.0/microservices/pages/public && cp -r /Users/agmac23/Desktop/surya/editor/build /Users/agmac23/Desktop/surya/flozy_v2.0/microservices/pages/public"
|
72
74
|
},
|
73
75
|
"eslintConfig": {
|
74
76
|
"extends": [
|