@ant-design/agentic-ui 2.28.4 → 2.28.5
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.
|
@@ -48,7 +48,7 @@ function _unsupported_iterable_to_array(o, minLen) {
|
|
|
48
48
|
if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _array_like_to_array(o, minLen);
|
|
49
49
|
}
|
|
50
50
|
import { useMergedState } from "rc-util";
|
|
51
|
-
import React, { createContext, useContext, useEffect, useMemo } from "react";
|
|
51
|
+
import React, { createContext, useContext, useEffect, useMemo, useRef } from "react";
|
|
52
52
|
import { MessagesContext } from "../../../Bubble/MessagesContent/BubbleContext";
|
|
53
53
|
import { I18nContext } from "../../../I18n";
|
|
54
54
|
import { EditorStoreContext, useEditorStore } from "../../../MarkdownEditor/editor/store";
|
|
@@ -155,6 +155,21 @@ export function ThinkBlock(props) {
|
|
|
155
155
|
}, [
|
|
156
156
|
isLastNode
|
|
157
157
|
]);
|
|
158
|
+
// 跟踪 thinkBlockContext?.expanded 的之前值
|
|
159
|
+
var prevExpandedRef = useRef(thinkBlockContext === null || thinkBlockContext === void 0 ? void 0 : thinkBlockContext.expanded);
|
|
160
|
+
// 当 thinkBlockContext?.expanded 从其他值变成 undefined 时,自动收起
|
|
161
|
+
useEffect(function() {
|
|
162
|
+
var prevExpanded = prevExpandedRef.current;
|
|
163
|
+
var currentExpanded = thinkBlockContext === null || thinkBlockContext === void 0 ? void 0 : thinkBlockContext.expanded;
|
|
164
|
+
// 如果之前有值(true 或 false),现在变成 undefined,则收起
|
|
165
|
+
if (prevExpanded !== undefined && currentExpanded === undefined) {
|
|
166
|
+
setExpanded(false);
|
|
167
|
+
}
|
|
168
|
+
// 更新之前的值
|
|
169
|
+
prevExpandedRef.current = currentExpanded;
|
|
170
|
+
}, [
|
|
171
|
+
thinkBlockContext === null || thinkBlockContext === void 0 ? void 0 : thinkBlockContext.expanded
|
|
172
|
+
]);
|
|
158
173
|
var rawContent = (element === null || element === void 0 ? void 0 : element.value) !== null && (element === null || element === void 0 ? void 0 : element.value) !== undefined ? String(element.value).trim() : '';
|
|
159
174
|
// 恢复内容中被转义的代码块
|
|
160
175
|
var content = restoreCodeBlocks(rawContent);
|