@flozy/editor 9.9.1 → 9.9.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.
@@ -30,6 +30,7 @@ const SearchButton = /*#__PURE__*/forwardRef((props, ref) => {
30
30
  const [skip, setSkip] = useState(0);
31
31
  const [search, setSearch] = useState("");
32
32
  const [isLoading, setIsLoading] = useState(false);
33
+ const [total, setTotal] = useState(0);
33
34
  const [debouncedSearch] = useDebounce(search, 300);
34
35
  const limit = 20;
35
36
  const observer = useRef();
@@ -63,24 +64,24 @@ const SearchButton = /*#__PURE__*/forwardRef((props, ref) => {
63
64
  }
64
65
  };
65
66
  useEffect(() => {
66
- getDocs({
67
- debouncedSearch,
68
- skip,
69
- limit,
70
- current_doc_id: currentId
71
- });
67
+ getDocs();
72
68
  }, [skip, debouncedSearch]);
73
69
  const getDocs = async () => {
70
+ if (isLoading) return;
71
+ if (total > 0 && mapData?.length >= total) return;
74
72
  setIsLoading(true);
75
73
  try {
76
74
  if (otherProps?.services) {
77
75
  const result = await otherProps?.services("getDocs", {
78
76
  skip,
79
77
  limit,
80
- search,
78
+ search: debouncedSearch,
81
79
  current_doc_id: currentId
82
80
  });
83
- setMapData(prev => skip === 0 ? result.data : [...prev, ...result.data]);
81
+ const docs = result?.data?.docs || [];
82
+ const totalCount = result?.data?.total || 0;
83
+ setMapData(prev => skip === 0 ? docs : [...prev, ...docs]);
84
+ setTotal(totalCount);
84
85
  }
85
86
  } catch (error) {
86
87
  console.error("Error fetching documents:", error);
@@ -259,7 +259,7 @@ const SearchAndDocList = ({
259
259
  xs: 12,
260
260
  children: /*#__PURE__*/_jsx(Typography, {
261
261
  sx: {
262
- display: mapData?.length === 0 ? 'flex' : 'none',
262
+ display: mapData?.length === 0 && !isLoading ? 'flex' : 'none',
263
263
  alignItems: "center",
264
264
  justifyContent: "center",
265
265
  color: theme?.palette?.text?.secondary,
@@ -269,15 +269,17 @@ const SearchAndDocList = ({
269
269
  },
270
270
  children: "No docs"
271
271
  })
272
- }), isLoading && /*#__PURE__*/_jsx(Grid, {
272
+ }), /*#__PURE__*/_jsx(Grid, {
273
273
  item: true,
274
+ xs: 12,
274
275
  sx: {
275
- display: "flex",
276
+ display: isLoading ? 'flex' : 'none',
277
+ alignItems: "center",
276
278
  justifyContent: "center",
277
- alignItems: 'center',
278
- minHeight: '400px',
279
- padding: '0px 16px 8px',
280
- position: 'absolute'
279
+ color: theme?.palette?.text?.secondary,
280
+ fontSize: '12px',
281
+ padding: '20px',
282
+ fontWeight: 700
281
283
  },
282
284
  children: /*#__PURE__*/_jsx(CircularProgress, {})
283
285
  })]
@@ -215,7 +215,8 @@ const MiniToolbar = props => {
215
215
  setPopper: setPopper,
216
216
  onClose: onClose,
217
217
  search: search,
218
- onSearch: onSearch
218
+ onSearch: onSearch,
219
+ closeMainPopup: onClose
219
220
  })]
220
221
  }) : null
221
222
  })]
@@ -147,7 +147,8 @@ export function getTextSizeVal(editor) {
147
147
  const currentElement = ReactEditor.toDOMNode(editor, currentNode);
148
148
  if (currentElement) {
149
149
  const element = currentElement.querySelector('span[data-slate-string="true"]');
150
- return getElementProperty(element, "font-size");
150
+ const fontSize = getElementProperty(element, "font-size");
151
+ return fontSize || 16;
151
152
  }
152
153
  } catch (err) {
153
154
  // console.log(err);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@flozy/editor",
3
- "version": "9.9.1",
3
+ "version": "9.9.3",
4
4
  "description": "An Editor for flozy app brain",
5
5
  "files": [
6
6
  "dist"