@flozy/editor 5.5.8 → 5.6.0

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.
Files changed (199) hide show
  1. package/dist/Editor/ChatEditor.js +25 -34
  2. package/dist/Editor/CommonEditor.js +26 -13
  3. package/dist/Editor/Editor.css +106 -20
  4. package/dist/Editor/Elements/AI/AIInput.js +0 -1
  5. package/dist/Editor/Elements/AI/CustomSelect.js +17 -10
  6. package/dist/Editor/Elements/AI/PopoverAIInput.js +59 -53
  7. package/dist/Editor/Elements/AI/Styles.js +24 -6
  8. package/dist/Editor/Elements/Accordion/Accordion.js +8 -1
  9. package/dist/Editor/Elements/AppHeader/AppHeader.js +6 -6
  10. package/dist/Editor/Elements/Button/EditorButton.js +6 -1
  11. package/dist/Editor/Elements/Carousel/CarouselItem.js +11 -3
  12. package/dist/Editor/Elements/Color Picker/ColorButtons.js +7 -5
  13. package/dist/Editor/Elements/Color Picker/Styles.js +8 -3
  14. package/dist/Editor/Elements/Color Picker/defaultColors.js +2 -2
  15. package/dist/Editor/Elements/DataView/DataView.js +124 -0
  16. package/dist/Editor/Elements/DataView/DataViewButton.js +23 -0
  17. package/dist/Editor/Elements/DataView/Layouts/ColumnView.js +83 -0
  18. package/dist/Editor/Elements/DataView/Layouts/DataTypes/CheckType.js +33 -0
  19. package/dist/Editor/Elements/DataView/Layouts/DataTypes/Components/Select.js +180 -0
  20. package/dist/Editor/Elements/DataView/Layouts/DataTypes/Components/SimpleSelect.js +62 -0
  21. package/dist/Editor/Elements/DataView/Layouts/DataTypes/Components/styles.js +68 -0
  22. package/dist/Editor/Elements/DataView/Layouts/DataTypes/DateType.js +35 -0
  23. package/dist/Editor/Elements/DataView/Layouts/DataTypes/MultiSelectType.js +39 -0
  24. package/dist/Editor/Elements/DataView/Layouts/DataTypes/NumberType.js +30 -0
  25. package/dist/Editor/Elements/DataView/Layouts/DataTypes/PersonType.js +30 -0
  26. package/dist/Editor/Elements/DataView/Layouts/DataTypes/SelectType.js +35 -0
  27. package/dist/Editor/Elements/DataView/Layouts/DataTypes/TextType.js +36 -0
  28. package/dist/Editor/Elements/DataView/Layouts/DataTypes/index.js +17 -0
  29. package/dist/Editor/Elements/DataView/Layouts/FilterSort/SortOptions/ChooseField.js +29 -0
  30. package/dist/Editor/Elements/DataView/Layouts/FilterSort/SortOptions/ChooseSort.js +38 -0
  31. package/dist/Editor/Elements/DataView/Layouts/FilterSort/SortOptions/index.js +86 -0
  32. package/dist/Editor/Elements/DataView/Layouts/FilterSort/index.js +71 -0
  33. package/dist/Editor/Elements/DataView/Layouts/FilterSort/styles.js +138 -0
  34. package/dist/Editor/Elements/DataView/Layouts/FilterView.js +213 -0
  35. package/dist/Editor/Elements/DataView/Layouts/Formula.js +29 -0
  36. package/dist/Editor/Elements/DataView/Layouts/Options/AddOptions.js +113 -0
  37. package/dist/Editor/Elements/DataView/Layouts/Options/AddProperty.js +44 -0
  38. package/dist/Editor/Elements/DataView/Layouts/Options/AllProperties.js +146 -0
  39. package/dist/Editor/Elements/DataView/Layouts/Options/ChangeProperty.js +79 -0
  40. package/dist/Editor/Elements/DataView/Layouts/Options/ColumnsList.js +57 -0
  41. package/dist/Editor/Elements/DataView/Layouts/Options/Constants.js +101 -0
  42. package/dist/Editor/Elements/DataView/Layouts/Options/EditOption.js +174 -0
  43. package/dist/Editor/Elements/DataView/Layouts/Options/EditProperty.js +241 -0
  44. package/dist/Editor/Elements/DataView/Layouts/Options/FilterProperty.js +45 -0
  45. package/dist/Editor/Elements/DataView/Layouts/Options/PropertyList.js +32 -0
  46. package/dist/Editor/Elements/DataView/Layouts/Options/index.js +110 -0
  47. package/dist/Editor/Elements/DataView/Layouts/Options/styles.js +217 -0
  48. package/dist/Editor/Elements/DataView/Layouts/TableStyles.js +131 -0
  49. package/dist/Editor/Elements/DataView/Layouts/TableView.js +253 -0
  50. package/dist/Editor/Elements/DataView/Layouts/ViewData.js +85 -0
  51. package/dist/Editor/Elements/DataView/Layouts/colStyles.js +10 -0
  52. package/dist/Editor/Elements/DataView/Layouts/index.js +25 -0
  53. package/dist/Editor/Elements/DataView/Providers/DataViewProvider.js +277 -0
  54. package/dist/Editor/Elements/DataView/Utils/globalSearch.js +15 -0
  55. package/dist/Editor/Elements/DataView/Utils/multiSortRows.js +88 -0
  56. package/dist/Editor/Elements/DataView/styles.js +169 -0
  57. package/dist/Editor/Elements/Divider/Divider.js +36 -20
  58. package/dist/Editor/Elements/Embed/Image.js +51 -16
  59. package/dist/Editor/Elements/Embed/Video.js +26 -3
  60. package/dist/Editor/Elements/Form/Form.js +38 -2
  61. package/dist/Editor/Elements/Form/FormElements/FormCheckbox.js +7 -1
  62. package/dist/Editor/Elements/Form/FormElements/FormDate.js +7 -1
  63. package/dist/Editor/Elements/Form/FormElements/FormEmail.js +7 -1
  64. package/dist/Editor/Elements/Form/FormElements/FormNumbers.js +7 -1
  65. package/dist/Editor/Elements/Form/FormElements/FormRadioButton.js +7 -1
  66. package/dist/Editor/Elements/Form/FormElements/FormText.js +7 -1
  67. package/dist/Editor/Elements/Form/FormElements/FormTextArea.js +6 -1
  68. package/dist/Editor/Elements/Form/FormPopup.js +12 -9
  69. package/dist/Editor/Elements/Form/Workflow/Styles.js +2 -0
  70. package/dist/Editor/Elements/FreeGrid/FreeGrid.js +1 -1
  71. package/dist/Editor/Elements/FreeGrid/FreeGridBox.js +4 -2
  72. package/dist/Editor/Elements/FreeGrid/FreeGridItem.js +20 -1
  73. package/dist/Editor/Elements/FreeGrid/breakpointConstants.js +4 -4
  74. package/dist/Editor/Elements/FreeGrid/styles.js +1 -1
  75. package/dist/Editor/Elements/Grid/GridButton.js +2 -2
  76. package/dist/Editor/Elements/Grid/GridItem.js +47 -36
  77. package/dist/Editor/Elements/Grid/Styles.js +50 -0
  78. package/dist/Editor/Elements/Link/LinkButton.js +1 -1
  79. package/dist/Editor/Elements/Search/SearchButton.js +1 -0
  80. package/dist/Editor/Elements/Signature/Signature.css +1 -1
  81. package/dist/Editor/Elements/Signature/SignatureOptions/TypeSignature.js +2 -2
  82. package/dist/Editor/Elements/Signature/SignaturePopup.js +17 -52
  83. package/dist/Editor/Elements/SimpleText/index.js +3 -2
  84. package/dist/Editor/Elements/SimpleText/style.js +15 -0
  85. package/dist/Editor/Elements/Table/AddRowCol.js +77 -0
  86. package/dist/Editor/Elements/Table/DragButton.js +142 -0
  87. package/dist/Editor/Elements/Table/DragStyles.js +70 -0
  88. package/dist/Editor/Elements/Table/Draggable.js +25 -0
  89. package/dist/Editor/Elements/Table/Droppable.js +53 -0
  90. package/dist/Editor/Elements/Table/Styles.js +88 -78
  91. package/dist/Editor/Elements/Table/Table.js +263 -140
  92. package/dist/Editor/Elements/Table/TableCell.js +365 -111
  93. package/dist/Editor/Elements/Table/TablePopup.js +9 -3
  94. package/dist/Editor/Elements/Table/TableRow.js +10 -2
  95. package/dist/Editor/Elements/Table/TableTool.js +101 -0
  96. package/dist/Editor/Elements/Table/tableHelper.js +71 -0
  97. package/dist/Editor/Elements/TopBanner/TopBanner.js +2 -1
  98. package/dist/Editor/MiniEditor.js +21 -2
  99. package/dist/Editor/Styles/EditorStyles.js +13 -4
  100. package/dist/Editor/Toolbar/FormatTools/BlockButton.js +10 -0
  101. package/dist/Editor/Toolbar/FormatTools/Dropdown.js +7 -12
  102. package/dist/Editor/Toolbar/FormatTools/FontFamilyAutocomplete.js +26 -4
  103. package/dist/Editor/Toolbar/FormatTools/MarkButton.js +3 -0
  104. package/dist/Editor/Toolbar/FormatTools/TextSize.js +5 -5
  105. package/dist/Editor/Toolbar/Mini/MiniToolbar.js +8 -8
  106. package/dist/Editor/Toolbar/Mini/Styles.js +9 -1
  107. package/dist/Editor/Toolbar/PopupTool/MiniTextFormat/InfinityAITool.js +7 -3
  108. package/dist/Editor/Toolbar/PopupTool/MiniTextFormat/index.js +6 -4
  109. package/dist/Editor/Toolbar/PopupTool/PopperHeader.js +19 -15
  110. package/dist/Editor/Toolbar/PopupTool/PopupToolStyle.js +547 -58
  111. package/dist/Editor/Toolbar/PopupTool/TextFormat.js +28 -16
  112. package/dist/Editor/Toolbar/PopupTool/index.js +3 -5
  113. package/dist/Editor/Toolbar/Toolbar.js +6 -0
  114. package/dist/Editor/Toolbar/toolbarGroups.js +4 -0
  115. package/dist/Editor/assets/svg/ArrowDownIcon.js +25 -0
  116. package/dist/Editor/assets/svg/ArrowUpIcon.js +25 -0
  117. package/dist/Editor/assets/svg/BrainIcon.js +2 -2
  118. package/dist/Editor/assets/svg/CalenderIconTick.js +64 -0
  119. package/dist/Editor/assets/svg/ChervDown.js +18 -0
  120. package/dist/Editor/assets/svg/ChervUp.js +18 -0
  121. package/dist/Editor/assets/svg/DataTableIcon.js +50 -0
  122. package/dist/Editor/assets/svg/DuplicateIcon.js +23 -0
  123. package/dist/Editor/assets/svg/EyeIcon.js +23 -0
  124. package/dist/Editor/assets/svg/EyeSlash.js +43 -0
  125. package/dist/Editor/assets/svg/HashtagIcon.js +33 -0
  126. package/dist/Editor/assets/svg/PlusIcon.js +23 -0
  127. package/dist/Editor/assets/svg/SelectRoundedIcon.js +24 -0
  128. package/dist/Editor/assets/svg/SettingsIcon.js +4 -4
  129. package/dist/Editor/assets/svg/SortByIcon.js +33 -0
  130. package/dist/Editor/assets/svg/TableIcons.js +220 -0
  131. package/dist/Editor/assets/svg/TickOutlined.js +23 -0
  132. package/dist/Editor/assets/svg/TrashCanIcon.js +38 -0
  133. package/dist/Editor/common/ColorPickerButton.js +85 -45
  134. package/dist/Editor/common/DnD/Draggable.js +2 -1
  135. package/dist/Editor/common/FontLoader/FontLoader.js +2 -2
  136. package/dist/Editor/common/Icon.js +54 -21
  137. package/dist/Editor/common/ImageSelector/Options/Upload.js +2 -1
  138. package/dist/Editor/common/ImageSelector/Styles.js +47 -6
  139. package/dist/Editor/common/ImageSelector/UploadStyles.js +18 -6
  140. package/dist/Editor/common/LinkSettings/NavComponents.js +2 -1
  141. package/dist/Editor/common/LinkSettings/index.js +2 -1
  142. package/dist/Editor/common/MentionsPopup/Styles.js +142 -8
  143. package/dist/Editor/common/MentionsPopup/index.js +1 -1
  144. package/dist/Editor/common/RnD/ElementSettings/Settings/FormSettings.js +107 -12
  145. package/dist/Editor/common/RnD/GuideLines/styles.js +3 -3
  146. package/dist/Editor/common/RnD/ShadowElement.js +1 -1
  147. package/dist/Editor/common/RnD/VirtualElement/index.js +5 -1
  148. package/dist/Editor/common/RnD/index.js +4 -3
  149. package/dist/Editor/common/Section/index.js +3 -3
  150. package/dist/Editor/common/Section/styles.js +5 -1
  151. package/dist/Editor/common/Select/index.js +20 -0
  152. package/dist/Editor/common/Select/styles.js +17 -0
  153. package/dist/Editor/common/Shorthands/elements.js +13 -1
  154. package/dist/Editor/common/StyleBuilder/fieldStyle.js +2 -1
  155. package/dist/Editor/common/StyleBuilder/fieldTypes/backgroundImage.js +4 -3
  156. package/dist/Editor/common/StyleBuilder/fieldTypes/bannerSpacing.js +35 -7
  157. package/dist/Editor/common/StyleBuilder/fieldTypes/borderRadius.js +15 -2
  158. package/dist/Editor/common/StyleBuilder/fieldTypes/color.js +2 -1
  159. package/dist/Editor/common/StyleBuilder/fieldTypes/fontSize.js +1 -1
  160. package/dist/Editor/common/StyleBuilder/fieldTypes/icons.js +2 -0
  161. package/dist/Editor/common/StyleBuilder/fieldTypes/radiusStyle.js +11 -11
  162. package/dist/Editor/common/StyleBuilder/fieldTypes/saveAsTemplate.js +22 -6
  163. package/dist/Editor/common/StyleBuilder/fieldTypes/selectBox.js +21 -2
  164. package/dist/Editor/common/StyleBuilder/fieldTypes/text.js +20 -4
  165. package/dist/Editor/common/StyleBuilder/fieldTypes/textOptions.js +12 -2
  166. package/dist/Editor/common/StyleBuilder/formStyle.js +268 -149
  167. package/dist/Editor/common/StyleBuilder/index.js +101 -20
  168. package/dist/Editor/common/StyleBuilder/tableStyle.js +69 -25
  169. package/dist/Editor/common/SwipeableDrawer/style.js +15 -4
  170. package/dist/Editor/common/ToolbarIcon.js +1 -1
  171. package/dist/Editor/common/Uploader.js +39 -37
  172. package/dist/Editor/common/iconListV2.js +598 -74
  173. package/dist/Editor/common/iconslist.js +25 -19
  174. package/dist/Editor/commonStyle.js +421 -15
  175. package/dist/Editor/helper/deserialize/index.js +31 -2
  176. package/dist/Editor/helper/enforceDateFormat.js +41 -0
  177. package/dist/Editor/helper/index.js +15 -2
  178. package/dist/Editor/helper/theme.js +15 -1
  179. package/dist/Editor/hooks/useBreakpoints.js +1 -1
  180. package/dist/Editor/hooks/useTable.js +210 -0
  181. package/dist/Editor/plugins/withCustomDeleteBackward.js +1 -1
  182. package/dist/Editor/plugins/withEmbeds.js +30 -26
  183. package/dist/Editor/plugins/withHTML.js +100 -12
  184. package/dist/Editor/plugins/withLayout.js +1 -0
  185. package/dist/Editor/utils/SlateUtilityFunctions.js +31 -11
  186. package/dist/Editor/utils/brains.js +1 -1
  187. package/dist/Editor/utils/chatEditor/SlateUtilityFunctions.js +75 -6
  188. package/dist/Editor/utils/customHooks/useResize.js +7 -4
  189. package/dist/Editor/utils/customHooks/useTableResize.js +6 -2
  190. package/dist/Editor/utils/dataView.js +43 -0
  191. package/dist/Editor/utils/embed.js +2 -1
  192. package/dist/Editor/utils/events.js +0 -1
  193. package/dist/Editor/utils/font.js +11 -4
  194. package/dist/Editor/utils/formfield.js +8 -4
  195. package/dist/Editor/utils/helper.js +100 -2
  196. package/dist/Editor/utils/insertNewLine.js +19 -1
  197. package/dist/Editor/utils/serializeToText.js +2 -0
  198. package/dist/Editor/utils/table.js +228 -24
  199. package/package.json +2 -2
@@ -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
- widthInPercent: 100,
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
- height: 300,
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
- Transforms.removeNodes(this.editor, {
148
- match: n => !Editor.isEditor(n) && Element.isElement(n) && n.type === "table"
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 path = action === "after" ? Path.next(currentRow) : currentRow;
191
- Transforms.insertNodes(this.editor, createRow(Array(table.columns).fill("")), {
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
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@flozy/editor",
3
- "version": "5.5.8",
3
+ "version": "5.6.0",
4
4
  "description": "An Editor for flozy app brain",
5
5
  "files": [
6
6
  "dist"
@@ -68,7 +68,7 @@
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/agmac30/Documents/CODE_BASE/flozy/client/node_modules/@flozy/editor/dist && babel src/components -d /Users/agmac30/Documents/CODE_BASE/flozy/client/node_modules/@flozy/editor/dist --copy-files"
72
72
  },
73
73
  "eslintConfig": {
74
74
  "extends": [