@ant-design/agentic-ui 2.30.21 → 2.30.23

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 (107) hide show
  1. package/dist/Bubble/MessagesContent/MarkdownPreview.d.ts +0 -58
  2. package/dist/Bubble/MessagesContent/MarkdownPreview.js +79 -155
  3. package/dist/Bubble/OpenAIMessageBubble/index.d.ts +11 -0
  4. package/dist/Bubble/OpenAIMessageBubble/index.js +8 -0
  5. package/dist/Bubble/OpenAIMessageBubble/mapOllamaMessages.d.ts +7 -0
  6. package/dist/Bubble/OpenAIMessageBubble/mapOllamaMessages.js +136 -0
  7. package/dist/Bubble/OpenAIMessageBubble/mapOpenAIMessages.d.ts +8 -0
  8. package/dist/Bubble/OpenAIMessageBubble/mapOpenAIMessages.js +156 -0
  9. package/dist/Bubble/OpenAIMessageBubble/mapOpenClawMessages.d.ts +8 -0
  10. package/dist/Bubble/OpenAIMessageBubble/mapOpenClawMessages.js +127 -0
  11. package/dist/Bubble/OpenAIMessageBubble/normalizeOllamaMessages.d.ts +16 -0
  12. package/dist/Bubble/OpenAIMessageBubble/normalizeOllamaMessages.js +110 -0
  13. package/dist/Bubble/OpenAIMessageBubble/normalizeOpenClawMessages.d.ts +10 -0
  14. package/dist/Bubble/OpenAIMessageBubble/normalizeOpenClawMessages.js +61 -0
  15. package/dist/Bubble/OpenAIMessageBubble/ollamaTypes.d.ts +48 -0
  16. package/dist/Bubble/OpenAIMessageBubble/ollamaTypes.js +1 -0
  17. package/dist/Bubble/OpenAIMessageBubble/openClawTypes.d.ts +27 -0
  18. package/dist/Bubble/OpenAIMessageBubble/openClawTypes.js +1 -0
  19. package/dist/Bubble/OpenAIMessageBubble/types.d.ts +71 -0
  20. package/dist/Bubble/OpenAIMessageBubble/types.js +1 -0
  21. package/dist/Bubble/OpenAIMessageBubble/useOllamaMessageBubbleData.d.ts +7 -0
  22. package/dist/Bubble/OpenAIMessageBubble/useOllamaMessageBubbleData.js +23 -0
  23. package/dist/Bubble/OpenAIMessageBubble/useOpenAIMessageBubbleData.d.ts +6 -0
  24. package/dist/Bubble/OpenAIMessageBubble/useOpenAIMessageBubbleData.js +20 -0
  25. package/dist/Bubble/OpenAIMessageBubble/useOpenClawMessageBubbleData.d.ts +7 -0
  26. package/dist/Bubble/OpenAIMessageBubble/useOpenClawMessageBubbleData.js +22 -0
  27. package/dist/Bubble/index.d.ts +2 -0
  28. package/dist/Bubble/index.js +1 -0
  29. package/dist/Hooks/useAutoScroll.js +6 -4
  30. package/dist/MarkdownEditor/BaseMarkdownEditor.d.ts +1 -50
  31. package/dist/MarkdownEditor/BaseMarkdownEditor.js +11 -55
  32. package/dist/MarkdownEditor/editor/Editor.js +35 -21
  33. package/dist/MarkdownEditor/editor/elements/Code/index.js +1 -0
  34. package/dist/MarkdownEditor/editor/elements/Table/SimpleTable.js +5 -1
  35. package/dist/MarkdownEditor/editor/elements/Table/commands/tableCommands.js +24 -8
  36. package/dist/MarkdownEditor/editor/elements/index.js +18 -14
  37. package/dist/MarkdownEditor/editor/plugins/elements.d.ts +2 -0
  38. package/dist/MarkdownEditor/editor/plugins/elements.js +4 -2
  39. package/dist/MarkdownEditor/editor/plugins/handlePaste.js +46 -35
  40. package/dist/MarkdownEditor/editor/plugins/hotKeyCommands/backspace.js +133 -133
  41. package/dist/MarkdownEditor/editor/plugins/hotKeyCommands/enter.js +156 -140
  42. package/dist/MarkdownEditor/editor/plugins/hotKeyCommands/match.d.ts +2 -1
  43. package/dist/MarkdownEditor/editor/plugins/hotKeyCommands/match.js +23 -4
  44. package/dist/MarkdownEditor/editor/plugins/hotKeyCommands/tab.js +40 -36
  45. package/dist/MarkdownEditor/editor/plugins/useKeyboard.js +46 -44
  46. package/dist/MarkdownEditor/editor/plugins/withCodeTagPlugin.js +1 -13
  47. package/dist/MarkdownEditor/editor/store.d.ts +15 -1
  48. package/dist/MarkdownEditor/editor/store.js +45 -34
  49. package/dist/MarkdownEditor/editor/tools/InsertAutocomplete.js +15 -11
  50. package/dist/MarkdownEditor/editor/utils/editorCommands.js +98 -17
  51. package/dist/MarkdownEditor/editor/utils/editorUtils.d.ts +11 -0
  52. package/dist/MarkdownEditor/editor/utils/editorUtils.js +43 -6
  53. package/dist/MarkdownEditor/editor/utils/keyboard.js +14 -12
  54. package/dist/MarkdownEditor/types.d.ts +36 -414
  55. package/dist/MarkdownEditor/types.js +1 -4
  56. package/dist/MarkdownInputField/AttachmentButton/AttachmentFileList/AttachmentFileListItem.d.ts +1 -1
  57. package/dist/MarkdownInputField/AttachmentButton/AttachmentFileList/AttachmentFileListItem.js +4 -5
  58. package/dist/MarkdownInputField/AttachmentButton/AttachmentFileList/index.d.ts +1 -1
  59. package/dist/MarkdownInputField/AttachmentButton/index.d.ts +1 -1
  60. package/dist/MarkdownInputField/MarkdownInputField.js +8 -1
  61. package/dist/MarkdownInputField/SendActions/index.js +7 -4
  62. package/dist/MarkdownInputField/SendButton/index.d.ts +6 -0
  63. package/dist/MarkdownInputField/SendButton/index.js +6 -0
  64. package/dist/MarkdownInputField/hooks/useMarkdownInputFieldHandlers.d.ts +2 -1
  65. package/dist/MarkdownInputField/hooks/useMarkdownInputFieldHandlers.js +12 -3
  66. package/dist/MarkdownInputField/hooks/useMarkdownInputFieldRefs.d.ts +1 -0
  67. package/dist/MarkdownInputField/hooks/useMarkdownInputFieldRefs.js +36 -5
  68. package/dist/MarkdownInputField/utils/renderHelpers.js +5 -0
  69. package/dist/MarkdownRenderer/AnimationText.d.ts +1 -5
  70. package/dist/MarkdownRenderer/AnimationText.js +2 -8
  71. package/dist/MarkdownRenderer/CharacterQueue.d.ts +0 -2
  72. package/dist/MarkdownRenderer/CharacterQueue.js +2 -2
  73. package/dist/MarkdownRenderer/FncRefForMarkdown.d.ts +24 -0
  74. package/dist/MarkdownRenderer/FncRefForMarkdown.js +65 -0
  75. package/dist/MarkdownRenderer/MarkdownRenderer.d.ts +1 -9
  76. package/dist/MarkdownRenderer/MarkdownRenderer.js +25 -18
  77. package/dist/MarkdownRenderer/StreamingCursor.d.ts +4 -0
  78. package/dist/MarkdownRenderer/StreamingCursor.js +20 -0
  79. package/dist/MarkdownRenderer/extractFootnoteDefinitions.d.ts +13 -0
  80. package/dist/MarkdownRenderer/extractFootnoteDefinitions.js +40 -0
  81. package/dist/MarkdownRenderer/markdownReactShared.d.ts +11 -38
  82. package/dist/MarkdownRenderer/markdownReactShared.js +28 -54
  83. package/dist/MarkdownRenderer/renderers/ChartRenderer.js +9 -1
  84. package/dist/MarkdownRenderer/renderers/CodeRenderer.d.ts +4 -1
  85. package/dist/MarkdownRenderer/renderers/CodeRenderer.js +27 -3
  86. package/dist/MarkdownRenderer/renderers/SchemaRenderer.d.ts +2 -0
  87. package/dist/MarkdownRenderer/renderers/SchemaRenderer.js +33 -5
  88. package/dist/MarkdownRenderer/streaming/MarkdownBlockPiece.d.ts +1 -3
  89. package/dist/MarkdownRenderer/streaming/MarkdownBlockPiece.js +16 -28
  90. package/dist/MarkdownRenderer/streaming/useStreamingMarkdownReact.js +2 -1
  91. package/dist/MarkdownRenderer/style.js +18 -0
  92. package/dist/MarkdownRenderer/types.d.ts +17 -93
  93. package/dist/MarkdownRenderer/useMarkdownToReact.js +1 -1
  94. package/dist/MarkdownRenderer/useStreaming.d.ts +1 -10
  95. package/dist/MarkdownRenderer/useStreaming.js +5 -13
  96. package/dist/Plugins/mermaid/MermaidRendererImpl.js +481 -7
  97. package/dist/Plugins/mermaid/style.js +71 -22
  98. package/dist/Plugins/mermaid/useMermaidRender.d.ts +2 -1
  99. package/dist/Plugins/mermaid/useMermaidRender.js +41 -13
  100. package/dist/Plugins/mermaid/utils.d.ts +16 -0
  101. package/dist/Plugins/mermaid/utils.js +197 -5
  102. package/dist/ThoughtChainList/MarkdownEditor.d.ts +1 -35
  103. package/dist/ThoughtChainList/MarkdownEditor.js +5 -44
  104. package/dist/Workspace/Browser/index.js +19 -1
  105. package/dist/Workspace/RealtimeFollow/index.d.ts +3 -0
  106. package/dist/Workspace/RealtimeFollow/index.js +5 -3
  107. package/package.json +8 -7
