@flozy/editor 4.9.2 → 4.9.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- 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
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { Transforms, Editor, Range, Element, Path, Node } from "slate";
|
|
2
2
|
import { ReactEditor } from "slate-react";
|
|
3
|
-
import { customInsertNode } from "./helper";
|
|
3
|
+
import { customInsertNode, getNode } from "./helper";
|
|
4
4
|
export const DEFAULT_TABLE_NODE = () => ({
|
|
5
5
|
type: "table",
|
|
6
6
|
children: [{
|
|
@@ -13,7 +13,10 @@ export const DEFAULT_TABLE_NODE = () => ({
|
|
|
13
13
|
text: ""
|
|
14
14
|
}],
|
|
15
15
|
cellBgColor: "#FFFFFF"
|
|
16
|
-
}]
|
|
16
|
+
}],
|
|
17
|
+
size: {
|
|
18
|
+
width: 120
|
|
19
|
+
}
|
|
17
20
|
}, {
|
|
18
21
|
type: "table-cell",
|
|
19
22
|
children: [{
|
|
@@ -22,7 +25,10 @@ export const DEFAULT_TABLE_NODE = () => ({
|
|
|
22
25
|
text: ""
|
|
23
26
|
}],
|
|
24
27
|
cellBgColor: "#FFFFFF"
|
|
25
|
-
}]
|
|
28
|
+
}],
|
|
29
|
+
size: {
|
|
30
|
+
width: 120
|
|
31
|
+
}
|
|
26
32
|
}, {
|
|
27
33
|
type: "table-cell",
|
|
28
34
|
children: [{
|
|
@@ -31,7 +37,10 @@ export const DEFAULT_TABLE_NODE = () => ({
|
|
|
31
37
|
text: ""
|
|
32
38
|
}],
|
|
33
39
|
cellBgColor: "#FFFFFF"
|
|
34
|
-
}]
|
|
40
|
+
}],
|
|
41
|
+
size: {
|
|
42
|
+
width: 120
|
|
43
|
+
}
|
|
35
44
|
}]
|
|
36
45
|
}, {
|
|
37
46
|
type: "table-row",
|
|
@@ -43,7 +52,10 @@ export const DEFAULT_TABLE_NODE = () => ({
|
|
|
43
52
|
text: ""
|
|
44
53
|
}],
|
|
45
54
|
cellBgColor: "#FFFFFF"
|
|
46
|
-
}]
|
|
55
|
+
}],
|
|
56
|
+
size: {
|
|
57
|
+
width: 120
|
|
58
|
+
}
|
|
47
59
|
}, {
|
|
48
60
|
type: "table-cell",
|
|
49
61
|
children: [{
|
|
@@ -52,7 +64,10 @@ export const DEFAULT_TABLE_NODE = () => ({
|
|
|
52
64
|
text: ""
|
|
53
65
|
}],
|
|
54
66
|
cellBgColor: "#FFFFFF"
|
|
55
|
-
}]
|
|
67
|
+
}],
|
|
68
|
+
size: {
|
|
69
|
+
width: 120
|
|
70
|
+
}
|
|
56
71
|
}, {
|
|
57
72
|
type: "table-cell",
|
|
58
73
|
children: [{
|
|
@@ -63,9 +78,7 @@ export const DEFAULT_TABLE_NODE = () => ({
|
|
|
63
78
|
cellBgColor: "#FFFFFF"
|
|
64
79
|
}],
|
|
65
80
|
size: {
|
|
66
|
-
|
|
67
|
-
height: 100,
|
|
68
|
-
width: 365.3307291666667
|
|
81
|
+
width: 120
|
|
69
82
|
}
|
|
70
83
|
}]
|
|
71
84
|
}, {
|
|
@@ -78,7 +91,10 @@ export const DEFAULT_TABLE_NODE = () => ({
|
|
|
78
91
|
text: ""
|
|
79
92
|
}],
|
|
80
93
|
cellBgColor: "#FFFFFF"
|
|
81
|
-
}]
|
|
94
|
+
}],
|
|
95
|
+
size: {
|
|
96
|
+
width: 120
|
|
97
|
+
}
|
|
82
98
|
}, {
|
|
83
99
|
type: "table-cell",
|
|
84
100
|
children: [{
|
|
@@ -87,7 +103,10 @@ export const DEFAULT_TABLE_NODE = () => ({
|
|
|
87
103
|
text: ""
|
|
88
104
|
}],
|
|
89
105
|
cellBgColor: "#FFFFFF"
|
|
90
|
-
}]
|
|
106
|
+
}],
|
|
107
|
+
size: {
|
|
108
|
+
width: 120
|
|
109
|
+
}
|
|
91
110
|
}, {
|
|
92
111
|
type: "table-cell",
|
|
93
112
|
children: [{
|
|
@@ -98,14 +117,14 @@ export const DEFAULT_TABLE_NODE = () => ({
|
|
|
98
117
|
cellBgColor: "#FFFFFF"
|
|
99
118
|
}],
|
|
100
119
|
size: {
|
|
101
|
-
|
|
102
|
-
widthInPercent: 100
|
|
120
|
+
width: 120
|
|
103
121
|
}
|
|
104
122
|
}]
|
|
105
123
|
}],
|
|
106
124
|
rows: 3,
|
|
107
125
|
columns: 3
|
|
108
126
|
});
|
|
127
|
+
const isFreeGridTable = n => !Editor.isEditor(n) && Element.isElement(n) && n.type === "freegridItem" && n.childType === "table";
|
|
109
128
|
const prefixKey = (obj, pk = "") => {
|
|
110
129
|
return Object.keys(obj).reduce((a, b) => {
|
|
111
130
|
a[`${pk}${b}`] = obj[b];
|
|
@@ -144,12 +163,49 @@ export class TableUtil {
|
|
|
144
163
|
customInsertNode(this.editor, newTable);
|
|
145
164
|
};
|
|
146
165
|
removeTable = () => {
|
|
147
|
-
|
|
148
|
-
match:
|
|
149
|
-
// mode:'highest'
|
|
166
|
+
const [freeGridItem] = Editor.nodes(this.editor, {
|
|
167
|
+
match: isFreeGridTable
|
|
150
168
|
});
|
|
169
|
+
if (freeGridItem) {
|
|
170
|
+
Transforms.removeNodes(this.editor, {
|
|
171
|
+
match: isFreeGridTable
|
|
172
|
+
});
|
|
173
|
+
} else {
|
|
174
|
+
Transforms.removeNodes(this.editor, {
|
|
175
|
+
match: n => !Editor.isEditor(n) && Element.isElement(n) && n.type === "table"
|
|
176
|
+
});
|
|
177
|
+
}
|
|
178
|
+
};
|
|
179
|
+
duplicateTable = () => {
|
|
180
|
+
const {
|
|
181
|
+
selection
|
|
182
|
+
} = this.editor;
|
|
183
|
+
if (!!selection && Range.isCollapsed(selection)) {
|
|
184
|
+
const [freeGridItem] = Editor.nodes(this.editor, {
|
|
185
|
+
match: isFreeGridTable
|
|
186
|
+
});
|
|
187
|
+
let clone;
|
|
188
|
+
let path;
|
|
189
|
+
if (freeGridItem) {
|
|
190
|
+
const [freeGridNode, freeGridPath] = freeGridItem;
|
|
191
|
+
clone = freeGridNode;
|
|
192
|
+
path = freeGridPath;
|
|
193
|
+
} else {
|
|
194
|
+
const [[tableNode, tablePath]] = Editor.nodes(this.editor, {
|
|
195
|
+
match: n => !Editor.isEditor(n) && Element.isElement(n) && n.type === "table"
|
|
196
|
+
});
|
|
197
|
+
clone = tableNode;
|
|
198
|
+
path = tablePath;
|
|
199
|
+
}
|
|
200
|
+
const nextPath = Path.next(path);
|
|
201
|
+
if (clone) {
|
|
202
|
+
const clonedNode = JSON.parse(JSON.stringify(clone));
|
|
203
|
+
Transforms.insertNodes(this.editor, clonedNode, {
|
|
204
|
+
at: nextPath
|
|
205
|
+
});
|
|
206
|
+
}
|
|
207
|
+
}
|
|
151
208
|
};
|
|
152
|
-
|
|
153
209
|
getDOMNode = path => {
|
|
154
210
|
try {
|
|
155
211
|
const [tableNode] = Editor.nodes(this.editor, {
|
|
@@ -186,9 +242,12 @@ export class TableUtil {
|
|
|
186
242
|
const [[table, tablePath]] = Editor.nodes(this.editor, {
|
|
187
243
|
match: n => !Editor.isEditor(n) && Element.isElement(n) && n.type === "table"
|
|
188
244
|
});
|
|
189
|
-
const [, currentRow] = tableNode;
|
|
190
|
-
const
|
|
191
|
-
|
|
245
|
+
const [currentRowData, currentRow] = tableNode;
|
|
246
|
+
const isDuplicate = action === "duplicate";
|
|
247
|
+
const isInsertNext = action === "after" || isDuplicate;
|
|
248
|
+
const path = isInsertNext ? Path.next(currentRow) : currentRow;
|
|
249
|
+
const insertData = isDuplicate ? JSON.parse(JSON.stringify(currentRowData)) : createRow(Array(table.columns).fill(""));
|
|
250
|
+
Transforms.insertNodes(this.editor, insertData, {
|
|
192
251
|
at: path
|
|
193
252
|
});
|
|
194
253
|
Transforms.setNodes(this.editor, {
|
|
@@ -199,6 +258,23 @@ export class TableUtil {
|
|
|
199
258
|
}
|
|
200
259
|
}
|
|
201
260
|
};
|
|
261
|
+
clearRow = () => {
|
|
262
|
+
const {
|
|
263
|
+
selection
|
|
264
|
+
} = this.editor;
|
|
265
|
+
if (!!selection && Range.isCollapsed(selection)) {
|
|
266
|
+
const [tableRow] = Editor.nodes(this.editor, {
|
|
267
|
+
match: n => !Editor.isEditor(n) && Element.isElement(n) && n.type === "table-row"
|
|
268
|
+
});
|
|
269
|
+
if (tableRow) {
|
|
270
|
+
const [tableRowNode, tableRowPath] = tableRow;
|
|
271
|
+
tableRowNode?.children?.forEach((cell, index) => {
|
|
272
|
+
const currentCellPath = [...tableRowPath, index];
|
|
273
|
+
clearCellText(this.editor, currentCellPath);
|
|
274
|
+
});
|
|
275
|
+
}
|
|
276
|
+
}
|
|
277
|
+
};
|
|
202
278
|
deleteRow = () => {
|
|
203
279
|
try {
|
|
204
280
|
const {
|
|
@@ -259,6 +335,58 @@ export class TableUtil {
|
|
|
259
335
|
}
|
|
260
336
|
}
|
|
261
337
|
};
|
|
338
|
+
duplicateColumn = () => {
|
|
339
|
+
const {
|
|
340
|
+
selection
|
|
341
|
+
} = this.editor;
|
|
342
|
+
if (!!selection && Range.isCollapsed(selection)) {
|
|
343
|
+
const [tableNode] = Editor.nodes(this.editor, {
|
|
344
|
+
match: n => !Editor.isEditor(n) && Element.isElement(n) && n.type === "table-cell"
|
|
345
|
+
});
|
|
346
|
+
if (tableNode) {
|
|
347
|
+
const [[table, tablePath]] = Editor.nodes(this.editor, {
|
|
348
|
+
match: n => !Editor.isEditor(n) && Element.isElement(n) && n.type === "table"
|
|
349
|
+
});
|
|
350
|
+
const [, currentCell] = tableNode;
|
|
351
|
+
const currentCellPath = currentCell;
|
|
352
|
+
const insertNextCellPath = Path.next(currentCell);
|
|
353
|
+
for (let row = 0; row < table.rows; row++) {
|
|
354
|
+
currentCellPath[currentCellPath.length - 2] = row;
|
|
355
|
+
insertNextCellPath[insertNextCellPath?.length - 2] = row;
|
|
356
|
+
const cellNode = getNode(this.editor, currentCellPath);
|
|
357
|
+
Transforms.insertNodes(this.editor, JSON.parse(JSON.stringify(cellNode)), {
|
|
358
|
+
at: insertNextCellPath
|
|
359
|
+
});
|
|
360
|
+
}
|
|
361
|
+
Transforms.setNodes(this.editor, {
|
|
362
|
+
columns: table.columns + 1
|
|
363
|
+
}, {
|
|
364
|
+
at: tablePath
|
|
365
|
+
});
|
|
366
|
+
}
|
|
367
|
+
}
|
|
368
|
+
};
|
|
369
|
+
clearColumn = () => {
|
|
370
|
+
const {
|
|
371
|
+
selection
|
|
372
|
+
} = this.editor;
|
|
373
|
+
if (!!selection && Range.isCollapsed(selection)) {
|
|
374
|
+
const [tableNode] = Editor.nodes(this.editor, {
|
|
375
|
+
match: n => !Editor.isEditor(n) && Element.isElement(n) && n.type === "table-cell"
|
|
376
|
+
});
|
|
377
|
+
if (tableNode) {
|
|
378
|
+
const [[table]] = Editor.nodes(this.editor, {
|
|
379
|
+
match: n => !Editor.isEditor(n) && Element.isElement(n) && n.type === "table"
|
|
380
|
+
});
|
|
381
|
+
const [, currentCell] = tableNode;
|
|
382
|
+
const currentCellPath = currentCell;
|
|
383
|
+
for (let row = 0; row < table.rows; row++) {
|
|
384
|
+
currentCellPath[currentCellPath.length - 2] = row;
|
|
385
|
+
clearCellText(this.editor, currentCellPath);
|
|
386
|
+
}
|
|
387
|
+
}
|
|
388
|
+
}
|
|
389
|
+
};
|
|
262
390
|
deleteColumn = () => {
|
|
263
391
|
try {
|
|
264
392
|
const {
|
|
@@ -326,6 +454,7 @@ export class TableUtil {
|
|
|
326
454
|
}, {
|
|
327
455
|
at: currentCellPath
|
|
328
456
|
});
|
|
457
|
+
applyColumnStyle(this.editor, currentCellPath, currentTablePath, cellProps, tableProps?.rows);
|
|
329
458
|
|
|
330
459
|
// cell bg entire
|
|
331
460
|
if (cellProps?.entireBgColor || tableProps?.borderColor || rowProps?.borderColor) {
|
|
@@ -363,6 +492,18 @@ export class TableUtil {
|
|
|
363
492
|
console.log(err);
|
|
364
493
|
}
|
|
365
494
|
};
|
|
495
|
+
resizeTableCell = (styleProps, rowNode) => {
|
|
496
|
+
const cellProps = parseByPrefixKey(styleProps, "col.");
|
|
497
|
+
const [rowData, rowPath] = rowNode;
|
|
498
|
+
rowData?.children.forEach((_, i) => {
|
|
499
|
+
const cellPath = [...rowPath, i];
|
|
500
|
+
Transforms.setNodes(this.editor, {
|
|
501
|
+
...cellProps
|
|
502
|
+
}, {
|
|
503
|
+
at: cellPath
|
|
504
|
+
});
|
|
505
|
+
});
|
|
506
|
+
};
|
|
366
507
|
getTableProps = () => {
|
|
367
508
|
const {
|
|
368
509
|
selection
|
|
@@ -500,7 +641,10 @@ export const createTableCell = text => {
|
|
|
500
641
|
children: [{
|
|
501
642
|
text
|
|
502
643
|
}]
|
|
503
|
-
}]
|
|
644
|
+
}],
|
|
645
|
+
size: {
|
|
646
|
+
width: 120
|
|
647
|
+
}
|
|
504
648
|
};
|
|
505
649
|
};
|
|
506
650
|
|
|
@@ -549,4 +693,43 @@ const createTableNode = (cellText, rows, columns) => {
|
|
|
549
693
|
columns
|
|
550
694
|
};
|
|
551
695
|
return tableNode;
|
|
696
|
+
};
|
|
697
|
+
const columnStyleKeys = ["entireBgColor", "entireBorderColor", "entireTextColor", "entireFontFamily", "entireFontWeight", "entireTextSize"];
|
|
698
|
+
const applyColumnStyle = (editor, currentCellPath, currentTablePath, cellProps, rows) => {
|
|
699
|
+
const colStyle = columnStyleKeys.reduce((acc, key) => {
|
|
700
|
+
const style = cellProps[key];
|
|
701
|
+
if (style) {
|
|
702
|
+
acc[key] = style;
|
|
703
|
+
}
|
|
704
|
+
return acc;
|
|
705
|
+
}, {});
|
|
706
|
+
for (let r = 0; r < rows; r++) {
|
|
707
|
+
const cellPosition = currentCellPath[currentCellPath?.length - 1]; // cell position on each row as per selected column cell
|
|
708
|
+
|
|
709
|
+
Transforms.setNodes(editor, colStyle, {
|
|
710
|
+
at: [...currentTablePath, r, cellPosition]
|
|
711
|
+
});
|
|
712
|
+
}
|
|
713
|
+
};
|
|
714
|
+
export const clearCellText = (editor, currentCellPath) => {
|
|
715
|
+
try {
|
|
716
|
+
const existingCellNode = getNode(editor, currentCellPath);
|
|
717
|
+
Transforms.removeNodes(editor, {
|
|
718
|
+
at: currentCellPath
|
|
719
|
+
});
|
|
720
|
+
Transforms.insertNodes(editor, {
|
|
721
|
+
...(existingCellNode || {}),
|
|
722
|
+
children: [{
|
|
723
|
+
type: "paragraph",
|
|
724
|
+
children: [{
|
|
725
|
+
text: ""
|
|
726
|
+
}],
|
|
727
|
+
cellBgColor: "#FFFFFF"
|
|
728
|
+
}]
|
|
729
|
+
}, {
|
|
730
|
+
at: currentCellPath
|
|
731
|
+
});
|
|
732
|
+
} catch (err) {
|
|
733
|
+
console.log(err);
|
|
734
|
+
}
|
|
552
735
|
};
|