@ant-design/agentic-ui 2.29.57 → 2.29.59

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.
@@ -727,21 +727,26 @@ import { VoiceButton } from "./VoiceButton";
727
727
  voiceDom
728
728
  ];
729
729
  }
730
+ var inPopover = context === null || context === void 0 ? void 0 : context.extraShowOnHover;
730
731
  return /*#__PURE__*/ React.createElement("div", {
731
732
  className: prefixCls,
732
- style: _object_spread({
733
+ style: _object_spread(_object_spread_props(_object_spread({
733
734
  display: 'flex',
734
735
  alignItems: 'center',
735
736
  justifyContent: 'space-between',
736
- width: '100%',
737
+ width: '100%'
738
+ }, inPopover ? {
739
+ padding: 0
740
+ } : {
737
741
  paddingLeft: placement === 'right' ? 0 : 'var(--padding-5x)',
738
742
  paddingRight: placement === 'right' ? 0 : 'var(--padding-5x)',
739
743
  paddingTop: placement === 'right' ? 0 : 'var(--padding-1x)',
740
- paddingBottom: placement === 'right' ? 0 : 'var(--padding-2x)',
744
+ paddingBottom: placement === 'right' ? 0 : 'var(--padding-2x)'
745
+ }), {
741
746
  color: 'var(--color-gray-text-secondary)',
742
747
  fontSize: (context === null || context === void 0 ? void 0 : context.compact) ? '11px' : '13px',
743
748
  gap: 4
744
- }, props.style)
749
+ }), props.style)
745
750
  }, typing && originalData.content !== '...' ? /*#__PURE__*/ React.createElement("div", {
746
751
  style: {
747
752
  display: 'flex',
@@ -3,3 +3,10 @@
3
3
  * 在 markdown 解析前替换,渲染与序列化时还原为 $。
4
4
  */
5
5
  export declare const JINJA_DOLLAR_PLACEHOLDER = "\uE01A";
6
+ /**
7
+ * 保护时间格式(如 02:20:31)不被 remark-directive 误解析为 textDirective。
8
+ * remark-directive 会将 ":20"、":31" 等解析为指令,导致 "Cannot handle unknown node textDirective"。
9
+ * 在数字与冒号间插入零宽空格 \u200B 以阻断误解析。
10
+ * 须在 remark-directive 解析前执行。
11
+ */
12
+ export declare function preprocessProtectTimeFromDirective(markdown: string): string;
@@ -2,3 +2,19 @@
2
2
  * 占位符:保护 Jinja 块内 $ 不被 remark-math 解析为数学公式。
3
3
  * 在 markdown 解析前替换,渲染与序列化时还原为 $。
4
4
  */ export var JINJA_DOLLAR_PLACEHOLDER = '\uE01A';
5
+ /** URL 协议占位符,用于保护时间格式预处理时不影响 https:// 等 */ var URL_PROTOCOL_PLACEHOLDER = '\uE01B\uE01B';
6
+ /**
7
+ * 保护时间格式(如 02:20:31)不被 remark-directive 误解析为 textDirective。
8
+ * remark-directive 会将 ":20"、":31" 等解析为指令,导致 "Cannot handle unknown node textDirective"。
9
+ * 在数字与冒号间插入零宽空格 \u200B 以阻断误解析。
10
+ * 须在 remark-directive 解析前执行。
11
+ */ export function preprocessProtectTimeFromDirective(markdown) {
12
+ if (!markdown || markdown.length === 0) return markdown;
13
+ var withProtocolProtected = markdown.replace(/:\/\//g, URL_PROTOCOL_PLACEHOLDER);
14
+ // 使用反斜杠转义冒号,阻止 ":20"、":31" 等被 remark-directive 解析为 textDirective
15
+ // remark-directive 官方推荐:\:port 可防止 :port 被解析为指令
16
+ var withTimeProtected = withProtocolProtected.replace(/:(\d)/g, function(_, d) {
17
+ return "\\:".concat(d);
18
+ });
19
+ return withTimeProtected.replace(/\uE01B\uE01B/g, '://');
20
+ }
@@ -65,6 +65,7 @@ import { convertParagraphToImage, fixStrongWithSpecialChars } from "../remarkPar
65
65
  import rehypeKatex from "rehype-katex";
66
66
  import remarkFrontmatter from "remark-frontmatter";
67
67
  import { EditorUtils } from "../../utils";
68
+ import { REMARK_REHYPE_DIRECTIVE_HANDLERS } from "../../utils/markdownToHtml";
68
69
  // 表格相关常量
69
70
  export var MIN_TABLE_CELL_LENGTH = 5; // 表格单元格最小长度
70
71
  export var tableRegex = /^\|.*\|\s*\n\|[-:| ]+\|/m;
@@ -72,7 +73,8 @@ export var tableRegex = /^\|.*\|\s*\n\|[-:| ]+\|/m;
72
73
  var stringifyObj = remark().use(remarkParse).use(fixStrongWithSpecialChars).use(convertParagraphToImage).use(remarkMath, {
73
74
  singleDollarTextMath: false
74
75
  }).use(remarkRehype, {
75
- allowDangerousHtml: true
76
+ allowDangerousHtml: true,
77
+ handlers: REMARK_REHYPE_DIRECTIVE_HANDLERS
76
78
  }).use(rehypeRaw).use(rehypeKatex).use(remarkGfm, {
77
79
  singleTilde: false
78
80
  }) // 禁用单波浪线删除线
@@ -81,8 +83,13 @@ var stringifyObj = remark().use(remarkParse).use(fixStrongWithSpecialChars).use(
81
83
  ]);
82
84
  var myRemark = {
83
85
  stringify: function stringify(obj) {
84
- var mdStr = stringifyObj.stringify(obj);
85
- return mdStr;
86
+ try {
87
+ var mdStr = stringifyObj.stringify(obj);
88
+ return mdStr;
89
+ } catch (error) {
90
+ console.error('myRemark.stringify error', obj);
91
+ return '';
92
+ }
86
93
  }
87
94
  };
88
95
  /**
@@ -167,6 +167,17 @@ import { shouldTreatInlineMathAsText } from "./parseMath";
167
167
  }
168
168
  continue;
169
169
  }
170
+ // remark-directive 的 textDirective/leafDirective,提取其 children 的文本内容
171
+ if (n.type === 'textDirective' || n.type === 'leafDirective') {
172
+ var directiveResult = parseText(n.children || [], leaf);
173
+ leafs = leafs.concat(directiveResult);
174
+ if (directiveResult.length === 0 && hasFormattingProps(leaf)) {
175
+ leafs.push(_object_spread_props(_object_spread({}, leaf), {
176
+ text: ''
177
+ }));
178
+ }
179
+ continue;
180
+ }
170
181
  // @ts-ignore
171
182
  leafs.push(_object_spread_props(_object_spread({}, leaf), {
172
183
  text: n.value || ''
@@ -269,6 +280,15 @@ import { shouldTreatInlineMathAsText } from "./parseMath";
269
280
  var inlineCodeResult = handleInlineCode(currentElement);
270
281
  return _object_spread({}, leafWithHtmlTags, inlineCodeResult);
271
282
  }
283
+ // remark-directive 的 textDirective/leafDirective,递归解析其 children
284
+ if (elementType === 'textDirective' || elementType === 'leafDirective') {
285
+ var _ref;
286
+ var children = currentElement.children || [];
287
+ var parsed = parseNodesFn(children, false, currentElement);
288
+ return (_ref = parsed === null || parsed === void 0 ? void 0 : parsed.at(0)) !== null && _ref !== void 0 ? _ref : {
289
+ text: ''
290
+ };
291
+ }
272
292
  // 处理内联元素(strong, link, emphasis, delete)
273
293
  var inlineElementTypes = [
274
294
  'strong',
@@ -98,6 +98,7 @@ function _unsupported_iterable_to_array(o, minLen) {
98
98
  if (n === "Map" || n === "Set") return Array.from(n);
99
99
  if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _array_like_to_array(o, minLen);
100
100
  }
101
+ import { preprocessProtectTimeFromDirective } from "./constants";
101
102
  import { applyContextPropsAndConfig } from "./parse/applyContextPropsAndConfig";
102
103
  import { handleBlockquote, handleContainerDirective, handleFootnoteDefinition, handleHeading, handleList, handleListItem, handleParagraph, handleTextAndInlineElements } from "./parse/parseBlockElements";
103
104
  import { handleCode, handleYaml } from "./parse/parseCode";
@@ -235,7 +236,8 @@ var removeAnswerTags = function removeAnswerTags(text) {
235
236
  {
236
237
  key: "preprocessMarkdown",
237
238
  value: function preprocessMarkdown(md) {
238
- var thinkProcessed = removeAnswerTags(preprocessThinkTags(md || ''));
239
+ var timeProtected = preprocessProtectTimeFromDirective(md || '');
240
+ var thinkProcessed = removeAnswerTags(preprocessThinkTags(timeProtected));
239
241
  var nonStandardProcessed = removeAnswerTags(preprocessNonStandardHtmlTags(thinkProcessed));
240
242
  return preprocessMarkdownTableNewlines(nonStandardProcessed);
241
243
  }
@@ -19,6 +19,24 @@ export interface MarkdownToHtmlConfig {
19
19
  * @returns 转义后的字符串
20
20
  */
21
21
  export declare function escapeHtml(html: string, encode?: boolean): string;
22
+ /**
23
+ * mdast-util-to-hast 自定义 handler:将 remark-directive 的 textDirective 转为 span 元素
24
+ * 避免 "Cannot handle unknown node textDirective" 错误
25
+ */
26
+ declare function textDirectiveHandler(state: any, node: any): any;
27
+ /**
28
+ * mdast-util-to-hast 自定义 handler:将 remark-directive 的 leafDirective 转为 span 元素
29
+ * 避免 "Cannot handle unknown node leafDirective" 错误
30
+ */
31
+ declare function leafDirectiveHandler(state: any, node: any): any;
32
+ /**
33
+ * remark-rehype 的 directive 节点 handlers,用于避免 "Cannot handle unknown node textDirective" 等错误
34
+ * 可复用于 parseTable 等其他使用 remark-rehype 的场景
35
+ */
36
+ export declare const REMARK_REHYPE_DIRECTIVE_HANDLERS: {
37
+ textDirective: typeof textDirectiveHandler;
38
+ leafDirective: typeof leafDirectiveHandler;
39
+ };
22
40
  export declare const DEFAULT_MARKDOWN_REMARK_PLUGINS: readonly MarkdownRemarkPlugin[];
23
41
  /**
24
42
  * 将 Markdown 内容转换为 HTML(异步版本)
@@ -85,3 +103,4 @@ export declare const markdownToHtml: (markdown: string, plugins?: MarkdownToHtml
85
103
  * - 同步版本可能影响用户界面响应性
86
104
  */
87
105
  export declare const markdownToHtmlSync: (markdown: string, plugins?: MarkdownToHtmlOptions, config?: MarkdownToHtmlConfig) => string;
106
+ export {};
@@ -255,7 +255,10 @@ var remarkRehypePlugin = remarkRehype;
255
255
  state.patch(node, result);
256
256
  return state.applyData(node, result);
257
257
  }
258
- var REMARK_REHYPE_DIRECTIVE_HANDLERS = {
258
+ /**
259
+ * remark-rehype 的 directive 节点 handlers,用于避免 "Cannot handle unknown node textDirective" 等错误
260
+ * 可复用于 parseTable 等其他使用 remark-rehype 的场景
261
+ */ export var REMARK_REHYPE_DIRECTIVE_HANDLERS = {
259
262
  textDirective: textDirectiveHandler,
260
263
  leafDirective: leafDirectiveHandler
261
264
  };
@@ -424,7 +424,7 @@ import { isMobileDevice, isVivoOrOppoDevice, isWeChat } from "../AttachmentButto
424
424
  * 处理文件重试
425
425
  */ var handleFileRetry = useRefFunction(function(file) {
426
426
  return _async_to_generator(function() {
427
- var map, url, isSuccess, uploadResult, unused, map1;
427
+ var map, url, isSuccess, uploadResult, error, map1;
428
428
  return _ts_generator(this, function(_state) {
429
429
  switch(_state.label){
430
430
  case 0:
@@ -486,11 +486,12 @@ import { isMobileDevice, isVivoOrOppoDevice, isWeChat } from "../AttachmentButto
486
486
  6
487
487
  ];
488
488
  case 5:
489
- unused = _state.sent();
489
+ error = _state.sent();
490
490
  file.status = 'error';
491
491
  map1 = new Map(fileMap);
492
492
  map1.set(file.uuid || '', file);
493
493
  updateAttachmentFiles(map1);
494
+ console.error('Error retrying file upload:', error);
494
495
  return [
495
496
  3,
496
497
  6
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ant-design/agentic-ui",
3
- "version": "2.29.57",
3
+ "version": "2.29.59",
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",