@myun/gimi-chat 0.9.25 → 0.9.26
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/dist/components/chat-input/index.js +41 -6
- package/dist/components/chat-input/index.module.css +2 -2
- package/dist/components/file-upload/index.d.ts +1 -0
- package/dist/components/file-upload/index.js +13 -2
- package/dist/components/upload-list/ImageFile.js +1 -1
- package/dist/components/upload-list/imageFile.module.css +6 -0
- package/dist/umd/index.min.js +1 -1
- package/package.json +1 -1
|
@@ -181,6 +181,41 @@ var ChatInput = /*#__PURE__*/React.forwardRef(function (props, ref) {
|
|
|
181
181
|
handleQuickInput(props.asrText, false);
|
|
182
182
|
}
|
|
183
183
|
}, [props.asrText, props.isRecording, props.isVoiceGetting, handleQuickInput]);
|
|
184
|
+
|
|
185
|
+
// 粘贴图片支持
|
|
186
|
+
React.useEffect(function () {
|
|
187
|
+
var el = inputWrapRef.current;
|
|
188
|
+
if (!el) return;
|
|
189
|
+
var handlePaste = function handlePaste(e) {
|
|
190
|
+
var _e$clipboardData, _agentObjRef$current, _fileList$length, _uploadFileRef$curren;
|
|
191
|
+
var items = Array.from(((_e$clipboardData = e.clipboardData) === null || _e$clipboardData === void 0 ? void 0 : _e$clipboardData.items) || []);
|
|
192
|
+
var imageItem = items.find(function (item) {
|
|
193
|
+
return item.kind === 'file' && item.type.startsWith('image/');
|
|
194
|
+
});
|
|
195
|
+
if (!imageItem) return;
|
|
196
|
+
|
|
197
|
+
// 有图片时阻止 tiptap 默认行为(避免图片被插入编辑器)
|
|
198
|
+
e.stopPropagation();
|
|
199
|
+
e.preventDefault();
|
|
200
|
+
|
|
201
|
+
// 前置校验:上传功能是否开启
|
|
202
|
+
if (!props.enableFileUpload || ((_agentObjRef$current = agentObjRef.current) === null || _agentObjRef$current === void 0 ? void 0 : _agentObjRef$current.openUploadFile) === 0) return;
|
|
203
|
+
if (props.disabled || isAskProcess) return;
|
|
204
|
+
if (((_fileList$length = fileList === null || fileList === void 0 ? void 0 : fileList.length) !== null && _fileList$length !== void 0 ? _fileList$length : 0) >= 10) {
|
|
205
|
+
Toast.info(t('chatInput.uploadLimitTen'));
|
|
206
|
+
return;
|
|
207
|
+
}
|
|
208
|
+
var file = imageItem.getAsFile();
|
|
209
|
+
if (!file) return;
|
|
210
|
+
(_uploadFileRef$curren = uploadFileRef.current) === null || _uploadFileRef$curren === void 0 || _uploadFileRef$curren.uploadFileByRaw(file);
|
|
211
|
+
};
|
|
212
|
+
|
|
213
|
+
// capture: true 确保在 tiptap 处理前拦截
|
|
214
|
+
el.addEventListener('paste', handlePaste, true);
|
|
215
|
+
return function () {
|
|
216
|
+
return el.removeEventListener('paste', handlePaste, true);
|
|
217
|
+
};
|
|
218
|
+
}, [props.enableFileUpload, props.disabled, isAskProcess, fileList, t]);
|
|
184
219
|
var handleTip = function handleTip() {
|
|
185
220
|
if ((fileList === null || fileList === void 0 ? void 0 : fileList.length) >= 10) {
|
|
186
221
|
return Toast.info(t('chatInput.uploadLimitTen'));
|
|
@@ -471,8 +506,8 @@ var ChatInput = /*#__PURE__*/React.forwardRef(function (props, ref) {
|
|
|
471
506
|
}, [UploadFileTool, props.hiddenDeepThink, AgentContainer]);
|
|
472
507
|
var stopSSe = function stopSSe() {
|
|
473
508
|
if (uploadFileRef.current) {
|
|
474
|
-
var _uploadFileRef$
|
|
475
|
-
(_uploadFileRef$
|
|
509
|
+
var _uploadFileRef$curren2;
|
|
510
|
+
(_uploadFileRef$curren2 = uploadFileRef.current) === null || _uploadFileRef$curren2 === void 0 || _uploadFileRef$curren2.abortUpload();
|
|
476
511
|
}
|
|
477
512
|
};
|
|
478
513
|
var handleDelFile = React.useCallback(function (uid) {
|
|
@@ -491,11 +526,11 @@ var ChatInput = /*#__PURE__*/React.forwardRef(function (props, ref) {
|
|
|
491
526
|
return item.uid === file.uid;
|
|
492
527
|
});
|
|
493
528
|
if ((_file === null || _file === void 0 ? void 0 : _file.status) === FileStatus.ANALYSE_FAILED) {
|
|
494
|
-
var _uploadFileRef$curren2;
|
|
495
|
-
(_uploadFileRef$curren2 = uploadFileRef.current) === null || _uploadFileRef$curren2 === void 0 || _uploadFileRef$curren2.handleSSEFileAnalyize(_file);
|
|
496
|
-
} else {
|
|
497
529
|
var _uploadFileRef$curren3;
|
|
498
|
-
(_uploadFileRef$curren3 = uploadFileRef.current) === null || _uploadFileRef$curren3 === void 0 || _uploadFileRef$curren3.
|
|
530
|
+
(_uploadFileRef$curren3 = uploadFileRef.current) === null || _uploadFileRef$curren3 === void 0 || _uploadFileRef$curren3.handleSSEFileAnalyize(_file);
|
|
531
|
+
} else {
|
|
532
|
+
var _uploadFileRef$curren4;
|
|
533
|
+
(_uploadFileRef$curren4 = uploadFileRef.current) === null || _uploadFileRef$curren4 === void 0 || _uploadFileRef$curren4.retryUpload(_file === null || _file === void 0 ? void 0 : _file.uid);
|
|
499
534
|
}
|
|
500
535
|
}, [fileList]);
|
|
501
536
|
var renderReference = React.useCallback(function () {
|
|
@@ -8,7 +8,7 @@
|
|
|
8
8
|
box-shadow: inset 0 2px #fff, 0 2px 10px rgba(84, 105, 140, 0.15);
|
|
9
9
|
border-radius: 10px;
|
|
10
10
|
}
|
|
11
|
-
@media (min-width:
|
|
11
|
+
@media (min-width: 1920px) {
|
|
12
12
|
.inputWrap {
|
|
13
13
|
max-width: 1000px;
|
|
14
14
|
}
|
|
@@ -65,7 +65,7 @@
|
|
|
65
65
|
scrollbar-width: thin;
|
|
66
66
|
scrollbar-color: #d1d1d1 transparent;
|
|
67
67
|
}
|
|
68
|
-
@media (min-width:
|
|
68
|
+
@media (min-width: 1920px) {
|
|
69
69
|
.chatInput {
|
|
70
70
|
max-width: 1000px;
|
|
71
71
|
}
|
|
@@ -12,6 +12,7 @@ export interface IFileUploadRef {
|
|
|
12
12
|
abortUpload: () => void;
|
|
13
13
|
handleSSEFileAnalyize: (file: FileItem) => void;
|
|
14
14
|
retryUpload: (uid: string) => void;
|
|
15
|
+
uploadFileByRaw: (file: File) => void;
|
|
15
16
|
}
|
|
16
17
|
declare const FileUpload: React.ForwardRefExoticComponent<IProps & React.RefAttributes<unknown>>;
|
|
17
18
|
export default FileUpload;
|
|
@@ -22,7 +22,7 @@ var IMAGE_TYPES = ['image/png', 'image/jpeg', 'image/jpg', 'image/gif', 'image/w
|
|
|
22
22
|
var MAX_IMAGE_COUNT = 10;
|
|
23
23
|
var MAX_FILE_COUNT = 1;
|
|
24
24
|
var MAX_TOTAL_COUNT = 10;
|
|
25
|
-
var MAX_IMAGE_SIZE =
|
|
25
|
+
var MAX_IMAGE_SIZE = 10; // MB
|
|
26
26
|
|
|
27
27
|
/** Redux FileItem → Semi Upload FileItem */
|
|
28
28
|
var transformFileItem = function transformFileItem(list) {
|
|
@@ -308,7 +308,18 @@ var FileUpload = /*#__PURE__*/React.forwardRef(function (props, ref) {
|
|
|
308
308
|
(_fileUploadAbortRef$c = fileUploadAbortRef.current) === null || _fileUploadAbortRef$c === void 0 || _fileUploadAbortRef$c.abort();
|
|
309
309
|
},
|
|
310
310
|
handleSSEFileAnalyize: handleSSEFileAnalyize,
|
|
311
|
-
retryUpload: retryUpload
|
|
311
|
+
retryUpload: retryUpload,
|
|
312
|
+
uploadFileByRaw: function uploadFileByRaw(file) {
|
|
313
|
+
var uid = "paste_".concat(Date.now(), "_").concat(Math.random().toString(36).slice(2));
|
|
314
|
+
customRequest({
|
|
315
|
+
file: {
|
|
316
|
+
uid: uid,
|
|
317
|
+
name: file.name,
|
|
318
|
+
size: file.size,
|
|
319
|
+
fileInstance: file
|
|
320
|
+
}
|
|
321
|
+
});
|
|
322
|
+
}
|
|
312
323
|
};
|
|
313
324
|
});
|
|
314
325
|
var trigger = /*#__PURE__*/React.createElement(Button, {
|
|
@@ -31,7 +31,7 @@ var ImageFile = function ImageFile(_ref) {
|
|
|
31
31
|
var isError = file.status === FileStatus.UPLOAD_FAILED || file.status === FileStatus.ANALYSE_FAILED || file.status === FileStatus.NETWORK_ERROR;
|
|
32
32
|
var isLoading = [FileStatus.PADDING, FileStatus.RETRING, FileStatus.UPLOADING].includes(file.status);
|
|
33
33
|
return /*#__PURE__*/React.createElement("div", {
|
|
34
|
-
className: classNames(styles.uploadBox, isMessage ? styles.messageImg :
|
|
34
|
+
className: classNames(styles.uploadBox, isMessage ? styles.messageImg : styles.inputImg, isSingle ? styles.singleImg : '')
|
|
35
35
|
}, /*#__PURE__*/React.createElement("img", {
|
|
36
36
|
src: file.fileUrl,
|
|
37
37
|
alt: "file-icon",
|