@ant-design/agentic-ui 2.1.0 → 2.3.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.
Files changed (46) hide show
  1. package/dist/History/components/HistoryEmpty.d.ts +17 -0
  2. package/dist/History/components/HistoryEmpty.js +50 -0
  3. package/dist/History/components/HistoryEmptyIcon.d.ts +5 -0
  4. package/dist/History/components/HistoryEmptyIcon.js +1214 -0
  5. package/dist/History/components/HistoryList.d.ts +1 -0
  6. package/dist/History/components/HistoryList.js +6 -0
  7. package/dist/History/components/SearchComponent.js +10 -4
  8. package/dist/History/components/index.d.ts +1 -0
  9. package/dist/History/components/index.js +2 -0
  10. package/dist/History/index.js +39 -27
  11. package/dist/History/style.js +12 -0
  12. package/dist/History/types/index.d.ts +2 -2
  13. package/dist/Hooks/useIntersectionOnce.d.ts +5 -0
  14. package/dist/Hooks/useIntersectionOnce.js +79 -0
  15. package/dist/Hooks/useLanguage.d.ts +2 -0
  16. package/dist/I18n/locales.d.ts +2 -0
  17. package/dist/I18n/locales.js +4 -0
  18. package/dist/MarkdownEditor/editor/parser/parserMarkdownToSlateNode.js +31 -3
  19. package/dist/MarkdownEditor/editor/parser/remarkParse.js +2 -2
  20. package/dist/MarkdownEditor/editor/utils/markdownToHtml.js +4 -4
  21. package/dist/MarkdownInputField/MarkdownInputField.js +24 -20
  22. package/dist/Plugins/chart/AreaChart/index.js +20 -9
  23. package/dist/Plugins/chart/BarChart/index.js +12 -1
  24. package/dist/Plugins/chart/ChartMark/Area.js +21 -10
  25. package/dist/Plugins/chart/ChartMark/Bar.js +19 -8
  26. package/dist/Plugins/chart/ChartMark/Column.js +19 -8
  27. package/dist/Plugins/chart/ChartMark/Line.js +20 -9
  28. package/dist/Plugins/chart/ChartMark/Pie.js +12 -1
  29. package/dist/Plugins/chart/ChartRender.js +183 -48
  30. package/dist/Plugins/chart/DonutChart/index.js +12 -1
  31. package/dist/Plugins/chart/FunnelChart/index.d.ts +2 -0
  32. package/dist/Plugins/chart/FunnelChart/index.js +69 -18
  33. package/dist/Plugins/chart/LineChart/index.js +20 -9
  34. package/dist/Plugins/chart/RadarChart/index.js +19 -8
  35. package/dist/Plugins/chart/ScatterChart/index.js +12 -1
  36. package/dist/Plugins/chart/loadChartRuntime.d.ts +18 -0
  37. package/dist/Plugins/chart/loadChartRuntime.js +91 -0
  38. package/dist/Plugins/defaultPlugins.d.ts +3 -0
  39. package/dist/Plugins/defaultPlugins.js +2 -0
  40. package/dist/Plugins/katex/InlineKatex.js +3 -2
  41. package/dist/Plugins/mermaid/Mermaid.d.ts +5 -2
  42. package/dist/Plugins/mermaid/Mermaid.js +130 -38
  43. package/dist/Plugins/mermaid/index.js +1 -1
  44. package/dist/TaskList/index.js +2 -8
  45. package/dist/TaskList/style.js +1 -7
  46. package/package.json +3 -3
