@flozy/editor 5.1.2 → 5.1.4

Sign up to get free protection for your applications and to get access to all the features.
Files changed (146) hide show
  1. package/dist/Editor/ChatEditor.js +34 -25
  2. package/dist/Editor/CommonEditor.js +7 -13
  3. package/dist/Editor/Editor.css +10 -52
  4. package/dist/Editor/Elements/AI/AIInput.js +1 -0
  5. package/dist/Editor/Elements/AI/CustomSelect.js +10 -17
  6. package/dist/Editor/Elements/AI/Styles.js +1 -7
  7. package/dist/Editor/Elements/Button/EditorButton.js +1 -0
  8. package/dist/Editor/Elements/Color Picker/ColorButtons.js +5 -7
  9. package/dist/Editor/Elements/Color Picker/Styles.js +3 -7
  10. package/dist/Editor/Elements/Color Picker/defaultColors.js +2 -2
  11. package/dist/Editor/Elements/Form/Form.js +2 -38
  12. package/dist/Editor/Elements/Form/FormElements/FormCheckbox.js +1 -7
  13. package/dist/Editor/Elements/Form/FormElements/FormDate.js +1 -7
  14. package/dist/Editor/Elements/Form/FormElements/FormEmail.js +1 -7
  15. package/dist/Editor/Elements/Form/FormElements/FormNumbers.js +1 -7
  16. package/dist/Editor/Elements/Form/FormElements/FormRadioButton.js +1 -7
  17. package/dist/Editor/Elements/Form/FormElements/FormText.js +1 -7
  18. package/dist/Editor/Elements/Form/FormElements/FormTextArea.js +1 -6
  19. package/dist/Editor/Elements/Form/FormPopup.js +9 -12
  20. package/dist/Editor/Elements/FreeGrid/FreeGrid.js +1 -1
  21. package/dist/Editor/Elements/FreeGrid/FreeGridItem.js +1 -20
  22. package/dist/Editor/Elements/Grid/GridButton.js +1 -2
  23. package/dist/Editor/Elements/Grid/GridItem.js +2 -3
  24. package/dist/Editor/Elements/Grid/Styles.js +3 -0
  25. package/dist/Editor/Elements/Link/LinkButton.js +1 -1
  26. package/dist/Editor/Elements/Signature/Signature.css +1 -1
  27. package/dist/Editor/Elements/Signature/SignatureOptions/TypeSignature.js +2 -2
  28. package/dist/Editor/Elements/Signature/SignaturePopup.js +48 -13
  29. package/dist/Editor/Elements/SimpleText/index.js +1 -8
  30. package/dist/Editor/Elements/SimpleText/style.js +1 -8
  31. package/dist/Editor/Elements/Table/Styles.js +43 -25
  32. package/dist/Editor/Elements/Table/Table.js +138 -206
  33. package/dist/Editor/Elements/Table/TableCell.js +102 -355
  34. package/dist/Editor/Elements/Table/TablePopup.js +3 -9
  35. package/dist/Editor/Elements/Table/TableRow.js +2 -10
  36. package/dist/Editor/Styles/EditorStyles.js +1 -3
  37. package/dist/Editor/Toolbar/FormatTools/BlockButton.js +0 -10
  38. package/dist/Editor/Toolbar/FormatTools/Dropdown.js +11 -7
  39. package/dist/Editor/Toolbar/FormatTools/FontFamilyAutocomplete.js +4 -10
  40. package/dist/Editor/Toolbar/FormatTools/MarkButton.js +0 -3
  41. package/dist/Editor/Toolbar/FormatTools/TextSize.js +2 -0
  42. package/dist/Editor/Toolbar/Mini/MiniToolbar.js +6 -3
  43. package/dist/Editor/Toolbar/Mini/Styles.js +1 -4
  44. package/dist/Editor/Toolbar/PopupTool/MiniTextFormat/index.js +3 -3
  45. package/dist/Editor/Toolbar/PopupTool/PopperHeader.js +11 -16
  46. package/dist/Editor/Toolbar/PopupTool/PopupToolStyle.js +49 -416
  47. package/dist/Editor/Toolbar/PopupTool/TextFormat.js +8 -62
  48. package/dist/Editor/Toolbar/PopupTool/index.js +6 -5
  49. package/dist/Editor/Toolbar/Toolbar.js +0 -6
  50. package/dist/Editor/Toolbar/toolbarGroups.js +0 -4
  51. package/dist/Editor/assets/svg/BrainIcon.js +2 -2
  52. package/dist/Editor/common/ColorPickerButton.js +2 -3
  53. package/dist/Editor/common/FontLoader/FontLoader.js +4 -4
  54. package/dist/Editor/common/Icon.js +23 -24
  55. package/dist/Editor/common/LinkSettings/NavComponents.js +1 -2
  56. package/dist/Editor/common/LinkSettings/index.js +1 -2
  57. package/dist/Editor/common/MentionsPopup/Styles.js +3 -151
  58. package/dist/Editor/common/MentionsPopup/index.js +1 -1
  59. package/dist/Editor/common/RnD/ElementSettings/Settings/FormSettings.js +12 -108
  60. package/dist/Editor/common/RnD/SwitchViewport/SwitchViewport.js +2 -14
  61. package/dist/Editor/common/Shorthands/elements.js +1 -13
  62. package/dist/Editor/common/StyleBuilder/fieldTypes/backgroundImage.js +0 -5
  63. package/dist/Editor/common/StyleBuilder/fieldTypes/card.js +2 -10
  64. package/dist/Editor/common/StyleBuilder/fieldTypes/index.js +1 -3
  65. package/dist/Editor/common/StyleBuilder/fieldTypes/textOptions.js +2 -5
  66. package/dist/Editor/common/StyleBuilder/formStyle.js +149 -268
  67. package/dist/Editor/common/StyleBuilder/index.js +11 -84
  68. package/dist/Editor/common/StyleBuilder/pageSettingsStyle.js +0 -4
  69. package/dist/Editor/common/StyleBuilder/tableStyle.js +25 -69
  70. package/dist/Editor/common/Uploader.js +0 -8
  71. package/dist/Editor/common/iconListV2.js +40 -378
  72. package/dist/Editor/common/iconslist.js +5 -8
  73. package/dist/Editor/commonStyle.js +9 -117
  74. package/dist/Editor/helper/deserialize/index.js +1 -4
  75. package/dist/Editor/helper/index.js +2 -2
  76. package/dist/Editor/helper/theme.js +1 -24
  77. package/dist/Editor/hooks/useMouseMove.js +2 -5
  78. package/dist/Editor/plugins/withCustomDeleteBackward.js +2 -3
  79. package/dist/Editor/plugins/withHTML.js +1 -17
  80. package/dist/Editor/plugins/withLayout.js +1 -48
  81. package/dist/Editor/utils/SlateUtilityFunctions.js +0 -18
  82. package/dist/Editor/utils/chatEditor/SlateUtilityFunctions.js +0 -21
  83. package/dist/Editor/utils/embed.js +1 -2
  84. package/dist/Editor/utils/events.js +1 -0
  85. package/dist/Editor/utils/font.js +4 -11
  86. package/dist/Editor/utils/formfield.js +4 -8
  87. package/dist/Editor/utils/helper.js +1 -34
  88. package/dist/Editor/utils/insertNewLine.js +1 -19
  89. package/dist/Editor/utils/pageSettings.js +2 -14
  90. package/dist/Editor/utils/serializeToText.js +0 -2
  91. package/dist/Editor/utils/table.js +24 -228
  92. package/package.json +1 -1
  93. package/dist/Editor/Elements/DataView/DataView.js +0 -101
  94. package/dist/Editor/Elements/DataView/DataViewButton.js +0 -23
  95. package/dist/Editor/Elements/DataView/Layouts/ColumnView.js +0 -59
  96. package/dist/Editor/Elements/DataView/Layouts/DataTypes/CheckType.js +0 -30
  97. package/dist/Editor/Elements/DataView/Layouts/DataTypes/Components/Select.js +0 -140
  98. package/dist/Editor/Elements/DataView/Layouts/DataTypes/Components/SimpleSelect.js +0 -40
  99. package/dist/Editor/Elements/DataView/Layouts/DataTypes/Components/styles.js +0 -59
  100. package/dist/Editor/Elements/DataView/Layouts/DataTypes/DateType.js +0 -26
  101. package/dist/Editor/Elements/DataView/Layouts/DataTypes/MultiSelectType.js +0 -38
  102. package/dist/Editor/Elements/DataView/Layouts/DataTypes/NumberType.js +0 -30
  103. package/dist/Editor/Elements/DataView/Layouts/DataTypes/PersonType.js +0 -30
  104. package/dist/Editor/Elements/DataView/Layouts/DataTypes/SelectType.js +0 -35
  105. package/dist/Editor/Elements/DataView/Layouts/DataTypes/TextType.js +0 -36
  106. package/dist/Editor/Elements/DataView/Layouts/DataTypes/index.js +0 -17
  107. package/dist/Editor/Elements/DataView/Layouts/FilterSort/SortOptions/ChooseField.js +0 -29
  108. package/dist/Editor/Elements/DataView/Layouts/FilterSort/SortOptions/ChooseSort.js +0 -38
  109. package/dist/Editor/Elements/DataView/Layouts/FilterSort/SortOptions/index.js +0 -74
  110. package/dist/Editor/Elements/DataView/Layouts/FilterSort/index.js +0 -64
  111. package/dist/Editor/Elements/DataView/Layouts/FilterSort/styles.js +0 -106
  112. package/dist/Editor/Elements/DataView/Layouts/FilterView.js +0 -174
  113. package/dist/Editor/Elements/DataView/Layouts/Formula.js +0 -29
  114. package/dist/Editor/Elements/DataView/Layouts/Options/AddOptions.js +0 -113
  115. package/dist/Editor/Elements/DataView/Layouts/Options/AddProperty.js +0 -37
  116. package/dist/Editor/Elements/DataView/Layouts/Options/AllProperties.js +0 -111
  117. package/dist/Editor/Elements/DataView/Layouts/Options/ChangeProperty.js +0 -62
  118. package/dist/Editor/Elements/DataView/Layouts/Options/ColumnsList.js +0 -36
  119. package/dist/Editor/Elements/DataView/Layouts/Options/Constants.js +0 -101
  120. package/dist/Editor/Elements/DataView/Layouts/Options/EditOption.js +0 -160
  121. package/dist/Editor/Elements/DataView/Layouts/Options/EditProperty.js +0 -190
  122. package/dist/Editor/Elements/DataView/Layouts/Options/FilterProperty.js +0 -42
  123. package/dist/Editor/Elements/DataView/Layouts/Options/PropertyList.js +0 -30
  124. package/dist/Editor/Elements/DataView/Layouts/Options/index.js +0 -110
  125. package/dist/Editor/Elements/DataView/Layouts/Options/styles.js +0 -179
  126. package/dist/Editor/Elements/DataView/Layouts/TableStyles.js +0 -100
  127. package/dist/Editor/Elements/DataView/Layouts/TableView.js +0 -227
  128. package/dist/Editor/Elements/DataView/Layouts/ViewData.js +0 -70
  129. package/dist/Editor/Elements/DataView/Layouts/index.js +0 -25
  130. package/dist/Editor/Elements/DataView/Providers/DataViewProvider.js +0 -288
  131. package/dist/Editor/Elements/DataView/Utils/globalSearch.js +0 -15
  132. package/dist/Editor/Elements/DataView/Utils/multiSortRows.js +0 -72
  133. package/dist/Editor/Elements/DataView/styles.js +0 -143
  134. package/dist/Editor/Elements/Table/AddRowCol.js +0 -77
  135. package/dist/Editor/Elements/Table/DragButton.js +0 -141
  136. package/dist/Editor/Elements/Table/DragStyles.js +0 -69
  137. package/dist/Editor/Elements/Table/Draggable.js +0 -25
  138. package/dist/Editor/Elements/Table/Droppable.js +0 -53
  139. package/dist/Editor/Elements/Table/TableTool.js +0 -101
  140. package/dist/Editor/Elements/Table/tableHelper.js +0 -71
  141. package/dist/Editor/assets/svg/TableIcons.js +0 -220
  142. package/dist/Editor/common/Select/index.js +0 -20
  143. package/dist/Editor/common/Select/styles.js +0 -17
  144. package/dist/Editor/common/StyleBuilder/fieldTypes/lineSpacing.js +0 -79
  145. package/dist/Editor/hooks/useTable.js +0 -175
  146. package/dist/Editor/utils/dataView.js +0 -43
