@flozy/editor 5.1.5 → 5.1.7
Sign up to get free protection for your applications and to get access to all the features.
- package/dist/Editor/ChatEditor.js +25 -34
- package/dist/Editor/CommonEditor.js +15 -9
- package/dist/Editor/Editor.css +56 -12
- package/dist/Editor/Elements/AI/AIInput.js +0 -1
- package/dist/Editor/Elements/AI/CustomSelect.js +17 -10
- package/dist/Editor/Elements/AI/Styles.js +7 -1
- package/dist/Editor/Elements/AppHeader/AppHeader.js +6 -6
- package/dist/Editor/Elements/Button/EditorButton.js +1 -1
- package/dist/Editor/Elements/Carousel/CarouselItem.js +1 -1
- package/dist/Editor/Elements/Color Picker/ColorButtons.js +7 -5
- package/dist/Editor/Elements/Color Picker/Styles.js +7 -3
- package/dist/Editor/Elements/Color Picker/defaultColors.js +2 -2
- package/dist/Editor/Elements/DataView/DataView.js +109 -0
- package/dist/Editor/Elements/DataView/DataViewButton.js +23 -0
- package/dist/Editor/Elements/DataView/Layouts/ColumnView.js +66 -0
- package/dist/Editor/Elements/DataView/Layouts/DataTypes/CheckType.js +30 -0
- package/dist/Editor/Elements/DataView/Layouts/DataTypes/Components/Select.js +162 -0
- package/dist/Editor/Elements/DataView/Layouts/DataTypes/Components/SimpleSelect.js +40 -0
- package/dist/Editor/Elements/DataView/Layouts/DataTypes/Components/styles.js +67 -0
- package/dist/Editor/Elements/DataView/Layouts/DataTypes/DateType.js +30 -0
- package/dist/Editor/Elements/DataView/Layouts/DataTypes/MultiSelectType.js +39 -0
- package/dist/Editor/Elements/DataView/Layouts/DataTypes/NumberType.js +30 -0
- package/dist/Editor/Elements/DataView/Layouts/DataTypes/PersonType.js +30 -0
- package/dist/Editor/Elements/DataView/Layouts/DataTypes/SelectType.js +35 -0
- package/dist/Editor/Elements/DataView/Layouts/DataTypes/TextType.js +36 -0
- package/dist/Editor/Elements/DataView/Layouts/DataTypes/index.js +17 -0
- package/dist/Editor/Elements/DataView/Layouts/FilterSort/SortOptions/ChooseField.js +29 -0
- package/dist/Editor/Elements/DataView/Layouts/FilterSort/SortOptions/ChooseSort.js +38 -0
- package/dist/Editor/Elements/DataView/Layouts/FilterSort/SortOptions/index.js +74 -0
- package/dist/Editor/Elements/DataView/Layouts/FilterSort/index.js +64 -0
- package/dist/Editor/Elements/DataView/Layouts/FilterSort/styles.js +106 -0
- package/dist/Editor/Elements/DataView/Layouts/FilterView.js +174 -0
- package/dist/Editor/Elements/DataView/Layouts/Formula.js +29 -0
- package/dist/Editor/Elements/DataView/Layouts/Options/AddOptions.js +113 -0
- package/dist/Editor/Elements/DataView/Layouts/Options/AddProperty.js +37 -0
- package/dist/Editor/Elements/DataView/Layouts/Options/AllProperties.js +111 -0
- package/dist/Editor/Elements/DataView/Layouts/Options/ChangeProperty.js +60 -0
- package/dist/Editor/Elements/DataView/Layouts/Options/ColumnsList.js +36 -0
- package/dist/Editor/Elements/DataView/Layouts/Options/Constants.js +101 -0
- package/dist/Editor/Elements/DataView/Layouts/Options/EditOption.js +160 -0
- package/dist/Editor/Elements/DataView/Layouts/Options/EditProperty.js +190 -0
- package/dist/Editor/Elements/DataView/Layouts/Options/FilterProperty.js +42 -0
- package/dist/Editor/Elements/DataView/Layouts/Options/PropertyList.js +30 -0
- package/dist/Editor/Elements/DataView/Layouts/Options/index.js +110 -0
- package/dist/Editor/Elements/DataView/Layouts/Options/styles.js +179 -0
- package/dist/Editor/Elements/DataView/Layouts/TableStyles.js +112 -0
- package/dist/Editor/Elements/DataView/Layouts/TableView.js +227 -0
- package/dist/Editor/Elements/DataView/Layouts/ViewData.js +70 -0
- package/dist/Editor/Elements/DataView/Layouts/index.js +25 -0
- package/dist/Editor/Elements/DataView/Providers/DataViewProvider.js +288 -0
- package/dist/Editor/Elements/DataView/Utils/globalSearch.js +15 -0
- package/dist/Editor/Elements/DataView/Utils/multiSortRows.js +72 -0
- package/dist/Editor/Elements/DataView/styles.js +143 -0
- package/dist/Editor/Elements/Divider/Divider.js +15 -14
- package/dist/Editor/Elements/Form/Form.js +38 -2
- package/dist/Editor/Elements/Form/FormElements/FormCheckbox.js +7 -1
- package/dist/Editor/Elements/Form/FormElements/FormDate.js +7 -1
- package/dist/Editor/Elements/Form/FormElements/FormEmail.js +7 -1
- package/dist/Editor/Elements/Form/FormElements/FormNumbers.js +7 -1
- package/dist/Editor/Elements/Form/FormElements/FormRadioButton.js +7 -1
- package/dist/Editor/Elements/Form/FormElements/FormText.js +7 -1
- package/dist/Editor/Elements/Form/FormElements/FormTextArea.js +6 -1
- package/dist/Editor/Elements/Form/FormPopup.js +12 -9
- package/dist/Editor/Elements/FreeGrid/FreeGrid.js +1 -1
- package/dist/Editor/Elements/FreeGrid/FreeGridItem.js +20 -1
- package/dist/Editor/Elements/FreeGrid/breakpointConstants.js +4 -4
- package/dist/Editor/Elements/FreeGrid/styles.js +1 -1
- package/dist/Editor/Elements/Grid/GridButton.js +2 -2
- package/dist/Editor/Elements/Grid/GridItem.js +21 -18
- package/dist/Editor/Elements/Link/LinkButton.js +1 -1
- package/dist/Editor/Elements/Signature/Signature.css +1 -1
- package/dist/Editor/Elements/Signature/SignatureOptions/TypeSignature.js +2 -2
- package/dist/Editor/Elements/Signature/SignaturePopup.js +13 -48
- package/dist/Editor/Elements/SimpleText/index.js +8 -1
- package/dist/Editor/Elements/SimpleText/style.js +13 -1
- package/dist/Editor/Elements/Table/AddRowCol.js +77 -0
- package/dist/Editor/Elements/Table/DragButton.js +141 -0
- package/dist/Editor/Elements/Table/DragStyles.js +70 -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 +25 -43
- package/dist/Editor/Elements/Table/Table.js +205 -138
- package/dist/Editor/Elements/Table/TableCell.js +355 -102
- 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/Elements/Table/tableHelper.js +71 -0
- package/dist/Editor/Styles/EditorStyles.js +3 -1
- package/dist/Editor/Toolbar/FormatTools/BlockButton.js +10 -0
- package/dist/Editor/Toolbar/FormatTools/Dropdown.js +7 -12
- package/dist/Editor/Toolbar/FormatTools/FontFamilyAutocomplete.js +10 -4
- package/dist/Editor/Toolbar/FormatTools/MarkButton.js +3 -0
- package/dist/Editor/Toolbar/FormatTools/TextSize.js +0 -2
- package/dist/Editor/Toolbar/Mini/MiniToolbar.js +3 -6
- package/dist/Editor/Toolbar/Mini/Styles.js +4 -1
- package/dist/Editor/Toolbar/PopupTool/MiniTextFormat/index.js +3 -3
- package/dist/Editor/Toolbar/PopupTool/PopperHeader.js +19 -15
- package/dist/Editor/Toolbar/PopupTool/PopupToolStyle.js +411 -49
- package/dist/Editor/Toolbar/PopupTool/TextFormat.js +62 -8
- package/dist/Editor/Toolbar/PopupTool/index.js +5 -6
- package/dist/Editor/Toolbar/Toolbar.js +6 -0
- package/dist/Editor/Toolbar/toolbarGroups.js +4 -0
- package/dist/Editor/assets/svg/BrainIcon.js +2 -2
- package/dist/Editor/assets/svg/TableIcons.js +220 -0
- package/dist/Editor/common/ColorPickerButton.js +3 -2
- package/dist/Editor/common/FontLoader/FontLoader.js +4 -4
- package/dist/Editor/common/Icon.js +20 -19
- package/dist/Editor/common/LinkSettings/NavComponents.js +2 -1
- package/dist/Editor/common/LinkSettings/index.js +2 -1
- package/dist/Editor/common/MentionsPopup/Styles.js +152 -8
- package/dist/Editor/common/MentionsPopup/index.js +1 -1
- package/dist/Editor/common/RnD/ElementSettings/Settings/FormSettings.js +108 -12
- package/dist/Editor/common/RnD/GuideLines/styles.js +3 -3
- package/dist/Editor/common/RnD/ShadowElement.js +1 -1
- package/dist/Editor/common/RnD/SwitchViewport/SwitchViewport.js +14 -2
- package/dist/Editor/common/Select/index.js +20 -0
- package/dist/Editor/common/Select/styles.js +17 -0
- package/dist/Editor/common/Shorthands/elements.js +13 -1
- package/dist/Editor/common/StyleBuilder/fieldTypes/backgroundImage.js +5 -0
- package/dist/Editor/common/StyleBuilder/fieldTypes/bannerSpacing.js +8 -4
- package/dist/Editor/common/StyleBuilder/fieldTypes/card.js +10 -2
- package/dist/Editor/common/StyleBuilder/fieldTypes/index.js +3 -1
- package/dist/Editor/common/StyleBuilder/fieldTypes/lineSpacing.js +79 -0
- package/dist/Editor/common/StyleBuilder/fieldTypes/radiusStyle.js +7 -7
- package/dist/Editor/common/StyleBuilder/fieldTypes/textOptions.js +5 -2
- package/dist/Editor/common/StyleBuilder/formStyle.js +268 -149
- package/dist/Editor/common/StyleBuilder/index.js +84 -11
- package/dist/Editor/common/StyleBuilder/pageSettingsStyle.js +4 -0
- package/dist/Editor/common/StyleBuilder/tableStyle.js +69 -25
- package/dist/Editor/common/SwipeableDrawer/style.js +15 -4
- package/dist/Editor/common/Uploader.js +8 -0
- package/dist/Editor/common/iconListV2.js +378 -40
- package/dist/Editor/common/iconslist.js +23 -17
- package/dist/Editor/commonStyle.js +126 -9
- package/dist/Editor/helper/deserialize/index.js +4 -1
- package/dist/Editor/helper/index.js +2 -2
- package/dist/Editor/helper/theme.js +24 -1
- package/dist/Editor/hooks/useMouseMove.js +5 -2
- package/dist/Editor/hooks/useTable.js +195 -0
- package/dist/Editor/plugins/withCustomDeleteBackward.js +3 -2
- package/dist/Editor/plugins/withHTML.js +17 -1
- package/dist/Editor/plugins/withLayout.js +48 -1
- package/dist/Editor/utils/SlateUtilityFunctions.js +18 -0
- package/dist/Editor/utils/button.js +4 -4
- package/dist/Editor/utils/chatEditor/SlateUtilityFunctions.js +21 -0
- package/dist/Editor/utils/dataView.js +43 -0
- package/dist/Editor/utils/embed.js +2 -1
- package/dist/Editor/utils/events.js +0 -1
- package/dist/Editor/utils/font.js +11 -4
- package/dist/Editor/utils/formfield.js +8 -4
- package/dist/Editor/utils/helper.js +67 -2
- package/dist/Editor/utils/insertNewLine.js +19 -1
- package/dist/Editor/utils/pageSettings.js +14 -2
- package/dist/Editor/utils/serializeToText.js +2 -0
- package/dist/Editor/utils/table.js +228 -24
- 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)) : createRowOnInsertAbove(currentRowData, currentRow, this.editor);
|
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,14 @@ export class TableUtil {
|
|
363
492
|
console.log(err);
|
364
493
|
}
|
365
494
|
};
|
495
|
+
resizeTableCell = (styleProps, path) => {
|
496
|
+
const cellProps = parseByPrefixKey(styleProps, "col.");
|
497
|
+
Transforms.setNodes(this.editor, {
|
498
|
+
...cellProps
|
499
|
+
}, {
|
500
|
+
at: path
|
501
|
+
});
|
502
|
+
};
|
366
503
|
getTableProps = () => {
|
367
504
|
const {
|
368
505
|
selection
|
@@ -485,14 +622,14 @@ export class TableUtil {
|
|
485
622
|
}
|
486
623
|
};
|
487
624
|
}
|
488
|
-
const createRow = cellText => {
|
489
|
-
const newRow = Array.from(cellText, value => createTableCell(value));
|
625
|
+
const createRow = (cellText, other) => {
|
626
|
+
const newRow = Array.from(cellText, value => createTableCell(value, other));
|
490
627
|
return {
|
491
628
|
type: "table-row",
|
492
629
|
children: newRow
|
493
630
|
};
|
494
631
|
};
|
495
|
-
export const createTableCell = text => {
|
632
|
+
export const createTableCell = (text, other = {}) => {
|
496
633
|
return {
|
497
634
|
type: "table-cell",
|
498
635
|
children: [{
|
@@ -500,7 +637,35 @@ export const createTableCell = text => {
|
|
500
637
|
children: [{
|
501
638
|
text
|
502
639
|
}]
|
503
|
-
}]
|
640
|
+
}],
|
641
|
+
size: {
|
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
|
+
};
|
663
|
+
}
|
664
|
+
return createTableCell("", other);
|
665
|
+
});
|
666
|
+
return {
|
667
|
+
type: "table-row",
|
668
|
+
children: rowChild
|
504
669
|
};
|
505
670
|
};
|
506
671
|
|
@@ -549,4 +714,43 @@ const createTableNode = (cellText, rows, columns) => {
|
|
549
714
|
columns
|
550
715
|
};
|
551
716
|
return tableNode;
|
717
|
+
};
|
718
|
+
const columnStyleKeys = ["entireBgColor", "entireBorderColor", "entireTextColor", "entireFontFamily", "entireFontWeight", "entireTextSize"];
|
719
|
+
const applyColumnStyle = (editor, currentCellPath, currentTablePath, cellProps, rows) => {
|
720
|
+
const colStyle = columnStyleKeys.reduce((acc, key) => {
|
721
|
+
const style = cellProps[key];
|
722
|
+
if (style) {
|
723
|
+
acc[key] = style;
|
724
|
+
}
|
725
|
+
return acc;
|
726
|
+
}, {});
|
727
|
+
for (let r = 0; r < rows; r++) {
|
728
|
+
const cellPosition = currentCellPath[currentCellPath?.length - 1]; // cell position on each row as per selected column cell
|
729
|
+
|
730
|
+
Transforms.setNodes(editor, colStyle, {
|
731
|
+
at: [...currentTablePath, r, cellPosition]
|
732
|
+
});
|
733
|
+
}
|
734
|
+
};
|
735
|
+
export const clearCellText = (editor, currentCellPath) => {
|
736
|
+
try {
|
737
|
+
const existingCellNode = getNode(editor, currentCellPath);
|
738
|
+
Transforms.removeNodes(editor, {
|
739
|
+
at: currentCellPath
|
740
|
+
});
|
741
|
+
Transforms.insertNodes(editor, {
|
742
|
+
...(existingCellNode || {}),
|
743
|
+
children: [{
|
744
|
+
type: "paragraph",
|
745
|
+
children: [{
|
746
|
+
text: ""
|
747
|
+
}],
|
748
|
+
cellBgColor: "#FFFFFF"
|
749
|
+
}]
|
750
|
+
}, {
|
751
|
+
at: currentCellPath
|
752
|
+
});
|
753
|
+
} catch (err) {
|
754
|
+
console.log(err);
|
755
|
+
}
|
552
756
|
};
|