@flozy/editor 4.9.1 → 4.9.3

Sign up to get free protection for your applications and to get access to all the features.
Files changed (34) hide show
  1. package/dist/Editor/Editor.css +17 -4
  2. package/dist/Editor/Elements/AI/CustomSelect.js +17 -10
  3. package/dist/Editor/Elements/AI/Styles.js +7 -1
  4. package/dist/Editor/Elements/Embed/Video.js +3 -2
  5. package/dist/Editor/Elements/FreeGrid/FreeGrid.js +1 -1
  6. package/dist/Editor/Elements/Grid/GridItem.js +28 -9
  7. package/dist/Editor/Elements/Grid/Styles.js +1 -0
  8. package/dist/Editor/Elements/Search/SearchAttachment.js +27 -18
  9. package/dist/Editor/Elements/Search/SearchButton.js +66 -9
  10. package/dist/Editor/Elements/Search/SearchList.js +87 -75
  11. package/dist/Editor/Elements/Table/AddRowCol.js +76 -0
  12. package/dist/Editor/Elements/Table/DragButton.js +134 -0
  13. package/dist/Editor/Elements/Table/DragStyles.js +43 -0
  14. package/dist/Editor/Elements/Table/Draggable.js +25 -0
  15. package/dist/Editor/Elements/Table/Droppable.js +53 -0
  16. package/dist/Editor/Elements/Table/Styles.js +23 -41
  17. package/dist/Editor/Elements/Table/Table.js +185 -137
  18. package/dist/Editor/Elements/Table/TableCell.js +339 -101
  19. package/dist/Editor/Elements/Table/TablePopup.js +9 -3
  20. package/dist/Editor/Elements/Table/TableRow.js +10 -2
  21. package/dist/Editor/Elements/Table/TableTool.js +101 -0
  22. package/dist/Editor/Toolbar/PopupTool/index.js +6 -8
  23. package/dist/Editor/assets/svg/DocsIcon.js +77 -10
  24. package/dist/Editor/assets/svg/TableIcons.js +220 -0
  25. package/dist/Editor/assets/svg/UserIcon.js +2 -2
  26. package/dist/Editor/common/RnD/ElementSettings/Settings/FormSettings.js +27 -38
  27. package/dist/Editor/common/StyleBuilder/embedVideoStyle.js +1 -1
  28. package/dist/Editor/common/StyleBuilder/index.js +43 -57
  29. package/dist/Editor/common/StyleBuilder/tableStyle.js +92 -1
  30. package/dist/Editor/common/iconListV2.js +52 -0
  31. package/dist/Editor/hooks/useTable.js +164 -0
  32. package/dist/Editor/utils/helper.js +1 -1
  33. package/dist/Editor/utils/table.js +204 -21
  34. package/package.json +1 -1
@@ -42,7 +42,7 @@ blockquote {
42
42
  }
43
43
 
44
44
  .editor-wrapper table {
45
- border-collapse: separate;
45
+ border-collapse: collapse;
46
46
  }
47
47
 
