@lobehub/chat 0.159.1 → 0.159.2

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.
package/CHANGELOG.md CHANGED
@@ -2,6 +2,31 @@
2
2
 
3
3
  # Changelog
4
4
 
5
+ ### [Version 0.159.2](https://github.com/lobehub/lobe-chat/compare/v0.159.1...v0.159.2)
6
+
7
+ <sup>Released on **2024-05-14**</sup>
8
+
9
+ #### 🐛 Bug Fixes
10
+
11
+ - **misc**: Dragging text mistakenly as image.
12
+
13
+ <br/>
14
+
15
+ <details>
16
+ <summary><kbd>Improvements and Fixes</kbd></summary>
17
+
18
+ #### What's fixed
19
+
20
+ - **misc**: Dragging text mistakenly as image, closes [#2111](https://github.com/lobehub/lobe-chat/issues/2111) ([3c047ef](https://github.com/lobehub/lobe-chat/commit/3c047ef))
21
+
22
+ </details>
23
+
24
+ <div align="right">
25
+
26
+ [![](https://img.shields.io/badge/-BACK_TO_TOP-151515?style=flat-square)](#readme-top)
27
+
28
+ </div>
29
+
5
30
  ### [Version 0.159.1](https://github.com/lobehub/lobe-chat/compare/v0.159.0...v0.159.1)
6
31
 
7
32
  <sup>Released on **2024-05-14**</sup>
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lobehub/chat",
3
- "version": "0.159.1",
3
+ "version": "0.159.2",
4
4
  "description": "Lobe Chat - an open-source, high-performance chatbot framework that supports speech synthesis, multimodal, and extensible Function Call plugin system. Supports one-click free deployment of your private ChatGPT/LLM web application.",
5
5
  "keywords": [
6
6
  "framework",
@@ -61,7 +61,12 @@ const useStyles = createStyles(({ css, token, stylish }) => {
61
61
  });
62
62
 
63
63
  const handleDragOver = (e: DragEvent) => {
64
- e.preventDefault();
64
+ if (!e.dataTransfer?.items || e.dataTransfer.items.length === 0) return;
65
+
66
+ const isFile = e.dataTransfer.types.includes('Files');
67
+ if (isFile) {
68
+ e.preventDefault();
69
+ }
65
70
  };
66
71
 
67
72
  const DragUpload = memo(() => {
@@ -92,43 +97,55 @@ const DragUpload = memo(() => {
92
97
  };
93
98
 
94
99
  const handleDragEnter = (e: DragEvent) => {
95
- e.preventDefault();
100
+ if (!e.dataTransfer?.items || e.dataTransfer.items.length === 0) return;
96
101
 
97
- dragCounter.current += 1;
98
- if (e.dataTransfer?.items && e.dataTransfer.items.length > 0) {
102
+ const isFile = e.dataTransfer.types.includes('Files');
103
+ if (isFile) {
104
+ dragCounter.current += 1;
105
+ e.preventDefault();
99
106
  setIsDragging(true);
100
107
  }
101
108
  };
102
109
 
103
110
  const handleDragLeave = (e: DragEvent) => {
104
- e.preventDefault();
111
+ if (!e.dataTransfer?.items || e.dataTransfer.items.length === 0) return;
105
112
 
106
- // reset counter
107
- dragCounter.current -= 1;
113
+ const isFile = e.dataTransfer.types.includes('Files');
114
+ if (isFile) {
115
+ e.preventDefault();
108
116
 
109
- if (dragCounter.current === 0) {
110
- setIsDragging(false);
117
+ // reset counter
118
+ dragCounter.current -= 1;
119
+
120
+ if (dragCounter.current === 0) {
121
+ setIsDragging(false);
122
+ }
111
123
  }
112
124
  };
113
125
 
114
126
  const handleDrop = async (e: DragEvent) => {
115
- e.preventDefault();
116
- // reset counter
117
- dragCounter.current = 0;
127
+ if (!e.dataTransfer?.items || e.dataTransfer.items.length === 0) return;
118
128
 
119
- setIsDragging(false);
129
+ const isFile = e.dataTransfer.types.includes('Files');
130
+ if (isFile) {
131
+ e.preventDefault();
120
132
 
121
- // get filesList
122
- // TODO: support folder files upload
123
- const files = e.dataTransfer?.files;
133
+ // reset counter
134
+ dragCounter.current = 0;
124
135
 
125
- // upload files
126
- uploadImages(files);
136
+ setIsDragging(false);
137
+
138
+ // get filesList
139
+ // TODO: support folder files upload
140
+ const files = e.dataTransfer?.files;
141
+
142
+ // upload files
143
+ uploadImages(files);
144
+ }
127
145
  };
128
146
 
129
147
  const handlePaste = (event: ClipboardEvent) => {
130
148
  // get files from clipboard
131
-
132
149
  const files = event.clipboardData?.files;
133
150
 
134
151
  uploadImages(files);