@ant-design/agentic-ui 2.30.24 → 2.30.26

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 (57) hide show
  1. package/dist/Bubble/AIBubble.js +2 -3
  2. package/dist/Bubble/Bubble.js +3 -2
  3. package/dist/Bubble/List/index.js +130 -23
  4. package/dist/Bubble/MessagesContent/index.js +94 -74
  5. package/dist/Bubble/OpenAIMessageBubble/index.d.ts +6 -6
  6. package/dist/Bubble/OpenAIMessageBubble/index.js +3 -3
  7. package/dist/Bubble/OpenAIMessageBubble/mapOllamaMessages.d.ts +1 -1
  8. package/dist/Bubble/OpenAIMessageBubble/mapOpenClawMessages.d.ts +1 -1
  9. package/dist/Bubble/OpenAIMessageBubble/normalizeOllamaMessages.d.ts +1 -1
  10. package/dist/Bubble/OpenAIMessageBubble/normalizeOpenClawMessages.d.ts +1 -1
  11. package/dist/Bubble/OpenAIMessageBubble/types.d.ts +1 -1
  12. package/dist/Bubble/OpenAIMessageBubble/useOllamaMessageBubbleData.d.ts +1 -1
  13. package/dist/Bubble/OpenAIMessageBubble/useOpenClawMessageBubbleData.d.ts +1 -1
  14. package/dist/Bubble/bubblePropsAreEqual.d.ts +23 -0
  15. package/dist/Bubble/bubblePropsAreEqual.js +272 -0
  16. package/dist/Components/TypingAnimation/index.d.ts +4 -1
  17. package/dist/Components/TypingAnimation/index.js +5 -3
  18. package/dist/MarkdownEditor/BaseMarkdownEditor.js +3 -2
  19. package/dist/MarkdownEditor/editor/elements/FootnoteDefinition/index.js +1 -2
  20. package/dist/MarkdownEditor/editor/elements/FootnoteReference/index.js +1 -2
  21. package/dist/MarkdownEditor/editor/elements/Head/index.js +1 -2
  22. package/dist/MarkdownEditor/editor/elements/LinkCard/index.js +1 -2
  23. package/dist/MarkdownEditor/editor/elements/Paragraph/ReadonlyParagraph.js +6 -3
  24. package/dist/MarkdownEditor/editor/elements/Paragraph/index.js +10 -30
  25. package/dist/MarkdownEditor/editor/elements/Table/EditableTable.js +1 -1
  26. package/dist/MarkdownEditor/editor/elements/index.js +1 -1
  27. package/dist/MarkdownEditor/editor/parser/parserMarkdownToSlateNode.js +1 -1
  28. package/dist/MarkdownEditor/editor/plugins/withListsPlugin.js +5 -4
  29. package/dist/MarkdownEditor/editor/plugins/withMarkdown.js +1 -1
  30. package/dist/MarkdownEditor/editor/plugins/withSanitizeInvalidChildren.d.ts +2 -1
  31. package/dist/MarkdownEditor/editor/plugins/withSanitizeInvalidChildren.js +174 -30
  32. package/dist/MarkdownEditor/editor/store.d.ts +4 -3
  33. package/dist/MarkdownEditor/editor/store.js +5 -0
  34. package/dist/MarkdownEditor/editor/tools/InsertAutocomplete.js +1 -0
  35. package/dist/MarkdownEditor/style.js +0 -6
  36. package/dist/MarkdownInputField/MarkdownInputField.js +1 -1
  37. package/dist/MarkdownRenderer/MarkdownRenderer.js +2 -2
  38. package/dist/MarkdownRenderer/index.d.ts +2 -2
  39. package/dist/MarkdownRenderer/index.js +1 -1
  40. package/dist/MarkdownRenderer/streaming/MarkdownBlockPiece.d.ts +1 -1
  41. package/dist/MarkdownRenderer/streaming/MarkdownBlockPiece.js +15 -3
  42. package/dist/MarkdownRenderer/streaming/useStreamingMarkdownReact.d.ts +2 -1
  43. package/dist/MarkdownRenderer/streaming/useStreamingMarkdownReact.js +4 -4
  44. package/dist/Plugins/chart/BarChart/index.js +1 -1
  45. package/dist/Plugins/chart/ChartAttrToolBar/index.js +1 -1
  46. package/dist/Plugins/chart/index.d.ts +1 -1
  47. package/dist/Plugins/code/utils/index.d.ts +1 -1
  48. package/dist/Plugins/mermaid/MermaidRendererImpl.js +53 -419
  49. package/dist/Plugins/mermaid/index.js +1 -2
  50. package/dist/Plugins/mermaid/style.js +57 -59
  51. package/dist/Plugins/mermaid/utils.js +67 -8
  52. package/dist/Schema/SchemaForm/index.js +1 -1
  53. package/dist/Workspace/File/FileComponent.js +1 -1
  54. package/dist/Workspace/File/PreviewComponent.js +16 -2
  55. package/dist/Workspace/File/index.d.ts +1 -1
  56. package/dist/Workspace/File/index.js +2 -1
  57. package/package.json +2 -1
