@flozy/editor 8.0.3 → 8.0.5

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.
@@ -1,6 +1,6 @@
1
1
  import React, { useCallback, useMemo, useRef, useState, useImperativeHandle, forwardRef } from "react";
2
- import { Editable, Slate, ReactEditor } from "slate-react";
3
- import { createEditor, Transforms, Editor } from "slate";
2
+ import { Editable, Slate, ReactEditor } from 'slate-react';
3
+ import { createEditor, Transforms, Editor } from 'slate';
4
4
  import withCommon from "./hooks/withCommon";
5
5
  import { getBlock, getMarked, serializeMentions } from "./utils/chatEditor/SlateUtilityFunctions";
6
6
  import MiniTextFormat from "./Toolbar/PopupTool/MiniTextFormat";
@@ -35,13 +35,13 @@ const ChatEditor = /*#__PURE__*/forwardRef((props, ref) => {
35
35
  const classes = usePopupStyle(theme);
36
36
  const convertedContent = draftToSlate({
37
37
  data: content && content?.length > 0 ? content : [{
38
- type: "paragraph",
38
+ type: 'paragraph',
39
39
  children: [{
40
- text: ""
40
+ text: ''
41
41
  }]
42
42
  }]
43
43
  });
44
- const [value] = useState(convertedContent);
44
+ const [value, setValue] = useState(convertedContent);
45
45
  const debouncedValue = useRef(value);
46
46
  const debounced = useDebouncedCallback(
47
47
  // function
@@ -142,6 +142,7 @@ const ChatEditor = /*#__PURE__*/forwardRef((props, ref) => {
142
142
  const mentionsRef = useRef();
143
143
  const customProps = {
144
144
  ...(otherProps || {}),
145
+ hideTools: ["settings", "add_column", "drag", "resize"],
145
146
  readOnly: isReadOnly,
146
147
  editorPlaceholder: "Write Something",
147
148
  page_id: 1
@@ -216,7 +217,7 @@ const ChatEditor = /*#__PURE__*/forwardRef((props, ref) => {
216
217
  editor
217
218
  });
218
219
  } else if (event.key === "Enter" && !isMobile) {
219
- const isEmpty = debouncedValue?.current.length === 1 && debouncedValue?.current[0].type === "paragraph" && debouncedValue?.current[0].children.length === 1 && debouncedValue?.current[0].children[0].text === "";
220
+ const isEmpty = debouncedValue?.current.length === 1 && debouncedValue?.current[0].type === 'paragraph' && debouncedValue?.current[0].children.length === 1 && debouncedValue?.current[0].children[0].text === '';
220
221
  if (isEmpty) {
221
222
  event.preventDefault();
222
223
  return;
@@ -16,7 +16,10 @@ const ColumnView = props => {
16
16
  selected,
17
17
  readOnly
18
18
  } = props;
19
- const DataType = DataTypes[property?.type] || DataTypes["text"];
19
+ const {
20
+ type
21
+ } = property;
22
+ const DataType = DataTypes[type] || DataTypes["text"];
20
23
  const anchorRef = useRef(null);
21
24
  const [anchorEl, setAnchorEl] = useState(null);
22
25
  const [popperRefresh, setPopperRefresh] = useState(new Date().getTime());
@@ -153,11 +153,9 @@ export default function Select(props) {
153
153
  ...optionProps,
154
154
  children: /*#__PURE__*/_jsx(Chip, {
155
155
  label: option.label || option.value || "",
156
+ classes: classes.chipText,
156
157
  sx: {
157
- background: option.color || appTheme?.palette?.editor?.tv_border1,
158
- "& .MuiChip-label": {
159
- paddingLeft: "12px !important"
160
- }
158
+ background: option.color || appTheme?.palette?.editor?.tv_border1
161
159
  },
162
160
  avatar: /*#__PURE__*/_jsx(AvatarIcon, {
163
161
  option: option,
@@ -172,6 +170,7 @@ export default function Select(props) {
172
170
  fullWidth: true,
173
171
  renderInput: params => {
174
172
  return /*#__PURE__*/_jsx(TextField, {
173
+ fullWidth: true,
175
174
  size: "small",
176
175
  ...params,
177
176
  placeholder: placeholder
@@ -3,7 +3,7 @@ const useCompStyles = (theme, appTheme) => ({
3
3
  border: `1px solid ${appTheme?.palette?.editor?.tv_border}`,
4
4
  background: appTheme?.palette?.editor?.tv_pop_bg,
5
5
  color: appTheme?.palette?.editor?.tv_text,
6
- fontSize: '14px',
6
+ fontSize: "14px",
7
7
  borderRadius: "8px",
8
8
  [theme?.breakpoints?.between("xs", "md")]: {},
9
9
  "& ul": {
@@ -63,6 +63,11 @@ const useCompStyles = (theme, appTheme) => ({
63
63
  }
64
64
  }
65
65
  }
66
+ },
67
+ chipText: {
68
+ "& .MuiChip-label": {
69
+ paddingLeft: "12px !important"
70
+ }
66
71
  }
67
72
  });
68
73
  export default useCompStyles;
@@ -1,7 +1,7 @@
1
1
  import React from "react";
2
2
  import DatePicker from "react-datepicker";
3
- import { useDataView } from "../../Providers/DataViewProvider";
4
3
  import { Grid } from "@mui/material";
4
+ import { useDataView } from "../../Providers/DataViewProvider";
5
5
  import useCommonStyle from "../../../../commonStyle";
6
6
  import { useEditorContext } from "../../../../hooks/useMouseMove";
7
7
  import { jsx as _jsx } from "react/jsx-runtime";
@@ -11,6 +11,7 @@ const useTableStyles = (theme, appTheme) => ({
11
11
  borderRadius: "7px 7px 0px 0px",
12
12
  overflow: "hidden",
13
13
  border: `1px solid ${appTheme?.palette?.editor?.tv_border}`,
14
+ tableLayout: "fixed",
14
15
  "& thead": {
15
16
  background: appTheme?.palette?.editor?.tv_header,
16
17
  height: "40px"
@@ -40,6 +41,11 @@ const useTableStyles = (theme, appTheme) => ({
40
41
  "& th, tr, td": {
41
42
  border: `1px solid ${appTheme?.palette?.editor?.tv_border}`
42
43
  },
44
+ "& th, & td": {
45
+ overflowX: "clip",
46
+ textOverflow: "ellipsis",
47
+ whiteSpace: "nowrap"
48
+ },
43
49
  "& .tv-act-btn": {
44
50
  color: appTheme?.palette?.editor?.tv_text,
45
51
  textTransform: "none",
@@ -86,13 +92,18 @@ const useTableStyles = (theme, appTheme) => ({
86
92
  paddingTop: "3px",
87
93
  paddingBottom: "3px",
88
94
  paddingLeft: "3px",
89
- maxWidth: "250px",
95
+ // maxWidth: "250px",
90
96
  overflow: "hidden",
91
97
  position: "relative",
92
98
  "& .tv-ms-tag-wrpr": {
93
99
  display: "flex",
94
100
  flexWrap: "nowrap",
95
- overflow: "auto"
101
+ overflow: "auto",
102
+ minWidth: "58px",
103
+ "& .MuiChip-deleteIcon": {
104
+ minWidth: "22px",
105
+ minHeight: "22px"
106
+ }
96
107
  },
97
108
  "&.Mui-disabled": {
98
109
  "& input": {
@@ -60,6 +60,7 @@ const SortIcon = props => {
60
60
  };
61
61
  const THead = props => {
62
62
  const thRef = useRef(null);
63
+ const [headerTextWidth, setHeaderTextWidth] = useState(200);
63
64
  const {
64
65
  iconType,
65
66
  isSort,
@@ -77,6 +78,13 @@ const THead = props => {
77
78
  minWidth: 30
78
79
  }
79
80
  });
81
+ const finalWidth = size?.width < headerTextWidth ? headerTextWidth : size?.width || 200;
82
+ useEffect(() => {
83
+ if (thRef?.current) {
84
+ const tw = (thRef?.current?.querySelectorAll(".dht-text")[0]?.getBoundingClientRect()?.width || 0) + 16 + 30;
85
+ setHeaderTextWidth(tw);
86
+ }
87
+ }, [thRef?.current, m?.label]);
80
88
  useEffect(() => {
81
89
  if (isDone) {
82
90
  handleResize({
@@ -87,9 +95,9 @@ const THead = props => {
87
95
  }, [isDone]);
88
96
  return /*#__PURE__*/_jsxs("th", {
89
97
  style: {
90
- minWidth: size?.width || 200,
91
- maxWidth: size?.width || 200,
92
- width: size?.width || 200
98
+ minWidth: finalWidth,
99
+ maxWidth: finalWidth,
100
+ width: finalWidth
93
101
  },
94
102
  ref: thRef,
95
103
  children: [/*#__PURE__*/_jsx(Box, {
@@ -107,7 +115,10 @@ const THead = props => {
107
115
  }),
108
116
  fullWidth: true,
109
117
  onClick: onEditProperty(m),
110
- children: m.label
118
+ children: /*#__PURE__*/_jsx("span", {
119
+ className: "dht-text",
120
+ children: m.label
121
+ })
111
122
  })
112
123
  }), /*#__PURE__*/_jsx(Resizer, {
113
124
  classes: classes,
@@ -133,7 +133,8 @@ const Table = props => {
133
133
  const classes = TableStyles(editorTheme);
134
134
  const {
135
135
  readOnly,
136
- isMobile
136
+ isMobile,
137
+ hideTools = []
137
138
  } = customProps;
138
139
  const [openSetttings, setOpenSettings] = useState(false);
139
140
  const [exandTools, setExpandTools] = useState(null);
@@ -304,16 +305,16 @@ const Table = props => {
304
305
  ...attributes,
305
306
  children: children
306
307
  })
307
- }), /*#__PURE__*/_jsx(AddRowCol, {
308
+ }), !hideTools.includes("add_column") && /*#__PURE__*/_jsx(AddRowCol, {
308
309
  ...commonAddBtnProps,
309
310
  addType: "col",
310
311
  onAdd: addCol
311
312
  })]
312
- }), /*#__PURE__*/_jsx(AddRowCol, {
313
+ }), !hideTools.includes("add_column") && /*#__PURE__*/_jsx(AddRowCol, {
313
314
  ...commonAddBtnProps,
314
315
  addType: "row",
315
316
  onAdd: addRow
316
- }), !readOnly && /*#__PURE__*/_jsx(ToolBar, {
317
+ }), !readOnly && !hideTools.includes("settings") && /*#__PURE__*/_jsx(ToolBar, {
317
318
  selected: selected,
318
319
  showTool: showTool,
319
320
  classes: classes,
@@ -48,7 +48,8 @@ const TableCell = props => {
48
48
  customProps
49
49
  } = props;
50
50
  const {
51
- readOnly
51
+ readOnly,
52
+ hideTools = []
52
53
  } = customProps;
53
54
  const isMobile = window.matchMedia("(max-width: 899px)")?.matches || false;
54
55
  const {
@@ -106,8 +107,8 @@ const TableCell = props => {
106
107
  const isFirstRow = row === 0;
107
108
  const isFirstColumn = column === 0;
108
109
  const [hoverRow, hoverCol] = hoverPath ? hoverPath.slice(-2) : [];
109
- const showColDrag = isFirstRow && hoverCol === column && !resizing && !readOnly;
110
- const showRowDrag = isFirstColumn && hoverRow === row && !resizing && !readOnly;
110
+ const showColDrag = isFirstRow && hoverCol === column && !resizing && !readOnly && !hideTools.includes("drag");
111
+ const showRowDrag = isFirstColumn && hoverRow === row && !resizing && !readOnly && !hideTools.includes("drag");
111
112
  const [parentProps] = tableNode || [{}];
112
113
  const [rowProps] = rowNode || [{}];
113
114
  const tableDOM = table.getDOMNode(path, true);
@@ -67,6 +67,7 @@ const MiniToolbar = props => {
67
67
  if (data) {
68
68
  setToolTip(false);
69
69
  setData(null);
70
+ setPopper(null);
70
71
  }
71
72
  }, [data]);
72
73
  useEffect(() => {
@@ -238,9 +238,9 @@ const withHtml = editor => {
238
238
  const isNonText = rootElement ? rootElement?.querySelector(NON_TEXT_TAGS.toString()) : false;
239
239
  const isGoogleSheet = parsed.body.querySelector("google-sheets-html-origin");
240
240
  if (isGoogleSheet) {
241
- if (editor.isChatEditor) {
242
- return;
243
- }
241
+ // if (editor.isChatEditor) {
242
+ // return;
243
+ // }
244
244
  const table = rootElement.querySelector("table");
245
245
  const colGrp = table.querySelector("colgroup");
246
246
  if (colGrp) {
@@ -256,15 +256,18 @@ const withHtml = editor => {
256
256
  }
257
257
  const fragment = deserialize(parsed.body);
258
258
  const formattedFragment = formatFragment[eltype] ? formatFragment[eltype](fragment) : fragment;
259
- let is_img_table = false;
260
- formattedFragment.map(f => {
261
- if (f.type === "image" || f?.type?.includes("table")) {
262
- is_img_table = true;
263
- }
264
- });
265
- if (editor.isChatEditor && is_img_table) {
266
- return;
267
- }
259
+
260
+ // let is_img_table = false;
261
+ // formattedFragment.map((f) => {
262
+ // if (f.type === "image" || f?.type?.includes("table")) {
263
+ // is_img_table = true;
264
+ // }
265
+ // });
266
+
267
+ // if (editor.isChatEditor && is_img_table) {
268
+ // return;
269
+ // }
270
+
268
271
  if (isTitlePath && isNonText) {
269
272
  insertAtNextNode(editor, formattedFragment);
270
273
  return;
@@ -8,6 +8,9 @@ import { isEmptyTextNode } from "../../helper";
8
8
  import { getBreakPointsValue } from "../../helper/theme";
9
9
  import insertNewLine from "../insertNewLine";
10
10
  import { getBorderColor } from "../helper";
11
+ import Table from "../../Elements/Table/Table";
12
+ import TableRow from "../../Elements/Table/TableRow";
13
+ import TableCell from "../../Elements/Table/TableCell";
11
14
  import { jsx as _jsx } from "react/jsx-runtime";
12
15
  const alignment = ["alignLeft", "alignRight", "alignCenter"];
13
16
  const list_types = ["orderedList", "unorderedList"];
@@ -406,6 +409,26 @@ export const getBlock = props => {
406
409
  return /*#__PURE__*/_jsx(Mentions, {
407
410
  ...props
408
411
  });
412
+ case "table":
413
+ return /*#__PURE__*/_jsx(Table, {
414
+ ...props
415
+ });
416
+ case "table-head":
417
+ return /*#__PURE__*/_jsx("thead", {
418
+ children: children
419
+ });
420
+ case "table-body":
421
+ return /*#__PURE__*/_jsx("tbody", {
422
+ children: children
423
+ });
424
+ case "table-row":
425
+ return /*#__PURE__*/_jsx(TableRow, {
426
+ ...props
427
+ });
428
+ case "table-cell":
429
+ return /*#__PURE__*/_jsx(TableCell, {
430
+ ...props
431
+ });
409
432
  default:
410
433
  return /*#__PURE__*/_jsx(SimpleText, {
411
434
  ...props,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@flozy/editor",
3
- "version": "8.0.3",
3
+ "version": "8.0.5",
4
4
  "description": "An Editor for flozy app brain",
5
5
  "files": [
6
6
  "dist"