48
48
  .editor-wrapper .editor-wrapperbutton {
@@ -1234,7 +1234,20 @@ blockquote {
1234
1234
 
1235
1235
  .settingsHeader {
1236
1236
  font-size: 14px !important;
1237
- font-weight: 600 !important;
1238
- font-family: Inter, sans-serif;
1239
- text-transform: uppercase;
1237
+ font-weight: 500 !important;
1238
+ }
1239
+ .hideScroll {
1240
+ overflow-anchor: none;
1241
+ }
1242
+
1243
+ .hideScroll::-webkit-scrollbar-track {
1244
+ background: none !important;
1245
+ }
1246
+
1247
+ .hideScroll::-webkit-scrollbar-thumb {
1248
+ background: none !important;
1249
+ }
1250
+
1251
+ .hideScroll::-webkit-scrollbar-thumb:hover {
1252
+ background: none !important;
1240
1253
  }
@@ -8,12 +8,14 @@ function CustomSelect({
8
8
  classes,
9
9
  options,
10
10
  onSend,
11
- show
11
+ show,
12
+ btnProps = {}
12
13
  }) {
13
14
  if (show) {
14
15
  return /*#__PURE__*/_jsx(Box, {
15
16
  component: "div",
16
17
  sx: classes.customSelectContainer,
18
+ className: "customSelectContainer",
17
19
  children: options?.map((groupOption, index) => {
18
20
  const {
19
21
  options,
@@ -28,7 +30,8 @@ function CustomSelect({
28
30
  return /*#__PURE__*/_jsx(DisplayOption, {
29
31
  option: option,
30
32
  classes: classes,
31
- onSend: onSend
33
+ onSend: onSend,
34
+ btnProps: btnProps
32
35
  }, i);
33
36
  })]
34
37
  }, index);
@@ -42,15 +45,18 @@ export default CustomSelect;
42
45
  function DisplayOption({
43
46
  option,
44
47
  classes,
45
- onSend
48
+ onSend,
49
+ btnProps = {}
46
50
  }) {
47
51
  const {
48
- Icon
52
+ Icon,
53
+ Component
49
54
  } = option;
50
55
  const [open, setOpen] = useState(false);
51
56
  const optionRef = useRef();
57
+ const showChild = option.options?.length || Component;
52
58
  const openOptions = e => {
53
- if (option.options?.length && !open) {
59
+ if (showChild && !open) {
54
60
  setOpen(e.currentTarget);
55
61
  return;
56
62
  }
@@ -66,7 +72,7 @@ function DisplayOption({
66
72
  e.stopPropagation();
67
73
 
68
74
  // is having child options
69
- if (option.options?.length) {
75
+ if (showChild) {
70
76
  openOptions(e);
71
77
  return;
72
78
  }
@@ -75,18 +81,19 @@ function DisplayOption({
75
81
  },
76
82
  id: "infinity-select-popover",
77
83
  className: open ? "active" : "",
84
+ ...btnProps,
78
85
  children: [/*#__PURE__*/_jsxs("div", {
79
86
  className: "option-label",
80
87
  id: "infinity-select-popover",
81
88
  children: [Icon && /*#__PURE__*/_jsx(Icon, {}), option.label]
82
- }), option.options?.length && /*#__PURE__*/_jsx(IconButton, {
89
+ }), showChild ? /*#__PURE__*/_jsx(IconButton, {
83
90
  children: /*#__PURE__*/_jsx(FaChevronRight, {
84
91
  color: "#94A3B8",
85
92
  size: 12
86
93
  })
87
- })]
94
+ }) : null]
88
95
  }), /*#__PURE__*/_jsx(Popper, {
89
- open: open && option.options,
96
+ open: open && showChild,
90
97
  anchorEl: open,
91
98
  sx: {
92
99
  zIndex: 9001,
@@ -96,7 +103,7 @@ function DisplayOption({
96
103
  setOpen(null);
97
104
  },
98
105
  placement: "right-start",
99
- children: /*#__PURE__*/_jsx(Box, {
106
+ children: Component ? /*#__PURE__*/_jsx(Component, {}) : /*#__PURE__*/_jsx(Box, {
100
107
  children: /*#__PURE__*/_jsx(CustomSelect, {
101
108
  options: option.options,
102
109
  onSend: onSend,
@@ -142,7 +142,13 @@ const Styles = theme => ({
142
142
  gap: "8px"
143
143
  },
144
144
  "&:hover": {
145
- background: `${theme?.palette?.containers?.bg3 || "#E9F3FE"}`
145
+ backgroundColor: `${theme?.palette?.editor?.menuOptionSelectedOption} !important`,
146
+ "& svg path": {
147
+ stroke: `${theme?.palette?.editor?.menuOptionTextColor} !important`
148
+ },
149
+ "& svg": {
150
+ color: `${theme?.palette?.editor?.menuOptionTextColor} !important`
151
+ }
146
152
  },
147
153
  "&.active": {
148
154
  background: `${theme?.palette?.containers?.bg3 || "#E9F3FE"}`,
@@ -101,6 +101,7 @@ const Video = ({
101
101
  horizantal
102
102
  } = alignment || {};
103
103
  const path = ReactEditor.findPath(editor, element);
104
+ const hasAspect = url && aspectRatio !== "custom" && aspectRatio;
104
105
  const getSize = () => {
105
106
  if (element?.size === undefined) {
106
107
  return {
@@ -190,10 +191,10 @@ const Video = ({
190
191
  width: {
191
192
  ...getBreakPointsValue(getSize(), null, "overrideReSize", true)
192
193
  },
193
- height: url && !aspectRatio ? {
194
+ height: url && (aspectRatio === "custom" || !aspectRatio) ? {
194
195
  ...getBreakPointsValue(getSize(), null, "overrideReSizeH", true)
195
196
  } : "auto",
196
- aspectRatio: aspectRatio ? aspectRatio : "auto"
197
+ aspectRatio: hasAspect ? aspectRatio : "auto"
197
198
  }, theme)
198
199
  };
199
200
  }
@@ -276,7 +276,7 @@ const FreeGrid = props => {
276
276
  ...insertFreeGridItem("table", {
277
277
  ...DEFAULT_TABLE_NODE()
278
278
  }, {
279
- height: 130,
279
+ height: 150,
280
280
  width: 400
281
281
  })
282
282
  }], {
@@ -1,6 +1,6 @@
1
1
  /* eslint-disable no-unused-vars */
2
2
  import React, { useEffect, useState, useRef } from "react";
3
- import { useTheme } from "@mui/material";
3
+ import { Button, Dialog, DialogActions, DialogContent, useTheme } from "@mui/material";
4
4
  import { Node, Path, Transforms } from "slate";
5
5
  import { useSlateStatic, ReactEditor } from "slate-react";
6
6
  import GridItemPopup from "./GridItemPopup";
@@ -83,7 +83,7 @@ const GridItem = props => {
83
83
  initColumnWidth,
84
84
  updateColumnWidth,
85
85
  updateColNodes
86
- } = useGrid();
86
+ } = useGrid() || {};
87
87
  const columnRef = useRef(null);
88
88
  const theme = useTheme();
89
89
  const classes = GridStyles(theme);
@@ -129,6 +129,7 @@ const GridItem = props => {
129
129
  const selected = hoverPath === path.join(",");
130
130
  const [showTool] = useEditorSelection(editor);
131
131
  const [parentDOM, setParentDOM] = useState({});
132
+ const [alert, setAlert] = useState(null);
132
133
  const [size, onMouseDown, resizing, onLoad, isDone] = useTableResize({
133
134
  ...parentDOM
134
135
  });
@@ -216,16 +217,23 @@ const GridItem = props => {
216
217
  try {
217
218
  const gridPath = Path.parent(path);
218
219
  const gridNode = Node.get(editor, gridPath);
219
- onAddGridItem({
220
- editor,
221
- element: gridNode,
222
- children: gridNode?.children || [],
223
- isColumn: gridNode?.equalItems
224
- });
220
+ if (gridNode?.children?.length === 5) {
221
+ setAlert("Maximum column limit exceeded");
222
+ } else {
223
+ onAddGridItem({
224
+ editor,
225
+ element: gridNode,
226
+ children: gridNode?.children || [],
227
+ isColumn: gridNode?.equalItems
228
+ });
229
+ }
225
230
  } catch (err) {
226
231
  console.log(err);
227
232
  }
228
233
  };
234
+ const handleClose = () => {
235
+ setAlert(null);
236
+ };
229
237
  const getBorderColor = () => {
230
238
  return borderColor || "transparent";
231
239
  };
@@ -334,7 +342,18 @@ const GridItem = props => {
334
342
  className: resizing ? "resizing" : "",
335
343
  onMouseDown: onMouseDown,
336
344
  height: "auto"
337
- }) : null]
345
+ }) : null, /*#__PURE__*/_jsxs(Dialog, {
346
+ open: Boolean(alert),
347
+ onClose: handleClose,
348
+ children: [/*#__PURE__*/_jsx(DialogContent, {
349
+ children: alert
350
+ }), /*#__PURE__*/_jsx(DialogActions, {
351
+ children: /*#__PURE__*/_jsx(Button, {
352
+ onClick: handleClose,
353
+ children: "Close"
354
+ })
355
+ })]
356
+ })]
338
357
  });
339
358
  };
340
359
  export default GridItem;
@@ -51,6 +51,7 @@ const GridStyles = theme => ({
51
51
  },
52
52
  "& .gi-inner-cw": {
53
53
  overflowX: "auto",
54
+ wordBreak: "break-word",
54
55
  "& .tableToolBar": {
55
56
  display: "flex",
56
57
  maxWidth: "100%",
@@ -21,6 +21,7 @@ const SearchAttachment = props => {
21
21
  const {
22
22
  theme
23
23
  } = useEditorContext();
24
+ const label = Boolean(title?.trim()) ? title : 'Untitled';
24
25
  const handleClick = () => {
25
26
  if (metadata && metadata?.actionHandler) {
26
27
  metadata?.actionHandler(type, element);
@@ -37,26 +38,28 @@ const SearchAttachment = props => {
37
38
  children: [/*#__PURE__*/_jsxs(Card, {
38
39
  style: {
39
40
  display: "flex",
40
- justifyContent: "center",
41
- alignItems: "center",
42
- width: "100%",
43
- maxWidth: '200px',
44
- padding: "2px",
41
+ justifyContent: "flex-start",
42
+ alignItems: "flex-end",
43
+ width: "fit-content",
44
+ maxWidth: '194px',
45
+ padding: "0px 10px",
45
46
  boxShadow: "none",
46
- border: `1px solid ${theme?.palette?.primary?.border2}`,
47
+ border: `1px solid ${theme?.palette?.primary?.slashBrainBorder}`,
47
48
  borderRadius: "7px",
48
- background: theme?.palette?.background?.paper,
49
- cursor: 'pointer'
49
+ background: theme?.palette?.containers?.slashBrainCardBg,
50
+ cursor: 'pointer',
51
+ "& *::selection": {
52
+ background: "#000"
53
+ }
50
54
  },
51
55
  onClick: handleClick,
52
56
  children: [/*#__PURE__*/_jsx(CardMedia, {
53
57
  sx: {
54
58
  "& svg": {
55
59
  '& path': {
56
- stroke: '#2563EB'
60
+ stroke: theme?.palette?.text?.slashBrainText
57
61
  }
58
- },
59
- marginTop: '3px'
62
+ }
60
63
  },
61
64
  children: /*#__PURE__*/_jsx(Icon, {
62
65
  icon: "docsIcon"
@@ -64,9 +67,8 @@ const SearchAttachment = props => {
64
67
  }), /*#__PURE__*/_jsx(CardContent, {
65
68
  sx: {
66
69
  display: "flex",
67
- justifyContent: "center",
68
- alignItems: "start",
69
- padding: "3px 5px",
70
+ alignItems: "center",
71
+ padding: "3px 0px 3px 5px",
70
72
  textDecoration: "none",
71
73
  flexDirection: "column",
72
74
  color: "#2563EB",
@@ -77,16 +79,23 @@ const SearchAttachment = props => {
77
79
  children: /*#__PURE__*/_jsx(Typography, {
78
80
  sx: {
79
81
  fontWeight: "500",
80
- color: "#2563EB",
81
- fontSize: "12px",
82
+ background: theme?.palette?.text?.slashBrainText,
83
+ WebkitBackgroundClip: "text",
84
+ WebkitTextFillColor: 'transparent',
85
+ fontSize: "14px",
82
86
  textOverflow: 'ellipsis',
83
87
  whiteSpace: 'nowrap',
84
88
  overflow: 'hidden',
85
89
  wordBreak: "break-word",
86
- maxWidth: '150px'
90
+ maxWidth: '150px',
91
+ lineHeight: 1.43,
92
+ "&::selection": {
93
+ WebkitTextFillColor: "#000"
94
+ }
87
95
  },
88
96
  component: "div",
89
- children: title
97
+ variant: "subtitle1",
98
+ children: label
90
99
  })
91
100
  })]
92
101
  }), /*#__PURE__*/_jsx("span", {
@@ -1,4 +1,4 @@
1
- import React, { forwardRef, useImperativeHandle, useState } from "react";
1
+ import React, { forwardRef, useCallback, useEffect, useImperativeHandle, useRef, useState } from "react";
2
2
  import ToolbarIcon from "../../common/ToolbarIcon";
3
3
  import Icon from "../../common/Icon";
4
4
  import { Paper, Popover } from "@mui/material";
@@ -6,6 +6,7 @@ import { ReactEditor, useSlateStatic } from "slate-react";
6
6
  import SwipeableDrawerComponent from "../../common/SwipeableDrawer";
7
7
  import SearchAndDocList from "./SearchList";
8
8
  import { insertBrain } from "../../utils/brains";
9
+ import { useDebounce } from "use-debounce";
9
10
  import { jsx as _jsx } from "react/jsx-runtime";
10
11
  import { Fragment as _Fragment } from "react/jsx-runtime";
11
12
  import { jsxs as _jsxs } from "react/jsx-runtime";
@@ -22,6 +23,22 @@ const SearchButton = /*#__PURE__*/forwardRef((props, ref) => {
22
23
  const [target, setTarget] = useState(selectionTarget);
23
24
  const open = Boolean(anchorEl);
24
25
  const isMobile = window.matchMedia("(max-width: 899px)")?.matches || false;
26
+ const [mapData, setMapData] = useState([]);
27
+ const [skip, setSkip] = useState(0);
28
+ const [search, setSearch] = useState("");
29
+ const [isLoading, setIsLoading] = useState(false);
30
+ const [debouncedSearch] = useDebounce(search, 300);
31
+ const limit = 20;
32
+ const observer = useRef();
33
+ const lastDocRef = useCallback(node => {
34
+ if (observer.current) observer.current.disconnect();
35
+ observer.current = new IntersectionObserver(entries => {
36
+ if (entries[0].isIntersecting) {
37
+ setSkip(prevSkip => prevSkip + limit);
38
+ }
39
+ });
40
+ if (node) observer.current.observe(node);
41
+ }, []);
25
42
  useImperativeHandle(ref, () => ({
26
43
  triggerClick: target => {
27
44
  setTarget(target);
@@ -42,6 +59,34 @@ const SearchButton = /*#__PURE__*/forwardRef((props, ref) => {
42
59
  console.log(err);
43
60
  }
44
61
  };
62
+ useEffect(() => {
63
+ getDocs({
64
+ debouncedSearch,
65
+ skip,
66
+ limit
67
+ });
68
+ }, [skip, debouncedSearch]);
69
+ const getDocs = async () => {
70
+ setIsLoading(true);
71
+ try {
72
+ if (otherProps?.services) {
73
+ const result = await otherProps?.services("getDocs", {
74
+ skip,
75
+ limit,
76
+ search
77
+ });
78
+ setMapData(prev => skip === 0 ? result.data : [...prev, ...result.data]);
79
+ }
80
+ } catch (error) {
81
+ console.error("Error fetching documents:", error);
82
+ } finally {
83
+ setIsLoading(false);
84
+ }
85
+ };
86
+ const onSearchChange = value => {
87
+ setSearch(value);
88
+ setSkip(0);
89
+ };
45
90
  const handleClose = () => {
46
91
  setAnchorEl(null);
47
92
  };
@@ -52,9 +97,7 @@ const SearchButton = /*#__PURE__*/forwardRef((props, ref) => {
52
97
  return /*#__PURE__*/_jsxs(_Fragment, {
53
98
  children: [/*#__PURE__*/_jsx(ToolbarIcon, {
54
99
  title: element?.name,
55
- onClick: () => {
56
- onClick();
57
- },
100
+ onClick: onClick,
58
101
  icon: /*#__PURE__*/_jsx(Icon, {
59
102
  icon: element?.name?.toLowerCase()
60
103
  }),
@@ -71,7 +114,10 @@ const SearchButton = /*#__PURE__*/forwardRef((props, ref) => {
71
114
  borderColor: theme?.palette?.type === 'dark' ? theme?.palette?.primary?.border2 : 'transparent'
72
115
  },
73
116
  children: /*#__PURE__*/_jsx(SearchAndDocList, {
74
- otherProps: otherProps,
117
+ mapData: mapData,
118
+ isLoading: isLoading,
119
+ lastDocRef: lastDocRef,
120
+ onSearchChange: onSearchChange,
75
121
  handleClick: handleClick,
76
122
  theme: theme,
77
123
  handleClose: handleClose
@@ -88,17 +134,28 @@ const SearchButton = /*#__PURE__*/forwardRef((props, ref) => {
88
134
  horizontal: "left"
89
135
  },
90
136
  onClose: handleClose,
137
+ sx: {
138
+ '& .MuiPaper-root': {
139
+ borderRadius: '12px !important'
140
+ }
141
+ },
91
142
  children: /*#__PURE__*/_jsx(Paper, {
92
143
  sx: {
93
- padding: "8px",
94
- maxWidth: '330px',
144
+ padding: 0,
145
+ width: '330px',
95
146
  background: theme?.palette?.background?.paper,
96
147
  border: '1px solid',
97
148
  borderColor: theme?.palette?.type === 'dark' ? theme?.palette?.primary?.border2 : 'transparent',
98
- borderRadius: '7px'
149
+ borderRadius: '12px',
150
+ '&.MuiPaper-root-MuiPopover-paper': {
151
+ borderRadius: '12px !important'
152
+ }
99
153
  },
100
154
  children: /*#__PURE__*/_jsx(SearchAndDocList, {
101
- otherProps: otherProps,
155
+ mapData: mapData,
156
+ isLoading: isLoading,
157
+ lastDocRef: lastDocRef,
158
+ onSearchChange: onSearchChange,
102
159
  handleClick: handleClick,
103
160
  theme: theme,
104
161
  handleClose: handleClose