@@ -54,6 +54,7 @@ export declare const generateHistoryItems: ({ filteredList, selectedIds, onSelec
54
54
  children: {
55
55
  key: string;
56
56
  type: "item";
57
+ onClick: () => void;
57
58
  label: React.JSX.Element;
58
59
  }[];
59
60
  }[];
@@ -61,6 +61,12 @@ var generateHistoryItems = ({
61
61
  return {
62
62
  key: item.sessionId || `item-${item.id}`,
63
63
  type: "item",
64
+ onClick: () => {
65
+ if (!item.sessionId) {
66
+ return;
67
+ }
68
+ onClick(item.sessionId, item);
69
+ },
64
70
  label: /* @__PURE__ */ React.createElement(
65
71
  HistoryItem,
66
72
  {
@@ -78,7 +78,9 @@ var HistorySearch = ({
78
78
  const ref = useRef(null);
79
79
  const trigger = (searchOptions == null ? void 0 : searchOptions.trigger) || "change";
80
80
  useClickAway(() => {
81
- setIsExpanded(false);
81
+ if (!inputValue) {
82
+ setIsExpanded(false);
83
+ }
82
84
  }, ref);
83
85
  const handleSearchWithLoading = (value) => __async(void 0, null, function* () {
84
86
  try {
@@ -121,16 +123,20 @@ var HistorySearch = ({
121
123
  justifyContent: "space-between",
122
124
  height: 32,
123
125
  // 固定高度为32px
124
- padding: isExpanded ? 0 : "0 6px 0 12px",
126
+ padding: isExpanded ? 0 : "0 6px 0 12px"
125
127
  // 输入框状态下移除padding
126
- marginBottom: 4
127
128
  }
128
129
  },
129
130
  isExpanded ? /* @__PURE__ */ React.createElement(
130
131
  Input,
131
132
  {
132
133
  placeholder: (_a = searchOptions == null ? void 0 : searchOptions.placeholder) != null ? _a : type === "task" ? (locale == null ? void 0 : locale["chat.task.search.placeholder"]) || "搜索任务" : (locale == null ? void 0 : locale["chat.history.search.placeholder"]) || "搜索话题",
133
- prefix: loading ? /* @__PURE__ */ React.createElement(Spin, { size: "small" }) : /* @__PURE__ */ React.createElement(SearchIcon, null),
134
+ prefix: loading ? /* @__PURE__ */ React.createElement(Spin, { size: "small" }) : /* @__PURE__ */ React.createElement(
135
+ SearchIcon,
136
+ {
137
+ style: { color: "var(--color-gray-text-secondary)" }
138
+ }
139
+ ),
134
140
  value: inputValue,
135
141
  onChange: handleInputChange,
136
142
  onKeyDown: handleKeyDown,
@@ -2,6 +2,7 @@ export { HistoryActionsBox } from './HistoryActionsBox';
2
2
  export { HistoryItem } from './HistoryItem';
3
3
  export { generateHistoryItems } from './HistoryList';
4
4
  export { HistoryRunningIcon, HistoryRunningIconContainer, type HistoryRunningIconContainerProps, type HistoryRunningIconProps, } from './HistoryRunningIcon';
5
+ export { HistoryEmpty } from './HistoryEmpty';
5
6
  export { HistoryLoadMore } from './LoadMoreComponent';
6
7
  export { HistoryNewChat } from './NewChatComponent';
7
8
  export { HistorySearch } from './SearchComponent';
@@ -6,11 +6,13 @@ import {
6
6
  HistoryRunningIcon,
7
7
  HistoryRunningIconContainer
8
8
  } from "./HistoryRunningIcon";
9
+ import { HistoryEmpty } from "./HistoryEmpty";
9
10
  import { HistoryLoadMore } from "./LoadMoreComponent";
10
11
  import { HistoryNewChat } from "./NewChatComponent";
11
12
  import { HistorySearch } from "./SearchComponent";
12
13
  export {
13
14
  HistoryActionsBox,
15
+ HistoryEmpty,
14
16
  HistoryItem,
15
17
  HistoryLoadMore,
16
18
  HistoryNewChat,
@@ -20,13 +20,14 @@ var __async = (__this, __arguments, generator) => {
20
20
  };
21
21
 
22
22
  // src/History/index.tsx
23
- import { History as HistoryIcon } from "@sofa-design/icons";
23
+ import { HistoryOutlined } from "@ant-design/icons";
24
24
  import { ConfigProvider, Popover } from "antd";
25
25
  import classNames from "classnames";
26
26
  import React, { useContext, useRef } from "react";
27
27
  import useClickAway from "../Hooks/useClickAway";
28
28
  import { ActionIconBox, BubbleConfigContext } from "../index";
29
29
  import {
30
+ HistoryEmpty,
30
31
  HistoryLoadMore,
31
32
  HistoryNewChat,
32
33
  HistorySearch,
@@ -70,7 +71,7 @@ var History = (props) => {
70
71
  onClick: (sessionId, item) => {
71
72
  var _a2, _b2;
72
73
  (_a2 = props.onClick) == null ? void 0 : _a2.call(props, sessionId, item);
73
- (_b2 = props.onSelected) == null ? void 0 : _b2.call(props, sessionId);
74
+ (_b2 = props.onSelected) == null ? void 0 : _b2.call(props, item);
74
75
  setOpen(false);
75
76
  },
76
77
  groupLabelRender: props.groupLabelRender,
@@ -98,11 +99,11 @@ var History = (props) => {
98
99
  style: {
99
100
  display: "flex",
100
101
  flexDirection: "column",
101
- gap: 12
102
+ height: "100%"
102
103
  }
103
104
  },
104
- ((_b = props.agent) == null ? void 0 : _b.enabled) && !!((_c = props.agent) == null ? void 0 : _c.onNewChat) && /* @__PURE__ */ React.createElement(HistoryNewChat, { onNewChat: handleNewChat }),
105
- ((_d = props.agent) == null ? void 0 : _d.enabled) && !!((_e = props.agent) == null ? void 0 : _e.onSearch) && /* @__PURE__ */ React.createElement(
105
+ ((_b = props.agent) == null ? void 0 : _b.enabled) && !!((_c = props.agent) == null ? void 0 : _c.onNewChat) && /* @__PURE__ */ React.createElement("div", { style: { flexShrink: 0, marginBottom: 12 } }, /* @__PURE__ */ React.createElement(HistoryNewChat, { onNewChat: handleNewChat })),
106
+ ((_d = props.agent) == null ? void 0 : _d.enabled) && !!((_e = props.agent) == null ? void 0 : _e.onSearch) && /* @__PURE__ */ React.createElement("div", { style: { flexShrink: 0 } }, /* @__PURE__ */ React.createElement(
106
107
  HistorySearch,
107
108
  {
108
109
  searchKeyword,
@@ -110,27 +111,38 @@ var History = (props) => {
110
111
  type: props.type,
111
112
  searchOptions: (_f = props.agent) == null ? void 0 : _f.searchOptions
112
113
  }
113
- ),
114
- (_h = (_g = props.slots) == null ? void 0 : _g.beforeHistoryList) == null ? void 0 : _h.call(_g, filteredList),
115
- (items == null ? void 0 : items.length) === 0 && !props.loading && (props == null ? void 0 : props.emptyRender) ? props.emptyRender() : /* @__PURE__ */ React.createElement(React.Fragment, null, /* @__PURE__ */ React.createElement(
116
- GroupMenu,
114
+ )),
115
+ /* @__PURE__ */ React.createElement(
116
+ "div",
117
117
  {
118
- selectedKeys: [props.sessionId],
119
- inlineIndent: 20,
120
- items,
121
- className: menuPrefixCls,
122
- loading: props.loading
123
- }
124
- ), ((_i = props.agent) == null ? void 0 : _i.enabled) && !!((_j = props.agent) == null ? void 0 : _j.onLoadMore) && /* @__PURE__ */ React.createElement(
125
- HistoryLoadMore,
126
- {
127
- onLoadMore: handleLoadMore,
128
- type: props.type,
129
- className: classNames(`${menuPrefixCls}-load-more`, hashId, {
130
- chat: props.type !== "task"
131
- })
132
- }
133
- ))
118
+ className: classNames(`${menuPrefixCls}-scroll-container`, hashId),
119
+ style: {
120
+ flex: 1,
121
+ overflow: "auto",
122
+ minHeight: 0
123
+ }
124
+ },
125
+ (_h = (_g = props.slots) == null ? void 0 : _g.beforeHistoryList) == null ? void 0 : _h.call(_g, filteredList),
126
+ (items == null ? void 0 : items.length) === 0 && !props.loading ? props.emptyRender ? props.emptyRender() : /* @__PURE__ */ React.createElement(HistoryEmpty, null) : /* @__PURE__ */ React.createElement(React.Fragment, null, /* @__PURE__ */ React.createElement(
127
+ GroupMenu,
128
+ {
129
+ selectedKeys: [props.sessionId],
130
+ inlineIndent: 20,
131
+ items,
132
+ className: menuPrefixCls,
133
+ loading: props.loading
134
+ }
135
+ ), ((_i = props.agent) == null ? void 0 : _i.enabled) && !!((_j = props.agent) == null ? void 0 : _j.onLoadMore) && /* @__PURE__ */ React.createElement(
136
+ HistoryLoadMore,
137
+ {
138
+ onLoadMore: handleLoadMore,
139
+ type: props.type,
140
+ className: classNames(`${menuPrefixCls}-load-more`, hashId, {
141
+ chat: props.type !== "task"
142
+ })
143
+ }
144
+ ))
145
+ )
134
146
  )
135
147
  );
136
148
  }
@@ -149,7 +161,7 @@ var History = (props) => {
149
161
  border: "1px solid var(--color-gray-border-light)"
150
162
  },
151
163
  getPopupContainer: (p) => p.parentElement || document.body,
152
- content: /* @__PURE__ */ React.createElement(React.Fragment, null, (items == null ? void 0 : items.length) === 0 && !(props == null ? void 0 : props.loading) && (props == null ? void 0 : props.emptyRender) ? /* @__PURE__ */ React.createElement("div", { "data-testid": "empty-state-popover" }, props.emptyRender()) : /* @__PURE__ */ React.createElement(
164
+ content: /* @__PURE__ */ React.createElement(React.Fragment, null, (items == null ? void 0 : items.length) === 0 && !(props == null ? void 0 : props.loading) ? /* @__PURE__ */ React.createElement("div", { "data-testid": "empty-state-popover" }, props.emptyRender ? props.emptyRender() : /* @__PURE__ */ React.createElement(HistoryEmpty, null)) : /* @__PURE__ */ React.createElement(
153
165
  GroupMenu,
154
166
  {
155
167
  selectedKeys: [props.sessionId],
@@ -187,7 +199,7 @@ var History = (props) => {
187
199
  key: "history",
188
200
  title: (locale == null ? void 0 : locale["chat.history"]) || "历史记录"
189
201
  },
190
- /* @__PURE__ */ React.createElement(HistoryIcon, null)
202
+ /* @__PURE__ */ React.createElement(HistoryOutlined, null)
191
203
  )
192
204
  )
193
205
  );
@@ -261,6 +261,18 @@ var genStyle = (token) => {
261
261
  transition: "transform 0.3s ease-out",
262
262
  transform: "translateX(0)",
263
263
  animation: "none"
264
+ },
265
+ "&-scroll-container": {
266
+ "&::-webkit-scrollbar": {
267
+ width: "4px"
268
+ },
269
+ "&::-webkit-scrollbar-track": {
270
+ backgroundColor: "transparent"
271
+ },
272
+ "&::-webkit-scrollbar-thumb": {
273
+ backgroundColor: "var(--color-gray-border-light)",
274
+ borderRadius: "4px"
275
+ }
264
276
  }
265
277
  }
266
278
  };
@@ -13,7 +13,7 @@ export interface HistoryProps {
13
13
  agentId: string;
14
14
  }) => Promise<HistoryDataType[]>;
15
15
  /** @deprecated 请使用 onClick 替代 */
16
- onSelected?: (sessionId: string) => void;
16
+ onSelected?: (item: HistoryDataType) => void;
17
17
  onClick?: (sessionId: string, item: HistoryDataType) => void;
18
18
  onDeleteItem?: (sessionId: string) => void;
19
19
  customDateFormatter?: (date: number | string | Date) => string;
@@ -100,5 +100,5 @@ export interface HistoryActionsBoxProps {
100
100
  */
101
101
  export interface ActionsBoxProps extends HistoryActionsBoxProps {
102
102
  /** @deprecated 请使用 onClick 替代 */
103
- onSelected?: (sessionId: string) => void;
103
+ onSelected?: (item: HistoryDataType) => void;
104
104
  }
@@ -0,0 +1,5 @@
1
+ import { RefObject } from 'react';
2
+ export interface UseIntersectionOnceOptions extends Omit<IntersectionObserverInit, 'root'> {
3
+ root?: RefObject<Element | null> | Element | null;
4
+ }
5
+ export declare const useIntersectionOnce: <T extends Element>(targetRef: RefObject<T>, options?: UseIntersectionOnceOptions) => boolean;
@@ -0,0 +1,79 @@
1
+ var __defProp = Object.defineProperty;
2
+ var __defProps = Object.defineProperties;
3
+ var __getOwnPropDescs = Object.getOwnPropertyDescriptors;
4
+ var __getOwnPropSymbols = Object.getOwnPropertySymbols;
5
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
6
+ var __propIsEnum = Object.prototype.propertyIsEnumerable;
7
+ var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
8
+ var __spreadValues = (a, b) => {
9
+ for (var prop in b || (b = {}))
10
+ if (__hasOwnProp.call(b, prop))
11
+ __defNormalProp(a, prop, b[prop]);
12
+ if (__getOwnPropSymbols)
13
+ for (var prop of __getOwnPropSymbols(b)) {
14
+ if (__propIsEnum.call(b, prop))
15
+ __defNormalProp(a, prop, b[prop]);
16
+ }
17
+ return a;
18
+ };
19
+ var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
20
+ var __objRest = (source, exclude) => {
21
+ var target = {};
22
+ for (var prop in source)
23
+ if (__hasOwnProp.call(source, prop) && exclude.indexOf(prop) < 0)
24
+ target[prop] = source[prop];
25
+ if (source != null && __getOwnPropSymbols)
26
+ for (var prop of __getOwnPropSymbols(source)) {
27
+ if (exclude.indexOf(prop) < 0 && __propIsEnum.call(source, prop))
28
+ target[prop] = source[prop];
29
+ }
30
+ return target;
31
+ };
32
+
33
+ // src/Hooks/useIntersectionOnce.ts
34
+ import { useEffect, useRef, useState } from "react";
35
+ var useIntersectionOnce = (targetRef, options = {}) => {
36
+ const _a = options, { root } = _a, restOptions = __objRest(_a, ["root"]);
37
+ const [isIntersecting, setIntersecting] = useState(false);
38
+ const observerRef = useRef(null);
39
+ useEffect(() => {
40
+ if (isIntersecting)
41
+ return;
42
+ const element = targetRef.current;
43
+ if (!element)
44
+ return;
45
+ if (typeof IntersectionObserver === "undefined") {
46
+ setIntersecting(true);
47
+ return;
48
+ }
49
+ const resolvedRoot = root && "current" in root ? root.current : root;
50
+ observerRef.current = new IntersectionObserver(
51
+ (entries) => {
52
+ entries.forEach((entry) => {
53
+ var _a2;
54
+ if (entry.isIntersecting || entry.intersectionRatio > 0) {
55
+ setIntersecting(true);
56
+ (_a2 = observerRef.current) == null ? void 0 : _a2.disconnect();
57
+ }
58
+ });
59
+ },
60
+ __spreadProps(__spreadValues({}, restOptions), { root: resolvedRoot != null ? resolvedRoot : null })
61
+ );
62
+ observerRef.current.observe(element);
63
+ return () => {
64
+ var _a2;
65
+ (_a2 = observerRef.current) == null ? void 0 : _a2.disconnect();
66
+ observerRef.current = null;
67
+ };
68
+ }, [
69
+ targetRef,
70
+ restOptions.rootMargin,
71
+ restOptions.threshold,
72
+ root,
73
+ isIntersecting
74
+ ]);
75
+ return isIntersecting;
76
+ };
77
+ export {
78
+ useIntersectionOnce
79
+ };
@@ -215,6 +215,8 @@ export declare function useLanguage(): {
215
215
  'chat.history.historyTasks': string;
216
216
  'chat.history.historyChats': string;
217
217
  'chat.task.search.placeholder': string;
218
+ 'chat.history.empty.chat.title': string;
219
+ 'chat.history.empty.chat.description': string;
218
220
  'taskList.expand': string;
219
221
  'taskList.collapse': string;
220
222
  'taskList.taskList': string;
@@ -179,6 +179,8 @@ export declare const cnLabels: {
179
179
  'chat.history.historyTasks': string;
180
180
  'chat.history.historyChats': string;
181
181
  'chat.task.search.placeholder': string;
182
+ 'chat.history.empty.chat.title': string;
183
+ 'chat.history.empty.chat.description': string;
182
184
  'taskList.expand': string;
183
185
  'taskList.collapse': string;
184
186
  'taskList.taskList': string;
@@ -174,6 +174,8 @@ var cnLabels = {
174
174
  "chat.history.historyTasks": "历史任务",
175
175
  "chat.history.historyChats": "历史对话",
176
176
  "chat.task.search.placeholder": "搜索任务",
177
+ "chat.history.empty.chat.title": "找不到相关结果",
178
+ "chat.history.empty.chat.description": "换个关键词试试吧",
177
179
  // TaskList 组件相关
178
180
  "taskList.expand": "展开",
179
181
  "taskList.collapse": "收起",
@@ -525,6 +527,8 @@ var enLabels = {
525
527
  "chat.history.historyTasks": "History Tasks",
526
528
  "chat.history.historyChats": "History Chats",
527
529
  "chat.task.search.placeholder": "Search Task",
530
+ "chat.history.empty.chat.title": "No related results found",
531
+ "chat.history.empty.chat.description": "Try a different keyword",
528
532
  // TaskList component related
529
533
  "taskList.expand": "Expand",
530
534
  "taskList.collapse": "Collapse",
@@ -37,6 +37,23 @@ var EMPTY_LINE_DISTANCE_THRESHOLD = 4;
37
37
  var EMPTY_LINE_CALCULATION_OFFSET = 2;
38
38
  var EMPTY_LINE_DIVISOR = 2;
39
39
  var MIN_TABLE_CELL_LENGTH = 5;
40
+ var INLINE_MATH_SUFFIX_PATTERN = "(?:%|[kKmMbB]|千|万|亿|兆|万亿|百万|亿万)?";
41
+ var INLINE_MATH_CURRENCY_PATTERN = new RegExp(
42
+ `^[+-]?\\d{1,3}(?:,\\d{3})*(?:\\.\\d+)?${INLINE_MATH_SUFFIX_PATTERN}$`
43
+ );
44
+ var INLINE_MATH_SIMPLE_NUMBER_PATTERN = new RegExp(
45
+ `^[+-]?\\d+(?:\\.\\d+)?${INLINE_MATH_SUFFIX_PATTERN}$`
46
+ );
47
+ var shouldTreatInlineMathAsText = (rawValue) => {
48
+ const trimmedValue = rawValue.trim();
49
+ if (!trimmedValue) {
50
+ return true;
51
+ }
52
+ if (/[=^_\\{}]/.test(trimmedValue)) {
53
+ return false;
54
+ }
55
+ return INLINE_MATH_CURRENCY_PATTERN.test(trimmedValue) || INLINE_MATH_SIMPLE_NUMBER_PATTERN.test(trimmedValue);
56
+ };
40
57
  var processSchemaLanguage = (element, value) => {
41
58
  let json = [];
42
59
  try {
@@ -101,7 +118,6 @@ var getColumnAlignment = (data, columns) => {
101
118
  };
102
119
  var stringifyObj = remark().use(remarkParse).use(fixStrongWithSpecialChars).use(remarkMath, {
103
120
  singleDollarTextMath: false
104
- // 暂时禁用单美元符号,只使用双美元符号 $$...$$
105
121
  }).use(remarkRehype, { allowDangerousHtml: true }).use(rehypeRaw).use(rehypeKatex).use(remarkGfm).use(remarkFrontmatter, ["yaml"]);
106
122
  var myRemark = {
107
123
  stringify: (obj) => {
@@ -268,9 +284,14 @@ var parseText = (els, leaf = {
268
284
  if (n.type === "inlineCode")
269
285
  leafs.push(__spreadProps(__spreadValues({}, leaf), { text: n.value, code: true }));
270
286
  if (n.type === "inlineMath") {
287
+ const inlineMathValue = typeof n.value === "string" ? n.value : "";
288
+ if (shouldTreatInlineMathAsText(inlineMathValue)) {
289
+ leafs.push(__spreadProps(__spreadValues({}, leaf), { text: `$${inlineMathValue}$` }));
290
+ continue;
291
+ }
271
292
  leafs.push(__spreadProps(__spreadValues({}, leaf), {
272
293
  type: "inline-katex",
273
- children: [{ text: n.value }]
294
+ children: [{ text: inlineMathValue }]
274
295
  }));
275
296
  continue;
276
297
  }
@@ -585,9 +606,16 @@ var handleImage = (currentElement) => {
585
606
  );
586
607
  };
587
608
  var handleInlineMath = (currentElement) => {
609
+ const inlineMathValue = typeof (currentElement == null ? void 0 : currentElement.value) === "string" ? currentElement.value : "";
610
+ if (shouldTreatInlineMathAsText(inlineMathValue)) {
611
+ return {
612
+ type: "paragraph",
613
+ children: [{ text: `$${inlineMathValue}$` }]
614
+ };
615
+ }
588
616
  return {
589
617
  type: "inline-katex",
590
- children: [{ text: currentElement.value }]
618
+ children: [{ text: inlineMathValue }]
591
619
  };
592
620
  };
593
621
  var handleMath = (currentElement) => {
@@ -108,8 +108,8 @@ function fixStrongWithSpecialChars() {
108
108
  };
109
109
  }
110
110
  var markdownParser = unified().use(remarkParse).use(remarkHtml).use(remarkGfm).use(fixStrongWithSpecialChars).use(remarkMath, {
111
- singleDollarTextMath: false
112
- // 暂时禁用单美元符号,只使用双美元符号 $$...$$
111
+ singleDollarTextMath: true
112
+ // 允许单美元符号渲染内联数学公式
113
113
  }).use(remarkRehype, { allowDangerousHtml: true }).use(rehypeRaw).use(rehypeKatex).use(remarkFrontmatter, ["yaml"]);
114
114
  var remarkParse_default = markdownParser;
115
115
  export {
@@ -33,8 +33,8 @@ import { fixStrongWithSpecialChars } from "../parser/remarkParse";
33
33
  var markdownToHtml = (markdown) => __async(void 0, null, function* () {
34
34
  try {
35
35
  const htmlContent = yield unified().use(remarkParse).use(remarkGfm).use(fixStrongWithSpecialChars).use(remarkMath, {
36
- singleDollarTextMath: false
37
- // 禁用单美元符号数学公式
36
+ singleDollarTextMath: true
37
+ // 允许单美元符号渲染内联数学公式
38
38
  }).use(remarkFrontmatter, ["yaml"]).use(remarkRehype, { allowDangerousHtml: true }).use(rehypeRaw).use(rehypeKatex).use(rehypeStringify).process(markdown);
39
39
  return String(htmlContent);
40
40
  } catch (error) {
@@ -45,8 +45,8 @@ var markdownToHtml = (markdown) => __async(void 0, null, function* () {
45
45
  var markdownToHtmlSync = (markdown) => {
46
46
  try {
47
47
  const processor = unified().use(remarkParse).use(remarkGfm).use(fixStrongWithSpecialChars).use(remarkMath, {
48
- singleDollarTextMath: false
49
- // 禁用单美元符号数学公式
48
+ singleDollarTextMath: true
49
+ // 允许单美元符号渲染内联数学公式
50
50
  }).use(remarkFrontmatter, ["yaml"]).use(remarkRehype, { allowDangerousHtml: true }).use(rehypeRaw).use(rehypeKatex).use(rehypeStringify);
51
51
  const file = processor.processSync(markdown);
52
52
  return String(file);
@@ -141,31 +141,35 @@ var MarkdownInputField = (_a) => {
141
141
  value: (_e = props.attachment) == null ? void 0 : _e.fileMap,
142
142
  onChange: (_f = props.attachment) == null ? void 0 : _f.onFileMapChange
143
143
  });
144
- const isMultiRowLayout = useMemo(() => {
145
- var _a3;
146
- return !!((props == null ? void 0 : props.quickActionRender) || ((_a3 = props == null ? void 0 : props.refinePrompt) == null ? void 0 : _a3.enable) || (props == null ? void 0 : props.actionsRender) || (props == null ? void 0 : props.toolsRender));
147
- }, [
148
- props == null ? void 0 : props.quickActionRender,
149
- (_g = props == null ? void 0 : props.refinePrompt) == null ? void 0 : _g.enable,
150
- props == null ? void 0 : props.actionsRender,
151
- props == null ? void 0 : props.toolsRender
152
- ]);
144
+ const hasEnlargeAction = !!((_g = props == null ? void 0 : props.enlargeable) == null ? void 0 : _g.enable);
145
+ const hasRefineAction = !!((_h = props == null ? void 0 : props.refinePrompt) == null ? void 0 : _h.enable);
146
+ const hasCustomQuickAction = !!(props == null ? void 0 : props.quickActionRender);
147
+ const hasActionsRender = !!(props == null ? void 0 : props.actionsRender);
148
+ const hasToolsRender = !!(props == null ? void 0 : props.toolsRender);
149
+ const quickActionCount = Number(hasEnlargeAction) + Number(hasRefineAction) + Number(hasCustomQuickAction);
150
+ const auxiliaryActionCount = Number(hasActionsRender) + Number(hasToolsRender);
151
+ const totalActionCount = quickActionCount + auxiliaryActionCount;
152
+ const isMultiRowLayout = totalActionCount > 0;
153
153
  const computedMinHeight = useMemo(() => {
154
- var _a3, _b3, _c2;
154
+ var _a3, _b3;
155
155
  if (isEnlarged)
156
156
  return "auto";
157
- if (((_a3 = props == null ? void 0 : props.enlargeable) == null ? void 0 : _a3.enable) && ((_b3 = props == null ? void 0 : props.refinePrompt) == null ? void 0 : _b3.enable)) {
157
+ if (((_a3 = props.style) == null ? void 0 : _a3.minHeight) !== void 0)
158
+ return props.style.minHeight;
159
+ if (hasEnlargeAction && hasRefineAction)
158
160
  return 140;
159
- }
161
+ if (totalActionCount === 1)
162
+ return 90;
160
163
  if (isMultiRowLayout)
161
164
  return 106;
162
- return ((_c2 = props.style) == null ? void 0 : _c2.minHeight) || 0;
165
+ return ((_b3 = props.style) == null ? void 0 : _b3.minHeight) || 0;
163
166
  }, [
164
167
  isEnlarged,
165
- (_h = props == null ? void 0 : props.enlargeable) == null ? void 0 : _h.enable,
166
- (_i = props == null ? void 0 : props.refinePrompt) == null ? void 0 : _i.enable,
168
+ hasEnlargeAction,
169
+ hasRefineAction,
167
170
  isMultiRowLayout,
168
- (_j = props.style) == null ? void 0 : _j.minHeight
171
+ totalActionCount,
172
+ (_i = props.style) == null ? void 0 : _i.minHeight
169
173
  ]);
170
174
  const {
171
175
  fileUploadDone,
@@ -311,7 +315,7 @@ var MarkdownInputField = (_a) => {
311
315
  );
312
316
  }, [
313
317
  fileMap,
314
- (_k = props.attachment) == null ? void 0 : _k.enable,
318
+ (_j = props.attachment) == null ? void 0 : _j.enable,
315
319
  handleFileRemoval,
316
320
  handleFileRetry,
317
321
  updateAttachmentFiles
@@ -351,7 +355,7 @@ var MarkdownInputField = (_a) => {
351
355
  supportedFormat,
352
356
  fileMap,
353
357
  onFileMapChange: setFileMap,
354
- upload: ((_l = props.attachment) == null ? void 0 : _l.upload) ? (file) => props.attachment.upload(file, 0) : void 0
358
+ upload: ((_k = props.attachment) == null ? void 0 : _k.upload) ? (file) => props.attachment.upload(file, 0) : void 0
355
359
  }),
356
360
  voiceRecognizer: props.voiceRecognizer,
357
361
  value,
@@ -406,7 +410,7 @@ var MarkdownInputField = (_a) => {
406
410
  [`${baseCls}-enlarged`]: isEnlarged
407
411
  }),
408
412
  style: __spreadProps(__spreadValues(__spreadValues({}, props.style), enlargedStyle), {
409
- height: isEnlarged ? `${(_n = (_m = props.enlargeable) == null ? void 0 : _m.height) != null ? _n : 980}px` : `min(${collapsedHeightPx}px,100%)`,
413
+ height: isEnlarged ? `${(_m = (_l = props.enlargeable) == null ? void 0 : _l.height) != null ? _m : 980}px` : `min(${collapsedHeightPx}px,100%)`,
410
414
  borderRadius: borderRadius || 16,
411
415
  minHeight: computedMinHeight,
412
416
  cursor: isLoading || props.disabled ? "not-allowed" : "auto",
@@ -539,7 +543,7 @@ var MarkdownInputField = (_a) => {
539
543
  ),
540
544
  sendActionsNode
541
545
  ) : sendActionsNode,
542
- (props == null ? void 0 : props.quickActionRender) || ((_o = props.refinePrompt) == null ? void 0 : _o.enable) ? /* @__PURE__ */ React.createElement(
546
+ (props == null ? void 0 : props.quickActionRender) || ((_n = props.refinePrompt) == null ? void 0 : _n.enable) || ((_o = props.enlargeable) == null ? void 0 : _o.enable) ? /* @__PURE__ */ React.createElement(
543
547
  QuickActions,
544
548
  {
545
549
  ref: quickActionsRef,
@@ -46,15 +46,7 @@ import {
46
46
  findDataPointByXValue
47
47
  } from "../utils";
48
48
  import { useStyle } from "./style";
49
- ChartJS.register(
50
- CategoryScale,
51
- LinearScale,
52
- PointElement,
53
- LineElement,
54
- Filler,
55
- Tooltip,
56
- Legend
57
- );
49
+ var areaChartComponentsRegistered = false;
58
50
  var hexToRgba = (hex, alpha) => {
59
51
  const sanitized = hex.replace("#", "");
60
52
  const isShort = sanitized.length === 3;
@@ -95,6 +87,25 @@ var AreaChart = ({
95
87
  statistic: statisticConfig,
96
88
  variant
97
89
  }) => {
90
+ useMemo(() => {
91
+ if (areaChartComponentsRegistered) {
92
+ return void 0;
93
+ }
94
+ if (typeof window === "undefined") {
95
+ return void 0;
96
+ }
97
+ ChartJS.register(
98
+ CategoryScale,
99
+ LinearScale,
100
+ PointElement,
101
+ LineElement,
102
+ Filler,
103
+ Tooltip,
104
+ Legend
105
+ );
106
+ areaChartComponentsRegistered = true;
107
+ return void 0;
108
+ }, []);
98
109
  const safeData = Array.isArray(data) ? data : [];
99
110
  const [windowWidth, setWindowWidth] = useState(
100
111
  typeof window !== "undefined" ? window.innerWidth : 768
@@ -45,7 +45,7 @@ import {
45
45
  findDataPointByXValue
46
46
  } from "../utils";
47
47
  import { useStyle } from "./style";
48
- ChartJS.register(CategoryScale, LinearScale, BarElement, Tooltip, Legend);
48
+ var barChartComponentsRegistered = false;
49
49
  var hexToRgba = (hex, alpha) => {
50
50
  const sanitized = hex.replace("#", "");
51
51
  const isShort = sanitized.length === 3;
@@ -93,6 +93,17 @@ var BarChart = ({
93
93
  dataLabelFormatter,
94
94
  chartOptions
95
95
  }) => {
96
+ useMemo(() => {
97
+ if (barChartComponentsRegistered) {
98
+ return void 0;
99
+ }
100
+ if (typeof window === "undefined") {
101
+ return void 0;
102
+ }
103
+ ChartJS.register(CategoryScale, LinearScale, BarElement, Tooltip, Legend);
104
+ barChartComponentsRegistered = true;
105
+ return void 0;
106
+ }, []);
96
107
  const safeData = Array.isArray(data) ? data : [];
97
108
  const [windowWidth, setWindowWidth] = useState(
98
109
  typeof window !== "undefined" ? window.innerWidth : 768
@@ -13,17 +13,28 @@ import {
13
13
  import React, { useImperativeHandle, useRef } from "react";
14
14
  import { Line } from "react-chartjs-2";
15
15
  import { Container } from "./Container";
16
- ChartJS.register(
17
- CategoryScale,
18
- LinearScale,
19
- PointElement,
20
- LineElement,
21
- Filler,
22
- Title,
23
- Tooltip,
24
- Legend
25
- );
16
+ var chartMarkAreaRegistered = false;
26
17
  var Area = (props) => {
18
+ React.useMemo(() => {
19
+ if (chartMarkAreaRegistered) {
20
+ return void 0;
21
+ }
22
+ if (typeof window === "undefined") {
23
+ return void 0;
24
+ }
25
+ ChartJS.register(
26
+ CategoryScale,
27
+ LinearScale,
28
+ PointElement,
29
+ LineElement,
30
+ Filler,
31
+ Title,
32
+ Tooltip,
33
+ Legend
34
+ );
35
+ chartMarkAreaRegistered = true;
36
+ return void 0;
37
+ }, []);
27
38
  const chartRef = React.useRef(void 0);
28
39
  const htmlRef = useRef(null);
29
40
  const lineChartRef = useRef(null);