@@ -51,99 +51,89 @@ function _object_spread_props(target, source) {
51
51
  return target;
52
52
  }
53
53
  import { useEditorStyleRegister } from "../../Hooks/useStyle";
54
+ /** 根容器内边距(与 ant-agentic-plugin-mermaid 设计一致) */ var MERMAID_ROOT_PADDING_PX = 8;
55
+ /** 左上角工具栏占位,避免与流程图节点重叠 */ var MERMAID_TOOLBAR_RESERVE_INLINE = 72;
54
56
  var genStyle = function genStyle(token) {
55
- var gridLightColor = 'rgba(0, 0, 0, 0.08)';
56
- var gridDarkColor = 'rgba(255, 255, 255, 0.14)';
57
- var _obj;
58
- return _obj = {}, _define_property(_obj, token.componentCls, {
57
+ return _define_property({}, token.componentCls, {
59
58
  marginBottom: '0.75em',
60
59
  cursor: 'default',
61
60
  userSelect: 'none',
62
- padding: '0.75rem 0',
61
+ padding: MERMAID_ROOT_PADDING_PX,
63
62
  borderRadius: '1em',
64
63
  maxWidth: '800px',
65
64
  border: "1px solid ".concat(token.colorBorder),
66
65
  backgroundColor: token.colorBgContainer,
67
66
  minWidth: '240px',
68
- minHeight: '200px',
67
+ minHeight: 'auto',
69
68
  display: 'flex',
70
69
  justifyContent: 'center',
71
- alignItems: 'center',
70
+ alignItems: 'stretch',
72
71
  flexDirection: 'column',
73
72
  position: 'relative',
74
- isolation: 'isolate',
75
- contain: 'layout style paint',
76
73
  overflow: 'hidden',
77
74
  transition: 'height 0.3s ease, min-height 0.3s ease',
78
- '&-fullscreen': {
79
- width: '100%',
80
- maxWidth: '100%',
81
- height: '100%'
82
- },
83
75
  '&-toolbar-float': {
84
76
  position: 'absolute',
85
- top: token.paddingSM,
86
- insetInlineEnd: token.paddingSM,
87
- left: 'auto',
77
+ top: MERMAID_ROOT_PADDING_PX,
78
+ insetInlineStart: MERMAID_ROOT_PADDING_PX,
79
+ insetInlineEnd: 'auto',
88
80
  zIndex: 10,
89
81
  display: 'flex',
90
82
  alignItems: 'center',
91
83
  gap: token.paddingXXS,
92
84
  pointerEvents: 'auto'
93
85
  },
94
- '&-viewport': {
95
- flex: 1,
86
+ /**
87
+ * 不用 flex:1 撑满父级,避免矮图下方大块留白;
88
+ * 内边距为工具栏与四周安全区,内容 flex 居中。
89
+ */ '&-viewport': {
96
90
  width: '100%',
97
- minHeight: 220,
98
- overflow: 'hidden',
91
+ minHeight: 120,
92
+ boxSizing: 'border-box',
93
+ paddingBlock: token.paddingLG,
94
+ paddingInlineStart: token.paddingLG + MERMAID_TOOLBAR_RESERVE_INLINE,
95
+ paddingInlineEnd: token.paddingLG,
96
+ overflow: 'auto',
99
97
  position: 'relative',
100
- touchAction: 'none',
101
- cursor: 'grab'
102
- },
103
- '&-viewport[data-mermaid-panning="true"]': {
104
- cursor: 'grabbing'
105
- },
106
- '&-viewport[data-mermaid-grid="true"]': {
107
- backgroundSize: '28px 28px',
108
- backgroundImage: "radial-gradient(circle, ".concat(gridLightColor, " 1.2px, transparent 1.2px)")
109
- },
110
- '&-viewport[data-mermaid-grid="true"]&-dark-grid': {
111
- backgroundImage: "radial-gradient(circle, ".concat(gridDarkColor, " 1.2px, transparent 1.2px)")
98
+ touchAction: 'auto',
99
+ cursor: 'default',
100
+ display: 'flex',
101
+ flexDirection: 'column',
102
+ justifyContent: 'center',
103
+ alignItems: 'center'
112
104
  },
113
105
  '& [data-mermaid-container="true"]': {
114
106
  zIndex: 0,
115
107
  width: '100%',
116
- minHeight: 220,
117
- display: 'block',
108
+ maxWidth: '100%',
109
+ minHeight: 0,
110
+ display: 'flex',
111
+ flexDirection: 'column',
118
112
  justifyContent: 'center',
113
+ alignItems: 'center',
119
114
  position: 'relative',
120
- isolation: 'isolate',
121
- contain: 'layout style paint',
122
115
  overflow: 'visible',
123
- transition: 'opacity 0.3s ease, height 0.3s ease, min-height 0.3s ease, max-height 0.3s ease',
124
- '--mermaid-pan-x': '0px',
125
- '--mermaid-pan-y': '0px',
126
- '--mermaid-scale': 1
116
+ transition: 'opacity 0.3s ease, height 0.3s ease, min-height 0.3s ease, max-height 0.3s ease'
127
117
  },
128
- '& [data-mermaid-wrapper]': {
118
+ /**
119
+ * 须为确定宽度,子 SVG 的 width:100% 才能按 viewBox 算出高度;
120
+ * 使用 max-content 时百分比参照异常,易出现「有 DOM 但看不见」。
121
+ */ '& [data-mermaid-wrapper]': {
129
122
  position: 'relative',
130
- width: 'max-content',
131
- maxWidth: 'none',
123
+ width: '100%',
124
+ maxWidth: '100%',
125
+ boxSizing: 'border-box',
132
126
  overflow: 'visible',
133
- isolation: 'isolate',
134
- contain: 'layout style paint',
135
- display: 'flex',
136
- justifyContent: 'flex-start',
137
- alignItems: 'flex-start',
127
+ display: 'block',
138
128
  minHeight: 0,
139
- transform: 'translate(var(--mermaid-pan-x), var(--mermaid-pan-y)) scale(var(--mermaid-scale))',
140
- transformOrigin: '0 0',
141
- willChange: 'transform'
129
+ marginInline: 'auto'
142
130
  },
143
131
  '& [data-mermaid-svg="true"]': {
132
+ display: 'block',
133
+ width: '100%',
144
134
  maxWidth: '100%',
145
135
  height: 'auto',
146
- overflow: 'hidden'
136
+ overflow: 'visible'
147
137
  },
148
138
  '&-error': {
149
139
  textAlign: 'center',
@@ -181,6 +171,12 @@ var genStyle = function genStyle(token) {
181
171
  }
182
172
  },
183
173
  '& svg': {
174
+ '& foreignObject': {
175
+ overflow: 'visible'
176
+ },
177
+ '& foreignObject div': {
178
+ overflow: 'visible'
179
+ },
184
180
  '& .node': {
185
181
  '& rect, & circle, & ellipse, & polygon': {
186
182
  stroke: token.colorBorder,
@@ -188,9 +184,13 @@ var genStyle = function genStyle(token) {
188
184
  fill: token.colorBgContainer
189
185
  }
190
186
  },
191
- '& text': {
192
- dominantBaseline: 'middle',
193
- textAnchor: 'middle',
187
+ /**
188
+ * 勿改 text-anchor / dominant-baseline:Mermaid 11 用 y、tspan 定位,
189
+ * 全局 middle 会把流程图标签挪出框外,看起来像空白。
190
+ */ '& text': {
191
+ fill: "".concat(token.colorText, " !important")
192
+ },
193
+ '& tspan': {
194
194
  fill: "".concat(token.colorText, " !important")
195
195
  },
196
196
  '& .nodeLabel': {
@@ -207,9 +207,7 @@ var genStyle = function genStyle(token) {
207
207
  fill: "".concat(token.colorText, " !important")
208
208
  }
209
209
  }
210
- }), _define_property(_obj, "".concat(token.componentCls, '[data-mermaid-theme="dark"] ').concat(token.componentCls, '-viewport[data-mermaid-grid="true"]'), {
211
- backgroundImage: "radial-gradient(circle, ".concat(gridDarkColor, " 1.2px, transparent 1.2px)")
212
- }), _obj;
210
+ });
213
211
  };
214
212
  export function useStyle(prefixCls) {
215
213
  return useEditorStyleRegister('agentic-plugin-mermaid', function(token) {
@@ -35,6 +35,19 @@ function _async_to_generator(fn) {
35
35
  });
36
36
  };
37
37
  }
38
+ function _define_property(obj, key, value) {
39
+ if (key in obj) {
40
+ Object.defineProperty(obj, key, {
41
+ value: value,
42
+ enumerable: true,
43
+ configurable: true,
44
+ writable: true
45
+ });
46
+ } else {
47
+ obj[key] = value;
48
+ }
49
+ return obj;
50
+ }
38
51
  function _instanceof(left, right) {
39
52
  if (right != null && typeof Symbol !== "undefined" && right[Symbol.hasInstance]) {
40
53
  return !!right[Symbol.hasInstance](left);
@@ -69,6 +82,45 @@ function _iterable_to_array_limit(arr, i) {
69
82
  function _non_iterable_rest() {
70
83
  throw new TypeError("Invalid attempt to destructure non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
71
84
  }
85
+ function _object_spread(target) {
86
+ for(var i = 1; i < arguments.length; i++){
87
+ var source = arguments[i] != null ? arguments[i] : {};
88
+ var ownKeys = Object.keys(source);
89
+ if (typeof Object.getOwnPropertySymbols === "function") {
90
+ ownKeys = ownKeys.concat(Object.getOwnPropertySymbols(source).filter(function(sym) {
91
+ return Object.getOwnPropertyDescriptor(source, sym).enumerable;
92
+ }));
93
+ }
94
+ ownKeys.forEach(function(key) {
95
+ _define_property(target, key, source[key]);
96
+ });
97
+ }
98
+ return target;
99
+ }
100
+ function ownKeys(object, enumerableOnly) {
101
+ var keys = Object.keys(object);
102
+ if (Object.getOwnPropertySymbols) {
103
+ var symbols = Object.getOwnPropertySymbols(object);
104
+ if (enumerableOnly) {
105
+ symbols = symbols.filter(function(sym) {
106
+ return Object.getOwnPropertyDescriptor(object, sym).enumerable;
107
+ });
108
+ }
109
+ keys.push.apply(keys, symbols);
110
+ }
111
+ return keys;
112
+ }
113
+ function _object_spread_props(target, source) {
114
+ source = source != null ? source : {};
115
+ if (Object.getOwnPropertyDescriptors) {
116
+ Object.defineProperties(target, Object.getOwnPropertyDescriptors(source));
117
+ } else {
118
+ ownKeys(Object(source)).forEach(function(key) {
119
+ Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key));
120
+ });
121
+ }
122
+ return target;
123
+ }
72
124
  function _sliced_to_array(arr, i) {
73
125
  return _array_with_holes(arr) || _iterable_to_array_limit(arr, i) || _unsupported_iterable_to_array(arr, i) || _non_iterable_rest();
74
126
  }
@@ -191,6 +243,16 @@ var DEFAULT_LIGHT_BORDER_COLOR = '#d9d9d9';
191
243
  var DEFAULT_DARK_BORDER_COLOR = '#434343';
192
244
  var DEFAULT_PRIMARY_COLOR = '#1677ff';
193
245
  var DEFAULT_FONT_FAMILY = 'Inter, -apple-system, Segoe UI, sans-serif';
246
+ /**
247
+ * 与宿主样式共存:流程图默认用 foreignObject 画 HTML 标签,易被外层 CSS 影响;
248
+ * 顶层与 flowchart 同时关闭 htmlLabels,强制走 SVG 文本(Mermaid 11 读取二者之一)。
249
+ */ var MERMAID_BASE_INIT = {
250
+ startOnLoad: false,
251
+ htmlLabels: false,
252
+ flowchart: {
253
+ htmlLabels: false
254
+ }
255
+ };
194
256
  var parseColorToRgb = function parseColorToRgb(color) {
195
257
  var normalizedColor = color.trim().toLowerCase();
196
258
  var shortHexMatch = normalizedColor.match(/^#([0-9a-f]{3})$/i);
@@ -318,17 +380,14 @@ export var applyMermaidTheme = function applyMermaidTheme(api, themeConfig) {
318
380
  return;
319
381
  }
320
382
  if (!themeConfig) {
321
- api.initialize({
322
- startOnLoad: false
323
- });
383
+ api.initialize(_object_spread({}, MERMAID_BASE_INIT));
324
384
  return;
325
385
  }
326
- api.initialize({
327
- startOnLoad: false,
386
+ api.initialize(_object_spread_props(_object_spread({}, MERMAID_BASE_INIT), {
328
387
  theme: 'base',
329
388
  darkMode: themeConfig.darkMode,
330
389
  themeVariables: themeConfig.themeVariables
331
- });
390
+ }));
332
391
  };
333
392
  /**
334
393
  * 加载 Mermaid 库
@@ -370,7 +429,7 @@ export var applyMermaidTheme = function applyMermaidTheme(api, themeConfig) {
370
429
  var svgElement = svgDoc.querySelector('svg');
371
430
  if (svgElement) {
372
431
  var existingStyle = svgElement.getAttribute('style') || '';
373
- var newStyle = "".concat(existingStyle, "; max-width: 100%; height: auto; overflow: hidden;").trim();
432
+ var newStyle = "".concat(existingStyle, "; display: block; max-width: 100%; width: 100%; height: auto; overflow: visible;").trim();
374
433
  svgElement.setAttribute('style', newStyle);
375
434
  svgElement.setAttribute('data-mermaid-svg', 'true');
376
435
  svgElement.setAttribute('class', (svgElement.getAttribute('class') || '') + ' mermaid-isolated');
@@ -386,7 +445,7 @@ export var applyMermaidTheme = function applyMermaidTheme(api, themeConfig) {
386
445
  tempDiv.innerHTML = svg;
387
446
  var extractedSvg = tempDiv.querySelector('svg');
388
447
  if (extractedSvg) {
389
- extractedSvg.setAttribute('style', 'max-width: 100%; height: auto; overflow: hidden;');
448
+ extractedSvg.setAttribute('style', 'display: block; max-width: 100%; width: 100%; height: auto; overflow: visible;');
390
449
  extractedSvg.setAttribute('data-mermaid-svg', 'true');
391
450
  wrapper.appendChild(extractedSvg);
392
451
  } else {
@@ -352,7 +352,7 @@ import { I18nContext, compileTemplate } from "../../I18n";
352
352
  },
353
353
  block: true,
354
354
  icon: /*#__PURE__*/ React.createElement(Plus, null)
355
- }, (locale === null || locale === void 0 ? void 0 : locale['schemaForm.addItem']) || '添加', " ", getPropertyTitle(property, key))));
355
+ }, (locale === null || locale === void 0 ? void 0 : locale['schemaForm.addItem']) || '添加', ' ', getPropertyTitle(property, key))));
356
356
  });
