@flozy/editor 9.1.1 → 9.1.3

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.
@@ -82,6 +82,14 @@ const ChatEditor = /*#__PURE__*/forwardRef((props, ref) => {
82
82
  // Focus enable
83
83
  enableFocus: () => {
84
84
  if (editor) {
85
+ if (editor.children.length === 0) {
86
+ Transforms.insertNodes(editor, {
87
+ type: "paragraph",
88
+ children: [{
89
+ text: ""
90
+ }]
91
+ });
92
+ }
85
93
  const position = {
86
94
  anchor: {
87
95
  path: [0],
@@ -179,6 +187,14 @@ const ChatEditor = /*#__PURE__*/forwardRef((props, ref) => {
179
187
  });
180
188
  };
181
189
  const handleEditorChange = newValue => {
190
+ if (editor.children.length === 0) {
191
+ Transforms.insertNodes(editor, {
192
+ type: "paragraph",
193
+ children: [{
194
+ text: ""
195
+ }]
196
+ });
197
+ }
182
198
  debounced(newValue);
183
199
  debouncedValue.current = newValue;
184
200
  };
@@ -12,9 +12,11 @@ import useTable, { TableProvider, getDefaultTableSelection } from "../../hooks/u
12
12
  import AddRowCol from "./AddRowCol";
13
13
  import TableTool from "./TableTool";
14
14
  import { MoreIcon, SettingsIcon } from "../../assets/svg/TableIcons";
15
+ import { DeleteIcon } from "../../assets/svg/AIIcons";
15
16
  import { getSelectedCls } from "../../utils/helper";
16
17
  import SwipeableDrawerComponent from "../../common/SwipeableDrawer";
17
18
  import { jsx as _jsx } from "react/jsx-runtime";
19
+ import { Fragment as _Fragment } from "react/jsx-runtime";
18
20
  import { jsxs as _jsxs } from "react/jsx-runtime";
19
21
  const hideRowDragBtns = (hide, dragRowBtnCls) => {
20
22
  const rowDragBtns = document.querySelectorAll(`.${dragRowBtnCls}`);
@@ -30,14 +32,16 @@ const ToolTableComponent = props => {
30
32
  const {
31
33
  updateTableSelection
32
34
  } = useTable();
33
- return /*#__PURE__*/_jsx(TableTool, {
34
- theme: editorTheme,
35
- handleToolAction: (type, option) => {
36
- handleAction(type, option);
37
- if (type === "duplicate") {
38
- updateTableSelection(getDefaultTableSelection());
35
+ return /*#__PURE__*/_jsx("div", {
36
+ children: /*#__PURE__*/_jsx(TableTool, {
37
+ theme: editorTheme,
38
+ handleToolAction: (type, option) => {
39
+ handleAction(type, option);
40
+ if (type === "duplicate") {
41
+ updateTableSelection(getDefaultTableSelection());
42
+ }
39
43
  }
40
- }
44
+ })
41
45
  });
42
46
  };
43
47
  const MoreTableSettings = props => {
@@ -89,34 +93,44 @@ const ToolBar = props => {
89
93
  handleExpand,
90
94
  handleAction,
91
95
  exandTools,
92
- openSetttings
96
+ openSetttings,
97
+ hideTools
93
98
  } = props;
94
99
  const {
95
100
  getSelectedCells
96
101
  } = useTable();
97
102
  const viewTool = selected && !showTool && getSelectedCells()?.length <= 1;
98
- return viewTool ? /*#__PURE__*/_jsxs(Box, {
103
+ return viewTool ? /*#__PURE__*/_jsx(Box, {
99
104
  component: "div",
100
105
  contentEditable: false,
101
106
  className: `tableToolBar ${exandTools ? "active" : ""}`,
102
107
  sx: classes.tableToolBar,
103
- children: [/*#__PURE__*/_jsx(Tooltip, {
104
- title: "Settings",
105
- arrow: true,
106
- onClick: () => handleAction("settings"),
107
- children: /*#__PURE__*/_jsx(IconButton, {
108
- className: getSelectedCls("toolbtn toggle", openSetttings),
109
- children: /*#__PURE__*/_jsx(SettingsIcon, {})
110
- })
111
- }), /*#__PURE__*/_jsx(Tooltip, {
112
- title: "Show Tools",
108
+ children: !hideTools.includes("settings") ? /*#__PURE__*/_jsxs(_Fragment, {
109
+ children: [/*#__PURE__*/_jsx(Tooltip, {
110
+ title: "Settings",
111
+ arrow: true,
112
+ onClick: () => handleAction("settings"),
113
+ children: /*#__PURE__*/_jsx(IconButton, {
114
+ className: getSelectedCls("toolbtn toggle", openSetttings),
115
+ children: /*#__PURE__*/_jsx(SettingsIcon, {})
116
+ })
117
+ }), /*#__PURE__*/_jsx(Tooltip, {
118
+ title: "Show Tools",
119
+ arrow: true,
120
+ onClick: handleExpand,
121
+ children: /*#__PURE__*/_jsx(IconButton, {
122
+ className: getSelectedCls("toolbtn toggle", exandTools),
123
+ children: /*#__PURE__*/_jsx(MoreIcon, {})
124
+ })
125
+ })]
126
+ }) : /*#__PURE__*/_jsx(Tooltip, {
127
+ title: "Delete",
113
128
  arrow: true,
114
- onClick: handleExpand,
129
+ onClick: () => handleAction("delete"),
115
130
  children: /*#__PURE__*/_jsx(IconButton, {
116
- className: getSelectedCls("toolbtn toggle", exandTools),
117
- children: /*#__PURE__*/_jsx(MoreIcon, {})
131
+ children: /*#__PURE__*/_jsx(DeleteIcon, {})
118
132
  })
119
- })]
133
+ })
120
134
  }) : null;
121
135
  };
122
136
  const Table = props => {
@@ -314,14 +328,15 @@ const Table = props => {
314
328
  ...commonAddBtnProps,
315
329
  addType: "row",
316
330
  onAdd: addRow
317
- }), !readOnly && !hideTools.includes("settings") && /*#__PURE__*/_jsx(ToolBar, {
331
+ }), !readOnly && /*#__PURE__*/_jsx(ToolBar, {
318
332
  selected: selected,
319
333
  showTool: showTool,
320
334
  classes: classes,
321
335
  handleExpand: handleExpand,
322
336
  handleAction: handleAction,
323
337
  exandTools: exandTools,
324
- openSetttings: openSetttings
338
+ openSetttings: openSetttings,
339
+ hideTools: hideTools
325
340
  }), /*#__PURE__*/_jsx(MoreTableSettings, {
326
341
  exandTools: exandTools,
327
342
  handleAction: handleAction,
@@ -174,6 +174,14 @@ export class TableUtil {
174
174
  Transforms.removeNodes(this.editor, {
175
175
  match: n => !Editor.isEditor(n) && Element.isElement(n) && n.type === "table"
176
176
  });
177
+ if (this.editor.children.length === 0) {
178
+ Transforms.insertNodes(this.editor, {
179
+ type: "paragraph",
180
+ children: [{
181
+ text: ""
182
+ }]
183
+ });
184
+ }
177
185
  }
178
186
  };
179
187
  duplicateTable = () => {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@flozy/editor",
3
- "version": "9.1.1",
3
+ "version": "9.1.3",
4
4
  "description": "An Editor for flozy app brain",
5
5
  "files": [
6
6
  "dist"