@ant-design/agentic-ui 2.11.1 → 2.12.0

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.
Files changed (37) hide show
  1. package/dist/Bubble/MessagesContent/BubbleExtra.js +7 -1
  2. package/dist/MarkdownEditor/editor/types/Table.d.ts +1 -0
  3. package/dist/MarkdownEditor/editor/utils/ace.d.ts +22 -105
  4. package/dist/MarkdownEditor/editor/utils/ace.js +328 -106
  5. package/dist/MarkdownEditor/types.d.ts +1 -1
  6. package/dist/MarkdownInputField/AttachmentButton/AttachmentButtonPopover.d.ts +2 -4
  7. package/dist/MarkdownInputField/AttachmentButton/AttachmentButtonPopover.js +8 -61
  8. package/dist/MarkdownInputField/AttachmentButton/index.d.ts +1 -1
  9. package/dist/MarkdownInputField/AttachmentButton/index.js +7 -19
  10. package/dist/MarkdownInputField/FileUploadManager/index.d.ts +1 -1
  11. package/dist/MarkdownInputField/FileUploadManager/index.js +137 -138
  12. package/dist/MarkdownInputField/MarkdownInputField.d.ts +32 -0
  13. package/dist/MarkdownInputField/MarkdownInputField.js +26 -8
  14. package/dist/MarkdownInputField/SendActions/index.d.ts +1 -1
  15. package/dist/Plugins/chart/ChartRender.js +75 -13
  16. package/dist/Plugins/chart/LineChart/index.js +10 -4
  17. package/dist/Plugins/chart/index.js +17 -5
  18. package/dist/Plugins/chart/utils.d.ts +40 -0
  19. package/dist/Plugins/chart/utils.js +116 -0
  20. package/dist/Plugins/code/CodeUI/Katex/Katex.d.ts +0 -1
  21. package/dist/Plugins/code/CodeUI/Katex/Katex.js +182 -6
  22. package/dist/Plugins/code/components/AceEditor.d.ts +4 -6
  23. package/dist/Plugins/code/components/AceEditor.js +362 -40
  24. package/dist/Plugins/code/loadAceEditor.d.ts +26 -0
  25. package/dist/Plugins/code/loadAceEditor.js +266 -0
  26. package/dist/Plugins/katex/InlineKatex.d.ts +0 -1
  27. package/dist/Plugins/katex/InlineKatex.js +183 -7
  28. package/dist/Plugins/katex/Katex.d.ts +0 -1
  29. package/dist/Plugins/katex/Katex.js +184 -6
  30. package/dist/Plugins/katex/loadKatex.d.ts +18 -0
  31. package/dist/Plugins/katex/loadKatex.js +181 -0
  32. package/dist/Plugins/mermaid/Mermaid.js +315 -113
  33. package/dist/Schema/SchemaEditor/AceEditorWrapper.d.ts +1 -1
  34. package/dist/Schema/SchemaEditor/AceEditorWrapper.js +342 -53
  35. package/dist/Utils/loadCSS.d.ts +31 -0
  36. package/dist/Utils/loadCSS.js +264 -0
  37. package/package.json +1 -1
@@ -47,12 +47,8 @@ function _unsupported_iterable_to_array(o, minLen) {
47
47
  import { AudioOutlined, FileImageOutlined, FileTextFilled, FolderOpenOutlined, PictureOutlined, VideoCameraOutlined } from "@ant-design/icons";
48
48
  import { Button, Modal, Tooltip } from "antd";
49
49
  import React, { useCallback, useContext, useMemo, useState } from "react";
50
- import { useRefFunction } from "../../Hooks/useRefFunction";
51
50
  import { I18nContext } from "../../I18n";
52
- import { isMobileDevice, isVivoOrOppoDevice, isWeChat, kbToSize } from "./utils";
53
- /**
54
- * 移动设备默认的文件类型 accept 值
55
- */ var MOBILE_DEFAULT_ACCEPT = 'application/vnd.ms-excel,application/vnd.openxmlformats-officedocument.spreadsheetml.sheet,application/vnd.ms-powerpoint,application/vnd.openxmlformats-officedocument.presentationml.presentation,application/msword,application/vnd.openxmlformats-officedocument.wordprocessingml.document,application/pdf,.csv,text/plain,application/x-zip-compressed';
51
+ import { isMobileDevice, isVivoOrOppoDevice, kbToSize } from "./utils";
56
52
  var FILE_SIZE_UNITS = {
57
53
  KB: 1024,
58
54
  MB: 1024 * 1024
@@ -133,7 +129,7 @@ export var AttachmentSupportedFormatsContent = function(param) {
133
129
  });
134
130
  };
