@ant-design/agentic-ui 2.29.17 → 2.29.18

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.
@@ -764,7 +764,7 @@ var defaultAllowedTypes = [
764
764
  * 实际的粘贴处理逻辑
765
765
  */ var handlePasteEvent = function(event) {
766
766
  return _async_to_generator(function() {
767
- var _props_onPaste, _event_clipboardData, pasteConfig, currentTextSelection, nodeList, curNode, types, allowedTypes, _event_clipboardData_getData, _event_clipboardData_getData1, _event_clipboardData1, text, _event_clipboardData_getData2, _event_clipboardData_getData3, _event_clipboardData2, text1, selection, e;
767
+ var _props_onPaste, _event_clipboardData, pasteConfig, currentTextSelection, nodeList, curNode, result, types, allowedTypes, result1, _event_clipboardData_getData, _event_clipboardData_getData1, _event_clipboardData1, text, _event_clipboardData_getData2, _event_clipboardData_getData3, _event_clipboardData2, text1, selection, e;
768
768
  return _ts_generator(this, function(_state) {
769
769
  switch(_state.label){
770
770
  case 0:
@@ -793,7 +793,12 @@ var defaultAllowedTypes = [
793
793
  ];
794
794
  }
795
795
  }
796
- (_props_onPaste = props.onPaste) === null || _props_onPaste === void 0 ? void 0 : _props_onPaste.call(props, event);
796
+ result = (_props_onPaste = props.onPaste) === null || _props_onPaste === void 0 ? void 0 : _props_onPaste.call(props, event);
797
+ if (result === false) {
798
+ return [
799
+ 2
800
+ ];
801
+ }
797
802
  types = ((_event_clipboardData = event.clipboardData) === null || _event_clipboardData === void 0 ? void 0 : _event_clipboardData.types) || [
798
803
  'text/plain'
799
804
  ];
@@ -816,7 +821,8 @@ var defaultAllowedTypes = [
816
821
  handleHtmlPaste(markdownEditorRef.current, event.clipboardData, props)
817
822
  ];
818
823
  case 1:
819
- if (_state.sent()) {
824
+ result1 = _state.sent();
825
+ if (result1 === false) {
820
826
  return [
821
827
  2
822
828
  ];
@@ -240,13 +240,32 @@ function _ts_generator(thisArg, body) {
240
240
  import { Editor, Element, Node, Path, Range, Transforms } from "slate";
241
241
  import { jsx } from "slate-hyperscript";
242
242
  import { debugInfo } from "../../../Utils/debugUtils";
243
- import { debugLog, EditorUtils } from "../utils";
243
+ import { EditorUtils } from "../utils";
244
244
  import { docxDeserializer } from "../utils/docx/docxDeserializer";
245
245
  import { BackspaceKey } from "./hotKeyCommands/backspace";
246
246
  // 性能优化常量
247
247
  var BATCH_SIZE = 10; // 每批处理的节点数量
248
248
  var BATCH_DELAY = 16; // 每批之间的延迟时间(ms),约60fps
249
249
  var MAX_SYNC_SIZE = 1000; // 同步处理的最大字符数
250
+ /** 文件上传时排除的片段类型 */ var UPLOAD_EXCLUDED_FRAGMENT_TYPES = [
251
+ 'media',
252
+ 'image'
253
+ ];
254
+ /** card 的第二个子节点为 media/image 时排除上传 */ var CARD_CONTENT_EXCLUDED_TYPES = [
255
+ 'media',
256
+ 'image'
257
+ ];
258
+ var shouldExcludeFromUpload = function(fragment) {
259
+ if (UPLOAD_EXCLUDED_FRAGMENT_TYPES.includes(fragment === null || fragment === void 0 ? void 0 : fragment.type)) {
260
+ return true;
261
+ }
262
+ if ((fragment === null || fragment === void 0 ? void 0 : fragment.type) === 'card') {
263
+ var _fragment_children;
264
+ var secondNode = fragment === null || fragment === void 0 ? void 0 : (_fragment_children = fragment.children) === null || _fragment_children === void 0 ? void 0 : _fragment_children[1];
265
+ return CARD_CONTENT_EXCLUDED_TYPES.includes(secondNode === null || secondNode === void 0 ? void 0 : secondNode.type);
266
+ }
267
+ return false;
268
+ };
250
269
  var findElementByNode = function(node) {
251
270
  var index = Array.prototype.indexOf.call(node.parentNode.childNodes, node);
252
271
  return node.parentElement.children[index];
@@ -1002,7 +1021,7 @@ var blobToFile = function(blobUrl, fileName) {
1002
1021
  };
1003
1022
  export var insertParsedHtmlNodes = function(editor, html, editorProps, rtl) {
1004
1023
  return _async_to_generator(function() {
1005
- var hideLoading, fragmentList, _Editor_nodes, node, selection, processedNodes, back, _Editor_nodes1, specialNode, parsed, inner, hasCodeTags, textContent, children, _Editor_nodes2, p, parent, nextPath, texts, text, processedNodes1, error;
1024
+ var fragmentList, fragmentsToUpload, _Editor_nodes, node, selection, processedNodes, back, _Editor_nodes1, specialNode, parsed, inner, hasCodeTags, textContent, children, _Editor_nodes2, p, parent, nextPath, texts, text, processedNodes1, error;
1006
1025
  return _ts_generator(this, function(_state) {
1007
1026
  switch(_state.label){
1008
1027
  case 0:
@@ -1020,8 +1039,6 @@ export var insertParsedHtmlNodes = function(editor, html, editorProps, rtl) {
1020
1039
  false
1021
1040
  ];
1022
1041
  }
1023
- // 2. 显示解析提示
1024
- hideLoading = message.loading('parsing...', 0);
1025
1042
  _state.label = 1;
1026
1043
  case 1:
1027
1044
  _state.trys.push([
@@ -1030,39 +1047,28 @@ export var insertParsedHtmlNodes = function(editor, html, editorProps, rtl) {
1030
1047
  ,
1031
1048
  18
1032
1049
  ]);
1033
- // 3. 异步解析 HTML
1034
- debugInfo('insertParsedHtmlNodes - 开始解析 HTML');
1035
1050
  return [
1036
1051
  4,
1037
1052
  parseHtmlOptimized(html, rtl)
1038
1053
  ];
1039
1054
  case 2:
1040
1055
  fragmentList = _state.sent();
1041
- debugInfo('insertParsedHtmlNodes - HTML 解析完成', {
1042
- fragmentListLength: fragmentList === null || fragmentList === void 0 ? void 0 : fragmentList.length,
1043
- fragmentTypes: fragmentList === null || fragmentList === void 0 ? void 0 : fragmentList.map(function(f) {
1044
- return f === null || f === void 0 ? void 0 : f.type;
1045
- })
1046
- });
1047
1056
  if (!(fragmentList === null || fragmentList === void 0 ? void 0 : fragmentList.length)) {
1048
- debugInfo('insertParsedHtmlNodes - 解析结果为空');
1049
- hideLoading();
1050
1057
  return [
1051
1058
  2,
1052
1059
  false
1053
1060
  ];
1054
1061
  }
1055
- // 4. 异步处理文件上传
1056
- debugInfo('insertParsedHtmlNodes - 开始处理文件上传');
1062
+ // 4. 异步处理文件上传(排除 media、image;card 需判断第二个节点类型)
1063
+ fragmentsToUpload = fragmentList.filter(function(f) {
1064
+ return !shouldExcludeFromUpload(f);
1065
+ });
1057
1066
  return [
1058
1067
  4,
1059
- upLoadFileBatch(fragmentList, editorProps)
1068
+ upLoadFileBatch(fragmentsToUpload, editorProps)
1060
1069
  ];
1061
1070
  case 3:
1062
1071
  _state.sent();
1063
- debugInfo('insertParsedHtmlNodes - 文件上传完成');
1064
- debugLog('wordFragmentList', fragmentList);
1065
- hideLoading();
1066
1072
  // 5. 获取当前节点
1067
1073
  _Editor_nodes = _sliced_to_array(Editor.nodes(editor, {
1068
1074
  match: function(n) {
@@ -1075,7 +1081,7 @@ export var insertParsedHtmlNodes = function(editor, html, editorProps, rtl) {
1075
1081
  5
1076
1082
  ];
1077
1083
  debugInfo('insertParsedHtmlNodes - 无有效选区,直接插入');
1078
- processedNodes = fragmentList === null || fragmentList === void 0 ? void 0 : fragmentList.map(function(item) {
1084
+ processedNodes = fragmentsToUpload === null || fragmentsToUpload === void 0 ? void 0 : fragmentsToUpload.map(function(item) {
1079
1085
  if (!item.type) {
1080
1086
  return {
1081
1087
  type: 'paragraph',
@@ -1189,15 +1195,15 @@ export var insertParsedHtmlNodes = function(editor, html, editorProps, rtl) {
1189
1195
  true
1190
1196
  ];
1191
1197
  }
1192
- if (!((node === null || node === void 0 ? void 0 : node[0].type) === 'list-item' && (fragmentList[0].type === 'list' || fragmentList[0].type === 'bulleted-list' || fragmentList[0].type === 'numbered-list'))) return [
1198
+ if (!((node === null || node === void 0 ? void 0 : node[0].type) === 'list-item' && (fragmentsToUpload[0].type === 'list' || fragmentsToUpload[0].type === 'bulleted-list' || fragmentsToUpload[0].type === 'numbered-list'))) return [
1193
1199
  3,
1194
1200
  12
1195
1201
  ];
1196
1202
  debugInfo('insertParsedHtmlNodes - 处理列表项', {
1197
1203
  currentNodeType: node[0].type,
1198
- fragmentListType: fragmentList[0].type
1204
+ fragmentListType: fragmentsToUpload[0].type
1199
1205
  });
1200
- children = fragmentList[0].children || [];
1206
+ children = fragmentsToUpload[0].children || [];
1201
1207
  debugInfo('insertParsedHtmlNodes - 列表项子节点', {
1202
1208
  childrenCount: children.length
1203
1209
  });
@@ -1269,13 +1275,13 @@ export var insertParsedHtmlNodes = function(editor, html, editorProps, rtl) {
1269
1275
  _state.sent();
1270
1276
  _state.label = 9;
1271
1277
  case 9:
1272
- if (!(fragmentList.length > 1)) return [
1278
+ if (!(fragmentsToUpload.length > 1)) return [
1273
1279
  3,
1274
1280
  11
1275
1281
  ];
1276
1282
  return [
1277
1283
  4,
1278
- insertNodesBatch(editor, fragmentList.slice(1), selection.anchor.path, {
1284
+ insertNodesBatch(editor, fragmentsToUpload.slice(1), selection.anchor.path, {
1279
1285
  select: true
1280
1286
  })
1281
1287
  ];
@@ -1290,7 +1296,7 @@ export var insertParsedHtmlNodes = function(editor, html, editorProps, rtl) {
1290
1296
  case 12:
1291
1297
  // 11. 处理表格单元格
1292
1298
  if ((node === null || node === void 0 ? void 0 : node[0].type) === 'table-cell') {
1293
- Transforms.insertFragment(editor, getTextsNode(fragmentList), {
1299
+ Transforms.insertFragment(editor, getTextsNode(fragmentsToUpload), {
1294
1300
  at: selection
1295
1301
  });
1296
1302
  return [
@@ -1302,8 +1308,8 @@ export var insertParsedHtmlNodes = function(editor, html, editorProps, rtl) {
1302
1308
  3,
1303
1309
  15
1304
1310
  ];
1305
- if (fragmentList[0].type) {
1306
- if (fragmentList[0].type !== 'paragraph') {
1311
+ if (fragmentsToUpload[0].type) {
1312
+ if (fragmentsToUpload[0].type !== 'paragraph') {
1307
1313
  Transforms.insertNodes(editor, {
1308
1314
  type: 'paragraph',
1309
1315
  children: [
@@ -1325,7 +1331,7 @@ export var insertParsedHtmlNodes = function(editor, html, editorProps, rtl) {
1325
1331
  false
1326
1332
  ];
1327
1333
  }
1328
- texts = fragmentList.filter(function(c) {
1334
+ texts = fragmentsToUpload.filter(function(c) {
1329
1335
  return c.text;
1330
1336
  });
1331
1337
  if (!texts.length) return [
@@ -1349,8 +1355,8 @@ export var insertParsedHtmlNodes = function(editor, html, editorProps, rtl) {
1349
1355
  ];
1350
1356
  case 15:
1351
1357
  // 13. 处理单个段落的特殊情况
1352
- if (fragmentList.length === 1 && (fragmentList[0].type === 'paragraph' || !fragmentList[0].type) && node) {
1353
- text = Node.string(fragmentList[0]);
1358
+ if (fragmentsToUpload.length === 1 && (fragmentsToUpload[0].type === 'paragraph' || !fragmentsToUpload[0].type) && node) {
1359
+ text = Node.string(fragmentsToUpload[0]);
1354
1360
  if (text) {
1355
1361
  Transforms.insertText(editor, text, {
1356
1362
  at: selection
@@ -1363,7 +1369,7 @@ export var insertParsedHtmlNodes = function(editor, html, editorProps, rtl) {
1363
1369
  }
1364
1370
  // 14. 默认情况:替换选中节点
1365
1371
  debugInfo('insertParsedHtmlNodes - 使用默认处理方式');
1366
- processedNodes1 = fragmentList === null || fragmentList === void 0 ? void 0 : fragmentList.map(function(item) {
1372
+ processedNodes1 = fragmentsToUpload === null || fragmentsToUpload === void 0 ? void 0 : fragmentsToUpload.map(function(item) {
1367
1373
  if (!item.type) {
1368
1374
  return {
1369
1375
  type: 'paragraph',
@@ -1401,7 +1407,6 @@ export var insertParsedHtmlNodes = function(editor, html, editorProps, rtl) {
1401
1407
  case 17:
1402
1408
  error = _state.sent();
1403
1409
  console.error('插入HTML节点失败:', error);
1404
- hideLoading();
1405
1410
  message.error('Content parsing failed, please try again');
1406
1411
  return [
1407
1412
  2,
@@ -395,7 +395,7 @@ export type MarkdownEditorProps = {
395
395
  };
396
396
  onFocus?: (value: string, schema: Elements[], e: React.FocusEvent<HTMLDivElement, Element>) => void;
397
397
  onBlur?: (value: string, schema: Elements[], e: React.MouseEvent<HTMLDivElement, Element>) => void;
398
- onPaste?: (e: React.ClipboardEvent<HTMLDivElement>) => void;
398
+ onPaste?: (e: React.ClipboardEvent<HTMLDivElement>) => boolean | void;
399
399
  /**
400
400
  * 自定义 markdown 转 HTML 的 remark 插件配置,格式类似 Babel 插件数组
401
401
  */
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ant-design/agentic-ui",
3
- "version": "2.29.17",
3
+ "version": "2.29.18",
4
4
  "description": "面向智能体的 UI 组件库,提供多步推理可视化、工具调用展示、任务执行协同等 Agentic UI 能力",
5
5
  "repository": "git@github.com:ant-design/agentic-ui.git",
6
6
  "license": "MIT",