357
357
  }, [
358
358
  readonly,
@@ -241,8 +241,8 @@ import { Empty } from "antd";
241
241
  import classNames from "clsx";
242
242
  import { AnimatePresence, motion } from "framer-motion";
243
243
  import React, { useContext, useEffect, useMemo, useRef, useState } from "react";
244
- import { useRefFunction } from "../../Hooks/useRefFunction";
245
244
  import { ActionIconBox } from "../../Components/ActionIconBox";
245
+ import { useRefFunction } from "../../Hooks/useRefFunction";
246
246
  import { I18nContext, compileTemplate } from "../../I18n";
247
247
  import { formatFileSize, formatLastModified } from "../utils";
248
248
  import { fileTypeProcessor, isImageFile } from "./FileTypeProcessor";
@@ -270,7 +270,14 @@ var PlaceholderContent = function PlaceholderContent(param) {
270
270
  }, /*#__PURE__*/ React.createElement(Spin, {
271
271
  size: "large",
272
272
  tip: (locale === null || locale === void 0 ? void 0 : locale['workspace.file.processing']) || '正在处理文件...'
273
- }));
273
+ }, /*#__PURE__*/ React.createElement("div", {
274
+ className: classNames("".concat(prefixCls, "-spin-anchor"), hashId),
275
+ style: {
276
+ minHeight: 64,
277
+ width: '100%'
278
+ },
279
+ "aria-hidden": true
280
+ })));
274
281
  }