@@ -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, getNode } from "./helper";
3
+ import { customInsertNode } from "./helper";
4
4
  export const DEFAULT_TABLE_NODE = () => ({
5
5
  type: "table",
6
6
  children: [{
@@ -13,10 +13,7 @@ export const DEFAULT_TABLE_NODE = () => ({
13
13
  text: ""
14
14
  }],
15
15
  cellBgColor: "#FFFFFF"
16
- }],
17
- size: {
18
- width: 120
19
- }
16
+ }]
20
17
  }, {
21
18
  type: "table-cell",
22
19
  children: [{
@@ -25,10 +22,7 @@ export const DEFAULT_TABLE_NODE = () => ({
25
22
  text: ""
26
23
  }],
27
24
  cellBgColor: "#FFFFFF"
28
- }],
29
- size: {
30
- width: 120
31
- }
25
+ }]
32
26
  }, {
33
27
  type: "table-cell",
34
28
  children: [{
@@ -37,10 +31,7 @@ export const DEFAULT_TABLE_NODE = () => ({
37
31
  text: ""
38
32
  }],
39
33
  cellBgColor: "#FFFFFF"
40
- }],
41
- size: {
42
- width: 120
43
- }
34
+ }]
44
35
  }]
45
36
  }, {
46
37
  type: "table-row",
@@ -52,10 +43,7 @@ export const DEFAULT_TABLE_NODE = () => ({
52
43
  text: ""
53
44
  }],
54
45
  cellBgColor: "#FFFFFF"
55
- }],
56
- size: {
57
- width: 120
58
- }
46
+ }]
59
47
  }, {
60
48
  type: "table-cell",
61
49
  children: [{
@@ -64,10 +52,7 @@ export const DEFAULT_TABLE_NODE = () => ({
64
52
  text: ""
65
53
  }],
66
54
  cellBgColor: "#FFFFFF"
67
- }],
68
- size: {
69
- width: 120
70
- }
55
+ }]
71
56
  }, {
72
57
  type: "table-cell",
73
58
  children: [{
@@ -78,7 +63,9 @@ export const DEFAULT_TABLE_NODE = () => ({
78
63
  cellBgColor: "#FFFFFF"
79
64
  }],
80
65
  size: {
81
- width: 120
66
+ widthInPercent: 100,
67
+ height: 100,
68
+ width: 365.3307291666667
82
69
  }
83
70
  }]
84
71
  }, {
@@ -91,10 +78,7 @@ export const DEFAULT_TABLE_NODE = () => ({
91
78
  text: ""
92
79
  }],
93
80
  cellBgColor: "#FFFFFF"
94
- }],
95
- size: {
96
- width: 120
97
- }
81
+ }]
98
82
  }, {
99
83
  type: "table-cell",
100
84
  children: [{
@@ -103,10 +87,7 @@ export const DEFAULT_TABLE_NODE = () => ({
103
87
  text: ""
104
88
  }],
105
89
  cellBgColor: "#FFFFFF"
106
- }],
107
- size: {
108
- width: 120
109
- }
90
+ }]
110
91
  }, {
111
92
  type: "table-cell",
112
93
  children: [{
@@ -117,14 +98,14 @@ export const DEFAULT_TABLE_NODE = () => ({
117
98
  cellBgColor: "#FFFFFF"
118
99
  }],
119
100
  size: {
120
- width: 120
101
+ height: 300,
102
+ widthInPercent: 100
121
103
  }
122
104
  }]
123
105
  }],
