@flozy/editor 5.0.1 → 5.0.2
Sign up to get free protection for your applications and to get access to all the features.
- package/dist/Editor/Elements/Carousel/Carousel.js +2 -1
- package/dist/Editor/Elements/Carousel/slick.min.css +1 -1
- package/dist/Editor/Elements/Table/TableCell.js +4 -5
- package/dist/Editor/Elements/TopBanner/Styles.js +18 -12
- package/dist/Editor/Elements/TopBanner/TopBanner.js +15 -6
- package/dist/Editor/Toolbar/PopupTool/index.js +10 -4
- package/dist/Editor/common/Icon.js +5 -1
- 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/utils/table.js +34 -13
- package/package.json +4 -2
@@ -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;
|
@@ -166,7 +166,7 @@ const TableCell = props => {
|
|
166
166
|
if (!resizing && tableResizing) {
|
167
167
|
table.resizeTableCell({
|
168
168
|
"col.size": size
|
169
|
-
},
|
169
|
+
}, path);
|
170
170
|
}
|
171
171
|
if (resizing) {
|
172
172
|
setTableResizing(currentPath);
|
@@ -205,9 +205,8 @@ const TableCell = props => {
|
|
205
205
|
});
|
206
206
|
}
|
207
207
|
};
|
208
|
-
const onMouseUp =
|
208
|
+
const onMouseUp = () => {
|
209
209
|
if (startCellPath?.length) {
|
210
|
-
e.preventDefault();
|
211
210
|
updateTableSelection({
|
212
211
|
endCellPath: path,
|
213
212
|
isDragging: false
|
@@ -232,7 +231,7 @@ const TableCell = props => {
|
|
232
231
|
});
|
233
232
|
}
|
234
233
|
};
|
235
|
-
const cellId = path.toString()
|
234
|
+
const cellId = "table-cell" + path.toString();
|
236
235
|
const cellRef = document.getElementById(cellId);
|
237
236
|
const contentEditable = !readOnly && isCellEditable(startCellPath, path);
|
238
237
|
const commonTdProps = useMemo(() => {
|
@@ -281,7 +280,7 @@ const TableCell = props => {
|
|
281
280
|
const isCellDragging = active?.id && active?.id === cellId;
|
282
281
|
const isRowDragging = isCellDragging && currentDraggingType === "row";
|
283
282
|
const isColDragging = isCellDragging && currentDraggingType === "col";
|
284
|
-
const width = size?.width || tableSize?.cellWidth;
|
283
|
+
const width = isHeader ? size?.width || tableSize?.cellWidth : "0px";
|
285
284
|
const sizeProps = {
|
286
285
|
minWidth: width,
|
287
286
|
maxWidth: width
|
@@ -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,
|
@@ -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
|
@@ -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
|
};
|
@@ -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": [
|