@@ -1,8 +1,9 @@
1
1
  import React from 'react';
2
+ import type { MermaidThemeToken } from './utils';
2
3
  /**
3
4
  * Mermaid 渲染 Hook
4
5
  */
5
- export declare const useMermaidRender: (code: string, divRef: React.RefObject<HTMLDivElement>, id: string, isVisible: boolean) => {
6
+ export declare const useMermaidRender: (code: string, divRef: React.RefObject<HTMLDivElement>, id: string, isVisible: boolean, themeToken?: MermaidThemeToken) => {
6
7
  error: string;
7
8
  renderedCode: string;
8
9
  };
@@ -172,25 +172,40 @@ function _ts_generator(thisArg, body) {
172
172
  };
173
173
  }
174
174
  }
175
- import { useEffect, useRef, useState } from "react";
176
- import { cleanupTempElement, loadMermaid, renderSvgToContainer } from "./utils";
175
+ import { useEffect, useMemo, useRef, useState } from "react";
176
+ import { applyMermaidTheme, cleanupTempElement, createMermaidThemeConfig, loadMermaid, renderSvgToContainer } from "./utils";
177
177
  /**
178
178
  * Mermaid 渲染 Hook
179
- */ export var useMermaidRender = function useMermaidRender(code, divRef, id, isVisible) {
179
+ */ export var useMermaidRender = function useMermaidRender(code, divRef, id, isVisible, themeToken) {
180
180
  var timer = useRef(null);
181
181
  var mermaidRef = useRef(null);
182
- var renderedCodeRef = useRef('');
182
+ var renderedSignatureRef = useRef('');
183
+ var latestRenderSignatureRef = useRef('');
184
+ var appliedThemeCacheKeyRef = useRef('');
183
185
  var _useState = _sliced_to_array(useState(''), 2), error = _useState[0], setError = _useState[1];
184
186
  var _useState1 = _sliced_to_array(useState(''), 2), renderedCode = _useState1[0], setRenderedCode = _useState1[1];
187
+ var themeConfig = useMemo(function() {
188
+ return createMermaidThemeConfig(themeToken);
189
+ }, [
190
+ themeToken === null || themeToken === void 0 ? void 0 : themeToken.colorBgContainer,
191
+ themeToken === null || themeToken === void 0 ? void 0 : themeToken.colorBgElevated,
192
+ themeToken === null || themeToken === void 0 ? void 0 : themeToken.colorBorder,
193
+ themeToken === null || themeToken === void 0 ? void 0 : themeToken.colorPrimary,
194
+ themeToken === null || themeToken === void 0 ? void 0 : themeToken.colorText,
195
+ themeToken === null || themeToken === void 0 ? void 0 : themeToken.colorTextSecondary,
196
+ themeToken === null || themeToken === void 0 ? void 0 : themeToken.fontFamily
197
+ ]);
198
+ var renderSignature = "".concat(themeConfig.cacheKey, "::").concat(code);
199
+ latestRenderSignatureRef.current = renderSignature;
185
200
  useEffect(function() {
186
- if (!isVisible || renderedCodeRef.current === code) {
201
+ if (!isVisible || renderedSignatureRef.current === renderSignature) {
187
202
  return;
188
203
  }
189
204
  if (timer.current) {
190
205
  window.clearTimeout(timer.current);
191
206
  }
192
207
  if (!code) {
193
- renderedCodeRef.current = '';
208
+ renderedSignatureRef.current = '';
194
209
  setRenderedCode('');
195
210
  setError('');
196
211
  if (divRef.current) {
@@ -198,14 +213,14 @@ import { cleanupTempElement, loadMermaid, renderSvgToContainer } from "./utils";
198
213
  }
199
214
  return;
200
215
  }
201
- var currentCode = code;
216
+ var currentSignature = renderSignature;
202
217
  timer.current = window.setTimeout(function() {
203
218
  return _async_to_generator(function() {
204
219
  var _mermaidRef_current, api, _tmp, trimmedCode, svg, err;
205
220
  return _ts_generator(this, function(_state) {
206
221
  switch(_state.label){
207
222
  case 0:
208
- if (code !== currentCode) {
223
+ if (latestRenderSignatureRef.current !== currentSignature) {
209
224
  timer.current = null;
210
225
  return [
211
226
  2
@@ -239,9 +254,13 @@ import { cleanupTempElement, loadMermaid, renderSvgToContainer } from "./utils";
239
254
  case 4:
240
255
  api = _tmp;
241
256
  mermaidRef.current = api;
257
+ if (appliedThemeCacheKeyRef.current !== themeConfig.cacheKey) {
258
+ applyMermaidTheme(api, themeConfig);
259
+ appliedThemeCacheKeyRef.current = themeConfig.cacheKey;
260
+ }
242
261
  trimmedCode = code.trim();
243
262
  if (!trimmedCode) {
244
- renderedCodeRef.current = '';
263
+ renderedSignatureRef.current = '';
245
264
  setRenderedCode('');
246
265
  setError('');
247
266
  if (divRef.current) {
@@ -258,10 +277,16 @@ import { cleanupTempElement, loadMermaid, renderSvgToContainer } from "./utils";
258
277
  ];
259
278
  case 5:
260
279
  svg = _state.sent().svg;
280
+ if (latestRenderSignatureRef.current !== currentSignature) {
281
+ timer.current = null;
282
+ return [
283
+ 2
284
+ ];
285
+ }
261
286
  if (divRef.current) {
262
287
  renderSvgToContainer(svg, divRef.current);
263
288
  }
264
- renderedCodeRef.current = code;
289
+ renderedSignatureRef.current = currentSignature;
265
290
  setRenderedCode(code);
266
291
  setError('');
267
292
  return [
@@ -270,9 +295,9 @@ import { cleanupTempElement, loadMermaid, renderSvgToContainer } from "./utils";
270
295
  ];
271
296
  case 6:
272
297
  err = _state.sent();
273
- if (code === currentCode) {
298
+ if (latestRenderSignatureRef.current === currentSignature) {
274
299
  setError(String(err));
275
- renderedCodeRef.current = code;
300
+ renderedSignatureRef.current = currentSignature;
276
301
  setRenderedCode(code);
277
302
  if (divRef.current) {
278
303
  divRef.current.innerHTML = '';
@@ -305,7 +330,10 @@ import { cleanupTempElement, loadMermaid, renderSvgToContainer } from "./utils";
305
330
  }, [
306
331
  code,
307
332
  id,
308
- isVisible
333
+ isVisible,
334
+ renderSignature,
335
+ themeConfig,
336
+ divRef
309
337
  ]);
310
338
  return {
311
339
  error: error,
@@ -1,4 +1,20 @@
1
1
  import type { MermaidApi } from './types';
2
+ export interface MermaidThemeToken {
3
+ colorBgContainer?: string;
4
+ colorBgElevated?: string;
5
+ colorText?: string;
6
+ colorTextSecondary?: string;
7
+ colorBorder?: string;
8
+ colorPrimary?: string;
9
+ fontFamily?: string;
10
+ }
11
+ export interface MermaidThemeConfig {
12
+ cacheKey: string;
13
+ darkMode: boolean;
14
+ themeVariables: Record<string, string>;
15
+ }
16
+ export declare const createMermaidThemeConfig: (token?: MermaidThemeToken) => MermaidThemeConfig;
17
+ export declare const applyMermaidTheme: (api: MermaidApi, themeConfig?: MermaidThemeConfig) => void;
2
18
  /**
3
19
  * 加载 Mermaid 库
4
20
  * 使用单例模式确保只加载一次,并初始化配置
@@ -1,3 +1,11 @@
1
+ function _array_like_to_array(arr, len) {
2
+ if (len == null || len > arr.length) len = arr.length;
3
+ for(var i = 0, arr2 = new Array(len); i < len; i++)arr2[i] = arr[i];
4
+ return arr2;
5
+ }
6
+ function _array_with_holes(arr) {
7
+ if (Array.isArray(arr)) return arr;
8
+ }
1
9
  function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) {
2
10
  try {
3
11
  var info = gen[key](arg);
@@ -34,6 +42,44 @@ function _instanceof(left, right) {
34
42
  return left instanceof right;
35
43
  }
36
44
  }
45
+ function _iterable_to_array_limit(arr, i) {
46
+ var _i = arr == null ? null : typeof Symbol !== "undefined" && arr[Symbol.iterator] || arr["@@iterator"];
47
+ if (_i == null) return;
48
+ var _arr = [];
49
+ var _n = true;
50
+ var _d = false;
51
+ var _s, _e;
52
+ try {
53
+ for(_i = _i.call(arr); !(_n = (_s = _i.next()).done); _n = true){
54
+ _arr.push(_s.value);
55
+ if (i && _arr.length === i) break;
56
+ }
57
+ } catch (err) {
58
+ _d = true;
59
+ _e = err;
60
+ } finally{
61
+ try {
62
+ if (!_n && _i["return"] != null) _i["return"]();
63
+ } finally{
64
+ if (_d) throw _e;
65
+ }
66
+ }
67
+ return _arr;
68
+ }
69
+ function _non_iterable_rest() {
70
+ 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
+ }
72
+ function _sliced_to_array(arr, i) {
73
+ return _array_with_holes(arr) || _iterable_to_array_limit(arr, i) || _unsupported_iterable_to_array(arr, i) || _non_iterable_rest();
74
+ }
75
+ function _unsupported_iterable_to_array(o, minLen) {
76
+ if (!o) return;
77
+ if (typeof o === "string") return _array_like_to_array(o, minLen);
78
+ var n = Object.prototype.toString.call(o).slice(8, -1);
79
+ if (n === "Object" && o.constructor) n = o.constructor.name;
80
+ if (n === "Map" || n === "Set") return Array.from(n);
81
+ if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _array_like_to_array(o, minLen);
82
+ }
37
83
  function _ts_generator(thisArg, body) {
38
84
  var f, y, t, _ = {
39
85
  label: 0,
@@ -134,6 +180,156 @@ function _ts_generator(thisArg, body) {
134
180
  }
135
181
  }
136
182
  var mermaidLoader = null;
183
+ var COLOR_DARKNESS_THRESHOLD = 145;
184
+ var DEFAULT_LIGHT_BACKGROUND = '#ffffff';
185
+ var DEFAULT_DARK_BACKGROUND = '#141414';
186
+ var DEFAULT_LIGHT_TEXT_COLOR = '#1f1f1f';
187
+ var DEFAULT_DARK_TEXT_COLOR = '#f5f5f5';
188
+ var DEFAULT_LIGHT_SECONDARY_TEXT_COLOR = '#595959';
189
+ var DEFAULT_DARK_SECONDARY_TEXT_COLOR = '#bfbfbf';
190
+ var DEFAULT_LIGHT_BORDER_COLOR = '#d9d9d9';
191
+ var DEFAULT_DARK_BORDER_COLOR = '#434343';
192
+ var DEFAULT_PRIMARY_COLOR = '#1677ff';
193
+ var DEFAULT_FONT_FAMILY = 'Inter, -apple-system, Segoe UI, sans-serif';
194
+ var parseColorToRgb = function parseColorToRgb(color) {
195
+ var normalizedColor = color.trim().toLowerCase();
196
+ var shortHexMatch = normalizedColor.match(/^#([0-9a-f]{3})$/i);
197
+ if (shortHexMatch) {
198
+ var _shortHexMatch__split_map = _sliced_to_array(shortHexMatch[1].split('').map(function(char) {
199
+ return Number.parseInt(char + char, 16);
200
+ }), 3), r = _shortHexMatch__split_map[0], g = _shortHexMatch__split_map[1], b = _shortHexMatch__split_map[2];
201
+ return {
202
+ r: r,
203
+ g: g,
204
+ b: b
205
+ };
206
+ }
207
+ var hexMatch = normalizedColor.match(/^#([0-9a-f]{6})$/i);
208
+ if (hexMatch) {
209
+ return {
210
+ r: Number.parseInt(hexMatch[1].slice(0, 2), 16),
211
+ g: Number.parseInt(hexMatch[1].slice(2, 4), 16),
212
+ b: Number.parseInt(hexMatch[1].slice(4, 6), 16)
213
+ };
214
+ }
215
+ var rgbMatch = normalizedColor.match(/^rgba?\((\d{1,3})[\s,]+(\d{1,3})[\s,]+(\d{1,3})(?:[\s,]+[\d.]+)?\)$/i);
216
+ if (rgbMatch) {
217
+ return {
218
+ r: Number.parseInt(rgbMatch[1], 10),
219
+ g: Number.parseInt(rgbMatch[2], 10),
220
+ b: Number.parseInt(rgbMatch[3], 10)
221
+ };
222
+ }
223
+ return null;
224
+ };
225
+ var isDarkBackground = function isDarkBackground(color) {
226
+ if (!color) {
227
+ return false;
228
+ }
229
+ var rgbColor = parseColorToRgb(color);
230
+ if (!rgbColor) {
231
+ return false;
232
+ }
233
+ var brightness = (rgbColor.r * 299 + rgbColor.g * 587 + rgbColor.b * 114) / 1000;
234
+ return brightness < COLOR_DARKNESS_THRESHOLD;
235
+ };
236
+ var isLightTextColor = function isLightTextColor(color) {
237
+ if (!color) {
238
+ return false;
239
+ }
240
+ var rgbColor = parseColorToRgb(color);
241
+ if (!rgbColor) {
242
+ return false;
243
+ }
244
+ var brightness = (rgbColor.r * 299 + rgbColor.g * 587 + rgbColor.b * 114) / 1000;
245
+ return brightness >= COLOR_DARKNESS_THRESHOLD;
246
+ };
247
+ var inferDarkMode = function inferDarkMode(token) {
248
+ if (isDarkBackground(token.colorBgContainer)) {
249
+ return true;
250
+ }
251
+ // Fallback for CSS variables / unresolved background colors.
252
+ return isLightTextColor(token.colorText);
253
+ };
254
+ export var createMermaidThemeConfig = function createMermaidThemeConfig() {
255
+ var token = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : {};
256
+ var darkMode = inferDarkMode(token);
257
+ var background = token.colorBgContainer ? token.colorBgContainer : darkMode ? DEFAULT_DARK_BACKGROUND : DEFAULT_LIGHT_BACKGROUND;
258
+ var elevatedBackground = token.colorBgElevated || (darkMode ? '#1f1f1f' : '#fafafa');
259
+ var textColor = token.colorText ? token.colorText : darkMode ? DEFAULT_DARK_TEXT_COLOR : DEFAULT_LIGHT_TEXT_COLOR;
260
+ var secondaryTextColor = token.colorTextSecondary ? token.colorTextSecondary : darkMode ? DEFAULT_DARK_SECONDARY_TEXT_COLOR : DEFAULT_LIGHT_SECONDARY_TEXT_COLOR;
261
+ var borderColor = token.colorBorder ? token.colorBorder : darkMode ? DEFAULT_DARK_BORDER_COLOR : DEFAULT_LIGHT_BORDER_COLOR;
262
+ var primaryColor = token.colorPrimary || DEFAULT_PRIMARY_COLOR;
263
+ var fontFamily = token.fontFamily || DEFAULT_FONT_FAMILY;
264
+ var themeVariables = {
265
+ primaryColor: primaryColor,
266
+ primaryTextColor: textColor,
267
+ primaryBorderColor: borderColor,
268
+ lineColor: borderColor,
269
+ mainBkg: background,
270
+ secondBkg: elevatedBackground,
271
+ tertiaryColor: elevatedBackground,
272
+ background: background,
273
+ textColor: textColor,
274
+ fontFamily: fontFamily,
275
+ clusterBkg: elevatedBackground,
276
+ clusterBorder: borderColor,
277
+ edgeLabelBackground: background,
278
+ edgeLabelTextColor: secondaryTextColor,
279
+ nodeBkg: background,
280
+ nodeBorder: borderColor,
281
+ defaultLinkColor: borderColor,
282
+ titleColor: textColor,
283
+ actorBkg: elevatedBackground,
284
+ actorBorder: borderColor,
285
+ actorTextColor: textColor,
286
+ actorLineColor: borderColor,
287
+ signalColor: secondaryTextColor,
288
+ signalTextColor: textColor,
289
+ labelBoxBkgColor: background,
290
+ labelBoxBorderColor: borderColor,
291
+ labelTextColor: textColor,
292
+ loopTextColor: textColor,
293
+ noteBkg: elevatedBackground,
294
+ noteBorderColor: borderColor,
295
+ noteTextColor: textColor,
296
+ activationBorderColor: borderColor,
297
+ activationBkgColor: elevatedBackground,
298
+ sequenceNumberColor: textColor
299
+ };
300
+ var cacheKey = [
301
+ darkMode ? 'dark' : 'light',
302
+ background,
303
+ elevatedBackground,
304
+ textColor,
305
+ secondaryTextColor,
306
+ borderColor,
307
+ primaryColor,
308
+ fontFamily
309
+ ].join('|');
310
+ return {
311
+ cacheKey: cacheKey,
312
+ darkMode: darkMode,
313
+ themeVariables: themeVariables
314
+ };
315
+ };
316
+ export var applyMermaidTheme = function applyMermaidTheme(api, themeConfig) {
317
+ if (!(api === null || api === void 0 ? void 0 : api.initialize)) {
318
+ return;
319
+ }
320
+ if (!themeConfig) {
321
+ api.initialize({
322
+ startOnLoad: false
323
+ });
324
+ return;
325
+ }
326
+ api.initialize({
327
+ startOnLoad: false,
328
+ theme: 'base',
329
+ darkMode: themeConfig.darkMode,
330
+ themeVariables: themeConfig.themeVariables
331
+ });
332
+ };
137
333
  /**
138
334
  * 加载 Mermaid 库
139
335
  * 使用单例模式确保只加载一次,并初始化配置
@@ -148,11 +344,7 @@ var mermaidLoader = null;
148
344
  // webpackChunkName 指定 chunk 名称,webpackMode 指定加载模式
149
345
  mermaidLoader = import(/* webpackChunkName: "mermaid" */ /* webpackMode: "lazy" */ "mermaid").then(function(module) {
150
346
  var api = module.default;
151
- if (api === null || api === void 0 ? void 0 : api.initialize) {
152
- api.initialize({
153
- startOnLoad: false
154
- });
155
- }
347
+ applyMermaidTheme(api);
156
348
  return api;
157
349
  }).catch(function(error) {
158
350
  mermaidLoader = null;
@@ -1,40 +1,6 @@
1
1
  import React from 'react';
2
2
  import { MarkdownEditorProps } from '../MarkdownEditor';
3
- /**
4
- * MarkdownEditorUpdate 组件 - Markdown 编辑器更新组件
5
- *
6
- * 该组件是对 MarkdownEditor 的封装,提供自动更新和格式化功能。
7
- * 主要用于在思维链中显示和更新 Markdown 内容。
8
- *
9
- * @component
10
- * @description Markdown 编辑器更新组件,提供自动更新和格式化功能
11
- * @param {MarkdownEditorProps & {isFinished?: boolean}} props - 组件属性
12
- * @param {boolean} [props.isFinished] - 内容是否已完成
13
- * @param {string} [props.initValue] - 初始内容
14
- * @param {boolean} [props.typewriter] - 是否启用打字机效果
15
- * @param {MarkdownEditorProps} props - 其他 MarkdownEditor 属性
16
- *
17
- * @example
18
- * ```tsx
19
- * import { MarkdownEditorUpdate } from './MarkdownEditor';
20
- *
21
- * <MarkdownEditorUpdate
22
- * initValue="# Hello World"
23
- * isFinished={true}
24
- * typewriter={false}
25
- * />
26
- * ```
27
- *
28
- * @returns {React.ReactElement} 渲染的 Markdown 编辑器组件
29
- *
30
- * @remarks
31
- * - 自动格式化 Markdown 内容
32
- * - 支持内容完成状态检测
33
- * - 提供打字机效果
34
- * - 只读模式
35
- * - 自动更新节点列表
36
- * - 响应式布局
37
- */
3
+ /** 思维链中的 MarkdownEditor 封装,自动格式化 + 流式更新 */
38
4
  export declare const MarkdownEditorUpdate: (props: MarkdownEditorProps & {
39
5
  isFinished?: boolean;
40
6
  }) => React.JSX.Element;
@@ -53,52 +53,13 @@ function _object_spread_props(target, source) {
53
53
  import React, { useEffect } from "react";
54
54
  import { MarkdownEditor, parserMdToSchema } from "../MarkdownEditor";
55
55
  import { MarkdownFormatter } from "../Plugins/formatter";
56
- /**
57
- * 将内容转换为列表格式的 Markdown
58
- * @param {string} content - 原始内容
59
- * @returns {string} 转换后的内容
60
- */ var toListMarkdown = function toListMarkdown(content) {
61
- return content;
62
- };
63
- /**
64
- * MarkdownEditorUpdate 组件 - Markdown 编辑器更新组件
65
- *
66
- * 该组件是对 MarkdownEditor 的封装,提供自动更新和格式化功能。
67
- * 主要用于在思维链中显示和更新 Markdown 内容。
68
- *
69
- * @component
70
- * @description Markdown 编辑器更新组件,提供自动更新和格式化功能
71
- * @param {MarkdownEditorProps & {isFinished?: boolean}} props - 组件属性
72
- * @param {boolean} [props.isFinished] - 内容是否已完成
73
- * @param {string} [props.initValue] - 初始内容
74
- * @param {boolean} [props.typewriter] - 是否启用打字机效果
75
- * @param {MarkdownEditorProps} props - 其他 MarkdownEditor 属性
76
- *
77
- * @example
78
- * ```tsx
79
- * import { MarkdownEditorUpdate } from './MarkdownEditor';
80
- *
81
- * <MarkdownEditorUpdate
82
- * initValue="# Hello World"
83
- * isFinished={true}
84
- * typewriter={false}
85
- * />
86
- * ```
87
- *
88
- * @returns {React.ReactElement} 渲染的 Markdown 编辑器组件
89
- *
90
- * @remarks
91
- * - 自动格式化 Markdown 内容
92
- * - 支持内容完成状态检测
93
- * - 提供打字机效果
94
- * - 只读模式
95
- * - 自动更新节点列表
96
- * - 响应式布局
97
- */ export var MarkdownEditorUpdate = function MarkdownEditorUpdate(props) {
56
+ /** 思维链中的 MarkdownEditor 封装,自动格式化 + 流式更新 */ export var MarkdownEditorUpdate = function MarkdownEditorUpdate(props) {
57
+ var _props_streaming;
98
58
  var editorRef = React.useRef();
99
59
  useEffect(function() {
100
60
  var _editorRef_current_store, _editorRef_current;
101
- (_editorRef_current = editorRef.current) === null || _editorRef_current === void 0 ? void 0 : (_editorRef_current_store = _editorRef_current.store) === null || _editorRef_current_store === void 0 ? void 0 : _editorRef_current_store.updateNodeList(parserMdToSchema(toListMarkdown(MarkdownFormatter.format(props.initValue || '') || '').trim(), props.plugins).schema);
61
+ var formatted = MarkdownFormatter.format(props.initValue || '') || '';
62
+ (_editorRef_current = editorRef.current) === null || _editorRef_current === void 0 ? void 0 : (_editorRef_current_store = _editorRef_current.store) === null || _editorRef_current_store === void 0 ? void 0 : _editorRef_current_store.updateNodeList(parserMdToSchema(formatted.trim(), props.plugins).schema);
102
63
  }, [
103
64
  props.initValue
104
65
  ]);
@@ -126,7 +87,7 @@ import { MarkdownFormatter } from "../Plugins/formatter";
126
87
  showLineNumbers: false
127
88
  }
128
89
  }, props), {
129
- typewriter: props.typewriter && !props.isFinished,
90
+ streaming: ((_props_streaming = props.streaming) !== null && _props_streaming !== void 0 ? _props_streaming : props.typewriter) && !props.isFinished,
130
91
  initValue: ""
131
92
  }));
132
93
  };
@@ -164,6 +164,15 @@ export var BrowserItemComponent = function BrowserItemComponent(param) {
164
164
  e.stopPropagation();
165
165
  onLocate === null || onLocate === void 0 ? void 0 : onLocate(item);
166
166
  };
167
+ var handleOpenFromSite = function handleOpenFromSite(e) {
168
+ e.preventDefault();
169
+ e.stopPropagation();
170
+ if (onOpen) {
171
+ onOpen(item);
172
+ return;
173
+ }
174
+ window.open(item.url, '_blank', 'noopener,noreferrer');
175
+ };
167
176
  return wrapSSR(/*#__PURE__*/ React.createElement(List.Item, {
168
177
  className: className,
169
178
  style: itemStyle,
@@ -197,7 +206,16 @@ export var BrowserItemComponent = function BrowserItemComponent(param) {
197
206
  }, /*#__PURE__*/ React.createElement("div", {
198
207
  className: classNames("".concat(prefixCls, "-result-item-title"), hashId)
199
208
  }, item.title)))), /*#__PURE__*/ React.createElement("div", {
200
- className: classNames("".concat(prefixCls, "-result-item-site"), hashId)
209
+ className: classNames("".concat(prefixCls, "-result-item-site"), hashId),
210
+ role: "link",
211
+ tabIndex: 0,
212
+ "aria-label": item.site,
213
+ onClick: handleOpenFromSite,
214
+ onKeyDown: function onKeyDown(event) {
215
+ if (event.key === 'Enter' || event.key === ' ') {
216
+ handleOpenFromSite(event);
217
+ }
218
+ }
201
219
  }, renderSiteAvatar(item.site, item.icon), /*#__PURE__*/ React.createElement(Tooltip, {
202
220
  title: item.site,
203
221
  mouseEnterDelay: 1
@@ -12,6 +12,9 @@ export interface RealtimeFollowData {
12
12
  title?: string;
13
13
  subTitle?: string;
14
14
  icon?: React.ComponentType;
15
+ /** 流式输出模式,同时传入时优先于 typewriter */
16
+ streaming?: boolean;
17
+ /** @deprecated 请使用 streaming */
15
18
  typewriter?: boolean;
16
19
  rightContent?: React.ReactNode;
17
20
  loadingRender?: React.ReactNode | (() => React.ReactNode);
@@ -268,7 +268,7 @@ var Overlay = function Overlay(param) {
268
268
  * ```
269
269
  */ export var RealtimeFollow = function RealtimeFollow(param) {
270
270
  var data = param.data, _param_htmlViewMode = param.htmlViewMode, htmlViewMode = _param_htmlViewMode === void 0 ? 'preview' : _param_htmlViewMode, prefixCls = param.prefixCls, hashId = param.hashId;
271
- var _data_typewriter, _data_content;
271
+ var _ref, _data_streaming, _data_content;
272
272
  var _data_markdownEditorProps;
273
273
  var getPrefixCls = useContext(ConfigProvider.ConfigContext).getPrefixCls;
274
274
  var finalPrefixCls = prefixCls || getPrefixCls('workspace-realtime');
@@ -282,13 +282,14 @@ var Overlay = function Overlay(param) {
282
282
  ]
283
283
  }), autoScrollRef = _useAutoScroll.containerRef, scrollToBottom = _useAutoScroll.scrollToBottom;
284
284
  useEffect(function() {
285
+ var _data_streaming;
285
286
  var _mdInstance_current;
286
287
  if (isTestEnv || !((_mdInstance_current = mdInstance.current) === null || _mdInstance_current === void 0 ? void 0 : _mdInstance_current.store)) return;
287
288
  if (!shouldUpdateEditor(data.type, htmlViewMode)) return;
288
289
  var content = getContentForEditor(data.type, data.content);
289
290
  var schema = parserMdToSchema(content, mdInstance.current.store.plugins).schema;
290
291
  mdInstance.current.store.updateNodeList(schema);
291
- if (data.typewriter && !isTestEnv) {
292
+ if (((_data_streaming = data.streaming) !== null && _data_streaming !== void 0 ? _data_streaming : data.typewriter) && !isTestEnv) {
292
293
  setTimeout(function() {
293
294
  return scrollToBottom();
294
295
  }, SCROLL_DELAY);
@@ -298,6 +299,7 @@ var Overlay = function Overlay(param) {
298
299
  data.type,
299
300
  htmlViewMode,
300
301
  isTestEnv,
302
+ data.streaming,
301
303
  data.typewriter,
302
304
  scrollToBottom
303
305
  ]);
@@ -338,7 +340,7 @@ var Overlay = function Overlay(param) {
338
340
  }
339
341
  var defaultProps = getEditorConfig(data.type);
340
342
  var mergedProps = _object_spread_props(_object_spread({}, defaultProps, data.markdownEditorProps), {
341
- typewriter: isTestEnv ? false : (_data_typewriter = data.typewriter) !== null && _data_typewriter !== void 0 ? _data_typewriter : defaultProps.typewriter,
343
+ streaming: isTestEnv ? false : (_ref = (_data_streaming = data.streaming) !== null && _data_streaming !== void 0 ? _data_streaming : data.typewriter) !== null && _ref !== void 0 ? _ref : defaultProps.typewriter,
342
344
  style: _object_spread({
343
345
  maxHeight: 'auto'
344
346
  }, defaultProps.style, (_data_markdownEditorProps = data.markdownEditorProps) === null || _data_markdownEditorProps === void 0 ? void 0 : _data_markdownEditorProps.style)
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ant-design/agentic-ui",
3
- "version": "2.30.21",
3
+ "version": "2.30.23",
4
4
  "description": "面向智能体的 UI 组件库,提供多步推理可视化、工具调用展示、任务执行协同等 Agentic UI 能力",
5
5
  "repository": "git@github.com:ant-design/agentic-ui.git",
6
6
  "license": "MIT",
@@ -23,6 +23,7 @@
23
23
  "lint": "pnpm run lint:es && pnpm run lint:css",
24
24
  "lint:css": "stylelint \"{src,test}/**/*.{css,less}\"",
25
25
  "lint:es": "eslint \"{src,test}/**/*.{js,jsx,ts,tsx}\"",
26
+ "playwright:install": "playwright install --with-deps chromium",
26
27
  "prepare": "husky install && dumi setup",
27
28
  "prettier": "prettier --write \"{src,docs,test}/**/*.{js,jsx,ts,tsx,css,less,json,md}\"",
28
29
  "preview": "pnpm dumi preview",
@@ -85,14 +86,14 @@
85
86
  "hast-util-to-jsx-runtime": "^2.3.6",
86
87
  "is-hotkey": "^0.2.0",
87
88
  "json5": "^2.2.3",
88
- "katex": "^0.16.28",
89
+ "katex": "^0.16.44",
89
90
  "lodash": "^4.17.23",
90
91
  "lodash-es": "^4.17.23",
91
92
  "lottie-react": "^2.4.1",
92
93
  "markdown-it": "^14.1.1",
93
94
  "markdown-it-container": "^4.0.0",
94
95
  "mdast-util-directive": "^3.1.0",
95
- "mermaid": "^11.12.2",
96
+ "mermaid": "^11.14.0",
96
97
  "micromark-extension-directive": "^4.0.0",
97
98
  "mustache": "^4.2.0",
98
99
  "nanoid": "^5.1.6",
@@ -118,11 +119,11 @@
118
119
  "remark-rehype": "^11.1.2",
119
120
  "rxjs": "^7.8.2",
120
121
  "slash2": "^2.0.0",
121
- "slate": "0.120.0",
122
- "slate-dom": "0.119.0",
122
+ "slate": "0.124.0",
123
+ "slate-dom": "0.124.0",
123
124
  "slate-history": "0.113.1",
124
125
  "slate-hyperscript": "0.100.0",
125
- "slate-react": "0.120.0",
126
+ "slate-react": "0.124.0",
126
127
  "string-width": "^7.2.0",
127
128
  "styled-components": "^6.3.8",
128
129
  "tailwind-merge": "^3.4.0",
@@ -175,7 +176,7 @@
175
176
  "prettier-plugin-packagejson": "^2.5.22",
176
177
  "react": "^18.3.1",
177
178
  "react-dom": "^18.3.1",
178
- "recharts": "^3.7.0",
179
+ "recharts": "^3.8.1",
179
180
  "sast": "^0.8.1",
180
181
  "stylelint": "^14.16.1",
181
182
  "typescript": "^5.9.3",