@flozy/editor 5.1.6 → 5.1.8

Sign up to get free protection for your applications and to get access to all the features.
Files changed (32) hide show
  1. package/dist/Editor/Elements/AppHeader/AppHeader.js +6 -6
  2. package/dist/Editor/Elements/DataView/DataView.js +9 -1
  3. package/dist/Editor/Elements/DataView/Layouts/ColumnView.js +10 -3
  4. package/dist/Editor/Elements/DataView/Layouts/DataTypes/Components/Select.js +27 -5
  5. package/dist/Editor/Elements/DataView/Layouts/DataTypes/Components/styles.js +9 -1
  6. package/dist/Editor/Elements/DataView/Layouts/DataTypes/DateType.js +5 -1
  7. package/dist/Editor/Elements/DataView/Layouts/DataTypes/MultiSelectType.js +2 -1
  8. package/dist/Editor/Elements/DataView/Layouts/DataTypes/PersonType.js +3 -3
  9. package/dist/Editor/Elements/DataView/Layouts/FilterSort/styles.js +1 -1
  10. package/dist/Editor/Elements/DataView/Layouts/Options/ChangeProperty.js +1 -3
  11. package/dist/Editor/Elements/DataView/Layouts/Options/styles.js +2 -2
  12. package/dist/Editor/Elements/DataView/Layouts/TableStyles.js +13 -1
  13. package/dist/Editor/Elements/DataView/styles.js +3 -3
  14. package/dist/Editor/Elements/FreeGrid/breakpointConstants.js +4 -4
  15. package/dist/Editor/Elements/FreeGrid/styles.js +1 -1
  16. package/dist/Editor/Elements/Grid/GridButton.js +0 -1
  17. package/dist/Editor/Elements/Grid/GridItem.js +21 -30
  18. package/dist/Editor/Elements/SimpleText/style.js +5 -0
  19. package/dist/Editor/Elements/Table/Styles.js +77 -59
  20. package/dist/Editor/Elements/Table/Table.js +51 -28
  21. package/dist/Editor/Elements/Table/TableCell.js +4 -1
  22. package/dist/Editor/Toolbar/FormatTools/Dropdown.js +1 -2
  23. package/dist/Editor/Toolbar/PopupTool/PopperHeader.js +3 -4
  24. package/dist/Editor/Toolbar/PopupTool/PopupToolStyle.js +0 -5
  25. package/dist/Editor/common/Icon.js +5 -5
  26. package/dist/Editor/common/MentionsPopup/Styles.js +0 -1
  27. package/dist/Editor/common/RnD/GuideLines/styles.js +3 -3
  28. package/dist/Editor/common/RnD/ShadowElement.js +1 -1
  29. package/dist/Editor/hooks/useTable.js +18 -6
  30. package/dist/Editor/utils/customHooks/useTableResize.js +6 -2
  31. package/dist/Editor/utils/helper.js +3 -0
  32. package/package.json +1 -1
@@ -250,10 +250,10 @@ function AppHeader(props) {
250
250
  },
