@flozy/editor 5.0.4 → 5.0.6

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 (77) hide show
  1. package/dist/Editor/CommonEditor.js +6 -4
  2. package/dist/Editor/Editor.css +19 -1
  3. package/dist/Editor/Elements/Button/EditorButton.js +71 -53
  4. package/dist/Editor/Elements/Color Picker/ColorButtons.js +4 -2
  5. package/dist/Editor/Elements/DataView/DataView.js +101 -0
  6. package/dist/Editor/Elements/DataView/DataViewButton.js +23 -0
  7. package/dist/Editor/Elements/DataView/Layouts/ColumnView.js +59 -0
  8. package/dist/Editor/Elements/DataView/Layouts/DataTypes/CheckType.js +30 -0
  9. package/dist/Editor/Elements/DataView/Layouts/DataTypes/Components/Select.js +128 -0
  10. package/dist/Editor/Elements/DataView/Layouts/DataTypes/Components/SimpleSelect.js +25 -0
  11. package/dist/Editor/Elements/DataView/Layouts/DataTypes/DateType.js +26 -0
  12. package/dist/Editor/Elements/DataView/Layouts/DataTypes/MultiSelectType.js +38 -0
  13. package/dist/Editor/Elements/DataView/Layouts/DataTypes/NumberType.js +30 -0
  14. package/dist/Editor/Elements/DataView/Layouts/DataTypes/PersonType.js +30 -0
  15. package/dist/Editor/Elements/DataView/Layouts/DataTypes/SelectType.js +35 -0
  16. package/dist/Editor/Elements/DataView/Layouts/DataTypes/TextType.js +36 -0
  17. package/dist/Editor/Elements/DataView/Layouts/DataTypes/index.js +17 -0
  18. package/dist/Editor/Elements/DataView/Layouts/FilterSort/SortOptions/ChooseField.js +28 -0
  19. package/dist/Editor/Elements/DataView/Layouts/FilterSort/SortOptions/ChooseSort.js +37 -0
  20. package/dist/Editor/Elements/DataView/Layouts/FilterSort/SortOptions/index.js +74 -0
  21. package/dist/Editor/Elements/DataView/Layouts/FilterSort/index.js +59 -0
  22. package/dist/Editor/Elements/DataView/Layouts/FilterSort/styles.js +66 -0
  23. package/dist/Editor/Elements/DataView/Layouts/FilterView.js +174 -0
  24. package/dist/Editor/Elements/DataView/Layouts/Formula.js +29 -0
  25. package/dist/Editor/Elements/DataView/Layouts/Options/AddOptions.js +113 -0
  26. package/dist/Editor/Elements/DataView/Layouts/Options/AddProperty.js +37 -0
  27. package/dist/Editor/Elements/DataView/Layouts/Options/AllProperties.js +111 -0
  28. package/dist/Editor/Elements/DataView/Layouts/Options/ChangeProperty.js +62 -0
  29. package/dist/Editor/Elements/DataView/Layouts/Options/ColumnsList.js +36 -0
  30. package/dist/Editor/Elements/DataView/Layouts/Options/Constants.js +101 -0
  31. package/dist/Editor/Elements/DataView/Layouts/Options/EditOption.js +158 -0
  32. package/dist/Editor/Elements/DataView/Layouts/Options/EditProperty.js +190 -0
  33. package/dist/Editor/Elements/DataView/Layouts/Options/FilterProperty.js +42 -0
  34. package/dist/Editor/Elements/DataView/Layouts/Options/PropertyList.js +30 -0
  35. package/dist/Editor/Elements/DataView/Layouts/Options/index.js +110 -0
  36. package/dist/Editor/Elements/DataView/Layouts/Options/styles.js +176 -0
  37. package/dist/Editor/Elements/DataView/Layouts/TableStyles.js +94 -0
  38. package/dist/Editor/Elements/DataView/Layouts/TableView.js +214 -0
  39. package/dist/Editor/Elements/DataView/Layouts/ViewData.js +83 -0
  40. package/dist/Editor/Elements/DataView/Layouts/index.js +25 -0
  41. package/dist/Editor/Elements/DataView/Providers/DataViewProvider.js +288 -0
  42. package/dist/Editor/Elements/DataView/Utils/globalSearch.js +15 -0
  43. package/dist/Editor/Elements/DataView/Utils/multiSortRows.js +72 -0
  44. package/dist/Editor/Elements/DataView/styles.js +133 -0
  45. package/dist/Editor/Elements/FreeGrid/styles.js +2 -1
  46. package/dist/Editor/Elements/Grid/GridItem.js +2 -1
  47. package/dist/Editor/Elements/Search/SearchAttachment.js +3 -2
  48. package/dist/Editor/Elements/Search/SearchButton.js +7 -2
  49. package/dist/Editor/Elements/Search/SearchList.js +51 -17
  50. package/dist/Editor/Elements/Signature/Signature.css +1 -1
  51. package/dist/Editor/Elements/Table/AddRowCol.js +1 -1
  52. package/dist/Editor/Elements/Table/DragButton.js +71 -68
  53. package/dist/Editor/Elements/Table/Styles.js +2 -2
  54. package/dist/Editor/Elements/Table/Table.js +10 -7
  55. package/dist/Editor/Elements/Table/TableCell.js +21 -21
  56. package/dist/Editor/Elements/Table/tableHelper.js +4 -16
  57. package/dist/Editor/Toolbar/PopupTool/index.js +1 -1
  58. package/dist/Editor/Toolbar/Toolbar.js +6 -0
  59. package/dist/Editor/Toolbar/toolbarGroups.js +4 -0
  60. package/dist/Editor/assets/svg/OpenLinkIcon.js +3 -3
  61. package/dist/Editor/common/Icon.js +7 -1
  62. package/dist/Editor/common/MentionsPopup/Styles.js +12 -4
  63. package/dist/Editor/common/MentionsPopup/index.js +1 -1
  64. package/dist/Editor/common/Shorthands/elements.js +13 -1
  65. package/dist/Editor/common/StyleBuilder/tableStyle.js +1 -1
  66. package/dist/Editor/common/SwipeableDrawer/style.js +1 -1
  67. package/dist/Editor/common/iconslist.js +6 -3
  68. package/dist/Editor/hooks/useTable.js +4 -5
  69. package/dist/Editor/plugins/withEmbeds.js +1 -1
  70. package/dist/Editor/plugins/withHTML.js +18 -2
  71. package/dist/Editor/plugins/withLayout.js +48 -1
  72. package/dist/Editor/utils/SlateUtilityFunctions.js +16 -0
  73. package/dist/Editor/utils/dataView.js +43 -0
  74. package/dist/Editor/utils/embed.js +2 -1
  75. package/dist/Editor/utils/helper.js +19 -1
  76. package/dist/Editor/utils/insertNewLine.js +19 -1
  77. package/package.json +1 -1
