@ant-design/agentic-ui 2.30.14 → 2.30.15
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/I18n/locales.js +2 -2
- package/dist/MarkdownEditor/editor/elements/Code/ReadonlyCode.js +1 -1
- package/dist/MarkdownEditor/editor/elements/Code/index.js +1 -1
- package/dist/MarkdownInputField/AttachmentButton/AttachmentButtonPopover.d.ts +1 -6
- package/dist/MarkdownInputField/AttachmentButton/AttachmentButtonPopover.js +2 -13
- package/dist/MarkdownInputField/AttachmentButton/AttachmentFileList/AttachmentFileListItem.js +2 -1
- package/dist/MarkdownInputField/AttachmentButton/index.d.ts +30 -0
- package/dist/MarkdownInputField/AttachmentButton/index.js +22 -6
- package/dist/MarkdownInputField/AttachmentButton/utils.d.ts +3 -6
- package/dist/MarkdownInputField/FileUploadManager/index.js +36 -21
- package/dist/MarkdownInputField/MarkdownInputField.js +2 -1
- package/dist/MarkdownInputField/hooks/useMarkdownInputFieldHandlers.d.ts +1 -0
- package/dist/MarkdownInputField/hooks/useMarkdownInputFieldHandlers.js +20 -0
- package/dist/MarkdownInputField/style.js +2 -1
- package/dist/MarkdownInputField/types/MarkdownInputFieldProps.d.ts +1 -1
- package/package.json +2 -1
package/dist/I18n/locales.js
CHANGED
|
@@ -340,7 +340,7 @@
|
|
|
340
340
|
'input.selectFile': '选择文件',
|
|
341
341
|
'input.openGallery': '打开相册',
|
|
342
342
|
'input.openFile': '打开文件',
|
|
343
|
-
'input.supportedFormatMessage': '
|
|
343
|
+
'input.supportedFormatMessage': '支持 ${extensions}等格式。',
|
|
344
344
|
'input.sendButtonTooltip.send': '按 Enter 键发送',
|
|
345
345
|
'input.sendButtonTooltip.newline': '按 Shift+Enter 键换行',
|
|
346
346
|
'input.sendButtonTooltip.send.mod': '按 Cmd/Ctrl+Enter 键发送',
|
|
@@ -768,7 +768,7 @@
|
|
|
768
768
|
'input.selectFile': 'Select File',
|
|
769
769
|
'input.openGallery': 'Open Gallery',
|
|
770
770
|
'input.openFile': 'Open File',
|
|
771
|
-
'input.supportedFormatMessage': 'Supports
|
|
771
|
+
'input.supportedFormatMessage': 'Supports ${extensions} formats.',
|
|
772
772
|
'input.sendButtonTooltip.send': 'Press Enter to send',
|
|
773
773
|
'input.sendButtonTooltip.newline': 'Press Shift+Enter for new line',
|
|
774
774
|
'input.sendButtonTooltip.send.mod': 'Press Cmd/Ctrl+Enter to send',
|
|
@@ -106,7 +106,7 @@ import { debugInfo } from "../../../../Utils/debugUtils";
|
|
|
106
106
|
// 检查代码块是否未闭合
|
|
107
107
|
var isUnclosed = (element === null || element === void 0 ? void 0 : (_element_otherProps2 = element.otherProps) === null || _element_otherProps2 === void 0 ? void 0 : _element_otherProps2.finished) === false;
|
|
108
108
|
return /*#__PURE__*/ React.createElement("div", _object_spread_props(_object_spread({}, attributes), {
|
|
109
|
-
"data-is-unclosed": isUnclosed,
|
|
109
|
+
"data-is-unclosed": isUnclosed || undefined,
|
|
110
110
|
"data-language": element === null || element === void 0 ? void 0 : element.language,
|
|
111
111
|
style: (element === null || element === void 0 ? void 0 : element.language) === 'html' ? {
|
|
112
112
|
display: (element === null || element === void 0 ? void 0 : (_element_otherProps3 = element.otherProps) === null || _element_otherProps3 === void 0 ? void 0 : _element_otherProps3.isConfig) ? 'none' : 'block'
|
|
@@ -85,7 +85,7 @@ export var Code = function Code(param) {
|
|
|
85
85
|
// 检查代码块是否未闭合
|
|
86
86
|
var isUnclosed = (element === null || element === void 0 ? void 0 : (_element_otherProps2 = element.otherProps) === null || _element_otherProps2 === void 0 ? void 0 : _element_otherProps2.finished) === false;
|
|
87
87
|
return /*#__PURE__*/ React.createElement("div", _object_spread_props(_object_spread({}, attributes), {
|
|
88
|
-
"data-is-unclosed": isUnclosed,
|
|
88
|
+
"data-is-unclosed": isUnclosed || undefined,
|
|
89
89
|
"data-language": element === null || element === void 0 ? void 0 : element.language,
|
|
90
90
|
style: {
|
|
91
91
|
height: '240px',
|
|
@@ -2,7 +2,6 @@ import React from 'react';
|
|
|
2
2
|
import type { LocalKeys } from '../../I18n';
|
|
3
3
|
export type SupportedFormat = {
|
|
4
4
|
type: string;
|
|
5
|
-
maxSize: number;
|
|
6
5
|
extensions: string[];
|
|
7
6
|
icon: React.ReactNode;
|
|
8
7
|
content?: React.ReactNode;
|
|
@@ -12,32 +11,28 @@ export type AttachmentButtonPopoverProps = {
|
|
|
12
11
|
supportedFormat?: SupportedFormat;
|
|
13
12
|
/** 上传图片的处理函数 */
|
|
14
13
|
uploadImage?: (forGallery?: boolean) => Promise<void>;
|
|
15
|
-
/** 国际化文案,可覆盖 I18n 上下文中的配置。支持 `input.openGallery`、`input.openFile`、`input.supportedFormatMessage`(模板变量:${
|
|
14
|
+
/** 国际化文案,可覆盖 I18n 上下文中的配置。支持 `input.openGallery`、`input.openFile`、`input.supportedFormatMessage`(模板变量:${extensions})等 */
|
|
16
15
|
locale?: Partial<LocalKeys>;
|
|
17
16
|
};
|
|
18
17
|
export declare const SupportedFileFormats: {
|
|
19
18
|
image: {
|
|
20
19
|
icon: React.JSX.Element;
|
|
21
20
|
type: string;
|
|
22
|
-
maxSize: number;
|
|
23
21
|
extensions: string[];
|
|
24
22
|
};
|
|
25
23
|
document: {
|
|
26
24
|
icon: React.JSX.Element;
|
|
27
25
|
type: string;
|
|
28
|
-
maxSize: number;
|
|
29
26
|
extensions: string[];
|
|
30
27
|
};
|
|
31
28
|
audio: {
|
|
32
29
|
icon: React.JSX.Element;
|
|
33
30
|
type: string;
|
|
34
|
-
maxSize: number;
|
|
35
31
|
extensions: string[];
|
|
36
32
|
};
|
|
37
33
|
video: {
|
|
38
34
|
icon: React.JSX.Element;
|
|
39
35
|
type: string;
|
|
40
|
-
maxSize: number;
|
|
41
36
|
extensions: string[];
|
|
42
37
|
};
|
|
43
38
|
};
|
|
@@ -77,12 +77,7 @@ import { Button, Modal, Tooltip } from "antd";
|
|
|
77
77
|
import React, { useContext, useMemo, useState } from "react";
|
|
78
78
|
import { useRefFunction } from "../../Hooks/useRefFunction";
|
|
79
79
|
import { compileTemplate, I18nContext } from "../../I18n";
|
|
80
|
-
import { isMobileDevice, isVivoOrOppoDevice
|
|
81
|
-
var FILE_SIZE_UNITS = {
|
|
82
|
-
KB: 1024,
|
|
83
|
-
MB: 1024 * 1024
|
|
84
|
-
};
|
|
85
|
-
var DEFAULT_MAX_SIZE = 5000;
|
|
80
|
+
import { isMobileDevice, isVivoOrOppoDevice } from "./utils";
|
|
86
81
|
var CONTENT_STYLE = {
|
|
87
82
|
fontSize: 16,
|
|
88
83
|
lineHeight: '1.5em',
|
|
@@ -92,7 +87,6 @@ export var SupportedFileFormats = {
|
|
|
92
87
|
image: {
|
|
93
88
|
icon: /*#__PURE__*/ React.createElement(FileImageOutlined, null),
|
|
94
89
|
type: '图片',
|
|
95
|
-
maxSize: 10 * FILE_SIZE_UNITS.KB,
|
|
96
90
|
extensions: [
|
|
97
91
|
'jpg',
|
|
98
92
|
'jpeg',
|
|
@@ -106,7 +100,6 @@ export var SupportedFileFormats = {
|
|
|
106
100
|
document: {
|
|
107
101
|
icon: /*#__PURE__*/ React.createElement(FileTextFilled, null),
|
|
108
102
|
type: '文档',
|
|
109
|
-
maxSize: 10 * FILE_SIZE_UNITS.KB,
|
|
110
103
|
extensions: [
|
|
111
104
|
'pdf',
|
|
112
105
|
'markdown',
|
|
@@ -123,7 +116,6 @@ export var SupportedFileFormats = {
|
|
|
123
116
|
audio: {
|
|
124
117
|
icon: /*#__PURE__*/ React.createElement(AudioOutlined, null),
|
|
125
118
|
type: '音频',
|
|
126
|
-
maxSize: 50 * FILE_SIZE_UNITS.KB,
|
|
127
119
|
extensions: [
|
|
128
120
|
'mp3',
|
|
129
121
|
'wav'
|
|
@@ -132,7 +124,6 @@ export var SupportedFileFormats = {
|
|
|
132
124
|
video: {
|
|
133
125
|
icon: /*#__PURE__*/ React.createElement(VideoCameraOutlined, null),
|
|
134
126
|
type: '视频',
|
|
135
|
-
maxSize: 100 * FILE_SIZE_UNITS.KB,
|
|
136
127
|
extensions: [
|
|
137
128
|
'mp4',
|
|
138
129
|
'avi',
|
|
@@ -140,15 +131,13 @@ export var SupportedFileFormats = {
|
|
|
140
131
|
]
|
|
141
132
|
}
|
|
142
133
|
};
|
|
143
|
-
var DEFAULT_FORMAT_MESSAGE = '
|
|
134
|
+
var DEFAULT_FORMAT_MESSAGE = '支持 ${extensions}等格式。';
|
|
144
135
|
var buildFormatMessage = function buildFormatMessage(format, locale) {
|
|
145
136
|
var _ref;
|
|
146
137
|
var _format_extensions;
|
|
147
|
-
var maxSize = kbToSize(format.maxSize || DEFAULT_MAX_SIZE);
|
|
148
138
|
var extensions = ((_format_extensions = format.extensions) === null || _format_extensions === void 0 ? void 0 : _format_extensions.join(', ')) || '';
|
|
149
139
|
var template = (_ref = locale === null || locale === void 0 ? void 0 : locale['input.supportedFormatMessage']) !== null && _ref !== void 0 ? _ref : DEFAULT_FORMAT_MESSAGE;
|
|
150
140
|
return compileTemplate(template, {
|
|
151
|
-
maxSize: maxSize,
|
|
152
141
|
extensions: extensions
|
|
153
142
|
});
|
|
154
143
|
};
|
package/dist/MarkdownInputField/AttachmentButton/AttachmentFileList/AttachmentFileListItem.js
CHANGED
|
@@ -122,7 +122,8 @@ export var AttachmentFileListItem = function AttachmentFileListItem(param) {
|
|
|
122
122
|
onDelete(file);
|
|
123
123
|
};
|
|
124
124
|
// 有 status 但无 url/previewUrl:文件内容未拿到,展示大小与格式占位块
|
|
125
|
-
|
|
125
|
+
// 注意:error 状态不走占位符,直接在下面的 file-item 中展示失败 UI
|
|
126
|
+
if (!isErrorStatus && isFileMetaPlaceholderState(file)) {
|
|
126
127
|
return /*#__PURE__*/ React.createElement(FileMetaPlaceholder, {
|
|
127
128
|
file: file,
|
|
128
129
|
className: className
|
|
@@ -48,6 +48,21 @@ export type AttachmentButtonProps = {
|
|
|
48
48
|
currentCount: number;
|
|
49
49
|
selectedCount: number;
|
|
50
50
|
}) => void;
|
|
51
|
+
/** 文件超出 maxFileSize 大小限制时的回调 */
|
|
52
|
+
onExceedMaxSize?: (info: {
|
|
53
|
+
file: AttachmentFile;
|
|
54
|
+
maxSize: number;
|
|
55
|
+
}) => void;
|
|
56
|
+
/** 文件上传失败时的回调 */
|
|
57
|
+
onUploadError?: (info: {
|
|
58
|
+
file: AttachmentFile;
|
|
59
|
+
error: unknown;
|
|
60
|
+
}) => void;
|
|
61
|
+
/**
|
|
62
|
+
* 上传失败时自动将文件从列表中移除(退回),不显示错误状态
|
|
63
|
+
* @default false
|
|
64
|
+
*/
|
|
65
|
+
removeFileOnUploadError?: boolean;
|
|
51
66
|
};
|
|
52
67
|
/**
|
|
53
68
|
* 文件上传配置
|
|
@@ -75,6 +90,21 @@ type UploadProps = {
|
|
|
75
90
|
currentCount: number;
|
|
76
91
|
selectedCount: number;
|
|
77
92
|
}) => void;
|
|
93
|
+
/** 文件超出 maxFileSize 大小限制时的回调 */
|
|
94
|
+
onExceedMaxSize?: (info: {
|
|
95
|
+
file: AttachmentFile;
|
|
96
|
+
maxSize: number;
|
|
97
|
+
}) => void;
|
|
98
|
+
/** 文件上传失败时的回调 */
|
|
99
|
+
onUploadError?: (info: {
|
|
100
|
+
file: AttachmentFile;
|
|
101
|
+
error: unknown;
|
|
102
|
+
}) => void;
|
|
103
|
+
/**
|
|
104
|
+
* 上传失败时自动将文件从列表中移除(退回),不显示错误状态
|
|
105
|
+
* @default false
|
|
106
|
+
*/
|
|
107
|
+
removeFileOnUploadError?: boolean;
|
|
78
108
|
};
|
|
79
109
|
/**
|
|
80
110
|
* 上传文件到服务器
|
|
@@ -259,14 +259,25 @@ var handleUploadSuccess = function handleUploadSuccess(file, url, map, props) {
|
|
|
259
259
|
file.url = url;
|
|
260
260
|
updateFileMap(map, file, props.onFileMapChange);
|
|
261
261
|
};
|
|
262
|
-
var handleUploadError = function handleUploadError(file, errorMsg, map, props) {
|
|
263
|
-
|
|
264
|
-
if (
|
|
265
|
-
|
|
262
|
+
var handleUploadError = function handleUploadError(file, errorMsg, map, props, rawError) {
|
|
263
|
+
var _props_onUploadError;
|
|
264
|
+
if (props.removeFileOnUploadError) {
|
|
265
|
+
var _props_onFileMapChange;
|
|
266
|
+
if (file.uuid) map.delete(file.uuid);
|
|
267
|
+
(_props_onFileMapChange = props.onFileMapChange) === null || _props_onFileMapChange === void 0 ? void 0 : _props_onFileMapChange.call(props, map);
|
|
268
|
+
} else {
|
|
269
|
+
file.status = 'error';
|
|
270
|
+
if (errorMsg !== null) file.errorMessage = errorMsg;
|
|
271
|
+
updateFileMap(map, file, props.onFileMapChange);
|
|
272
|
+
}
|
|
273
|
+
(_props_onUploadError = props.onUploadError) === null || _props_onUploadError === void 0 ? void 0 : _props_onUploadError.call(props, {
|
|
274
|
+
file: file,
|
|
275
|
+
error: rawError !== null && rawError !== void 0 ? rawError : errorMsg
|
|
276
|
+
});
|
|
266
277
|
};
|
|
267
278
|
var processFile = function processFile(file, index, map, props) {
|
|
268
279
|
return _async_to_generator(function() {
|
|
269
|
-
var maxSizeKb, raw, _ref, url, isSuccess, errorMsg, error, errorMessage;
|
|
280
|
+
var _props_onExceedMaxSize, maxSizeKb, raw, _ref, url, isSuccess, errorMsg, error, errorMessage;
|
|
270
281
|
return _ts_generator(this, function(_state) {
|
|
271
282
|
switch(_state.label){
|
|
272
283
|
case 0:
|
|
@@ -277,12 +288,17 @@ var processFile = function processFile(file, index, map, props) {
|
|
|
277
288
|
case 1:
|
|
278
289
|
_state.sent();
|
|
279
290
|
if (!validateFileSize(file, props)) {
|
|
291
|
+
;
|
|
280
292
|
maxSizeKb = Math.round((props.maxFileSize || 0) / 1024);
|
|
281
293
|
raw = getLocaleMessage(props.locale, 'markdownInput.fileSizeExceeded', DEFAULT_MESSAGES.fileSizeExceeded(maxSizeKb));
|
|
282
294
|
file.errorMessage = raw.includes('${maxSize}') ? raw.replace(/\$\{maxSize\}/g, String(maxSizeKb)) : raw;
|
|
283
295
|
file.errorCode = 'FILE_SIZE_EXCEEDED';
|
|
284
296
|
file.status = 'error';
|
|
285
297
|
updateFileMap(map, file, props.onFileMapChange);
|
|
298
|
+
(_props_onExceedMaxSize = props.onExceedMaxSize) === null || _props_onExceedMaxSize === void 0 ? void 0 : _props_onExceedMaxSize.call(props, {
|
|
299
|
+
file: file,
|
|
300
|
+
maxSize: props.maxFileSize || 0
|
|
301
|
+
});
|
|
286
302
|
return [
|
|
287
303
|
2
|
|
288
304
|
];
|
|
@@ -313,7 +329,7 @@ var processFile = function processFile(file, index, map, props) {
|
|
|
313
329
|
case 4:
|
|
314
330
|
error = _state.sent();
|
|
315
331
|
errorMessage = _instanceof(error, Error) ? error.message : getLocaleMessage(props.locale, 'uploadFailed', DEFAULT_MESSAGES.uploadFailed);
|
|
316
|
-
handleUploadError(file, errorMessage, map, props);
|
|
332
|
+
handleUploadError(file, errorMessage, map, props, error);
|
|
317
333
|
return [
|
|
318
334
|
3,
|
|
319
335
|
5
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import type { AttachmentFile } from './types';
|
|
1
2
|
/**
|
|
2
3
|
* 将KB转换为可读的文件大小格式
|
|
3
4
|
* 支持从字节(B)到TB的所有单位,最小单位为B
|
|
@@ -40,18 +41,14 @@ export declare const isMediaFile: (file: File) => boolean;
|
|
|
40
41
|
/**
|
|
41
42
|
* 是否为「仅元信息占位」状态:有 status 但无 url/previewUrl,内容未拿到时整行以 FileMetaPlaceholder 风格展示
|
|
42
43
|
*/
|
|
43
|
-
export declare const isAttachmentFileLoading: (status?:
|
|
44
|
+
export declare const isAttachmentFileLoading: (status?: AttachmentFile['status'] | null) => boolean;
|
|
44
45
|
/**
|
|
45
46
|
* 是否应该展示 FileMetaPlaceholder:
|
|
46
47
|
* - 有状态
|
|
47
48
|
* - 非 loading(uploading/pending)
|
|
48
49
|
* - 且没有可预览 URL
|
|
49
50
|
*/
|
|
50
|
-
export declare const isFileMetaPlaceholderState: (file:
|
|
51
|
-
status?: string;
|
|
52
|
-
url?: string;
|
|
53
|
-
previewUrl?: string;
|
|
54
|
-
}) => boolean;
|
|
51
|
+
export declare const isFileMetaPlaceholderState: (file: AttachmentFile) => boolean;
|
|
55
52
|
/**
|
|
56
53
|
* 获取设备品牌
|
|
57
54
|
*
|
|
@@ -416,30 +416,32 @@ import { isMobileDevice, isVivoOrOppoDevice, isWeChat } from "../AttachmentButto
|
|
|
416
416
|
* 处理文件重试
|
|
417
417
|
*/ var handleFileRetry = useRefFunction(function(file) {
|
|
418
418
|
return _async_to_generator(function() {
|
|
419
|
-
var map, url, isSuccess, uploadResult, error,
|
|
419
|
+
var map, url, isSuccess, uploadResult, _attachment_onUploadError, error, _attachment_onUploadError1;
|
|
420
420
|
return _ts_generator(this, function(_state) {
|
|
421
421
|
switch(_state.label){
|
|
422
422
|
case 0:
|
|
423
|
+
map = new Map(fileMap);
|
|
424
|
+
_state.label = 1;
|
|
425
|
+
case 1:
|
|
423
426
|
_state.trys.push([
|
|
424
|
-
|
|
425
|
-
|
|
427
|
+
1,
|
|
428
|
+
6,
|
|
426
429
|
,
|
|
427
|
-
|
|
430
|
+
7
|
|
428
431
|
]);
|
|
429
432
|
file.status = 'uploading';
|
|
430
|
-
map = new Map(fileMap);
|
|
431
433
|
map.set(file.uuid || '', file);
|
|
432
434
|
updateAttachmentFiles(map);
|
|
433
435
|
isSuccess = false;
|
|
434
436
|
if (!(attachment === null || attachment === void 0 ? void 0 : attachment.uploadWithResponse)) return [
|
|
435
437
|
3,
|
|
436
|
-
|
|
438
|
+
3
|
|
437
439
|
];
|
|
438
440
|
return [
|
|
439
441
|
4,
|
|
440
442
|
attachment.uploadWithResponse(file, 0)
|
|
441
443
|
];
|
|
442
|
-
case
|
|
444
|
+
case 2:
|
|
443
445
|
uploadResult = _state.sent();
|
|
444
446
|
url = uploadResult.fileUrl;
|
|
445
447
|
isSuccess = uploadResult.uploadStatus === 'SUCCESS';
|
|
@@ -447,48 +449,61 @@ import { isMobileDevice, isVivoOrOppoDevice, isWeChat } from "../AttachmentButto
|
|
|
447
449
|
file.uploadResponse = uploadResult;
|
|
448
450
|
return [
|
|
449
451
|
3,
|
|
450
|
-
|
|
452
|
+
5
|
|
451
453
|
];
|
|
452
|
-
case
|
|
454
|
+
case 3:
|
|
453
455
|
if (!(attachment === null || attachment === void 0 ? void 0 : attachment.upload)) return [
|
|
454
456
|
3,
|
|
455
|
-
|
|
457
|
+
5
|
|
456
458
|
];
|
|
457
459
|
return [
|
|
458
460
|
4,
|
|
459
461
|
attachment.upload(file, 0)
|
|
460
462
|
];
|
|
461
|
-
case
|
|
463
|
+
case 4:
|
|
462
464
|
url = _state.sent();
|
|
463
465
|
isSuccess = !!url;
|
|
464
|
-
_state.label =
|
|
465
|
-
case
|
|
466
|
+
_state.label = 5;
|
|
467
|
+
case 5:
|
|
466
468
|
if (isSuccess && url) {
|
|
467
469
|
file.status = 'done';
|
|
468
470
|
file.url = url;
|
|
469
471
|
map.set(file.uuid || '', file);
|
|
470
472
|
updateAttachmentFiles(map);
|
|
471
473
|
} else {
|
|
474
|
+
;
|
|
472
475
|
file.status = 'error';
|
|
473
476
|
map.set(file.uuid || '', file);
|
|
474
477
|
updateAttachmentFiles(map);
|
|
478
|
+
attachment === null || attachment === void 0 ? void 0 : (_attachment_onUploadError = attachment.onUploadError) === null || _attachment_onUploadError === void 0 ? void 0 : _attachment_onUploadError.call(attachment, {
|
|
479
|
+
file: file,
|
|
480
|
+
error: null
|
|
481
|
+
});
|
|
475
482
|
}
|
|
476
483
|
return [
|
|
477
484
|
3,
|
|
478
|
-
|
|
485
|
+
7
|
|
479
486
|
];
|
|
480
|
-
case
|
|
487
|
+
case 6:
|
|
481
488
|
error = _state.sent();
|
|
482
|
-
|
|
483
|
-
|
|
484
|
-
|
|
485
|
-
|
|
489
|
+
if (attachment === null || attachment === void 0 ? void 0 : attachment.removeFileOnUploadError) {
|
|
490
|
+
map.delete(file.uuid || '');
|
|
491
|
+
updateAttachmentFiles(map);
|
|
492
|
+
} else {
|
|
493
|
+
file.status = 'error';
|
|
494
|
+
map.set(file.uuid || '', file);
|
|
495
|
+
updateAttachmentFiles(map);
|
|
496
|
+
}
|
|
497
|
+
attachment === null || attachment === void 0 ? void 0 : (_attachment_onUploadError1 = attachment.onUploadError) === null || _attachment_onUploadError1 === void 0 ? void 0 : _attachment_onUploadError1.call(attachment, {
|
|
498
|
+
file: file,
|
|
499
|
+
error: error
|
|
500
|
+
});
|
|
486
501
|
console.error('Error retrying file upload:', error);
|
|
487
502
|
return [
|
|
488
503
|
3,
|
|
489
|
-
|
|
504
|
+
7
|
|
490
505
|
];
|
|
491
|
-
case
|
|
506
|
+
case 7:
|
|
492
507
|
return [
|
|
493
508
|
2
|
|
494
509
|
];
|
|
@@ -290,7 +290,7 @@ var MarkdownInputFieldComponent = function MarkdownInputFieldComponent(_0) {
|
|
|
290
290
|
stopRecording: stopRecording,
|
|
291
291
|
isEnlarged: isEnlarged,
|
|
292
292
|
setIsEnlarged: setIsEnlarged
|
|
293
|
-
}), handleEnlargeClick = _useMarkdownInputFieldHandlers.handleEnlargeClick, sendMessage = _useMarkdownInputFieldHandlers.sendMessage, handlePaste = _useMarkdownInputFieldHandlers.handlePaste, handleKeyDown = _useMarkdownInputFieldHandlers.handleKeyDown, activeInput = _useMarkdownInputFieldHandlers.activeInput;
|
|
293
|
+
}), handleEnlargeClick = _useMarkdownInputFieldHandlers.handleEnlargeClick, sendMessage = _useMarkdownInputFieldHandlers.sendMessage, handlePaste = _useMarkdownInputFieldHandlers.handlePaste, handleKeyDown = _useMarkdownInputFieldHandlers.handleKeyDown, handleContainerClick = _useMarkdownInputFieldHandlers.handleContainerClick, activeInput = _useMarkdownInputFieldHandlers.activeInput;
|
|
294
294
|
// 渲染辅助
|
|
295
295
|
var attachmentList = useAttachmentList({
|
|
296
296
|
attachment: attachment,
|
|
@@ -370,6 +370,7 @@ var MarkdownInputFieldComponent = function MarkdownInputFieldComponent(_0) {
|
|
|
370
370
|
onMouseLeave: function onMouseLeave() {
|
|
371
371
|
return setHover(false);
|
|
372
372
|
},
|
|
373
|
+
onClick: handleContainerClick,
|
|
373
374
|
onKeyDown: handleKeyDown
|
|
374
375
|
}, /*#__PURE__*/ React.createElement(BorderBeamAnimation, {
|
|
375
376
|
isVisible: isFocused && !animationComplete,
|
|
@@ -27,6 +27,7 @@ export declare const useMarkdownInputFieldHandlers: ({ props, markdownEditorRef,
|
|
|
27
27
|
sendMessage: () => Promise<void>;
|
|
28
28
|
handlePaste: (e: React.ClipboardEvent<HTMLDivElement>) => Promise<void>;
|
|
29
29
|
handleKeyDown: (e: React.KeyboardEvent<HTMLDivElement>) => void;
|
|
30
|
+
handleContainerClick: (e: React.MouseEvent<HTMLDivElement, MouseEvent>) => void;
|
|
30
31
|
activeInput: (active: boolean) => void;
|
|
31
32
|
};
|
|
32
33
|
export {};
|
|
@@ -179,7 +179,9 @@ function _ts_generator(thisArg, body) {
|
|
|
179
179
|
}
|
|
180
180
|
}
|
|
181
181
|
import { Editor, Transforms } from "slate";
|
|
182
|
+
import { ReactEditor } from "slate-react";
|
|
182
183
|
import { useRefFunction } from "../../Hooks/useRefFunction";
|
|
184
|
+
import { EditorUtils } from "../../MarkdownEditor/editor/utils/editorUtils";
|
|
183
185
|
import { upLoadFileToServer } from "../AttachmentButton";
|
|
184
186
|
import { isMobileDevice } from "../AttachmentButton/utils";
|
|
185
187
|
import { getFileListFromDataTransferItems } from "../FilePaste";
|
|
@@ -384,6 +386,23 @@ import { getFileListFromDataTransferItems } from "../FilePaste";
|
|
|
384
386
|
// 这里不需要显式 return,函数结束自然会继续执行(但这里是 void,所以 return 也无妨)
|
|
385
387
|
// 注意:上面的 return 是阻止了默认行为并发送,这里的 implicit return 是允许默认行为(换行)
|
|
386
388
|
});
|
|
389
|
+
var handleContainerClick = useRefFunction(function(e) {
|
|
390
|
+
var _markdownEditorRef_current_markdownEditorRef, _markdownEditorRef_current;
|
|
391
|
+
if (props.disabled) return;
|
|
392
|
+
var editor = markdownEditorRef === null || markdownEditorRef === void 0 ? void 0 : (_markdownEditorRef_current = markdownEditorRef.current) === null || _markdownEditorRef_current === void 0 ? void 0 : (_markdownEditorRef_current_markdownEditorRef = _markdownEditorRef_current.markdownEditorRef) === null || _markdownEditorRef_current_markdownEditorRef === void 0 ? void 0 : _markdownEditorRef_current_markdownEditorRef.current;
|
|
393
|
+
if (!editor) return;
|
|
394
|
+
try {
|
|
395
|
+
if (ReactEditor.isFocused(editor)) return;
|
|
396
|
+
} catch (unused) {
|
|
397
|
+
// ignore
|
|
398
|
+
}
|
|
399
|
+
var target = e.target;
|
|
400
|
+
var isInteractive = target.closest('button') || target.closest('a') || target.closest('input') || target.closest('[contenteditable="true"]');
|
|
401
|
+
if (isInteractive) return;
|
|
402
|
+
EditorUtils.focus(editor);
|
|
403
|
+
var end = Editor.end(editor, []);
|
|
404
|
+
Transforms.select(editor, end);
|
|
405
|
+
});
|
|
387
406
|
var activeInput = useRefFunction(function(active) {
|
|
388
407
|
if (inputRef.current) {
|
|
389
408
|
if (active) {
|
|
@@ -402,6 +421,7 @@ import { getFileListFromDataTransferItems } from "../FilePaste";
|
|
|
402
421
|
sendMessage: sendMessage,
|
|
403
422
|
handlePaste: handlePaste,
|
|
404
423
|
handleKeyDown: handleKeyDown,
|
|
424
|
+
handleContainerClick: handleContainerClick,
|
|
405
425
|
activeInput: activeInput
|
|
406
426
|
};
|
|
407
427
|
};
|
|
@@ -174,6 +174,7 @@ var genStyle = function genStyle(token) {
|
|
|
174
174
|
maxHeight: 400,
|
|
175
175
|
height: '100%',
|
|
176
176
|
overflowY: 'visible',
|
|
177
|
+
cursor: 'text',
|
|
177
178
|
scrollbarColor: 'var(--color-gray-text-tertiary, #505c716b) transparent',
|
|
178
179
|
scrollbarWidth: 'thin',
|
|
179
180
|
'&&-disabled': {
|
|
@@ -186,7 +187,7 @@ var genStyle = function genStyle(token) {
|
|
|
186
187
|
}
|
|
187
188
|
},
|
|
188
189
|
// 仅覆盖 MarkdownInputField 内的代码块默认高度
|
|
189
|
-
'& [data-language][data-is-unclosed]': {
|
|
190
|
+
'& [data-language][data-is-unclosed="true"]': {
|
|
190
191
|
height: "".concat(DEFAULT_INPUT_CODE_BLOCK_HEIGHT, "px !important"),
|
|
191
192
|
minHeight: "".concat(DEFAULT_INPUT_CODE_BLOCK_HEIGHT, "px !important")
|
|
192
193
|
},
|
|
@@ -112,7 +112,7 @@ export type MarkdownInputFieldProps = {
|
|
|
112
112
|
* attachment={{
|
|
113
113
|
* enable: true,
|
|
114
114
|
* accept: '.pdf,.doc,.docx',
|
|
115
|
-
*
|
|
115
|
+
* maxFileSize: 10 * 1024 * 1024, // 10MB(字节)
|
|
116
116
|
* onUpload: async (file) => {
|
|
117
117
|
* const url = await uploadFile(file);
|
|
118
118
|
* return { url };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ant-design/agentic-ui",
|
|
3
|
-
"version": "2.30.
|
|
3
|
+
"version": "2.30.15",
|
|
4
4
|
"description": "面向智能体的 UI 组件库,提供多步推理可视化、工具调用展示、任务执行协同等 Agentic UI 能力",
|
|
5
5
|
"repository": "git@github.com:ant-design/agentic-ui.git",
|
|
6
6
|
"license": "MIT",
|
|
@@ -24,6 +24,7 @@
|
|
|
24
24
|
"lint:css": "stylelint \"{src,test}/**/*.{css,less}\"",
|
|
25
25
|
"lint:es": "eslint \"{src,test}/**/*.{js,jsx,ts,tsx}\"",
|
|
26
26
|
"prepare": "husky install && dumi setup",
|
|
27
|
+
"prepublishOnly": "npm run build && npm run test",
|
|
27
28
|
"prettier": "prettier --write \"{src,docs,test}/**/*.{js,jsx,ts,tsx,css,less,json,md}\"",
|
|
28
29
|
"preview": "pnpm dumi preview",
|
|
29
30
|
"report:demo": "node scripts/generateDemoReport.js",
|