251
251
  sx: {
252
252
  mr: 2,
253
- [theme.breakpoints.up("sm")]: {
253
+ [theme?.breakpoints?.up("sm")]: {
254
254
  display: "none"
255
255
  },
256
- [theme.breakpoints.between("xs", "md")]: {
256
+ [theme?.breakpoints.between("xs", "md")]: {
257
257
  display: "block"
258
258
  }
259
259
  },
@@ -272,10 +272,10 @@ function AppHeader(props) {
272
272
  },
273
273
  sx: {
274
274
  flexGrow: 1,
275
- [theme.breakpoints.up("sm")]: {
275
+ [theme?.breakpoints?.up("sm")]: {
276
276
  display: "block"
277
277
  },
278
- [theme.breakpoints.between("xs", "md")]: {
278
+ [theme?.breakpoints?.between("xs", "md")]: {
279
279
  display: "none"
280
280
  },
281
281
  "& img": {
@@ -293,10 +293,10 @@ function AppHeader(props) {
293
293
  }) : null, appTitle]
294
294
  }), /*#__PURE__*/_jsxs(Box, {
295
295
  sx: {
296
- [theme.breakpoints.up("sm")]: {
296
+ [theme?.breakpoints?.up("sm")]: {
297
297
  display: "block"
298
298
  },
299
- [theme.breakpoints.between("xs", "md")]: {
299
+ [theme?.breakpoints?.between("xs", "md")]: {
300
300
  display: "none"
301
301
  }
302
302
  },
@@ -34,6 +34,14 @@ const DataView = props => {
34
34
  } = element;
35
35
  const classes = useDataViewStyles(theme, appTheme);
36
36
  const path = ReactEditor.findPath(editor, element);
37
+ const users = CHARACTERS?.map(m => {
38
+ const name = [m?.first_name || "", m?.last_name || ""]?.join(" ").trim();
39
+ return {
40
+ value: m?.email,
41
+ name: name || m?.username || m?.email,
42
+ avatar: m?.avatar || null
43
+ };
44
+ });
37
45
  const onDuplicate = () => {
38
46
  try {
39
47
  const newPath = ReactEditor.findPath(editor, element);
@@ -80,7 +88,7 @@ const DataView = props => {
80
88
  properties,
81
89
  layouts,
82
90
  rows,
83
- users: CHARACTERS,
91
+ users: users,
84
92
  tableTitle: title
85
93
  },
86
94
  path: path,
@@ -27,8 +27,13 @@ const ColumnView = props => {
27
27
  };
28
28
  return /*#__PURE__*/_jsxs(Box, {
29
29
  component: "td",
30
- ref: anchorRef,
31
- children: [/*#__PURE__*/_jsx(DataType, {
30
+ children: [needAnchor ? /*#__PURE__*/_jsx("span", {
31
+ ref: anchorRef,
32
+ style: {
33
+ position: "absolute",
34
+ width: "1px"
35
+ }
36
+ }) : null, /*#__PURE__*/_jsx(DataType, {
32
37
  options: property?.options,
33
38
  property: property?.key,
34
39
  value: row[property?.key] || "",
@@ -37,13 +42,15 @@ const ColumnView = props => {
37
42
  readOnly: readOnly
38
43
  }), needAnchor && !readOnly ? /*#__PURE__*/_jsx(Popper, {
39
44
  sx: {
40
- zIndex: 1000
45
+ zIndex: 1000,
46
+ marginTop: "20px !important"
41
47
  },
42
48
  open: open,
43
49
  anchorEl: anchorEl,
44
50
  placement: "left",
45
51
  container: anchorRef?.current,
46
52
  className: `tv-tr-pop ${selected ? "active" : ""}`,
53
+ disablePortal: true,
47
54
  children: /*#__PURE__*/_jsx(Checkbox, {
48
55
  onClick: handleSelect(row?.id),
49
56
  size: "small",
@@ -1,10 +1,22 @@
1
1
  import React from "react";
2
2
  import TextField from "@mui/material/TextField";
3
3
  import Autocomplete from "@mui/material/Autocomplete";
4
- import { Box, Chip, useTheme } from "@mui/material";
4
+ import { Avatar, Box, Chip, useTheme } from "@mui/material";
5
5
  import { useEditorContext } from "../../../../../hooks/useMouseMove";
6
6
  import useCompStyles from "./styles";
7
7
  import { jsx as _jsx } from "react/jsx-runtime";
8
+ const AvatarIcon = props => {
9
+ const {
10
+ option,
11
+ avatar
12
+ } = props;
13
+ const nameIndex = option.label || option.value;
14
+ return avatar ? /*#__PURE__*/_jsx(Avatar, {
15
+ alt: option.label || option.value,
16
+ src: option.avatar || null,
17
+ children: nameIndex[0] || ""
18
+ }) : null;
19
+ };
8
20
  const filter = (opt, params, selectedOpt) => {
9
21
  const selectedVals = selectedOpt?.map(m => m?.value);
10
22
  const fv = opt?.filter(f => !selectedVals.includes(f.value));
@@ -20,14 +32,16 @@ export default function Select(props) {
20
32
  } = useEditorContext();
21
33
  const classes = useCompStyles(theme, appTheme);
22
34
  const {
23
- value,
35
+ value: pValue,
24
36
  onChange,
25
37
  options,
26
38
  multiple = false,
27
39
  limitTags = 2,
28
40
  placeholder = "",
29
- disabled = false
41
+ disabled = false,
42
+ optionAvatar = false
30
43
  } = props;
44
+ const value = Array.isArray(pValue) ? pValue : [];
31
45
  return /*#__PURE__*/_jsx(Autocomplete, {
32
46
  disabled: disabled,
33
47
  className: "tv-ac-field",
@@ -101,7 +115,11 @@ export default function Select(props) {
101
115
  sx: {
102
116
  background: option?.color || "#CCC",
103
117
  border: "none"
104
- }
118
+ },
119
+ avatar: /*#__PURE__*/_jsx(AvatarIcon, {
120
+ option: option,
121
+ avatar: optionAvatar
122
+ })
105
123
  }, key) : null;
106
124
  })
107
125
  });
@@ -117,7 +135,11 @@ export default function Select(props) {
117
135
  label: option.label || option.value || "",
118
136
  sx: {
119
137
  backgroundColor: option.color || "#CCC"
120
- }
138
+ },
139
+ avatar: /*#__PURE__*/_jsx(AvatarIcon, {
140
+ option: option,
141
+ avatar: optionAvatar
142
+ })
121
143
  })
122
144
  }, key);
123
145
  },
@@ -4,7 +4,7 @@ const useCompStyles = (theme, appTheme) => ({
4
4
  background: appTheme?.palette?.editor?.tv_pop_bg,
5
5
  color: appTheme?.palette?.editor?.tv_text_primary,
6
6
  borderRadius: "8px",
7
- [theme.breakpoints.between("xs", "md")]: {},
7
+ [theme?.breakpoints?.between("xs", "md")]: {},
8
8
  "& ul": {
9
9
  padding: "4px",
10
10
  "& li": {
@@ -40,6 +40,14 @@ const useCompStyles = (theme, appTheme) => ({
40
40
  borderRadius: "8px",
41
41
  color: appTheme?.palette?.editor?.tv_text_primary,
42
42
  fontSize: "14px",
43
+ "& .MuiAvatar-root": {
44
+ width: "20px",
45
+ height: "20px",
46
+ marginLeft: "8px",
47
+ fontSize: "16px",
48
+ padding: "2px",
49
+ textTransform: "capitalize"
50
+ },
43
51
  "&.Mui-selected": {
44
52
  background: appTheme?.palette?.editor?.tv_hover_bg,
45
53
  color: appTheme?.palette?.editor?.tv_hover_text,
@@ -2,6 +2,10 @@ import React from "react";
2
2
  import DatePicker from "react-datepicker";
3
3
  import { useDataView } from "../../Providers/DataViewProvider";
4
4
  import { jsx as _jsx } from "react/jsx-runtime";
5
+ function isValidDate(dateString) {
6
+ const date = new Date(dateString);
7
+ return !isNaN(date.getTime());
8
+ }
5
9
  const DateType = props => {
6
10
  const {
7
11
  rowIndex,
@@ -19,7 +23,7 @@ const DateType = props => {
19
23
  };
20
24
  return /*#__PURE__*/_jsx(DatePicker, {
21
25
  disabled: readOnly,
22
- selected: value ? new Date(value) : "",
26
+ selected: isValidDate(value) ? new Date(value) : "",
23
27
  onChange: handleChange
24
28
  });
25
29
  };
@@ -6,7 +6,7 @@ const MultiSelectType = props => {
6
6
  const {
7
7
  rowIndex,
8
8
  property,
9
- value,
9
+ value: pValue,
10
10
  options,
11
11
  label = "",
12
12
  readOnly
@@ -14,6 +14,7 @@ const MultiSelectType = props => {
14
14
  const {
15
15
  onChange
16
16
  } = useDataView();
17
+ const value = Array.isArray(pValue) ? pValue : [];
17
18
  const coloredValues = [...(value || [])]?.map(m => {
18
19
  return {
19
20
  ...m,
@@ -13,7 +13,6 @@ const PersonType = props => {
13
13
  onChange,
14
14
  users
15
15
  } = useDataView();
16
- console.log(users);
17
16
  const handleChange = data => {
18
17
  onChange(rowIndex, {
19
18
  [property]: data?.filter(f => f?.value)
@@ -22,9 +21,10 @@ const PersonType = props => {
22
21
  return /*#__PURE__*/_jsx(Select, {
23
22
  value: value || [],
24
23
  onChange: handleChange,
25
- options: users,
24
+ options: users || [],
26
25
  multiple: false,
27
- disabled: readOnly
26
+ disabled: readOnly,
27
+ optionAvatar: true
28
28
  });
29
29
  };
30
30
  export default PersonType;
@@ -6,7 +6,7 @@ const useFilterSortStyles = (theme, appTheme) => ({
6
6
  background: appTheme?.palette?.editor?.tv_pop_bg,
7
7
  color: appTheme?.palette?.editor?.tv_text_primary,
8
8
  borderRadius: "12px",
9
- [theme.breakpoints.between("xs", "md")]: {
9
+ [theme?.breakpoints?.between("xs", "md")]: {
10
10
  borderRadius: "16px 16px 0px 0px",
11
11
  maxHeight: "50%"
12
12
  },
@@ -2,7 +2,6 @@ import React from "react";
2
2
  import { Box, IconButton } from "@mui/material";
3
3
  import CloseIcon from "@mui/icons-material/Close";
4
4
  import PropertyList from "./PropertyList";
5
- import { TYPE_LABELS } from "./Constants";
6
5
  import ArrowBackIcon from "@mui/icons-material/ArrowBack";
7
6
  import { jsx as _jsx } from "react/jsx-runtime";
8
7
  import { jsxs as _jsxs } from "react/jsx-runtime";
@@ -16,8 +15,7 @@ const ChangeProperty = props => {
16
15
  const onSelect = property => () => {
17
16
  onEvent("updateProperty", {
18
17
  ...(mode?.edit || {}),
19
- type: property?.type,
20
- label: TYPE_LABELS[mode?.type] === mode?.label ? property?.label : mode?.label
18
+ type: property?.type
21
19
  });
22
20
  };
23
21
  const onBack = () => {
@@ -6,7 +6,7 @@ const useOptionsStyles = (theme, appTheme) => ({
6
6
  borderRadius: "12px",
7
7
  background: appTheme?.palette?.editor?.tv_pop_bg,
8
8
  color: appTheme?.palette?.editor?.tv_text_primary,
9
- [theme.breakpoints.between("xs", "md")]: {
9
+ [theme?.breakpoints?.between("xs", "md")]: {
10
10
  borderRadius: "16px 16px 0px 0px",
11
11
  maxHeight: "50%"
12
12
  },
@@ -171,7 +171,7 @@ const useOptionsStyles = (theme, appTheme) => ({
171
171
  justifyContent: "space-between",
172
172
  marginBottom: "8px"
173
173
  },
174
- [theme.breakpoints.between("xs", "md")]: {
174
+ [theme?.breakpoints?.between("xs", "md")]: {
175
175
  width: "calc(100% - 24px)"
176
176
  }
177
177
  }
@@ -3,7 +3,7 @@ const useTableStyles = (theme, appTheme) => ({
3
3
  border: `1px solid ${appTheme?.palette?.editor?.tv_border}`,
4
4
  borderRadius: "7px 7px 0px 0px",
5
5
  overflowX: "auto",
6
- [theme.breakpoints.between("xs", "md")]: {}
6
+ [theme?.breakpoints?.between("xs", "md")]: {}
7
7
  },
8
8
  table: {
9
9
  borderCollapse: "separate",
@@ -86,6 +86,18 @@ const useTableStyles = (theme, appTheme) => ({
86
86
  "& svg": {
87
87
  color: appTheme?.palette?.editor?.tv_text
88
88
  }
89
+ },
90
+ "& .MuiAvatar-root": {
91
+ width: "20px",
92
+ height: "20px",
93
+ marginLeft: "8px",
94
+ fontSize: "16px",
95
+ padding: "2px",
96
+ textTransform: "capitalize"
97
+ },
98
+ "& .MuiChip-label": {
99
+ paddingLeft: "6px",
100
+ paddingRight: "8px"
89
101
  }
90
102
  }
91
103
  },
@@ -34,7 +34,7 @@ const useDataViewStyles = (theme, appTheme) => ({
34
34
  "& .mr": {
35
35
  marginRight: "4px"
36
36
  },
37
- [theme.breakpoints.between("xs", "md")]: {
37
+ [theme?.breakpoints?.between("xs", "md")]: {
38
38
  display: "flex",
39
39
  flexDirection: "column"
40
40
  }
@@ -105,13 +105,13 @@ const useDataViewStyles = (theme, appTheme) => ({
105
105
  "& .MuiInputBase-root": {
106
106
  width: "100%"
107
107
  },
108
- [theme.breakpoints.between("xs", "md")]: {
108
+ [theme?.breakpoints?.between("xs", "md")]: {
109
109
  width: "100%",
110
110
  marginRight: "0px"
111
111
  }
112
112
  },
113
113
  "& .tv-fi-wrpr": {
114
- [theme.breakpoints.between("xs", "md")]: {
114
+ [theme?.breakpoints?.between("xs", "md")]: {
115
115
  width: "100%",
116
116
  justifyContent: "end"
117
117
  }
@@ -47,22 +47,22 @@ export function wrapThemeBreakpoints(sxProp, prop, theme) {
47
47
  const formatedSxProp = Object.keys(sxProp).reduce((a, b) => {
48
48
  switch (b) {
49
49
  case "md":
50
- a[theme.breakpoints.up("lg")] = {
50
+ a[theme?.breakpoints?.up("lg")] = {
51
51
  [prop]: sxProp["md"] || sxProp["lg"]
52
52
  };
53
53
  break;
54
54
  case "sm":
55
- a[theme.breakpoints.up("lg")] = {
55
+ a[theme?.breakpoints?.up("lg")] = {
56
56
  [prop]: sxProp["sm"] || sxProp["lg"]
57
57
  };
58
58
  break;
59
59
  case "xs":
60
- a[theme.breakpoints.between("xs", "md")] = {
60
+ a[theme?.breakpoints?.between("xs", "md")] = {
61
61
  [prop]: sxProp["xs"] || sxProp["lg"]
62
62
  };
63
63
  break;
64
64
  default:
65
- a[theme.breakpoints.up("lg")] = {
65
+ a[theme?.breakpoints?.up("lg")] = {
66
66
  [prop]: sxProp["lg"]
67
67
  };
68
68
  }
@@ -318,7 +318,7 @@ const useFreeGridStyles = ({
318
318
  "& .element-toolbar": {
319
319
  display: "none"
320
320
  },
321
- [theme.breakpoints.between("xs", "md")]: {
321
+ [theme?.breakpoints?.between("xs", "md")]: {
322
322
  marginLeft: `calc((100% - 320px) * 0.5)`
323
323
  }
324
324
  },
@@ -1,7 +1,6 @@
1
1
  import React, { useState } from "react";
2
2
  import { Button, Dialog, DialogContent, DialogTitle, Grid, Tooltip, Box } from "@mui/material";
3
3
  import { insertGrid, insertPlainGrid } from "../../utils/grid";
4
- import { GridIcon } from "../../common/iconslist";
5
4
  import ToolbarIcon from "../../common/ToolbarIcon";
6
5
  import GridStyles from "./Styles";
7
6
  import { GridElement } from "../../common/iconListV2";
@@ -51,18 +51,7 @@ const GridItemToolbar = props => {
51
51
  placement: "top-end",
52
52
  sx: classes.popTools,
53
53
  className: "gi-tool-pp",
54
- container: columnRef?.current,
55
- modifiers: [{
56
- name: "preventOverflow",
57
- options: {
58
- boundary: "clippingParents" // Ensure it respects parent boundaries
59
- }
60
- }, {
61
- name: "hide",
62
- options: {
63
- padding: 8 // Adjust padding for visibility
64
- }
65
- }],
54
+ disablePortal: true,
66
55
  children: [/*#__PURE__*/_jsx(Tooltip, {
67
56
  title: "Column Settings",
68
57
  arrow: true,
@@ -305,24 +294,26 @@ const GridItem = props => {
305
294
  },
306
295
  "data-path": path.join(","),
307
296
  "data-info": "handle-outside-editor-click",
308
- children: [!readOnly && /*#__PURE__*/_jsxs("div", {
309
- className: `element-selector ${selected ? "selected" : ""}`,
310
- contentEditable: false,
311
- style: {
312
- zIndex: 1000
313
- },
314
- children: [/*#__PURE__*/_jsx("div", {
315
- className: "element-selector-dots tl",
316
- children: " "
317
- }), /*#__PURE__*/_jsx("div", {
318
- className: "element-selector-dots tr",
319
- children: " "
320
- }), /*#__PURE__*/_jsx("div", {
321
- className: "element-selector-dots bl",
322
- children: " "
323
- }), /*#__PURE__*/_jsx("div", {
324
- className: "element-selector-dots br",
325
- children: " "
297
+ children: [!readOnly && /*#__PURE__*/_jsxs(_Fragment, {
298
+ children: [/*#__PURE__*/_jsxs("div", {
299
+ className: `element-selector ${selected ? "selected" : ""}`,
300
+ contentEditable: false,
301
+ style: {
302
+ zIndex: 1000
303
+ },
304
+ children: [/*#__PURE__*/_jsx("div", {
305
+ className: "element-selector-dots tl",
306
+ children: " "
307
+ }), /*#__PURE__*/_jsx("div", {
308
+ className: "element-selector-dots tr",
309
+ children: " "
310
+ }), /*#__PURE__*/_jsx("div", {
311
+ className: "element-selector-dots bl",
312
+ children: " "
313
+ }), /*#__PURE__*/_jsx("div", {
314
+ className: "element-selector-dots br",
315
+ children: " "
316
+ })]
326
317
  }), /*#__PURE__*/_jsx(GridItemToolbar, {
327
318
  classes: classes,
328
319
  selected: selected,
@@ -12,6 +12,11 @@ const SimpleTextStyle = ({
12
12
  opacity: 0
13
13
  }
14
14
  },
15
+ "&.dataView, &.signature": {
16
+ "& .placeholder-simple-text": {
17
+ opacity: 0
18
+ }
19
+ },
15
20
  "& .placeholder-simple-text": {
16
21
  color: "#94A3B8",
17
22
  background: "transparent",
@@ -1,70 +1,88 @@
1
- const TableStyles = theme => ({
2
- tableToolBar: {
3
- position: "absolute",
4
- top: "-24px",
5
- left: 0,
6
- transition: "all 0.3s",
7
- "& button": {
8
- backgroundColor: theme?.palette?.editor?.background,
9
- border: "1px solid rgba(37, 99, 235, 0.32)",
10
- boxShadow: "0px 0px 10px 0px rgba(0, 0, 0, 0.16)",
11
- borderRadius: "50%",
12
- padding: "4px",
13
- margin: "2px",
14
- "&:hover": {
15
- backgroundColor: theme?.palette?.editor?.background
1
+ const TableStyles = theme => {
2
+ const {
3
+ background,
4
+ closeButtonSvgStroke,
5
+ activeColor,
6
+ signaturePopUpTabButtonSelectedBg,
7
+ signaturePopUpTabButtonSelectedSvg
8
+ } = theme?.palette?.editor || {};
9
+ return {
10
+ tableToolBar: {
11
+ position: "absolute",
12
+ top: "-24px",
13
+ left: 0,
14
+ transition: "all 0.3s",
15
+ "& button": {
16
+ backgroundColor: background,
17
+ border: "1px solid rgba(37, 99, 235, 0.32)",
18
+ boxShadow: "0px 0px 10px 0px rgba(0, 0, 0, 0.16)",
19
+ borderRadius: "50%",
20
+ padding: "4px",
21
+ margin: "2px",
22
+ "&:hover": {
23
+ backgroundColor: background
24
+ },
25
+ "& svg": {
26
+ width: "18px",
27
+ height: "18px",
28
+ "& path": {
29
+ stroke: closeButtonSvgStroke
30
+ }
31
+ },
32
+ "&.selected": {
33
+ outline: `1.5px solid ${activeColor || "#2563EB"}`,
34
+ background: signaturePopUpTabButtonSelectedBg,
35
+ "& svg": {
36
+ "& path": {
37
+ stroke: signaturePopUpTabButtonSelectedSvg
38
+ }
39
+ }
40
+ }
16
41
  },
17
- "& svg": {
18
- width: "18px",
19
- height: "18px",
20
- "& path": {
21
- stroke: theme?.palette?.editor?.closeButtonSvgStroke
42
+ "&.active": {
43
+ width: "auto",
44
+ "& .toggle": {
45
+ rotate: "180deg"
46
+ }
47
+ },
48
+ "& .toolbtn": {
49
+ "& svg": {
50
+ stroke: "rgb(100, 116, 139)"
22
51
  }
23
52
  }
24
53
  },
25
- "&.active": {
26
- width: "auto",
27
- "& .toggle": {
28
- rotate: "180deg"
29
- }
30
- },
31
- "& .toolbtn": {
32
- "& svg": {
33
- stroke: "rgb(100, 116, 139)"
54
+ table: {
55
+ "& td": {
56
+ padding: "8px 8px"
57
+ },
58
+ "& .selection-area-tc": {
59
+ position: "absolute",
60
+ width: "100%",
61
+ height: "100%",
62
+ top: 0,
63
+ left: 0,
64
+ outline: "1px solid #2563EB",
65
+ pointerEvents: "none"
66
+ },
67
+ "& .hide-drag-btn-wrapper": {
68
+ "& .row-drag-btn": {
69
+ display: "none"
70
+ }
34
71
  }
35
- }
36
- },
37
- table: {
38
- "& td": {
39
- padding: "8px 8px"
40
72
  },
41
- "& .selection-area-tc": {
73
+ cellResizer: {
42
74
  position: "absolute",
43
- width: "100%",
44
- height: "100%",
75
+ cursor: "col-resize",
76
+ right: "-2px",
45
77
  top: 0,
46
- left: 0,
47
- outline: "1px solid #2563EB",
48
- pointerEvents: "none"
49
- },
50
- "& .hide-drag-btn-wrapper": {
51
- "& .row-drag-btn": {
52
- display: "none"
78
+ background: "transparent",
79
+ width: "3px",
80
+ borderRadius: "0px",
81
+ zIndex: 1,
82
+ "&:hover": {
83
+ background: "#2563EB"
53
84
  }
54
85
  }
55
- },
56
- cellResizer: {
57
- position: "absolute",
58
- cursor: "col-resize",
59
- right: "-2px",
60
- top: 0,
61
- background: "transparent",
62
- width: "3px",
63
- borderRadius: "0px",
64
- zIndex: 1,
65
- "&:hover": {
66
- background: "#2563EB"
67
- }
68
- }
69
- });
86
+ };
87
+ };
70
88
  export default TableStyles;
@@ -1,17 +1,18 @@
1
1
  import React, { useEffect, useRef, useState } from "react";
2
2
  import { Editor, Transforms } from "slate";
3
3
  import { ReactEditor, useSelected, useSlateStatic } from "slate-react";
4
- import { Box, IconButton, Tooltip, Table as TableComp, TableBody, useTheme, Popper, Fade } from "@mui/material";
4
+ import { Box, IconButton, Tooltip, Table as TableComp, TableBody, useTheme, Popper, Fade, ClickAwayListener } from "@mui/material";
5
5
  import { TableUtil } from "../../utils/table";
6
6
  import TablePopup from "./TablePopup";
7
7
  import { useEditorContext, useEditorSelection } from "../../hooks/useMouseMove";
8
8
  import TableStyles from "./Styles";
9
9
  import "./table.css";
10
10
  import { groupByBreakpoint } from "../../helper/theme";
11
- import useTable, { TableProvider } from "../../hooks/useTable";
11
+ import useTable, { TableProvider, getDefaultTableSelection } from "../../hooks/useTable";
12
12
  import AddRowCol from "./AddRowCol";
13
13
  import TableTool from "./TableTool";
14
14
  import { MoreIcon, SettingsIcon } from "../../assets/svg/TableIcons";
15
+ import { getSelectedCls } from "../../utils/helper";
15
16
  import { jsx as _jsx } from "react/jsx-runtime";
16
17
  import { jsxs as _jsxs } from "react/jsx-runtime";
17
18
  const hideRowDragBtns = (hide, dragRowBtnCls) => {
@@ -20,6 +21,40 @@ const hideRowDragBtns = (hide, dragRowBtnCls) => {
20
21
  rowDragBtns?.forEach(btn => btn.style.display = hide);
21
22
  }
22
23
  };
24
+ const MoreTableSettings = props => {
25
+ const {
26
+ exandTools,
27
+ handleAction,
28
+ editorTheme,
29
+ setExpandTools
30
+ } = props;
31
+ const {
32
+ updateTableSelection
33
+ } = useTable();
34
+ return /*#__PURE__*/_jsx(Popper, {
35
+ open: Boolean(exandTools),
36
+ anchorEl: exandTools,
37
+ contentEditable: false,
38
+ sx: {
39
+ zIndex: 2000
40
+ },
41
+ placement: "bottom-start",
42
+ children: /*#__PURE__*/_jsx(ClickAwayListener, {
43
+ onClickAway: () => setExpandTools(false),
44
+ children: /*#__PURE__*/_jsx("div", {
45
+ children: /*#__PURE__*/_jsx(TableTool, {
46
+ theme: editorTheme,
47
+ handleToolAction: (type, option) => {
48
+ handleAction(type, option);
49
+ if (type === "duplicate") {
50
+ updateTableSelection(getDefaultTableSelection());
51
+ }
52
+ }
53
+ })
54
+ })
55
+ })
56
+ });
57
+ };
23
58
  const ToolBar = props => {
24
59
  const {
25
60
  selected,
@@ -27,7 +62,8 @@ const ToolBar = props => {
27
62
  classes,
28
63
  handleExpand,
29
64
  handleAction,
30
- exandTools
65
+ exandTools,
66
+ openSetttings
31
67
  } = props;
32
68
  const {
33
69
  getSelectedCells
@@ -43,7 +79,7 @@ const ToolBar = props => {
43
79
  arrow: true,
44
80
  onClick: () => handleAction("settings"),
45
81
  children: /*#__PURE__*/_jsx(IconButton, {
46
- className: "toolbtn toggle",
82
+ className: getSelectedCls("toolbtn toggle", openSetttings),
47
83
  children: /*#__PURE__*/_jsx(SettingsIcon, {})
48
84
  })
49
85
  }), /*#__PURE__*/_jsx(Tooltip, {
@@ -51,7 +87,7 @@ const ToolBar = props => {
51
87
  arrow: true,
52
88
  onClick: handleExpand,
53
89
  children: /*#__PURE__*/_jsx(IconButton, {
54
- className: "toolbtn toggle",
90
+ className: getSelectedCls("toolbtn toggle", exandTools),
55
91
  children: /*#__PURE__*/_jsx(MoreIcon, {})
56
92
  })
57
93
  })]
@@ -100,6 +136,7 @@ const Table = props => {
100
136
  break;
101
137
  case "duplicate":
102
138
  table.duplicateTable();
139
+ setExpandTools(false);
103
140
  break;
104
141
  case "settings":
105
142
  if (tableProps) {
@@ -198,7 +235,8 @@ const Table = props => {
198
235
  otherProps: {
199
236
  dragRowBtnCls,
200
237
  tablePath: path,
201
- openSetttings
238
+ openSetttings,
239
+ exandTools
202
240
  },
203
241
  children: [/*#__PURE__*/_jsxs("div", {
204
242
  style: {
@@ -249,28 +287,13 @@ const Table = props => {
249
287
  classes: classes,
250
288
  handleExpand: handleExpand,
251
289
  handleAction: handleAction,
252
- exandTools: exandTools
253
- }), /*#__PURE__*/_jsx(Popper, {
254
- open: Boolean(exandTools),
255
- anchorEl: exandTools,
256
- transition: true,
257
- contentEditable: false,
258
- sx: {
259
- zIndex: 2000
260
- },
261
- placement: "bottom-start",
262
- children: ({
263
- TransitionProps
264
- }) => /*#__PURE__*/_jsx(Fade, {
265
- ...TransitionProps,
266
- timeout: 350,
267
- children: /*#__PURE__*/_jsx("div", {
268
- children: /*#__PURE__*/_jsx(TableTool, {
269
- theme: editorTheme,
270
- handleToolAction: handleAction
271
- })
272
- })
273
- })
290
+ exandTools: exandTools,
291
+ openSetttings: openSetttings
292
+ }), /*#__PURE__*/_jsx(MoreTableSettings, {
293
+ exandTools: exandTools,
294
+ handleAction: handleAction,
295
+ editorTheme: editorTheme,
296
+ setExpandTools: setExpandTools
274
297
  }), openSetttings ? /*#__PURE__*/_jsx(TablePopup, {
275
298
  element: tableProps?.styleProps || {},
276
299
  onSave: onSave,
@@ -87,7 +87,10 @@ const TableCell = props => {
87
87
  const isHeader = path.length >= 2 ? path[path.length - 2] === 0 : false;
88
88
  const [size, onMouseDown, resizing, onLoad] = useTableResize({
89
89
  parentDOM,
90
- size: element?.size
90
+ size: element?.size,
91
+ minMaxProps: {
92
+ minWidth: 30
93
+ }
91
94
  });
92
95
  const [tableSize, setTableSize] = useState({});
93
96
  const [openSettings, setOpenSettings] = useState(false);
@@ -1,8 +1,7 @@
1
1
  import React from "react";
2
2
  import { Select, MenuItem } from "@mui/material";
3
3
  import { addMarkData, activeMark } from "../../utils/SlateUtilityFunctions.js";
4
- import { fontFamilyMap } from "../../utils/font";
5
- import KeyboardArrowDownRoundedIcon from '@mui/icons-material/KeyboardArrowDownRounded';
4
+ import KeyboardArrowDownRoundedIcon from "@mui/icons-material/KeyboardArrowDownRounded";
6
5
  import { jsx as _jsx } from "react/jsx-runtime";
7
6
  const Dropdown = ({
8
7
  classes,
@@ -1,7 +1,6 @@
1
1
  import React, { useState } from "react";
2
2
  import { Grid, Typography, IconButton, Tooltip, TextField, InputAdornment } from "@mui/material";
3
3
  import CloseIcon from "@mui/icons-material/Close";
4
- import OpenInFullIcon from "@mui/icons-material/OpenInFull";
5
4
  import CloseFullscreenIcon from "@mui/icons-material/CloseFullscreen";
6
5
  import Icon from "../../common/Icon";
7
6
  import { ToggleFullScreenIcon } from "../../common/iconListV2";
@@ -68,14 +67,14 @@ const PopperHeader = props => {
68
67
  justifyContent: "end",
69
68
  children: [needFullscreen ? /*#__PURE__*/_jsxs(Grid, {
70
69
  sx: {
71
- position: 'relative'
70
+ position: "relative"
72
71
  },
73
72
  className: "inputField",
74
73
  children: [/*#__PURE__*/_jsx(IconButton, {
75
- className: openSearch ? 'searchContainer' : '',
74
+ className: openSearch ? "searchContainer" : "",
76
75
  onClick: handleSearchButton,
77
76
  children: /*#__PURE__*/_jsx(Icon, {
78
- icon: openSearch ? 'closeIcon' : 'SearchIcon'
77
+ icon: openSearch ? "closeIcon" : "SearchIcon"
79
78
  })
80
79
  }), openSearch && /*#__PURE__*/_jsx(SearchBox, {
81
80
  classes: classes,
@@ -177,11 +177,6 @@ const usePopupStyle = theme => ({
177
177
  justifyContent: "start",
178
178
  borderRadius: "10px !important",
179
179
  transition: "background-color 0.3s ease",
180
- "& .colorBoxElementIcon": {
181
- "& path": {
182
- fill: theme?.palette?.type === "dark" ? "none" : ""
183
- }
184
- },
185
180
  "& .signatureElementIcon": {
186
181
  "& path": {
187
182
  fill: `${theme?.palette?.editor?.closeButtonSvgStroke}`
@@ -21,11 +21,11 @@ import TextIcon from "../assets/svg/TextIcon";
21
21
  import AddElementIcon from "../assets/svg/AddElementIcon";
22
22
  import AddTemplateIcon from "../assets/svg/AddTemplateIcon";
23
23
  import OpenLinkIcon from "../assets/svg/OpenLinkIcon";
24
+ import EditIcon from "@mui/icons-material/Edit";
25
+ import DeleteIcon from "@mui/icons-material/Delete";
24
26
  import { BrainIcon } from "../assets/svg/BrainIcon";
25
27
  import DocsIcon from "../assets/svg/DocsIcon";
26
28
  import UserIcon from "../assets/svg/UserIcon";
27
- import EditIcon from "@mui/icons-material/Edit";
28
- import DeleteIcon from "@mui/icons-material/Delete";
29
29
  import { jsx as _jsx } from "react/jsx-runtime";
30
30
  import { jsxs as _jsxs } from "react/jsx-runtime";
31
31
  const iconList = {
@@ -276,11 +276,11 @@ const iconList = {
276
276
  fill: "#64748B"
277
277
  }
278
278
  }),
279
+ editIcon: /*#__PURE__*/_jsx(EditIcon, {}),
280
+ deleteIcon: /*#__PURE__*/_jsx(DeleteIcon, {}),
279
281
  brain: /*#__PURE__*/_jsx(BrainIcon, {}),
280
282
  docsIcon: /*#__PURE__*/_jsx(DocsIcon, {}),
281
- userIcon: /*#__PURE__*/_jsx(UserIcon, {}),
282
- editIcon: /*#__PURE__*/_jsx(EditIcon, {}),
283
- deleteIcon: /*#__PURE__*/_jsx(DeleteIcon, {})
283
+ userIcon: /*#__PURE__*/_jsx(UserIcon, {})
284
284
  };
285
285
  export const icons = {
286
286
  ...iconList
@@ -3,7 +3,6 @@ const usePopupStyles = theme => ({
3
3
  position: "absolute",
4
4
  zIndex: 1300,
5
5
  borderRadius: "10px",
6
- padding: "0px",
7
6
  boxShadow: "0px 4px 10px 0px #00000029",
8
7
  overflow: "hidden",
9
8
  padding: "8px 0px !important",
@@ -22,7 +22,7 @@ const useGuideLineStyle = ({
22
22
  backgroundColor: "#FFF",
23
23
  pointerEvents: "none",
24
24
  zIndex: 1,
25
- [theme.breakpoints.between("xs", "md")]: {
25
+ [theme?.breakpoints?.between("xs", "md")]: {
26
26
  left: "calc(50% - 160px)"
27
27
  }
28
28
  },
@@ -35,13 +35,13 @@ const useGuideLineStyle = ({
35
35
  backgroundColor: "#FFF",
36
36
  pointerEvents: "none",
37
37
  zIndex: 1,
38
- [theme.breakpoints.between("xs", "md")]: {
38
+ [theme?.breakpoints?.between("xs", "md")]: {
39
39
  left: "calc(50% + 160px)"
40
40
  }
41
41
  },
42
42
  "& .white-wrapper": {
43
43
  overflowX: "hidden",
44
- [theme.breakpoints.between("xs", "md")]: {
44
+ [theme?.breakpoints?.between("xs", "md")]: {
45
45
  position: "absolute",
46
46
  width: "calc(50% - 162px)",
47
47
  height: "calc(100% - 2px)",
@@ -10,7 +10,7 @@ const useShadowElementStyles = ({
10
10
  position: "relative",
11
11
  backgroundColor: "rgba(0,0,0,0)",
12
12
  marginLeft: `calc((100% - 980px) * 0.5)`,
13
- [theme.breakpoints.between("xs", "md")]: {
13
+ [theme?.breakpoints?.between("xs", "md")]: {
14
14
  marginLeft: `calc((100% - 320px) * 0.5)`
15
15
  }
16
16
  }
@@ -8,6 +8,19 @@ import { serializeToText } from "../utils/serializeToText";
8
8
  import { createCopiedTableStructure, getRectangleBounds, tableNodeToDom } from "../Elements/Table/tableHelper";
9
9
  import { jsx as _jsx } from "react/jsx-runtime";
10
10
  import { jsxs as _jsxs } from "react/jsx-runtime";
11
+ const selectFirstCell = (tablePath, editor, updateTableSelection) => {
12
+ const firstCell = [...tablePath, 0, 0];
13
+ const end = Editor.end(editor, firstCell);
14
+ Transforms.select(editor, {
15
+ anchor: end,
16
+ focus: end
17
+ });
18
+ updateTableSelection({
19
+ startCellPath: firstCell,
20
+ endCellPath: [],
21
+ isDragging: false
22
+ });
23
+ };
11
24
  const handleDragEnd = (dragData, editor, resetAll) => {
12
25
  const {
13
26
  active,
@@ -65,7 +78,7 @@ export const TableProvider = ({
65
78
  otherProps = {}
66
79
  }) => {
67
80
  const {
68
- openSetttings
81
+ tablePath
69
82
  } = otherProps;
70
83
  const [hoverPath, setHoverPath] = useState(null);
71
84
  const [tableSelection, setTableSelection] = useState(getDefaultTableSelection());
@@ -105,7 +118,8 @@ export const TableProvider = ({
105
118
  tableSelection,
106
119
  tableResizing,
107
120
  setTableResizing,
108
- otherProps
121
+ otherProps,
122
+ resetAll
109
123
  };
110
124
  }, [hoverPath, editor?.selection, tableSelection, tableResizing]);
111
125
  useEffect(() => {
@@ -171,10 +185,8 @@ export const TableProvider = ({
171
185
  };
172
186
  }, [tableSelection, editor, tableSelection]);
173
187
  useEffect(() => {
174
- if (!openSetttings) {
175
- resetAll();
176
- }
177
- }, [openSetttings]);
188
+ selectFirstCell(tablePath, editor, updateTableSelection);
189
+ }, []);
178
190
  return /*#__PURE__*/_jsx(TableContext.Provider, {
179
191
  value: values,
180
192
  children: /*#__PURE__*/_jsxs(DndContext, {
@@ -2,7 +2,8 @@ import { useState } from "react";
2
2
  const useTableResize = ({
3
3
  parentDOM,
4
4
  size: defaultSize,
5
- onDone
5
+ onDone,
6
+ minMaxProps = {}
6
7
  }) => {
7
8
  const {
8
9
  width
@@ -38,10 +39,13 @@ const useTableResize = ({
38
39
  setIsDone(1);
39
40
  };
40
41
  const onMouseMove = e => {
42
+ const {
43
+ minWidth
44
+ } = minMaxProps || {};
41
45
  setSize(currentSize => {
42
46
  const calcWidth = currentSize?.width + e.movementX;
43
47
  return {
44
- width: calcWidth,
48
+ width: minWidth && calcWidth < minWidth ? minWidth : calcWidth,
45
49
  height: currentSize.height + e.movementY,
46
50
  widthInPercent: calcWidth / width * 100
47
51
  };
@@ -676,4 +676,7 @@ export function getInitialValue(value = [], readOnly) {
676
676
  return newValue;
677
677
  }
678
678
  return value;
679
+ }
680
+ export function getSelectedCls(defaultCls = "", selected, selectedClsName = "selected") {
681
+ return `${defaultCls} ${selected ? selectedClsName : ""}`;
679
682
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@flozy/editor",
3
- "version": "5.1.6",
3
+ "version": "5.1.8",
4
4
  "description": "An Editor for flozy app brain",
5
5
  "files": [
6
6
  "dist"