@flozy/editor 4.9.2 → 4.9.4
Sign up to get free protection for your applications and to get access to all the features.
- package/dist/Editor/Editor.css +16 -9
- package/dist/Editor/Elements/AI/CustomSelect.js +17 -10
- package/dist/Editor/Elements/AI/PopoverAIInput.js +3 -3
- package/dist/Editor/Elements/AI/Styles.js +7 -1
- package/dist/Editor/Elements/Carousel/Carousel.js +3 -0
- package/dist/Editor/Elements/Divider/Divider.js +4 -2
- package/dist/Editor/Elements/FreeGrid/FreeGrid.js +1 -1
- package/dist/Editor/Elements/Search/SearchAttachment.js +32 -26
- package/dist/Editor/Elements/Search/SearchButton.js +66 -9
- package/dist/Editor/Elements/Search/SearchList.js +87 -75
- package/dist/Editor/Elements/Table/AddRowCol.js +76 -0
- package/dist/Editor/Elements/Table/DragButton.js +134 -0
- package/dist/Editor/Elements/Table/DragStyles.js +43 -0
- package/dist/Editor/Elements/Table/Draggable.js +25 -0
- package/dist/Editor/Elements/Table/Droppable.js +53 -0
- package/dist/Editor/Elements/Table/Styles.js +23 -41
- package/dist/Editor/Elements/Table/Table.js +185 -137
- package/dist/Editor/Elements/Table/TableCell.js +339 -101
- package/dist/Editor/Elements/Table/TablePopup.js +9 -3
- package/dist/Editor/Elements/Table/TableRow.js +10 -2
- package/dist/Editor/Elements/Table/TableTool.js +101 -0
- package/dist/Editor/Toolbar/PopupTool/PopupToolStyle.js +1 -2
- package/dist/Editor/Toolbar/PopupTool/index.js +19 -19
- package/dist/Editor/assets/svg/DocsIcon.js +77 -10
- package/dist/Editor/assets/svg/TableIcons.js +220 -0
- package/dist/Editor/assets/svg/UserIcon.js +2 -2
- package/dist/Editor/common/MentionsPopup/Styles.js +1 -1
- package/dist/Editor/common/RnD/ElementSettings/Settings/FormSettings.js +9 -35
- package/dist/Editor/common/StyleBuilder/formStyle.js +101 -69
- package/dist/Editor/common/StyleBuilder/index.js +8 -34
- package/dist/Editor/common/StyleBuilder/tableStyle.js +92 -1
- package/dist/Editor/common/iconListV2.js +52 -0
- package/dist/Editor/hooks/useEditorScroll.js +1 -1
- package/dist/Editor/hooks/useTable.js +164 -0
- package/dist/Editor/utils/helper.js +1 -1
- package/dist/Editor/utils/table.js +204 -21
- package/package.json +1 -1
@@ -214,40 +214,14 @@ const StyleBuilder = props => {
|
|
214
214
|
}, `accordion_${i}`)
|
215
215
|
}, i);
|
216
216
|
} else {
|
217
|
-
return /*#__PURE__*/_jsx(
|
218
|
-
|
219
|
-
|
220
|
-
|
221
|
-
|
222
|
-
|
223
|
-
|
224
|
-
|
225
|
-
},
|
226
|
-
children: /*#__PURE__*/_jsx(Typography, {
|
227
|
-
variant: "body1",
|
228
|
-
className: "settingsHeader",
|
229
|
-
color: "primary",
|
230
|
-
style: {
|
231
|
-
fontSize: "14px !important",
|
232
|
-
fontWeight: "400"
|
233
|
-
},
|
234
|
-
children: m?.tab
|
235
|
-
})
|
236
|
-
}), /*#__PURE__*/_jsx(AccordionDetails, {
|
237
|
-
sx: {
|
238
|
-
padding: "5px"
|
239
|
-
},
|
240
|
-
children: /*#__PURE__*/_jsx(StyleContent, {
|
241
|
-
renderTabs: renderTabs,
|
242
|
-
value: m.value,
|
243
|
-
element: elementProps,
|
244
|
-
onChange: onElementPropsChange,
|
245
|
-
customProps: customProps,
|
246
|
-
handleClose: handleClose
|
247
|
-
}, `tab_${m.value}_$${i}`)
|
248
|
-
})]
|
249
|
-
}, `accordion_${i}`)
|
250
|
-
}, i);
|
217
|
+
return /*#__PURE__*/_jsx(StyleContent, {
|
218
|
+
renderTabs: renderTabs,
|
219
|
+
value: m.value,
|
220
|
+
element: elementProps,
|
221
|
+
onChange: onElementPropsChange,
|
222
|
+
customProps: customProps,
|
223
|
+
handleClose: handleClose
|
224
|
+
}, `tab_${m.value}_$${i}`);
|
251
225
|
}
|
252
226
|
})
|
253
227
|
}), needActions ? /*#__PURE__*/_jsxs(DialogActions, {
|
@@ -1,3 +1,6 @@
|
|
1
|
+
import { toolbarGroups } from "../../Toolbar/toolbarGroups";
|
2
|
+
import { fontOptions } from "../../utils/font";
|
3
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
1
4
|
const tableStyle = [{
|
2
5
|
tab: "Table",
|
3
6
|
value: "tableSettings",
|
@@ -48,4 +51,92 @@ const tableStyle = [{
|
|
48
51
|
placeholder: "Hide on Mobile"
|
49
52
|
}]
|
50
53
|
}];
|
51
|
-
export default tableStyle;
|
54
|
+
export default tableStyle;
|
55
|
+
const allTools = toolbarGroups.flat();
|
56
|
+
const fontWeight = allTools.find(f => f.format === "fontWeight");
|
57
|
+
export const tableRowStyle = [{
|
58
|
+
tab: "Row",
|
59
|
+
value: "rowSettings",
|
60
|
+
fields: [{
|
61
|
+
label: "Font Family",
|
62
|
+
key: "row.fontFamily",
|
63
|
+
type: "textOptions",
|
64
|
+
webFont: true,
|
65
|
+
options: fontOptions,
|
66
|
+
renderOption: option => {
|
67
|
+
return /*#__PURE__*/_jsx("span", {
|
68
|
+
style: {
|
69
|
+
fontFamily: option.value
|
70
|
+
},
|
71
|
+
children: option.text
|
72
|
+
});
|
73
|
+
}
|
74
|
+
}, {
|
75
|
+
label: "Font Weight",
|
76
|
+
key: "row.fontWeight",
|
77
|
+
type: "textOptions",
|
78
|
+
options: fontWeight?.options,
|
79
|
+
width: 7
|
80
|
+
}, {
|
81
|
+
label: "Font Size",
|
82
|
+
key: "row.textSize",
|
83
|
+
type: "fontSize",
|
84
|
+
width: 5,
|
85
|
+
placeholder: "16px or 1em"
|
86
|
+
}, {
|
87
|
+
label: "Text Color",
|
88
|
+
key: "row.textColor",
|
89
|
+
type: "color"
|
90
|
+
}, {
|
91
|
+
label: "Background",
|
92
|
+
key: "row.bgColor",
|
93
|
+
type: "color"
|
94
|
+
}, {
|
95
|
+
label: "Border",
|
96
|
+
key: "row.borderColor",
|
97
|
+
type: "color"
|
98
|
+
}]
|
99
|
+
}];
|
100
|
+
export const tableColumnStyle = [{
|
101
|
+
tab: "Column",
|
102
|
+
value: "columnSettings",
|
103
|
+
fields: [{
|
104
|
+
label: "Font Family",
|
105
|
+
key: "col.entireFontFamily",
|
106
|
+
type: "textOptions",
|
107
|
+
webFont: true,
|
108
|
+
options: fontOptions,
|
109
|
+
renderOption: option => {
|
110
|
+
return /*#__PURE__*/_jsx("span", {
|
111
|
+
style: {
|
112
|
+
fontFamily: option.value
|
113
|
+
},
|
114
|
+
children: option.text
|
115
|
+
});
|
116
|
+
}
|
117
|
+
}, {
|
118
|
+
label: "Font Weight",
|
119
|
+
key: "col.entireFontWeight",
|
120
|
+
type: "textOptions",
|
121
|
+
options: fontWeight?.options,
|
122
|
+
width: 7
|
123
|
+
}, {
|
124
|
+
label: "Font Size",
|
125
|
+
key: "col.entireTextSize",
|
126
|
+
type: "fontSize",
|
127
|
+
width: 5,
|
128
|
+
placeholder: "16px or 1em"
|
129
|
+
}, {
|
130
|
+
label: "Entire Text Color",
|
131
|
+
key: "col.entireTextColor",
|
132
|
+
type: "color"
|
133
|
+
}, {
|
134
|
+
label: "Background",
|
135
|
+
key: "col.entireBgColor",
|
136
|
+
type: "color"
|
137
|
+
}, {
|
138
|
+
label: "Border",
|
139
|
+
key: "col.entireBorderColor",
|
140
|
+
type: "color"
|
141
|
+
}]
|
142
|
+
}];
|
@@ -1192,4 +1192,56 @@ export function CodeElementIcon() {
|
|
1192
1192
|
strokeLinejoin: "round"
|
1193
1193
|
})]
|
1194
1194
|
});
|
1195
|
+
}
|
1196
|
+
export function DragIcon() {
|
1197
|
+
return /*#__PURE__*/_jsxs("svg", {
|
1198
|
+
width: "16",
|
1199
|
+
height: "12",
|
1200
|
+
viewBox: "0 0 10 6",
|
1201
|
+
fill: "none",
|
1202
|
+
xmlns: "http://www.w3.org/2000/svg",
|
1203
|
+
children: [/*#__PURE__*/_jsx("ellipse", {
|
1204
|
+
cx: "1.49462",
|
1205
|
+
cy: "4.42384",
|
1206
|
+
rx: "0.779289",
|
1207
|
+
ry: "0.779289",
|
1208
|
+
transform: "rotate(-90 1.49462 4.42384)",
|
1209
|
+
fill: "#94A3B8"
|
1210
|
+
}), /*#__PURE__*/_jsx("ellipse", {
|
1211
|
+
cx: "4.99999",
|
1212
|
+
cy: "4.42384",
|
1213
|
+
rx: "0.779289",
|
1214
|
+
ry: "0.779289",
|
1215
|
+
transform: "rotate(-90 4.99999 4.42384)",
|
1216
|
+
fill: "#94A3B8"
|
1217
|
+
}), /*#__PURE__*/_jsx("ellipse", {
|
1218
|
+
cx: "8.50732",
|
1219
|
+
cy: "4.42384",
|
1220
|
+
rx: "0.779289",
|
1221
|
+
ry: "0.779289",
|
1222
|
+
transform: "rotate(-90 8.50732 4.42384)",
|
1223
|
+
fill: "#94A3B8"
|
1224
|
+
}), /*#__PURE__*/_jsx("ellipse", {
|
1225
|
+
cx: "1.49462",
|
1226
|
+
cy: "0.91993",
|
1227
|
+
rx: "0.779289",
|
1228
|
+
ry: "0.779289",
|
1229
|
+
transform: "rotate(-90 1.49462 0.91993)",
|
1230
|
+
fill: "#94A3B8"
|
1231
|
+
}), /*#__PURE__*/_jsx("ellipse", {
|
1232
|
+
cx: "4.99999",
|
1233
|
+
cy: "0.91993",
|
1234
|
+
rx: "0.779289",
|
1235
|
+
ry: "0.779289",
|
1236
|
+
transform: "rotate(-90 4.99999 0.91993)",
|
1237
|
+
fill: "#94A3B8"
|
1238
|
+
}), /*#__PURE__*/_jsx("ellipse", {
|
1239
|
+
cx: "8.50732",
|
1240
|
+
cy: "0.91993",
|
1241
|
+
rx: "0.779289",
|
1242
|
+
ry: "0.779289",
|
1243
|
+
transform: "rotate(-90 8.50732 0.91993)",
|
1244
|
+
fill: "#94A3B8"
|
1245
|
+
})]
|
1246
|
+
});
|
1195
1247
|
}
|
@@ -0,0 +1,164 @@
|
|
1
|
+
import { ClickAwayListener } from "@mui/material";
|
2
|
+
import { createContext, useContext, useEffect, useMemo, useState } from "react";
|
3
|
+
import { clearCellText } from "../utils/table";
|
4
|
+
import { Editor, Element, Transforms } from "slate";
|
5
|
+
import { DndContext, PointerSensor, useSensor, useSensors } from "@dnd-kit/core";
|
6
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
7
|
+
const handleDragEnd = (dragData, editor, resetAll) => {
|
8
|
+
const {
|
9
|
+
active,
|
10
|
+
over
|
11
|
+
} = dragData;
|
12
|
+
if (over) {
|
13
|
+
const {
|
14
|
+
dragType,
|
15
|
+
path: startCellPath
|
16
|
+
} = active?.data?.current || {};
|
17
|
+
const {
|
18
|
+
path: overCellPath
|
19
|
+
} = over?.data?.current || {};
|
20
|
+
if (startCellPath?.length) {
|
21
|
+
if (dragType === "row") {
|
22
|
+
const startRowPath = startCellPath.slice(0, -1);
|
23
|
+
const overRowPath = overCellPath.slice(0, -1);
|
24
|
+
Transforms.moveNodes(editor, {
|
25
|
+
at: startRowPath,
|
26
|
+
to: overRowPath
|
27
|
+
});
|
28
|
+
} else {
|
29
|
+
const [startCol] = startCellPath.slice(-1);
|
30
|
+
const [overCol] = overCellPath.slice(-1);
|
31
|
+
const [tableData] = Editor.nodes(editor, {
|
32
|
+
at: startCellPath,
|
33
|
+
match: n => !Editor.isEditor(n) && Element.isElement(n) && n.type === "table"
|
34
|
+
});
|
35
|
+
const [tableNode, tablePath] = tableData;
|
36
|
+
const rows = tableNode?.rows || 0;
|
37
|
+
for (let row = 0; row < rows; row++) {
|
38
|
+
const startColPath = [...tablePath, row, startCol];
|
39
|
+
const overColPath = [...tablePath, row, overCol];
|
40
|
+
Transforms.moveNodes(editor, {
|
41
|
+
at: startColPath,
|
42
|
+
to: overColPath
|
43
|
+
});
|
44
|
+
}
|
45
|
+
}
|
46
|
+
resetAll();
|
47
|
+
}
|
48
|
+
}
|
49
|
+
};
|
50
|
+
const getRectangleBounds = tableSelection => {
|
51
|
+
const {
|
52
|
+
startCellPath,
|
53
|
+
endCellPath
|
54
|
+
} = tableSelection;
|
55
|
+
if (!startCellPath?.length) return [];
|
56
|
+
const startPath = startCellPath.slice(0, -2);
|
57
|
+
const startCell = startCellPath.slice(-2);
|
58
|
+
const endCell = endCellPath.slice(-2);
|
59
|
+
const [startRow, startCol] = startCell;
|
60
|
+
const [endRow, endCol] = endCell?.length ? endCell : startCell;
|
61
|
+
const minRow = Math.min(startRow, endRow);
|
62
|
+
const maxRow = Math.max(startRow, endRow);
|
63
|
+
const minCol = Math.min(startCol, endCol);
|
64
|
+
const maxCol = Math.max(startCol, endCol);
|
65
|
+
const selectedPaths = [];
|
66
|
+
for (let row = minRow; row <= maxRow; row++) {
|
67
|
+
for (let col = minCol; col <= maxCol; col++) {
|
68
|
+
selectedPaths.push([...startPath, row, col]);
|
69
|
+
}
|
70
|
+
}
|
71
|
+
return selectedPaths;
|
72
|
+
};
|
73
|
+
const TableContext = /*#__PURE__*/createContext();
|
74
|
+
export function getDefaultTableSelection() {
|
75
|
+
return {
|
76
|
+
startCellPath: [],
|
77
|
+
endCellPath: [],
|
78
|
+
isDragging: false
|
79
|
+
};
|
80
|
+
}
|
81
|
+
export const TableProvider = ({
|
82
|
+
editor,
|
83
|
+
children,
|
84
|
+
otherProps
|
85
|
+
}) => {
|
86
|
+
const [hoverPath, setHoverPath] = useState(null);
|
87
|
+
const [tableSelection, setTableSelection] = useState(getDefaultTableSelection());
|
88
|
+
const [tableResizing, setTableResizing] = useState(null);
|
89
|
+
|
90
|
+
// for the button events (like onclick,...etc) inside draggable component to work correctly
|
91
|
+
const sensors = useSensors(useSensor(PointerSensor, {
|
92
|
+
activationConstraint: {
|
93
|
+
delay: 250,
|
94
|
+
distance: 0 // throws exceeded distance error
|
95
|
+
}
|
96
|
+
}));
|
97
|
+
|
98
|
+
const getSelectedCells = () => {
|
99
|
+
return getRectangleBounds(tableSelection);
|
100
|
+
};
|
101
|
+
const updateTableSelection = update => {
|
102
|
+
setTableSelection(prev => ({
|
103
|
+
...prev,
|
104
|
+
...update
|
105
|
+
}));
|
106
|
+
};
|
107
|
+
const resetAll = () => {
|
108
|
+
setTableSelection(getDefaultTableSelection());
|
109
|
+
Transforms.deselect(editor);
|
110
|
+
|
111
|
+
// hide drag icons after drag completion
|
112
|
+
setTimeout(() => setHoverPath(null), 200);
|
113
|
+
};
|
114
|
+
const values = useMemo(() => {
|
115
|
+
return {
|
116
|
+
hoverPath,
|
117
|
+
setHoverPath,
|
118
|
+
editor,
|
119
|
+
getSelectedCells,
|
120
|
+
updateTableSelection,
|
121
|
+
tableSelection,
|
122
|
+
tableResizing,
|
123
|
+
setTableResizing,
|
124
|
+
otherProps
|
125
|
+
};
|
126
|
+
}, [hoverPath, editor?.selection, tableSelection, tableResizing]);
|
127
|
+
useEffect(() => {
|
128
|
+
const handleKeyDown = event => {
|
129
|
+
if (event.key === "Backspace") {
|
130
|
+
const selectedCells = getSelectedCells();
|
131
|
+
if (selectedCells?.length > 1) {
|
132
|
+
selectedCells.forEach(currentCellPath => {
|
133
|
+
clearCellText(editor, currentCellPath);
|
134
|
+
});
|
135
|
+
}
|
136
|
+
}
|
137
|
+
};
|
138
|
+
window.addEventListener("keydown", handleKeyDown);
|
139
|
+
return () => {
|
140
|
+
window.removeEventListener("keydown", handleKeyDown);
|
141
|
+
};
|
142
|
+
}, [tableSelection]);
|
143
|
+
useEffect(() => {
|
144
|
+
// on deselect table on insert
|
145
|
+
Transforms.deselect(editor);
|
146
|
+
}, []);
|
147
|
+
return /*#__PURE__*/_jsx(TableContext.Provider, {
|
148
|
+
value: values,
|
149
|
+
children: /*#__PURE__*/_jsx(ClickAwayListener, {
|
150
|
+
onClickAway: () => setTableSelection(getDefaultTableSelection()),
|
151
|
+
children: /*#__PURE__*/_jsx(DndContext, {
|
152
|
+
sensors: sensors,
|
153
|
+
onDragEnd: data => handleDragEnd(data, editor, resetAll),
|
154
|
+
children: /*#__PURE__*/_jsx("div", {
|
155
|
+
children: children
|
156
|
+
})
|
157
|
+
})
|
158
|
+
})
|
159
|
+
});
|
160
|
+
};
|
161
|
+
function useTable() {
|
162
|
+
return useContext(TableContext);
|
163
|
+
}
|
164
|
+
export default useTable;
|