135
131
  export var AttachmentButtonPopover = function(param) {
136
- var children = param.children, supportedFormat = param.supportedFormat, onFileSelect = param.onFileSelect, _param_allowMultiple = param.allowMultiple, allowMultiple = _param_allowMultiple === void 0 ? true : _param_allowMultiple;
132
+ var children = param.children, supportedFormat = param.supportedFormat, uploadImage = param.uploadImage;
137
133
  var _useState = _sliced_to_array(useState(false), 2), modalOpen = _useState[0], setModalOpen = _useState[1];
138
134
  var locale = useContext(I18nContext).locale;
139
135
  var isVivoOrOppo = useMemo(function() {
@@ -142,9 +138,6 @@ export var AttachmentButtonPopover = function(param) {
142
138
  var isMobile = useMemo(function() {
143
139
  return isMobileDevice();
144
140
  }, []);
145
- var isWeChatEnv = useMemo(function() {
146
- return isWeChat();
147
- }, []);
148
141
  var trigger = useMemo(function() {
149
142
  return isVivoOrOppo ? [
150
143
  'click'
@@ -155,54 +148,6 @@ export var AttachmentButtonPopover = function(param) {
155
148
  }, [
156
149
  isVivoOrOppo
157
150
  ]);
158
- var format = supportedFormat || SupportedFileFormats.image;
159
- var extensions = format.extensions || [];
160
- /**
161
- * 根据支持的格式获取 accept 属性值
162
- * 优先级:微信 > 手机品牌(oppo/vivo)> 移动设备 > 相册模式 > 默认
163
- */ var getAcceptValue = useRefFunction(function(forGallery) {
164
- // 相册模式
165
- if (forGallery) {
166
- return 'image/*';
167
- }
168
- // 1. 微信环境最优先:设置为空字符串以打开文件浏览器
169
- if (isWeChatEnv) {
170
- return '*';
171
- }
172
- // 2. 手机品牌其次(oppo/vivo):设置为空字符串以打开文件浏览器
173
- if (isVivoOrOppo) {
174
- return '*';
175
- }
176
- // 3. 移动设备其次:设置为空字符串以打开文件浏览器
177
- if (isMobile) {
178
- return '*';
179
- }
180
- // 5. 默认情况:使用具体扩展名列表
181
- return extensions.length > 0 ? extensions.map(function(ext) {
182
- return ".".concat(ext);
183
- }).join(',') : MOBILE_DEFAULT_ACCEPT;
184
- });
185
- /**
186
- * 创建文件输入并触发选择
187
- */ var triggerFileInput = useRefFunction(function(forGallery) {
188
- var accept = getAcceptValue(forGallery);
189
- var input = document.createElement('input');
190
- input.type = 'file';
191
- input.accept = accept;
192
- input.multiple = allowMultiple;
193
- input.style.display = 'none';
194
- input.onchange = function(e) {
195
- var target = e.target;
196
- if (target.files && target.files.length > 0 && onFileSelect) {
197
- onFileSelect(target.files, accept);
198
- }
199
- // 清理
200
- input.remove();
201
- };
202
- document.body.appendChild(input);
203
- input.click();
204
- setModalOpen(false);
205
- });
206
151
  var handleClick = useCallback(function(e) {
207
152
  if (isVivoOrOppo) {
208
153
  e.stopPropagation();
@@ -213,14 +158,16 @@ export var AttachmentButtonPopover = function(param) {
213
158
  isVivoOrOppo
214
159
  ]);
215
160
  var handleOpenGallery = useCallback(function() {
216
- triggerFileInput(true);
161
+ uploadImage === null || uploadImage === void 0 ? void 0 : uploadImage(true);
162
+ setModalOpen(false);
217
163
  }, [
218
- triggerFileInput
164
+ uploadImage
219
165
  ]);
220
166
  var handleOpenFile = useCallback(function() {
221
- triggerFileInput(false);
167
+ uploadImage === null || uploadImage === void 0 ? void 0 : uploadImage(false);
168
+ setModalOpen(false);
222
169
  }, [
223
- triggerFileInput
170
+ uploadImage
224
171
  ]);
225
172
  if (isVivoOrOppo) {
226
173
  return /*#__PURE__*/ React.createElement("div", {
@@ -93,7 +93,7 @@ export declare const upLoadFileToServer: (files: ArrayLike<File>, props: UploadP
93
93
  */
94
94
  export declare const AttachmentButton: React.FC<AttachmentButtonProps & {
95
95
  /** 上传图片的处理函数 */
96
- uploadImage(): Promise<void>;
96
+ uploadImage(forGallery?: boolean): Promise<void>;
97
97
  /** 按钮标题文本 */
98
98
  title?: React.ReactNode;
99
99
  }>;
@@ -369,15 +369,17 @@ var processFile = /*#__PURE__*/ function() {
369
369
  hideLoading = message.loading(getLocaleMessage(props.locale, 'uploading', DEFAULT_MESSAGES.uploading));
370
370
  fileList = Array.from(files);
371
371
  fileList.forEach(prepareFile);
372
- fileList.forEach(function(file) {
373
- return updateFileMap(map, file, props.onFileMapChange);
374
- });
372
+ // 在添加到 fileMap 之前先验证文件数量
375
373
  if (!validateFileCount(fileList.length, existingFileCount, props)) {
376
374
  hideLoading();
377
375
  return [
378
376
  2
379
377
  ];
380
378
  }
379
+ // 验证通过后再添加到 fileMap
380
+ fileList.forEach(function(file) {
381
+ return updateFileMap(map, file, props.onFileMapChange);
382
+ });
381
383
  _state.label = 1;
382
384
  case 1:
383
385
  _state.trys.push([
@@ -470,7 +472,7 @@ var ButtonContent = function(param) {
470
472
  * />
471
473
  * ```
472
474
  */ export var AttachmentButton = function(param) {
473
- var disabled = param.disabled, uploadImage = param.uploadImage, title = param.title, supportedFormat = param.supportedFormat, render = param.render, upload = param.upload, uploadWithResponse = param.uploadWithResponse, fileMap = param.fileMap, onFileMapChange = param.onFileMapChange, maxFileSize = param.maxFileSize, maxFileCount = param.maxFileCount, minFileCount = param.minFileCount, allowMultiple = param.allowMultiple;
475
+ var disabled = param.disabled, uploadImage = param.uploadImage, title = param.title, supportedFormat = param.supportedFormat, render = param.render;
474
476
  var context = useContext(ConfigProvider.ConfigContext);
475
477
  var prefix = context === null || context === void 0 ? void 0 : context.getPrefixCls('agentic-md-editor-attachment-button');
476
478
  var _useStyle = useStyle(prefix), wrapSSR = _useStyle.wrapSSR, hashId = _useStyle.hashId;
@@ -484,26 +486,12 @@ var ButtonContent = function(param) {
484
486
  }, /*#__PURE__*/ React.createElement(ButtonContent, {
485
487
  title: title
486
488
  }));
487
- var handleFileSelect = function(files) {
488
- // 触发文件上传
489
- upLoadFileToServer(files, {
490
- upload: upload,
491
- uploadWithResponse: uploadWithResponse,
492
- fileMap: fileMap,
493
- onFileMapChange: onFileMapChange,
494
- maxFileSize: maxFileSize,
495
- maxFileCount: maxFileCount,
496
- minFileCount: minFileCount,
497
- locale: {}
498
- });
499
- };
500
489
  var wrapper = render ? render({
501
490
  children: buttonWithStyle,
502
491
  supportedFormat: format
503
492
  }) : /*#__PURE__*/ React.createElement(AttachmentButtonPopover, {
504
493
  supportedFormat: format,
505
- onFileSelect: handleFileSelect,
506
- allowMultiple: allowMultiple
494
+ uploadImage: uploadImage
507
495
  }, buttonWithStyle);
508
496
  return wrapSSR(/*#__PURE__*/ React.createElement("div", {
509
497
  className: classNames("".concat(prefix), hashId, _define_property({}, "".concat(prefix, "-disabled"), disabled)),
@@ -21,7 +21,7 @@ export interface FileUploadManagerReturn {
21
21
  /** 支持的文件格式 */
22
22
  supportedFormat: SupportedFileFormatsType;
23
23
  /** 上传图片 */
24
- uploadImage: () => Promise<void>;
24
+ uploadImage: (forGallery?: boolean) => Promise<void>;
25
25
  /** 更新附件文件列表 */
26
26
  updateAttachmentFiles: (newFileMap?: Map<string, AttachmentFile>) => void;
27
27
  /** 处理文件删除 */
@@ -180,7 +180,7 @@ import { useRefFunction } from "../../Hooks/useRefFunction";
180
180
  import { I18nContext } from "../../I18n";
181
181
  import { upLoadFileToServer } from "../AttachmentButton";
182
182
  import { SupportedFileFormats } from "../AttachmentButton/AttachmentButtonPopover";
183
- import { isMobileDevice, isVivoOrOppoDevice } from "../AttachmentButton/utils";
183
+ import { isMobileDevice, isVivoOrOppoDevice, isWeChat } from "../AttachmentButton/utils";
184
184
  /**
185
185
  * 文件上传管理器
186
186
  *
@@ -200,167 +200,166 @@ import { isMobileDevice, isVivoOrOppoDevice } from "../AttachmentButton/utils";
200
200
  onFileMapChange === null || onFileMapChange === void 0 ? void 0 : onFileMapChange(new Map(newFileMap));
201
201
  });
202
202
  /**
203
+ * 移动设备默认的文件类型 accept 值
204
+ */ var MOBILE_DEFAULT_ACCEPT = 'application/vnd.ms-excel,application/vnd.openxmlformats-officedocument.spreadsheetml.sheet,application/vnd.ms-powerpoint,application/vnd.openxmlformats-officedocument.presentationml.presentation,application/msword,application/vnd.openxmlformats-officedocument.wordprocessingml.document,application/pdf,.csv,text/plain,application/x-zip-compressed';
205
+ /**
203
206
  * 根据支持的格式获取 accept 属性值
204
- * 在移动设备上,使用默认的 accept
205
- * vivo oppo 手机上,如果只支持图片格式,使用 image/* 打开相册;否则使用具体扩展名打开文件选择器
206
- */ var getAcceptValue = function() {
207
+ * 优先级:微信 > 手机品牌(oppo/vivo)> 移动设备 > 相册模式 > 默认
208
+ */ var getAcceptValue = useRefFunction(function(forGallery) {
209
+ // 相册模式
210
+ if (forGallery) {
211
+ return 'image/*';
212
+ }
207
213
  var isMobile = isMobileDevice();
208
214
  var isVivoOrOppo = isVivoOrOppoDevice();
215
+ var isWeChatEnv = isWeChat();
209
216
  var extensions = (supportedFormat === null || supportedFormat === void 0 ? void 0 : supportedFormat.extensions) || [];
210
- // vivo/oppo 设备:判断是否只包含图片格式
211
- var imageExtensions = [
212
- 'jpg',
213
- 'jpeg',
214
- 'png',
215
- 'gif',
216
- 'bmp',
217
- 'webp',
218
- 'svg'
219
- ];
220
- var isImageOnly = extensions.length > 0 && extensions.every(function(ext) {
221
- return imageExtensions.includes(ext.toLowerCase());
222
- });
223
- if (isImageOnly) {
224
- // 只支持图片格式,使用 image/* 打开相册
225
- return 'image/*';
217
+ // 1. 微信环境最优先:设置为空字符串以打开文件浏览器
218
+ if (isWeChatEnv) {
219
+ return '*';
226
220
  }
227
- // 如果是移动设备,返回默认的 accept 值
228
- if (isMobile) {
229
- return '';
221
+ // 2. 手机品牌其次(oppo/vivo):设置为空字符串以打开文件浏览器
222
+ if (isVivoOrOppo) {
223
+ return '*';
230
224
  }
231
- if (!isVivoOrOppo) {
232
- // vivo/oppo 设备,直接使用扩展名列表
233
- return extensions.length > 0 ? extensions.map(function(ext) {
234
- return ".".concat(ext);
235
- }).join(',') : 'image/*';
225
+ // 3. 移动设备其次:设置为空字符串以打开文件浏览器
226
+ if (isMobile) {
227
+ return '*';
236
228
  }
237
- // 支持其他格式,使用具体扩展名列表打开文件选择器
229
+ // 4. 默认情况:使用具体扩展名列表
238
230
  return extensions.length > 0 ? extensions.map(function(ext) {
239
231
  return ".".concat(ext);
240
- }).join(',') : 'image/*';
241
- };
232
+ }).join(',') : MOBILE_DEFAULT_ACCEPT;
233
+ });
242
234
  /**
243
235
  * 上传图片
244
- */ var uploadImage = useRefFunction(/*#__PURE__*/ _async_to_generator(function() {
245
- var isUploading, _iteratorNormalCompletion, _didIteratorError, _iteratorError, _iterator, _step, file, currentFileCount, errorMsg, input, _attachment_allowMultiple;
246
- return _ts_generator(this, function(_state) {
247
- // 检查是否有文件正在上传中
248
- isUploading = false;
249
- _iteratorNormalCompletion = true, _didIteratorError = false, _iteratorError = undefined;
250
- try {
251
- for(_iterator = ((fileMap === null || fileMap === void 0 ? void 0 : fileMap.values()) || [])[Symbol.iterator](); !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true){
252
- file = _step.value;
253
- if (file.status === 'uploading') {
254
- isUploading = true;
255
- break;
256
- }
257
- }
258
- } catch (err) {
259
- _didIteratorError = true;
260
- _iteratorError = err;
261
- } finally{
236
+ */ var uploadImage = useRefFunction(/*#__PURE__*/ function() {
237
+ var _ref = _async_to_generator(function(forGallery) {
238
+ var isUploading, _iteratorNormalCompletion, _didIteratorError, _iteratorError, _iterator, _step, file, currentFileCount, errorMsg, accept, input, _attachment_allowMultiple;
239
+ return _ts_generator(this, function(_state) {
240
+ // 检查是否有文件正在上传中
241
+ isUploading = false;
242
+ _iteratorNormalCompletion = true, _didIteratorError = false, _iteratorError = undefined;
262
243
  try {
263
- if (!_iteratorNormalCompletion && _iterator.return != null) {
264
- _iterator.return();
244
+ for(_iterator = ((fileMap === null || fileMap === void 0 ? void 0 : fileMap.values()) || [])[Symbol.iterator](); !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true){
245
+ file = _step.value;
246
+ if (file.status === 'uploading') {
247
+ isUploading = true;
248
+ break;
249
+ }
265
250
  }
251
+ } catch (err) {
252
+ _didIteratorError = true;
253
+ _iteratorError = err;
266
254
  } finally{
267
- if (_didIteratorError) {
268
- throw _iteratorError;
255
+ try {
256
+ if (!_iteratorNormalCompletion && _iterator.return != null) {
257
+ _iterator.return();
258
+ }
259
+ } finally{
260
+ if (_didIteratorError) {
261
+ throw _iteratorError;
262
+ }
269
263
  }
270
264
  }
271
- }
272
- if (isUploading) {
273
- return [
274
- 2
275
- ];
276
- }
277
- // 检查是否已达到最大文件数量限制
278
- currentFileCount = (fileMap === null || fileMap === void 0 ? void 0 : fileMap.size) || 0;
279
- if ((attachment === null || attachment === void 0 ? void 0 : attachment.maxFileCount) && currentFileCount >= attachment.maxFileCount) {
280
- errorMsg = (locale === null || locale === void 0 ? void 0 : locale['markdownInput.maxFileCountExceeded']) ? locale['markdownInput.maxFileCountExceeded'].replace('${maxFileCount}', String(attachment.maxFileCount)) : "最多只能上传 ".concat(attachment.maxFileCount, " 个文件");
281
- message.error(errorMsg);
282
- return [
283
- 2
284
- ];
285
- }
286
- input = document.createElement('input');
287
- input.id = 'uploadImage' + '_' + Math.random();
288
- input.type = 'file';
289
- input.accept = getAcceptValue();
290
- input.multiple = (_attachment_allowMultiple = attachment === null || attachment === void 0 ? void 0 : attachment.allowMultiple) !== null && _attachment_allowMultiple !== void 0 ? _attachment_allowMultiple : true;
291
- input.style.display = 'none';
292
- input.onchange = /*#__PURE__*/ function() {
293
- var _ref = _async_to_generator(function(e) {
294
- var error;
295
- return _ts_generator(this, function(_state) {
296
- switch(_state.label){
297
- case 0:
298
- if (input.dataset.readonly) {
265
+ if (isUploading) {
266
+ return [
267
+ 2
268
+ ];
269
+ }
270
+ // 检查是否已达到最大文件数量限制
271
+ currentFileCount = (fileMap === null || fileMap === void 0 ? void 0 : fileMap.size) || 0;
272
+ if ((attachment === null || attachment === void 0 ? void 0 : attachment.maxFileCount) && currentFileCount >= attachment.maxFileCount) {
273
+ errorMsg = (locale === null || locale === void 0 ? void 0 : locale['markdownInput.maxFileCountExceeded']) ? locale['markdownInput.maxFileCountExceeded'].replace('${maxFileCount}', String(attachment.maxFileCount)) : "最多只能上传 ".concat(attachment.maxFileCount, " 个文件");
274
+ message.error(errorMsg);
275
+ return [
276
+ 2
277
+ ];
278
+ }
279
+ accept = getAcceptValue(forGallery || false);
280
+ input = document.createElement('input');
281
+ input.id = 'uploadImage' + '_' + Math.random();
282
+ input.type = 'file';
283
+ input.accept = accept;
284
+ input.multiple = (_attachment_allowMultiple = attachment === null || attachment === void 0 ? void 0 : attachment.allowMultiple) !== null && _attachment_allowMultiple !== void 0 ? _attachment_allowMultiple : true;
285
+ input.style.display = 'none';
286
+ input.onchange = /*#__PURE__*/ function() {
287
+ var _ref = _async_to_generator(function(e) {
288
+ var error;
289
+ return _ts_generator(this, function(_state) {
290
+ switch(_state.label){
291
+ case 0:
292
+ if (input.dataset.readonly) {
293
+ return [
294
+ 2
295
+ ];
296
+ }
297
+ input.dataset.readonly = 'true';
298
+ _state.label = 1;
299
+ case 1:
300
+ _state.trys.push([
301
+ 1,
302
+ 3,
303
+ 4,
304
+ 5
305
+ ]);
306
+ return [
307
+ 4,
308
+ upLoadFileToServer(e.target.files, _object_spread_props(_object_spread({}, attachment), {
309
+ fileMap: fileMap,
310
+ onFileMapChange: function(newFileMap) {
311
+ updateAttachmentFiles(newFileMap);
312
+ },
313
+ locale: locale
314
+ }))
315
+ ];
316
+ case 2:
317
+ _state.sent();
318
+ return [
319
+ 3,
320
+ 5
321
+ ];
322
+ case 3:
323
+ error = _state.sent();
324
+ console.error('Error uploading files:', error);
325
+ return [
326
+ 3,
327
+ 5
328
+ ];
329
+ case 4:
330
+ input.value = '';
331
+ delete input.dataset.readonly;
332
+ return [
333
+ 7
334
+ ];
335
+ case 5:
299
336
  return [
300
337
  2
301
338
  ];
302
- }
303
- input.dataset.readonly = 'true';
304
- _state.label = 1;
305
- case 1:
306
- _state.trys.push([
307
- 1,
308
- 3,
309
- 4,
310
- 5
311
- ]);
312
- return [
313
- 4,
314
- upLoadFileToServer(e.target.files, _object_spread_props(_object_spread({}, attachment), {
315
- fileMap: fileMap,
316
- onFileMapChange: function(newFileMap) {
317
- updateAttachmentFiles(newFileMap);
318
- },
319
- locale: locale
320
- }))
321
- ];
322
- case 2:
323
- _state.sent();
324
- return [
325
- 3,
326
- 5
327
- ];
328
- case 3:
329
- error = _state.sent();
330
- console.error('Error uploading files:', error);
331
- return [
332
- 3,
333
- 5
334
- ];
335
- case 4:
336
- input.value = '';
337
- delete input.dataset.readonly;
338
- return [
339
- 7
340
- ];
341
- case 5:
342
- return [
343
- 2
344
- ];
345
- }
339
+ }
340
+ });
346
341
  });
347
- });
348
- return function(e) {
349
- return _ref.apply(this, arguments);
350
- };
351
- }();
352
- if (input.dataset.readonly) {
342
+ return function(e) {
343
+ return _ref.apply(this, arguments);
344
+ };
345
+ }();
346
+ if (input.dataset.readonly) {
347
+ return [
348
+ 2
349
+ ];
350
+ }
351
+ document.body.appendChild(input);
352
+ input.click();
353
+ input.remove();
353
354
  return [
354
355
  2
355
356
  ];
356
- }
357
- input.click();
358
- input.remove();
359
- return [
360
- 2
361
- ];
357
+ });
362
358
  });
363
- }));
359
+ return function(forGallery) {
360
+ return _ref.apply(this, arguments);
361
+ };
362
+ }());
364
363
  /**
365
364
  * 处理文件删除
366
365
  */ var handleFileRemoval = useRefFunction(/*#__PURE__*/ function() {
@@ -383,6 +383,38 @@ export type MarkdownInputFieldProps = {
383
383
  * ```
384
384
  */
385
385
  isShowBackTo?: boolean;
386
+ /**
387
+ * 输入框的最大高度(像素)
388
+ * @description 设置输入框的最大高度,超出部分将显示滚动条。如果同时设置了 style.maxHeight,则以该属性优先
389
+ * @example
390
+ * ```tsx
391
+ * <MarkdownInputField maxHeight={300} />
392
+ * ```
393
+ */
394
+ maxHeight?: number | string;
395
+ /**
396
+ * 输入文本的最大字符数限制
397
+ * @description 限制输入文本的最大字符数,超出限制后将无法继续输入
398
+ * @example
399
+ * ```tsx
400
+ * <MarkdownInputField maxLength={500} />
401
+ * ```
402
+ */
403
+ maxLength?: number;
404
+ /**
405
+ * 当输入达到最大长度限制时的回调函数
406
+ * @description 当用户尝试输入超出最大长度限制的内容时触发
407
+ * @example
408
+ * ```tsx
409
+ * <MarkdownInputField
410
+ * maxLength={100}
411
+ * onMaxLengthExceeded={() => {
412
+ * message.warning('已达到最大字数限制');
413
+ * }}
414
+ * />
415
+ * ```
416
+ */
417
+ onMaxLengthExceeded?: (value: string) => void;
386
418
  };
387
419
  /**
388
420
  * MarkdownInputField 组件 - Markdown输入字段组件
@@ -314,7 +314,7 @@ import { useVoiceInputManager } from "./VoiceInputManager";
314
314
  "onFocus",
315
315
  "isShowTopOperatingArea"
316
316
  ]);
317
- var _props_style, _props_attachment, _props_style1, _props_attachment1, _props_attachment2, _props_attachment3, _props_enlargeable, _props_refinePrompt, _props_style2, _props_attachment4, _props_attachment5, _props_enlargeable1, _props_refinePrompt1, _props_enlargeable2, _props_enlargeable3;
317
+ var _props_style, _props_attachment, _props_attachment1, _props_attachment2, _props_attachment3, _props_enlargeable, _props_refinePrompt, _props_style1, _props_attachment4, _props_attachment5, _props_enlargeable1, _props_refinePrompt1, _props_enlargeable2, _props_enlargeable3;
318
318
  var getPrefixCls = useContext(ConfigProvider.ConfigContext).getPrefixCls;
319
319
  var baseCls = getPrefixCls('agentic-md-input-field');
320
320
  var _useStyle = useStyle(baseCls), wrapSSR = _useStyle.wrapSSR, hashId = _useStyle.hashId;
@@ -349,10 +349,13 @@ import { useVoiceInputManager } from "./VoiceInputManager";
349
349
  ]);
350
350
  var collapsedHeight = useMemo(function() {
351
351
  var _props_style;
352
- var mh = (_props_style = props.style) === null || _props_style === void 0 ? void 0 : _props_style.maxHeight;
353
- var base = typeof mh === 'number' ? mh : mh ? parseFloat(String(mh)) || 114 : 114;
352
+ var _props_maxHeight;
353
+ // 优先使用 maxHeight prop,其次使用 style.maxHeight,最后使用默认值
354
+ var maxHeightValue = (_props_maxHeight = props.maxHeight) !== null && _props_maxHeight !== void 0 ? _props_maxHeight : (_props_style = props.style) === null || _props_style === void 0 ? void 0 : _props_style.maxHeight;
355
+ var base = typeof maxHeightValue === 'number' ? maxHeightValue : maxHeightValue ? parseFloat(String(maxHeightValue)) || 114 : 114;
354
356
  return base;
355
357
  }, [
358
+ props.maxHeight,
356
359
  (_props_style = props.style) === null || _props_style === void 0 ? void 0 : _props_style.maxHeight,
357
360
  (_props_attachment = props.attachment) === null || _props_attachment === void 0 ? void 0 : _props_attachment.enable
358
361
  ]);
@@ -361,7 +364,7 @@ import { useVoiceInputManager } from "./VoiceInputManager";
361
364
  var extra = ((_props_attachment = props.attachment) === null || _props_attachment === void 0 ? void 0 : _props_attachment.enable) ? 90 : 0;
362
365
  return collapsedHeight + extra;
363
366
  }, [
364
- (_props_style1 = props.style) === null || _props_style1 === void 0 ? void 0 : _props_style1.maxHeight,
367
+ collapsedHeight,
365
368
  (_props_attachment1 = props.attachment) === null || _props_attachment1 === void 0 ? void 0 : _props_attachment1.enable
366
369
  ]);
367
370
  var _useMergedState1 = _sliced_to_array(useMergedState(undefined, {
@@ -396,7 +399,7 @@ import { useVoiceInputManager } from "./VoiceInputManager";
396
399
  hasRefineAction,
397
400
  isMultiRowLayout,
398
401
  totalActionCount,
399
- (_props_style2 = props.style) === null || _props_style2 === void 0 ? void 0 : _props_style2.minHeight
402
+ (_props_style1 = props.style) === null || _props_style1 === void 0 ? void 0 : _props_style1.minHeight
400
403
  ]);
401
404
  // 文件上传管理
402
405
  var _useFileUploadManager = useFileUploadManager({
@@ -714,7 +717,7 @@ import { useVoiceInputManager } from "./VoiceInputManager";
714
717
  minHeight: computedMinHeight,
715
718
  cursor: isLoading || props.disabled ? 'not-allowed' : 'auto',
716
719
  opacity: props.disabled ? 0.5 : 1,
717
- maxHeight: isEnlarged ? 'none' : "min(".concat(collapsedHeightPx, "px,100%)"),
720
+ maxHeight: isEnlarged ? 'none' : props.maxHeight !== undefined ? typeof props.maxHeight === 'number' ? "".concat(props.maxHeight, "px") : props.maxHeight : "min(".concat(collapsedHeightPx, "px,100%)"),
718
721
  transition: 'height, max-height 0.3s,border-radius 0.3s,box-shadow 0.3s,transform 0.3s,opacity 0.3s,background 0.3s'
719
722
  }),
720
723
  tabIndex: 1,
@@ -733,8 +736,10 @@ import { useVoiceInputManager } from "./VoiceInputManager";
733
736
  borderTopRightRadius: 'inherit',
734
737
  maxHeight: isEnlarged ? 'none' : function() {
735
738
  var _props_style, _props_attachment;
736
- var mh = (_props_style = props.style) === null || _props_style === void 0 ? void 0 : _props_style.maxHeight;
737
- var base = typeof mh === 'number' ? mh : mh ? parseFloat(String(mh)) || 400 : 400;
739
+ var _props_maxHeight;
740
+ // 优先使用 maxHeight prop,其次使用 style.maxHeight,最后使用默认值
741
+ var maxHeightValue = (_props_maxHeight = props.maxHeight) !== null && _props_maxHeight !== void 0 ? _props_maxHeight : (_props_style = props.style) === null || _props_style === void 0 ? void 0 : _props_style.maxHeight;
742
+ var base = typeof maxHeightValue === 'number' ? maxHeightValue : maxHeightValue ? parseFloat(String(maxHeightValue)) || 400 : 400;
738
743
  var extra = ((_props_attachment = props.attachment) === null || _props_attachment === void 0 ? void 0 : _props_attachment.enable) ? 90 : 0;
739
744
  return "min(".concat(base + extra, "px)");
740
745
  }(),
@@ -778,6 +783,19 @@ import { useVoiceInputManager } from "./VoiceInputManager";
778
783
  initValue: props.value,
779
784
  onChange: function(value) {
780
785
  var _props_onChange;
786
+ // 检查并限制字符数
787
+ if (props.maxLength !== undefined) {
788
+ if (value.length > props.maxLength) {
789
+ var _props_onChange1, _props_onMaxLengthExceeded, // 更新编辑器内容以反映截断后的值
790
+ _markdownEditorRef_current_store, _markdownEditorRef_current;
791
+ var truncatedValue = value.slice(0, props.maxLength);
792
+ setValue(truncatedValue);
793
+ (_props_onChange1 = props.onChange) === null || _props_onChange1 === void 0 ? void 0 : _props_onChange1.call(props, truncatedValue);
794
+ (_props_onMaxLengthExceeded = props.onMaxLengthExceeded) === null || _props_onMaxLengthExceeded === void 0 ? void 0 : _props_onMaxLengthExceeded.call(props, value);
795
+ (_markdownEditorRef_current = markdownEditorRef.current) === null || _markdownEditorRef_current === void 0 ? void 0 : (_markdownEditorRef_current_store = _markdownEditorRef_current.store) === null || _markdownEditorRef_current_store === void 0 ? void 0 : _markdownEditorRef_current_store.setMDContent(truncatedValue);
796
+ return;
797
+ }
798
+ }
781
799
  setValue(value);
782
800
  (_props_onChange = props.onChange) === null || _props_onChange === void 0 ? void 0 : _props_onChange.call(props, value);
783
801
  },
@@ -31,7 +31,7 @@ export interface SendActionsProps {
31
31
  /** 是否允许空内容提交 */
32
32
  allowEmptySubmit?: boolean;
33
33
  /** 上传图片回调 */
34
- uploadImage?: () => Promise<void>;
34
+ uploadImage?: (forGallery?: boolean) => Promise<void>;
35
35
  /** 开始录音回调 */
36
36
  onStartRecording?: () => Promise<void>;
37
37
  /** 停止录音回调 */