@ant-design/agentic-ui 2.28.4 → 2.28.6
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";
|
|
@@ -134,7 +134,7 @@ export function ThinkBlock(props) {
|
|
|
134
134
|
// 1. Context 提供的 expanded(受控模式)
|
|
135
135
|
// 2. editorProps?.codeProps?.alwaysExpandedDeepThink
|
|
136
136
|
// 3. 默认值(false)
|
|
137
|
-
var _useMergedState = _sliced_to_array(useMergedState((_editorProps_codeProps_alwaysExpandedDeepThink = editorProps === null || editorProps === void 0 ? void 0 : (_editorProps_codeProps = editorProps.codeProps) === null || _editorProps_codeProps === void 0 ? void 0 : _editorProps_codeProps.alwaysExpandedDeepThink) !== null && _editorProps_codeProps_alwaysExpandedDeepThink !== void 0 ? _editorProps_codeProps_alwaysExpandedDeepThink :
|
|
137
|
+
var _useMergedState = _sliced_to_array(useMergedState((_editorProps_codeProps_alwaysExpandedDeepThink = editorProps === null || editorProps === void 0 ? void 0 : (_editorProps_codeProps = editorProps.codeProps) === null || _editorProps_codeProps === void 0 ? void 0 : _editorProps_codeProps.alwaysExpandedDeepThink) !== null && _editorProps_codeProps_alwaysExpandedDeepThink !== void 0 ? _editorProps_codeProps_alwaysExpandedDeepThink : true, {
|
|
138
138
|
value: (editorProps === null || editorProps === void 0 ? void 0 : (_editorProps_codeProps1 = editorProps.codeProps) === null || _editorProps_codeProps1 === void 0 ? void 0 : _editorProps_codeProps1.alwaysExpandedDeepThink) ? true : (_thinkBlockContext_expanded = thinkBlockContext === null || thinkBlockContext === void 0 ? void 0 : thinkBlockContext.expanded) !== null && _thinkBlockContext_expanded !== void 0 ? _thinkBlockContext_expanded : undefined,
|
|
139
139
|
defaultValue: true,
|
|
140
140
|
onChange: thinkBlockContext === null || thinkBlockContext === void 0 ? void 0 : thinkBlockContext.onExpandedChange
|
|
@@ -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);
|