@ant-design/agentic-ui 2.23.0 → 2.24.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.
@@ -71,15 +71,15 @@ var canRenderThoughtChain = function(placement, role, thoughtChainEnabled) {
71
71
  if (thoughtChainEnabled === false) return false;
72
72
  return true;
73
73
  };
74
- /**
75
- * BubbleBeforeNode 组件
76
- *
77
- * 在聊天气泡之前渲染思维链或任务列表,显示AI的思考过程
78
- *
79
- * @example
80
- * ```tsx
81
- * <BubbleBeforeNode bubble={bubbleData} />
82
- * ```
74
+ /**
75
+ * BubbleBeforeNode 组件
76
+ *
77
+ * 在聊天气泡之前渲染思维链或任务列表,显示AI的思考过程
78
+ *
79
+ * @example
80
+ * ```tsx
81
+ * <BubbleBeforeNode bubble={bubbleData} />
82
+ * ```
83
83
  */ export var BubbleBeforeNode = function(param) {
84
84
  var bubble = param.bubble, className = param.className, style = param.style;
85
85
  var _context_thoughtChain, _originData_extra, _context_thoughtChain1, _context_thoughtChain2;
@@ -470,17 +470,31 @@ import partialJsonParse from "../json-parse";
470
470
  var isComment = commentValue.trim().startsWith('<!--') && commentValue.trim().endsWith('-->');
471
471
  // 检查是否是 otherProps 序列化生成的 JSON 注释
472
472
  // 这些注释应该被跳过,不应该被解析为 HTML 代码块
473
+ // 但是,如果注释包含图表配置(chartType),应该保留为 code 节点以便表格解析器使用
473
474
  if (isComment) {
474
475
  try {
476
+ var _parsed_;
475
477
  var commentContent = commentValue.replace('<!--', '').replace('-->', '').trim();
476
478
  var parsed = JSON.parse(commentContent);
477
- // 如果能够成功解析为 JSON 对象,且是对象类型(不是数组或基本类型),
478
- // 则认为是 otherProps 序列化生成的注释,应该返回 null 或空文本
479
- // 这些注释应该在 parserMarkdownToSlateNode 中被跳过
479
+ // 检查是否是图表配置
480
+ var isChartConfig = // 对象格式:{"chartType": ...}
481
+ (typeof parsed === "undefined" ? "undefined" : _type_of(parsed)) === 'object' && parsed !== null && !Array.isArray(parsed) && parsed.chartType || // 数组格式:[{"chartType": ...}]
482
+ Array.isArray(parsed) && parsed.length > 0 && _type_of(parsed[0]) === 'object' && ((_parsed_ = parsed[0]) === null || _parsed_ === void 0 ? void 0 : _parsed_.chartType);
483
+ // 如果能够成功解析为 JSON 对象,且是对象类型(不是数组或基本类型)
484
+ // 注意:对象格式的图表配置已经在 handleHtml 中转换为数组格式了
485
+ // 这里只处理非图表配置的对象格式注释
480
486
  if ((typeof parsed === "undefined" ? "undefined" : _type_of(parsed)) === 'object' && parsed !== null && !Array.isArray(parsed)) {
481
- return {
482
- text: ''
483
- };
487
+ // 如果包含 chartType 字段,说明是图表配置,应该已经在 handleHtml 中转换为数组格式
488
+ // 这里不应该再匹配到对象格式的图表配置,继续正常处理
489
+ if (isChartConfig && parsed.chartType) {
490
+ // 继续正常处理,创建 code 节点(此时应该已经是数组格式了)
491
+ } else {
492
+ // 否则认为是 otherProps 序列化生成的注释,应该返回空文本
493
+ // 这些注释应该在 parserMarkdownToSlateNode 中被跳过
494
+ return {
495
+ text: ''
496
+ };
497
+ }
484
498
  }
485
499
  } catch (e) {
486
500
  // 解析失败,不是 JSON 格式的注释,继续正常处理
@@ -704,6 +718,26 @@ import partialJsonParse from "../json-parse";
704
718
  var trimmedValue = (currentElement === null || currentElement === void 0 ? void 0 : (_currentElement_value = currentElement.value) === null || _currentElement_value === void 0 ? void 0 : _currentElement_value.trim()) || '';
705
719
  var isUnclosedComment = trimmedValue.startsWith('<!--') && !trimmedValue.endsWith('-->');
706
720
  var processedValue = isUnclosedComment ? trimmedValue + '-->' : (currentElement === null || currentElement === void 0 ? void 0 : currentElement.value) || '';
721
+ // 检查是否是对象格式的图表配置,如果是则转换为数组格式
722
+ var isComment = processedValue.trim().startsWith('<!--') && processedValue.trim().endsWith('-->');
723
+ if (isComment) {
724
+ try {
725
+ var commentContent = processedValue.replace('<!--', '').replace('-->', '').trim();
726
+ var parsed = JSON.parse(commentContent);
727
+ // 如果是对象格式且包含 chartType,转换为数组格式
728
+ if ((typeof parsed === "undefined" ? "undefined" : _type_of(parsed)) === 'object' && parsed !== null && !Array.isArray(parsed) && parsed.chartType) {
729
+ var arrayFormat = [
730
+ parsed
731
+ ];
732
+ var convertedContent = JSON.stringify(arrayFormat);
733
+ processedValue = "<!--".concat(convertedContent, "-->");
734
+ // 同时更新 currentElement.value,以便后续处理使用
735
+ currentElement.value = processedValue;
736
+ }
737
+ } catch (e) {
738
+ // 解析失败,不是 JSON 格式的注释,继续正常处理
739
+ }
740
+ }
707
741
  var value = (processedValue === null || processedValue === void 0 ? void 0 : processedValue.replace('<!--', '').replace('-->', '').trim()) || '{}';
708
742
  var contextProps = parseCommentContextProps(value, processedValue);
709
743
  var isBlockLevel = !parent || [
@@ -150,11 +150,7 @@ var myRemark = {
150
150
  */ export var parseTableOrChart = function(table, preNode, plugins, parseNodes, parserConfig) {
151
151
  var _table_children, _tableHeader_children, _table_children_slice, _table_children1, _table_align, _chartConfig_, _config_at, _config_at1;
152
152
  var keyMap = new Map();
153
- // @ts-ignore
154
- var config = // @ts-ignore
155
- (preNode === null || preNode === void 0 ? void 0 : preNode.type) === 'code' && // @ts-ignore
156
- (preNode === null || preNode === void 0 ? void 0 : preNode.language) === 'html' && (// @ts-ignore
157
- preNode === null || preNode === void 0 ? void 0 : preNode.otherProps) ? preNode === null || preNode === void 0 ? void 0 : preNode.otherProps : {};
153
+ var config = (preNode === null || preNode === void 0 ? void 0 : preNode.type) === 'code' && (preNode === null || preNode === void 0 ? void 0 : preNode.language) === 'html' && (preNode === null || preNode === void 0 ? void 0 : preNode.otherProps) ? preNode === null || preNode === void 0 ? void 0 : preNode.otherProps : parserConfig || {};
158
154
  var tableHeader = table === null || table === void 0 ? void 0 : (_table_children = table.children) === null || _table_children === void 0 ? void 0 : _table_children.at(0);
159
155
  var columns = (tableHeader === null || tableHeader === void 0 ? void 0 : (_tableHeader_children = tableHeader.children) === null || _tableHeader_children === void 0 ? void 0 : _tableHeader_children.map(function(node) {
160
156
  var _myRemark_stringify;
@@ -239,7 +235,7 @@ var myRemark = {
239
235
  chartConfig = convertObjectToArray(chartConfig);
240
236
  var isChart = (chartConfig === null || chartConfig === void 0 ? void 0 : chartConfig.chartType) || Array.isArray(chartConfig) && (chartConfig === null || chartConfig === void 0 ? void 0 : (_chartConfig_ = chartConfig[0]) === null || _chartConfig_ === void 0 ? void 0 : _chartConfig_.chartType) || (config === null || config === void 0 ? void 0 : config.chartType) || (config === null || config === void 0 ? void 0 : (_config_at1 = config.at) === null || _config_at1 === void 0 ? void 0 : (_config_at = _config_at1.call(config, 0)) === null || _config_at === void 0 ? void 0 : _config_at.chartType);
241
237
  // 计算合并单元格信息
242
- var mergeCells = config.mergeCells || [];
238
+ var mergeCells = (config === null || config === void 0 ? void 0 : config.mergeCells) || [];
243
239
  // 创建合并单元格映射,用于快速查找
244
240
  var mergeMap = new Map();
245
241
  mergeCells === null || mergeCells === void 0 ? void 0 : mergeCells.forEach(function(param) {
@@ -1,4 +1,4 @@
1
- import { Elements } from '../../el';
1
+ import { ChartTypeConfig, Elements } from '../../el';
2
2
  import { MarkdownEditorPlugin } from '../../plugin';
3
3
  /**
4
4
  * 解析Markdown字符串的配置选项
@@ -10,6 +10,7 @@ export interface ParserMarkdownToSlateNodeConfig {
10
10
  paragraphTag?: string;
11
11
  /** 是否正在输入中(打字机模式) */
12
12
  typing?: boolean;
13
+ config?: ChartTypeConfig[];
13
14
  }
14
15
  /**
15
16
  * Markdown 到 Slate 节点解析器类
@@ -18,7 +19,7 @@ export interface ParserMarkdownToSlateNodeConfig {
18
19
  * 使用类形式可以避免在函数调用链中传递配置参数和插件。
19
20
  */
20
21
  export declare class MarkdownToSlateParser {
21
- private readonly config;
22
+ private config;
22
23
  private readonly plugins;
23
24
  constructor(config?: ParserMarkdownToSlateNodeConfig, plugins?: MarkdownEditorPlugin[]);
24
25
  /**
@@ -59,6 +59,30 @@ function _object_spread(target) {
59
59
  }
60
60
  return target;
61
61
  }
62
+ function ownKeys(object, enumerableOnly) {
63
+ var keys = Object.keys(object);
64
+ if (Object.getOwnPropertySymbols) {
65
+ var symbols = Object.getOwnPropertySymbols(object);
66
+ if (enumerableOnly) {
67
+ symbols = symbols.filter(function(sym) {
68
+ return Object.getOwnPropertyDescriptor(object, sym).enumerable;
69
+ });
70
+ }
71
+ keys.push.apply(keys, symbols);
72
+ }
73
+ return keys;
74
+ }
75
+ function _object_spread_props(target, source) {
76
+ source = source != null ? source : {};
77
+ if (Object.getOwnPropertyDescriptors) {
78
+ Object.defineProperties(target, Object.getOwnPropertyDescriptors(source));
79
+ } else {
80
+ ownKeys(Object(source)).forEach(function(key) {
81
+ Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key));
82
+ });
83
+ }
84
+ return target;
85
+ }
62
86
  function _to_consumable_array(arr) {
63
87
  return _array_without_holes(arr) || _iterable_to_array(arr) || _unsupported_iterable_to_array(arr) || _non_iterable_spread();
64
88
  }
@@ -162,6 +186,11 @@ import mdastParser from "./remarkParse";
162
186
  // 对齐注释(如 {"align":"center"})不包含这些属性,应该被保留
163
187
  isOtherPropsComment = hasCodeMetadataProps;
164
188
  }
189
+ if (Array.isArray(htmlCommentProps)) {
190
+ htmlCommentProps = {
191
+ config: htmlCommentProps
192
+ };
193
+ }
165
194
  } catch (e) {
166
195
  // 解析失败,不是 JSON 格式的注释,可能是真正的 HTML 注释
167
196
  isOtherPropsComment = false;
@@ -184,12 +213,18 @@ import mdastParser from "./remarkParse";
184
213
  // 如果 HTML 注释不是代码块元数据注释,但包含 JSON 对象属性(如对齐注释),
185
214
  // 应该跳过注释本身,但将属性应用到下一个元素
186
215
  if (isHtmlComment && !isOtherPropsComment && htmlCommentProps && Object.keys(htmlCommentProps).length > 0) {
187
- // 将对齐注释等非代码块元数据注释的属性存储到 contextProps 中,供下一个元素使用
188
- contextProps = _object_spread({}, contextProps, htmlCommentProps);
189
- // 同时将属性作为 config 传递,以便 applyContextPropsAndConfig 设置 otherProps
190
- config = _object_spread({}, config, htmlCommentProps);
191
- // 跳过 HTML 注释本身,避免生成独立的 HTML 代码节点
192
- return "continue";
216
+ if (!Array.isArray(htmlCommentProps)) {
217
+ // 将对齐注释等非代码块元数据注释的属性存储到 contextProps 中,供下一个元素使用
218
+ contextProps = _object_spread({}, contextProps, htmlCommentProps);
219
+ // 同时将属性作为 config 传递,以便 applyContextPropsAndConfig 设置 otherProps
220
+ config = _object_spread({}, config, htmlCommentProps, contextProps);
221
+ // 跳过 HTML 注释本身,避免生成独立的 HTML 代码节点
222
+ return "continue";
223
+ } else {
224
+ config = _object_spread_props(_object_spread({}, config), {
225
+ config: _to_consumable_array((config === null || config === void 0 ? void 0 : config.config) || []).concat(_to_consumable_array(htmlCommentProps))
226
+ });
227
+ }
193
228
  }
194
229
  // 如果当前元素应该使用 contextProps 中的属性作为 config(用于设置 otherProps)
195
230
  // 这主要针对对齐注释等场景,需要同时设置 contextProps 和 otherProps
@@ -237,6 +272,9 @@ import mdastParser from "./remarkParse";
237
272
  }
238
273
  }
239
274
  }
275
+ if (Object.keys(config).length > 0) {
276
+ _this.config = _object_spread({}, _this.config, config);
277
+ }
240
278
  // 如果插件没有处理,使用默认处理逻辑
241
279
  if (!pluginHandled) {
242
280
  // 使用统一的处理函数,通过 this 访问配置和插件
@@ -17,7 +17,14 @@ export type CodeNode<T = Record<string, any>> = {
17
17
  className?: string;
18
18
  language?: string;
19
19
  render?: boolean;
20
+ mergeCells?: Array<{
21
+ row: number;
22
+ col: number;
23
+ rowSpan: number;
24
+ colSpan: number;
25
+ }>;
20
26
  frontmatter?: boolean;
27
+ config?: Record<string, any>[];
21
28
  } & T;
22
29
  children: [{
23
30
  text: string;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ant-design/agentic-ui",
3
- "version": "2.23.0",
3
+ "version": "2.24.0",
4
4
  "description": "面向智能体的 UI 组件库,提供多步推理可视化、工具调用展示、任务执行协同等 Agentic UI 能力",
5
5
  "repository": "git@github.com:ant-design/agentic-ui.git",
6
6
  "license": "MIT",