275
282
  if (contentState.status === 'error') {
276
283
  return /*#__PURE__*/ React.createElement(PlaceholderContent, {
@@ -357,7 +364,14 @@ var PlaceholderContent = function PlaceholderContent(param) {
357
364
  }, /*#__PURE__*/ React.createElement(Spin, {
358
365
  size: "large",
359
366
  tip: (locale === null || locale === void 0 ? void 0 : locale['workspace.loadingFileContent']) || '正在加载文件内容...'
360
- }));
367
+ }, /*#__PURE__*/ React.createElement("div", {
368
+ className: classNames("".concat(prefixCls, "-spin-anchor"), hashId),
369
+ style: {
370
+ minHeight: 64,
371
+ width: '100%'
372
+ },
373
+ "aria-hidden": true
374
+ })));
361
375
  }
362
376
  return /*#__PURE__*/ React.createElement("div", {
363
377
  className: classNames("".concat(prefixCls, "-text"), hashId)
@@ -1,6 +1,6 @@
1
1
  export { FileComponent as File } from './FileComponent';
2
2
  export { PreviewComponent } from './PreviewComponent';
3
3
  export type { PreviewComponentProps } from './PreviewComponent';
4
+ export { getFileTypeName } from '../types';
4
5
  export type { FileActionRef, FileBuiltinActions, FileNode, FileProps, FileRenderContext, FileType, GroupNode, } from '../types';
5
6
  export { getFileTypeIcon, getGroupIcon } from './utils';
6
- export { getFileTypeName } from '../types';
@@ -1,4 +1,5 @@
1
1
  export { FileComponent as File } from "./FileComponent";
2
2
  export { PreviewComponent } from "./PreviewComponent";
3
- export { getFileTypeIcon, getGroupIcon } from "./utils";
3
+ // 导出类型和工具函数
4
4
  export { getFileTypeName } from "../types";
5
+ export { getFileTypeIcon, getGroupIcon } from "./utils";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ant-design/agentic-ui",
3
- "version": "2.30.24",
3
+ "version": "2.30.26",
4
4
  "description": "面向智能体的 UI 组件库,提供多步推理可视化、工具调用展示、任务执行协同等 Agentic UI 能力",
5
5
  "repository": "git@github.com:ant-design/agentic-ui.git",
6
6
  "license": "MIT",
@@ -25,6 +25,7 @@
25
25
  "lint:es": "eslint \"{src,test}/**/*.{js,jsx,ts,tsx}\"",
26
26
  "playwright:install": "playwright install --with-deps chromium",
27
27
  "prepare": "husky install && dumi setup",
28
+ "prepublishOnly": "npm run build",
28
29
  "prettier": "prettier --write \"{src,docs,test}/**/*.{js,jsx,ts,tsx,css,less,json,md}\"",
29
30
  "preview": "pnpm dumi preview",
30
31
  "report:demo": "node scripts/generateDemoReport.js",