124
106
  rows: 3,
125
107
  columns: 3
126
108
  });
127
- const isFreeGridTable = n => !Editor.isEditor(n) && Element.isElement(n) && n.type === "freegridItem" && n.childType === "table";
128
109
  const prefixKey = (obj, pk = "") => {
129
110
  return Object.keys(obj).reduce((a, b) => {
130
111
  a[`${pk}${b}`] = obj[b];
@@ -163,49 +144,12 @@ export class TableUtil {
163
144
  customInsertNode(this.editor, newTable);
164
145
  };
165
146
  removeTable = () => {
166
- const [freeGridItem] = Editor.nodes(this.editor, {
167
- match: isFreeGridTable
147
+ Transforms.removeNodes(this.editor, {
148
+ match: n => !Editor.isEditor(n) && Element.isElement(n) && n.type === "table"
149
+ // mode:'highest'
168
150
  });
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
- }
208
151
  };
152
+
209
153
  getDOMNode = path => {
210
154
  try {
211
155
  const [tableNode] = Editor.nodes(this.editor, {
@@ -242,12 +186,9 @@ export class TableUtil {
242
186
  const [[table, tablePath]] = Editor.nodes(this.editor, {
243
187
  match: n => !Editor.isEditor(n) && Element.isElement(n) && n.type === "table"
244
188
  });
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, {
189
+ const [, currentRow] = tableNode;
190
+ const path = action === "after" ? Path.next(currentRow) : currentRow;
191
+ Transforms.insertNodes(this.editor, createRow(Array(table.columns).fill("")), {
251
192
  at: path
252
193
  });
253
194
  Transforms.setNodes(this.editor, {
@@ -258,23 +199,6 @@ export class TableUtil {
258
199
  }
259
200
  }
260
201
  };
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
- };
278
202
  deleteRow = () => {
279
203
  try {
280
204
  const {
@@ -335,58 +259,6 @@ export class TableUtil {
335
259
  }
336
260
  }
337
261
  };
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
- };
390
262
  deleteColumn = () => {
391
263
  try {
392
264
  const {
@@ -454,7 +326,6 @@ export class TableUtil {
454
326
  }, {
455
327
  at: currentCellPath
456
328
  });
457
- applyColumnStyle(this.editor, currentCellPath, currentTablePath, cellProps, tableProps?.rows);
458
329
 
459
330
  // cell bg entire
460
331
  if (cellProps?.entireBgColor || tableProps?.borderColor || rowProps?.borderColor) {
@@ -492,14 +363,6 @@ export class TableUtil {
492
363
  console.log(err);
493
364
  }
494
365
  };
495
- resizeTableCell = (styleProps, path) => {
496
- const cellProps = parseByPrefixKey(styleProps, "col.");
497
- Transforms.setNodes(this.editor, {
498
- ...cellProps
499
- }, {
500
- at: path
501
- });
502
- };
503
366
  getTableProps = () => {
504
367
  const {
505
368
  selection
@@ -622,14 +485,14 @@ export class TableUtil {
622
485
  }
623
486
  };
624
487
  }
625
- const createRow = (cellText, other) => {
626
- const newRow = Array.from(cellText, value => createTableCell(value, other));
488
+ const createRow = cellText => {
489
+ const newRow = Array.from(cellText, value => createTableCell(value));
627
490
  return {
628
491
  type: "table-row",
629
492
  children: newRow
630
493
  };
631
494
  };
632
- export const createTableCell = (text, other = {}) => {
495
+ export const createTableCell = text => {
633
496
  return {
634
497
  type: "table-cell",
635
498
  children: [{
@@ -637,35 +500,7 @@ export const createTableCell = (text, other = {}) => {
637
500
  children: [{
638
501
  text
639
502
  }]
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
503
+ }]
669
504
  };
670
505
  };
671
506
 
@@ -714,43 +549,4 @@ const createTableNode = (cellText, rows, columns) => {
714
549
  columns
715
550
  };
716
551
  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
- }
756
552
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@flozy/editor",
3
- "version": "5.1.2",
3
+ "version": "5.1.4",
4
4
  "description": "An Editor for flozy app brain",
5
5
  "files": [
6
6
  "dist"
@@ -1,101 +0,0 @@
1
- import React from "react";
2
- import { Node, Path, Transforms } from "slate";
3
- import { ReactEditor, useSlateStatic } from "slate-react";
4
- import { Box, useTheme } from "@mui/material";
5
- import { DataViewProvider } from "./Providers/DataViewProvider";
6
- import useDataViewStyles from "./styles";
7
- import LayoutView from "./Layouts";
8
- import FilterView from "./Layouts/FilterView";
9
- import { insertLineBreakAtEndOfPath } from "../../utils/helper";
10
- import { useEditorContext } from "../../hooks/useMouseMove";
11
- import { jsx as _jsx } from "react/jsx-runtime";
12
- import { jsxs as _jsxs } from "react/jsx-runtime";
13
- const DataView = props => {
14
- const {
15
- theme: appTheme
16
- } = useEditorContext();
17
- const theme = useTheme();
18
- const editor = useSlateStatic();
19
- const {
20
- attributes,
21
- children,
22
- element,
23
- customProps,
24
- title
25
- } = props;
26
- const {
27
- CHARACTERS,
28
- readOnly
29
- } = customProps || {};
30
- const {
31
- properties,
32
- layouts,
33
- rows
34
- } = element;
35
- const classes = useDataViewStyles(theme, appTheme);
36
- const path = ReactEditor.findPath(editor, element);
37
- const onDuplicate = () => {
38
- try {
39
- const newPath = ReactEditor.findPath(editor, element);
40
- const dataViewNode = Node.get(editor, newPath);
41
- const cloneNode = JSON.parse(JSON.stringify(dataViewNode));
42
- const toPath = Path.next(Path.parent(newPath));
43
- Transforms.insertNodes(editor, [{
44
- type: "paragraph",
45
- children: [{
46
- ...cloneNode
47
- }]
48
- }], {
49
- at: toPath
50
- });
51
- } catch (err) {
52
- console.log(err);
53
- }
54
- };
55
- const onDelete = () => {
56
- try {
57
- const newPath = ReactEditor.findPath(editor, element);
58
- Transforms.removeNodes(editor, {
59
- at: newPath
60
- });
61
- } catch (err) {
62
- console.log(err);
63
- }
64
- };
65
- const onEnter = () => {
66
- try {
67
- const newPath = ReactEditor.findPath(editor, element);
68
- const toPath = Path.previous(Path.parent(newPath));
69
- insertLineBreakAtEndOfPath(editor, toPath);
70
- } catch (err) {
71
- console.log(err);
72
- }
73
- };
74
- return /*#__PURE__*/_jsx(Box, {
75
- ...attributes,
76
- className: "fe-dataview",
77
- sx: classes.root,
78
- children: /*#__PURE__*/_jsxs(DataViewProvider, {
79
- initialData: {
80
- properties,
81
- layouts,
82
- rows,
83
- users: CHARACTERS,
84
- tableTitle: title
85
- },
86
- path: path,
87
- editor: editor,
88
- children: [/*#__PURE__*/_jsx(FilterView, {
89
- classes: classes,
90
- onEnter: onEnter,
91
- onDelete: onDelete,
92
- onDuplicate: onDuplicate,
93
- readOnly: readOnly
94
- }), /*#__PURE__*/_jsx(LayoutView, {
95
- readOnly: readOnly,
96
- children: children
97
- })]
98
- })
99
- });
100
- };
101
- export default DataView;
@@ -1,23 +0,0 @@
1
- import React from "react";
2
- import ToolbarIcon from "../../common/ToolbarIcon";
3
- import Icon from "../../common/Icon";
4
- import { insertDataView } from "../../utils/dataView";
5
- import { jsx as _jsx } from "react/jsx-runtime";
6
- const DataViewButton = props => {
7
- const {
8
- editor,
9
- icoBtnType
10
- } = props;
11
- const onClick = () => {
12
- insertDataView(editor);
13
- };
14
- return /*#__PURE__*/_jsx(ToolbarIcon, {
15
- title: "Dynamic Table",
16
- onClick: onClick,
17
- icon: /*#__PURE__*/_jsx(Icon, {
18
- icon: "dataView"
19
- }),
20
- icoBtnType: icoBtnType
21
- });
22
- };
23
- export default DataViewButton;
@@ -1,59 +0,0 @@
1
- import React, { useEffect, useRef, useState } from "react";
2
- import { Box, Checkbox, Popper } from "@mui/material";
3
- import DataTypes from "./DataTypes";
4
- import { jsx as _jsx } from "react/jsx-runtime";
5
- import { jsxs as _jsxs } from "react/jsx-runtime";
6
- const ColumnView = props => {
7
- const {
8
- needAnchor,
9
- rowIndex,
10
- row,
11
- property,
12
- onSelect,
13
- selected,
14
- readOnly
15
- } = props;
16
- const DataType = DataTypes[property?.type] || DataTypes["text"];
17
- const anchorRef = useRef(null);
18
- const [anchorEl, setAnchorEl] = useState(null);
19
- const open = Boolean(anchorEl);
20
- useEffect(() => {
21
- if (anchorRef?.current) {
22
- setAnchorEl(anchorRef?.current);
23
- }
24
- }, [anchorRef?.current]);
25
- const handleSelect = id => e => {
26
- onSelect(id, e.target.checked);
27
- };
28
- return /*#__PURE__*/_jsxs(Box, {
29
- component: "td",
30
- ref: anchorRef,
31
- children: [/*#__PURE__*/_jsx(DataType, {
32
- options: property?.options,
33
- property: property?.key,
34
- value: row[property?.key] || "",
35
- rowIndex: rowIndex,
36
- label: property?.label,
37
- readOnly: readOnly
38
- }), needAnchor && !readOnly ? /*#__PURE__*/_jsx(Popper, {
39
- sx: {
40
- zIndex: 1000
41
- },
42
- open: open,
43
- anchorEl: anchorEl,
44
- placement: "left",
45
- container: anchorRef?.current,
46
- className: `tv-tr-pop ${selected ? "active" : ""}`,
47
- children: /*#__PURE__*/_jsx(Checkbox, {
48
- onClick: handleSelect(row?.id),
49
- size: "small",
50
- className: "tv-ck-box",
51
- sx: {
52
- mr: 0
53
- },
54
- checked: selected
55
- })
56
- }) : null]
57
- });
58
- };
59
- export default ColumnView;
@@ -1,30 +0,0 @@
1
- import React from "react";
2
- import { useDataView } from "../../Providers/DataViewProvider";
3
- import Checkbox from "@mui/material/Checkbox";
4
- import CheckCircleOutlineIcon from "@mui/icons-material/CheckCircleOutline";
5
- import CheckCircleIcon from "@mui/icons-material/CheckCircle";
6
- import { jsx as _jsx } from "react/jsx-runtime";
7
- const CheckType = props => {
8
- const {
9
- rowIndex,
10
- property,
11
- value,
12
- readOnly
13
- } = props;
14
- const {
15
- onChange
16
- } = useDataView();
17
- const handleChange = e => {
18
- onChange(rowIndex, {
19
- [property]: e?.target?.checked
20
- });
21
- };
22
- return /*#__PURE__*/_jsx(Checkbox, {
23
- checked: value,
24
- icon: /*#__PURE__*/_jsx(CheckCircleOutlineIcon, {}),
25
- checkedIcon: /*#__PURE__*/_jsx(CheckCircleIcon, {}),
26
- onChange: handleChange,
27
- disabled: readOnly
28
- }, rowIndex);
29
- };
30
- export default CheckType;