@@ -188,9 +188,6 @@ const TableCell = props => {
188
188
  setHoverPath(null);
189
189
  };
190
190
  const onMouseDownInCell = e => {
191
- if (!contentEditable) {
192
- e.preventDefault();
193
- }
194
191
  if (
195
192
  // for shift selection
196
193
  e.shiftKey && startCellPath?.length && startCellPath.toString() !== path.toString()) {
@@ -218,13 +215,6 @@ const TableCell = props => {
218
215
  const selectionPath = currentEditorSelection?.slice(0, -2);
219
216
  const isCellSelected = selectionPath?.length && Path.equals(selectionPath, path);
220
217
  if (!isCellSelected) {
221
- // focus the clicked cell
222
- ReactEditor.focus(editor);
223
- Transforms.select(editor, {
224
- anchor: Editor.end(editor, path),
225
- focus: Editor.end(editor, path)
226
- });
227
-
228
218
  // after mousedown event, onclick is triggered, while onclick, dragging should be disabled and focus should be on that clicked cell to edit the contents inside it.
229
219
  updateTableSelection({
230
220
  isDragging: false
@@ -238,9 +228,11 @@ const TableCell = props => {
238
228
  const props = {
239
229
  id: cellId
240
230
  };
241
- if (!contentEditable) {
242
- props.contentEditable = false;
243
- }
231
+
232
+ // if (!contentEditable) {
233
+ // props.contentEditable = false;
234
+ // }
235
+
244
236
  return props;
245
237
  }, [contentEditable, cellId]);
246
238
  const handleTouchMove = e => {
@@ -256,7 +248,7 @@ const TableCell = props => {
256
248
  isDragging: false
257
249
  });
258
250
  };
259
- const tbProps = resizing || over || readOnly ? {
251
+ const tbProps = tableResizing || resizing || over || readOnly ? {
260
252
  ...commonTdProps,
261
253
  contentEditable: false
262
254
  } : {
@@ -405,6 +397,7 @@ const TableCell = props => {
405
397
  fontSize: entireTextSize || "inherit",
406
398
  color: entireTextColor || "inherit",
407
399
  cursor: "text",
400
+ verticalAlign: "top",
408
401
  ...(sizeProps || {})
409
402
  },
410
403
  ...tbProps,
@@ -417,26 +410,33 @@ const TableCell = props => {
417
410
  ...dndProps,
418
411
  dragType: currentDraggingType,
419
412
  tableDOM: tableDOM
420
- }) : null, children, isHeader && !readOnly && tableSize?.height && !showTool ? /*#__PURE__*/_jsx(Resizer, {
413
+ }) : null, /*#__PURE__*/_jsx("div", {
414
+ style: {
415
+ overflow: "auto hidden"
416
+ },
417
+ children: children
418
+ }), isHeader && !readOnly && tableSize?.height && !showTool ? /*#__PURE__*/_jsx(Resizer, {
421
419
  classes: classes,
422
420
  onMouseDown: onMouseDown,
423
421
  height: tableDOM.getBoundingClientRect()?.height
424
- }) : null, hasSelected && !readOnly ? /*#__PURE__*/_jsx("div", {
422
+ }) : null, hasSelected && !readOnly && !tableResizing ? /*#__PURE__*/_jsx("div", {
425
423
  className: "selection-area-tc",
426
424
  contentEditable: false
427
- }) : null, showColDrag || isColDragging ? /*#__PURE__*/_jsx(DragButton, {
425
+ }) : null, /*#__PURE__*/_jsx(DragButton, {
428
426
  ...commonDragBtnProps,
429
427
  placement: "top",
430
428
  dragType: "col",
431
429
  onDrag: onColDrag,
432
- hideDelete: rowProps?.children?.length <= 1
433
- }) : null, showRowDragBtn ? /*#__PURE__*/_jsx(DragButton, {
430
+ hideDelete: rowProps?.children?.length <= 1,
431
+ show: showColDrag || isColDragging
432
+ }), /*#__PURE__*/_jsx(DragButton, {
434
433
  ...commonDragBtnProps,
435
434
  dragType: "row",
436
435
  onDrag: onRowDrag,
437
436
  hideDelete: parentProps?.children?.length <= 1,
438
- className: dragRowBtnCls
439
- }) : null]
437
+ className: dragRowBtnCls,
438
+ show: showRowDragBtn
439
+ })]
440
440
  }), openSettings ? /*#__PURE__*/_jsx(TablePopup, {
441
441
  element: tableProps?.styleProps || {},
442
442
  customProps: customProps,
@@ -23,7 +23,7 @@ export const getRectangleBounds = tableSelection => {
23
23
  }
24
24
  return selectedPaths;
25
25
  };
26
- export const createCopiedTableStructure = (editor, tableSelection, currentTableNode, tablePath, selectedText) => {
26
+ export const createCopiedTableStructure = (editor, tableSelection, currentTableNode, tablePath) => {
27
27
  const selectedCells = getRectangleBounds(tableSelection);
28
28
  const formattedCells = selectedCells.map(cell => cell.slice(-2));
29
29
  const tableChild = [];
@@ -42,19 +42,7 @@ export const createCopiedTableStructure = (editor, tableSelection, currentTableN
42
42
  columnIndexes.forEach((columnIndex, col_i) => {
43
43
  const cellPath = [...tablePath, rowIndex, columnIndex];
44
44
  const columnNode = getNode(editor, cellPath);
45
- const cellNode = selectedText // we can select text in only one column
46
- ? {
47
- ...columnNode,
48
- type: "table-cell",
49
- children: [{
50
- type: "paragraph",
51
- children: [{
52
- text: selectedText
53
- }],
54
- cellBgColor: "#FFFFFF"
55
- }]
56
- } : columnNode;
57
- row.children.push(cellNode);
45
+ row.children.push(columnNode);
58
46
  });
59
47
  tableChild.push(row);
60
48
  });
@@ -67,13 +55,13 @@ export const createCopiedTableStructure = (editor, tableSelection, currentTableN
67
55
 
68
56
  return table;
69
57
  };
70
- export const tableNodeToDom = (tableNode, selectedText) => {
58
+ export const tableNodeToDom = tableNode => {
71
59
  const tableEle = document.createElement("table");
72
60
  tableNode.children?.forEach(row => {
73
61
  const rowEle = document.createElement("tr");
74
62
  row?.children?.forEach(cell => {
75
63
  const cellEle = document.createElement("td");
76
- const cellText = selectedText || serializeToText(cell);
64
+ const cellText = serializeToText(cell);
77
65
  cellEle.innerHTML = cellText;
78
66
  rowEle.appendChild(cellEle);
79
67
  });
@@ -92,7 +92,7 @@ const PopupTool = props => {
92
92
  }
93
93
  }, [selection, selectedElement?.path, selectedElement?.enable]);
94
94
  const handleClose = () => {
95
- setAnchorEl(null);
95
+ // setAnchorEl(null);
96
96
  setOpen(false);
97
97
  setPopupType("");
98
98
  };
@@ -32,6 +32,7 @@ import ColorboxButton from "../Elements/Colorbox/ColorboxButton.js";
32
32
  import DividerButton from "../Elements/Divider/DividerButton.js";
33
33
  import EmbedScript from "../Elements/EmbedScript/EmbedScript.js";
34
34
  import FreeGridButton from "../Elements/FreeGrid/FreeGridButton.js";
35
+ import DataViewButton from "../Elements/DataView/DataViewButton.js";
35
36
  import SearchButton from "../Elements/Search/SearchButton.js";
36
37
  import { jsx as _jsx } from "react/jsx-runtime";
37
38
  import { jsxs as _jsxs } from "react/jsx-runtime";
@@ -118,6 +119,11 @@ export const RenderToolbarIcon = props => {
118
119
  editor: editor,
119
120
  icoBtnType: icoBtnType
120
121
  }, element.id);
122
+ case "dataView":
123
+ return /*#__PURE__*/_jsx(DataViewButton, {
124
+ editor: editor,
125
+ icoBtnType: icoBtnType
126
+ }, element.id);
121
127
  case "id":
122
128
  return /*#__PURE__*/_jsx(Id, {
123
129
  editor: editor
@@ -191,6 +191,10 @@ export const toolbarGroups = [[{
191
191
  id: 42,
192
192
  type: "table",
193
193
  group: "elements"
194
+ }, {
195
+ id: 51,
196
+ type: "dataView",
197
+ group: "elements"
194
198
  }, {
195
199
  id: 48,
196
200
  format: "divider",
@@ -9,19 +9,19 @@ const OpenLinkIcon = props => {
9
9
  xmlns: "http://www.w3.org/2000/svg",
10
10
  children: [/*#__PURE__*/_jsx("path", {
11
11
  d: "M7.58325 6.41615L12.3666 1.63281",
12
- stroke: "#0F172A",
12
+ stroke: "#64748B",
13
13
  strokeWidth: "1.5",
14
14
  strokeLinecap: "round",
15
15
  strokeLinejoin: "round"
16
16
  }), /*#__PURE__*/_jsx("path", {
17
17
  d: "M12.8334 3.96602V1.16602H10.0334",
18
- stroke: "#0F172A",
18
+ stroke: "#64748B",
19
19
  strokeWidth: "1.5",
20
20
  strokeLinecap: "round",
21
21
  strokeLinejoin: "round"
22
22
  }), /*#__PURE__*/_jsx("path", {
23
23
  d: "M6.41675 1.16602H5.25008C2.33341 1.16602 1.16675 2.33268 1.16675 5.24935V8.74935C1.16675 11.666 2.33341 12.8327 5.25008 12.8327H8.75008C11.6667 12.8327 12.8334 11.666 12.8334 8.74935V7.58268",
24
- stroke: "#0F172A",
24
+ stroke: "#64748B",
25
25
  strokeWidth: "1.5",
26
26
  strokeLinecap: "round",
27
27
  strokeLinejoin: "round"
@@ -11,6 +11,7 @@ import ArrowRightIcon from "@mui/icons-material/ArrowRight";
11
11
  import ArrowDropDownIcon from "@mui/icons-material/ArrowDropDown";
12
12
  import EmailRoundedIcon from "@mui/icons-material/EmailRounded";
13
13
  import InfoOutlinedIcon from "@mui/icons-material/InfoOutlined";
14
+ import GridOnIcon from "@mui/icons-material/GridOn";
14
15
  import { AccordionTextFormatIcon, BoldTextFormatIcon, BulletedListTextFormatIcon, ButtonElementIcon, CarouselElementIcon, CheckListTextFormatIcon, ColorBoxElementIcon, DividerElementIcon, DocUploadElementIcon, EmbedElementIcon, EmojiElementIcon, FormElementIcon, GridElementIcon, H1, H2, H3, ImageElementIcon, ItalicTextFormatIcon, LinkIconV2, OrderedListTextFormatIcon, SignatureElementIcon, TableElementIcon, TopBannerElementIcon, UnderlineTextFormatIcon, VideoElementIcon, CalendlyIcon, LeftAlignTextFormat, CenterAlignTextFormat, RightAlignTextFormat, JustifyTextFormat, FreeGridElement, AppHeaderElement, CodeElementIcon } from "./iconListV2";
15
16
  import MoreVertRoundedIcon from "@mui/icons-material/MoreVertRounded";
16
17
  import SettingsIcon from "../assets/svg/SettingsIcon";
@@ -24,7 +25,7 @@ import { BrainIcon } from "../assets/svg/BrainIcon";
24
25
  import DocsIcon from "../assets/svg/DocsIcon";
25
26
  import UserIcon from "../assets/svg/UserIcon";
26
27
  import EditIcon from "@mui/icons-material/Edit";
27
- import DeleteIcon from '@mui/icons-material/Delete';
28
+ import DeleteIcon from "@mui/icons-material/Delete";
28
29
  import { jsx as _jsx } from "react/jsx-runtime";
29
30
  import { jsxs as _jsxs } from "react/jsx-runtime";
30
31
  const iconList = {
@@ -270,6 +271,11 @@ const iconList = {
270
271
  addElement: /*#__PURE__*/_jsx(AddElementIcon, {}),
271
272
  addTemplate: /*#__PURE__*/_jsx(AddTemplateIcon, {}),
272
273
  openLinkIcon: /*#__PURE__*/_jsx(OpenLinkIcon, {}),
274
+ dataView: /*#__PURE__*/_jsx(GridOnIcon, {
275
+ sx: {
276
+ fill: "#64748B"
277
+ }
278
+ }),
273
279
  brain: /*#__PURE__*/_jsx(BrainIcon, {}),
274
280
  docsIcon: /*#__PURE__*/_jsx(DocsIcon, {}),
275
281
  userIcon: /*#__PURE__*/_jsx(UserIcon, {}),
@@ -13,13 +13,21 @@ const usePopupStyles = theme => ({
13
13
  "& .MuiBox-root": {
14
14
  "& .renderComp": {
15
15
  padding: "2px 0px 2px 1px",
16
- background: "transparent !important"
16
+ background: "transparent !important",
17
+ "&:hover": {
18
+ borderRadius: "10px",
19
+ background: `${theme?.palette?.editor?.menuOptionHoverBackground} !important`
20
+ }
17
21
  },
18
22
  "& button": {
19
- padding: "0px 0px 0px 6px",
23
+ padding: "0px 0px 0px 4px !important",
20
24
  "& svg": {
21
- // width: "19px !important",
22
- paddingRight: "6px"
25
+ width: "18px !important",
26
+ margin: "5px 12px 6px 6px !important"
27
+ },
28
+ "&:hover": {
29
+ borderRadius: "10px",
30
+ background: `${theme?.palette?.editor?.menuOptionHoverBackground} !important`
23
31
  }
24
32
  },
25
33
  "& .active": {
@@ -97,7 +97,7 @@ const MentionsPopup = /*#__PURE__*/forwardRef((props, ref) => {
97
97
  id: `cmd-li-ind-${index}}`,
98
98
  component: "div",
99
99
  onClick: handleClick(char, i),
100
- className: `${i === index ? "active" : " "} ${char.renderComponent ? "renderComp" : ""}`,
100
+ className: `${type !== 'elements' && i === index ? "active" : " "} ${char.renderComponent ? "renderComp" : ""}`,
101
101
  sx: classes.listItem,
102
102
  ref: i === index ? papperRef : null,
103
103
  children: char.renderComponent ? char.renderComponent({
@@ -13,6 +13,7 @@ import { insertDivider } from "../../utils/divider";
13
13
  import { insertFreeGrid } from "../../utils/freegrid";
14
14
  import { Transforms } from "slate";
15
15
  import { insertInfinityAI } from "../../utils/infinityAI";
16
+ import { insertDataView } from "../../utils/dataView";
16
17
  import SearchButton from "../../Elements/Search/SearchButton";
17
18
  import { jsx as _jsx } from "react/jsx-runtime";
18
19
  const ELEMENTS_LIST = [{
@@ -158,7 +159,7 @@ const ELEMENTS_LIST = [{
158
159
  renderComponent: rest => /*#__PURE__*/_jsx(SearchButton, {
159
160
  ...rest,
160
161
  element: {
161
- name: 'Brain'
162
+ name: "Brain"
162
163
  },
163
164
  icoBtnType: "cmd"
164
165
  })
@@ -262,6 +263,17 @@ const ELEMENTS_LIST = [{
262
263
  onInsert: editor => {
263
264
  insertInfinityAI(editor);
264
265
  }
266
+ }, {
267
+ name: "Dynamic Table",
268
+ group: "Dynamic Table",
269
+ desc: "",
270
+ type: "dataView",
271
+ icon: /*#__PURE__*/_jsx(Icon, {
272
+ icon: "dataView"
273
+ }),
274
+ onInsert: editor => {
275
+ insertDataView(editor);
276
+ }
265
277
  }];
266
278
  const elements = props => {
267
279
  const {
@@ -5,7 +5,7 @@ import { jsx as _jsx } from "react/jsx-runtime";
5
5
  const allTools = toolbarGroups.flat();
6
6
  const fontWeight = allTools.find(f => f.format === "fontWeight");
7
7
  function getKey(prefix, key) {
8
- const settingKey = prefix === "col" ? capitalizeFirstLetter(key) : key;
8
+ const settingKey = prefix === "col" ? `entire${capitalizeFirstLetter(key)}` : key;
9
9
  return `${prefix}.${settingKey}`;
10
10
  }
11
11
  function getCommonSettings(prefix) {
@@ -6,7 +6,7 @@ const Styles = theme => ({
6
6
  "& .MuiDrawer-paper": {
7
7
  borderTopLeftRadius: 8,
8
8
  borderTopRightRadius: 8,
9
- backgroundColor: theme.palette.containers.card
9
+ backgroundColor: theme?.palette?.editor?.miniToolBarBackground
10
10
  }
11
11
  },
12
12
  childContainer: {
@@ -1343,19 +1343,22 @@ export const GridAddSectionIcon = props => /*#__PURE__*/_jsxs("svg", {
1343
1343
  stroke: "#64748B",
1344
1344
  strokeWidth: "1.5",
1345
1345
  strokeLinecap: "round",
1346
- strokeLinejoin: "round"
1346
+ strokeLinejoin: "round",
1347
+ className: "fillStroke"
1347
1348
  }), /*#__PURE__*/_jsx("path", {
1348
1349
  d: "M10.1733 6.125V14.875",
1349
1350
  stroke: "#64748B",
1350
1351
  strokeWidth: "1.5",
1351
1352
  strokeLinecap: "round",
1352
- strokeLinejoin: "round"
1353
+ strokeLinejoin: "round",
1354
+ className: "fillStroke"
1353
1355
  }), /*#__PURE__*/_jsx("path", {
1354
1356
  d: "M5.79834 10.5H14.5483",
1355
1357
  stroke: "#64748B",
1356
1358
  strokeWidth: "1.5",
1357
1359
  strokeLinecap: "round",
1358
- strokeLinejoin: "round"
1360
+ strokeLinejoin: "round",
1361
+ className: "fillStroke"
1359
1362
  })]
1360
1363
  });
1361
1364
  export const FormIcon = () => {
@@ -123,21 +123,20 @@ export const TableProvider = ({
123
123
  try {
124
124
  const isTextSelected = editor?.selection && !Range.isCollapsed(editor.selection);
125
125
  const customCopy = tableSelection?.startCellPath?.length;
126
- if (customCopy) {
126
+ if (customCopy && !isTextSelected) {
127
127
  event.preventDefault(); // Prevent default copy behavior
128
128
 
129
129
  const {
130
130
  tablePath
131
131
  } = otherProps;
132
132
  const [node] = Editor.node(editor, tablePath);
133
- const selectedText = isTextSelected ? Editor.string(editor, editor.selection) : "";
134
- const copiedTableNode = createCopiedTableStructure(editor, tableSelection, node, tablePath, selectedText);
133
+ const copiedTableNode = createCopiedTableStructure(editor, tableSelection, node, tablePath);
135
134
  const tableNode = [copiedTableNode];
136
135
  const encodedTableNode = encodeToBase64(tableNode);
137
136
  event.clipboardData.setData("application/x-slate-fragment", encodedTableNode);
138
- const textData = selectedText || serializeToText(tableNode);
137
+ const textData = serializeToText(tableNode);
139
138
  event.clipboardData.setData("text/plain", textData);
140
- const tableDom = tableNodeToDom(copiedTableNode, selectedText);
139
+ const tableDom = tableNodeToDom(copiedTableNode);
141
140
  event.clipboardData.setData("text/html", tableDom?.outerHTML);
142
141
  }
143
142
  } catch (err) {
@@ -22,7 +22,7 @@ const withEmbeds = editor => {
22
22
  const parentNode = Node.get(editor, parentPath);
23
23
  const previousPath = Path.previous(parentPath);
24
24
  const previousNode = Node.get(editor, previousPath);
25
- if (BlockTypes.includes(previousNode?.children[0]?.type) && parentNode?.type?.indexOf("heading") >= 0) {
25
+ if (BlockTypes.includes(previousNode?.children[0]?.type) && parentNode?.type?.indexOf("heading") >= 0 && editor.selection.focus.offset === 0) {
26
26
  insertNodes(...[{
27
27
  type: "paragraph",
28
28
  children: [{
@@ -68,6 +68,12 @@ const handleInsert = (editor, defaultInsert, fragment = []) => {
68
68
  defaultInsert();
69
69
  }
70
70
  };
71
+ const getTableCellChild = (fragment = []) => {
72
+ const table = fragment.find(node => node.type === "table");
73
+ const row = table?.children?.find(node => node.type === "table-row");
74
+ const cell = row?.children?.find(node => node.type === "table-cell");
75
+ return cell?.children || [];
76
+ };
71
77
  const formatFragment = {
72
78
  "list-item": fragment => {
73
79
  let refactorFragment = [];
@@ -104,9 +110,19 @@ const withHtml = editor => {
104
110
  const slateHTML = data?.getData("application/x-slate-fragment");
105
111
  const html = data?.getData("text/html");
106
112
  const currentEl = getCurrentElement(editor);
107
- const eltype = currentEl?.type;
113
+ let eltype = currentEl?.type;
108
114
  if (slateHTML && !formatFragment[eltype]) {
115
+ const [tableCellNode] = Editor.nodes(editor, {
116
+ match: n => !Editor.isEditor(n) && Element.isElement(n) && n.type === "table-cell"
117
+ });
109
118
  const decoded = decodeAndParseBase64(slateHTML);
119
+ if (tableCellNode) {
120
+ const tableCellChild = getTableCellChild(decoded);
121
+ if (tableCellChild?.length) {
122
+ Transforms.insertFragment(editor, tableCellChild);
123
+ return;
124
+ }
125
+ }
110
126
  const [tableNode] = Editor.nodes(editor, {
111
127
  match: n => !Editor.isEditor(n) && Element.isElement(n) && n.type === "table"
112
128
  });
@@ -160,7 +176,7 @@ const withHtml = editor => {
160
176
  const formattedFragment = formatFragment[eltype] ? formatFragment[eltype](fragment) : fragment;
161
177
  let is_img_table = false;
162
178
  formattedFragment.map(f => {
163
- if (f.type === 'image' || f?.type?.includes('table')) {
179
+ if (f.type === "image" || f?.type?.includes("table")) {
164
180
  is_img_table = true;
165
181
  }
166
182
  });
@@ -56,8 +56,55 @@ const withLayout = editor => {
56
56
  }]
57
57
  };
58
58
  Transforms.insertNodes(editor, paragraph, {
59
- at: path.concat(1)
59
+ at: [0]
60
60
  });
61
+ return;
62
+ }
63
+ const extractFirstText = node => {
64
+ if (node.text) {
65
+ return node.text;
66
+ }
67
+ if (node.children) {
68
+ for (const child of node.children) {
69
+ const text = extractFirstText(child);
70
+ if (text) {
71
+ return text;
72
+ }
73
+ }
74
+ }
75
+ return "";
76
+ };
77
+ const extractRemainingNodes = node => {
78
+ if (!node.children) {
79
+ return [];
80
+ }
81
+ const [, ...remainingChildren] = node.children;
82
+ return remainingChildren.map(child => ({
83
+ ...child
84
+ }));
85
+ };
86
+ const firstNode = editor.children[0];
87
+ const firstContent = extractFirstText(firstNode);
88
+ if (firstNode.type !== "title") {
89
+ const titleNode = {
90
+ type: "title",
91
+ children: [{
92
+ text: firstContent
93
+ }]
94
+ };
95
+ Transforms.removeNodes(editor, {
96
+ at: [0]
97
+ });
98
+ Transforms.insertNodes(editor, titleNode, {
99
+ at: [0],
100
+ select: true
101
+ });
102
+ const remainingNodes = extractRemainingNodes(firstNode);
103
+ if (remainingNodes.length > 0) {
104
+ Transforms.insertNodes(editor, remainingNodes, {
105
+ at: [1]
106
+ });
107
+ }
61
108
  }
62
109
  ORDERS_LAYOUT.forEach((enforce, index) => {
63
110
  if (index < editor.children.length) {
@@ -43,6 +43,9 @@ import Code from "../Elements/EmbedScript/Code";
43
43
  import FreeGrid from "../Elements/FreeGrid/FreeGrid";
44
44
  import FreeGridItem from "../Elements/FreeGrid/FreeGridItem";
45
45
  import FreeGridBox from "../Elements/FreeGrid/FreeGridBox";
46
+ import DataView from "../Elements/DataView/DataView";
47
+ import ViewData from "../Elements/DataView/Layouts/ViewData";
48
+ import ColumnView from "../Elements/DataView/Layouts/ColumnView";
46
49
  import SearchAttachment from "../Elements/Search/SearchAttachment";
47
50
  // import { wrapThemeBreakpoints } from "../Elements/FreeGrid/breakpointConstants";
48
51
  import { jsx as _jsx } from "react/jsx-runtime";
@@ -564,6 +567,19 @@ export const getBlock = props => {
564
567
  contentEditable: false,
565
568
  children: children
566
569
  });
570
+ // Data View
571
+ case "dataView":
572
+ return /*#__PURE__*/_jsx(DataView, {
573
+ ...props
574
+ });
575
+ case "viewData":
576
+ return /*#__PURE__*/_jsx(ViewData, {
577
+ ...props
578
+ });
579
+ case "columnView":
580
+ return /*#__PURE__*/_jsx(ColumnView, {
581
+ ...props
582
+ });
567
583
  default:
568
584
  return /*#__PURE__*/_jsx(SimpleText, {
569
585
  ...props,
@@ -0,0 +1,43 @@
1
+ import { Transforms } from "slate";
2
+ const getDefaultDatView = () => ({
3
+ type: "paragraph",
4
+ children: [{
5
+ type: "dataView",
6
+ title: "",
7
+ layouts: [{
8
+ key: "view1",
9
+ type: "table",
10
+ label: "Table 1 View",
11
+ value: "table1",
12
+ filter: [],
13
+ sort: []
14
+ }],
15
+ properties: [{
16
+ key: "column1",
17
+ label: "Task",
18
+ type: "text",
19
+ visible: true,
20
+ default: true
21
+ }],
22
+ rows: [{
23
+ id: new Date().getTime(),
24
+ column1: ""
25
+ }],
26
+ children: [{
27
+ type: "viewData",
28
+ children: [{
29
+ text: ""
30
+ }]
31
+ }]
32
+ }]
33
+ });
34
+ export const insertDataView = editor => {
35
+ try {
36
+ Transforms.insertNodes(editor, {
37
+ ...getDefaultDatView()
38
+ });
39
+ Transforms.move(editor);
40
+ } catch (err) {
41
+ console.log(err);
42
+ }
43
+ };
@@ -1,5 +1,5 @@
1
1
  import { Transforms } from "slate";
2
- import insertNewLine from "./insertNewLine";
2
+ import insertNewLine, { insertNewLineAfterCurrentPath } from "./insertNewLine";
3
3
  export const insertDefaultEmbed = (editor, type, defaultURL = "", extProps = {}) => {
4
4
  try {
5
5
  const url = defaultURL ? defaultURL : type === "image" ? "" : "";
@@ -56,6 +56,7 @@ export const insertEmbed = (editor, embedData, format) => {
56
56
  at: editor.selection.anchor.path
57
57
  });
58
58
  insertNewLine(editor);
59
+ insertNewLineAfterCurrentPath(editor);
59
60
  } catch (err) {
60
61
  console.log(err);
61
62
  }
@@ -626,4 +626,22 @@ export const isPageSettings = (event, editor) => {
626
626
  export function capitalizeFirstLetter(str) {
627
627
  if (!str) return str;
628
628
  return str.charAt(0).toUpperCase() + str.slice(1);
629
- }
629
+ }
630
+ export const insertLineBreakAtEndOfPath = (editor, path) => {
631
+ try {
632
+ const [node, nodePath] = Editor.node(editor, path); // Get the node at the specified path
633
+ if (node) {
634
+ // Insert the line break
635
+ Transforms.insertNodes(editor, {
636
+ type: "paragraph",
637
+ children: [{
638
+ text: ""
639
+ }]
640
+ }, {
641
+ at: nodePath
642
+ });
643
+ }
644
+ } catch (err) {
645
+ console.log(err);
646
+ }
647
+ };
@@ -1,4 +1,4 @@
1
- import { Transforms } from "slate";
1
+ import { Editor, Element, Path, Transforms } from "slate";
2
2
  const insertNewLine = editor => {
3
3
  Transforms.insertNodes(editor, {
4
4
  type: "paragraph",
@@ -9,4 +9,22 @@ const insertNewLine = editor => {
9
9
  at: [editor.children.length]
10
10
  });
11
11
  };
12
+ export const insertNewLineAfterCurrentPath = editor => {
13
+ const currentPath = editor?.selection?.anchor?.path;
14
+ const [tableNode] = Editor.nodes(editor, {
15
+ match: n => !Editor.isEditor(n) && Element.isElement(n) && n.type === "table"
16
+ });
17
+ if (currentPath && tableNode) {
18
+ const currentParentPath = Path.parent(currentPath);
19
+ const nextPath = Path.next(currentParentPath);
20
+ Transforms.insertNodes(editor, {
21
+ type: "paragraph",
22
+ children: [{
23
+ text: ""
24
+ }]
25
+ }, {
26
+ at: nextPath
27
+ });
28
+ }
29
+ };
12
30
  export default insertNewLine;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@flozy/editor",
3
- "version": "5.0.4",
3
+ "version": "5.0.6",
4
4
  "description": "An Editor for flozy app brain",
5
5
  "files": [
6
6
  "dist"