@ant-design/agentic-ui 2.30.25 → 2.30.27

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 +20 -6
  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.d.ts +2 -2
  24. package/dist/MarkdownEditor/editor/elements/Paragraph/ReadonlyParagraph.js +3 -6
  25. package/dist/MarkdownEditor/editor/elements/Paragraph/index.js +1 -10
  26. package/dist/MarkdownEditor/editor/elements/Table/EditableTable.js +1 -1
  27. package/dist/MarkdownEditor/editor/elements/index.js +1 -1
  28. package/dist/MarkdownEditor/editor/parser/parserMarkdownToSlateNode.js +1 -1
  29. package/dist/MarkdownEditor/editor/plugins/withMarkdown.js +1 -1
  30. package/dist/MarkdownEditor/editor/plugins/withSanitizeInvalidChildren.js +80 -38
  31. package/dist/MarkdownEditor/editor/store.js +1 -0
  32. package/dist/MarkdownEditor/editor/tools/InsertAutocomplete.js +1 -0
  33. package/dist/MarkdownEditor/editor/utils/editorUtils.d.ts +6 -0
  34. package/dist/MarkdownEditor/editor/utils/editorUtils.js +28 -1
  35. package/dist/MarkdownEditor/style.js +0 -6
  36. package/dist/MarkdownInputField/hooks/useMarkdownInputFieldRefs.js +0 -3
  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 +1 -1
@@ -0,0 +1,272 @@
1
+ /**
2
+ * Bubble 自定义 memo 比较(见 Bubble.tsx)。
3
+ *
4
+ * 维护约定:
5
+ * - 在 BubbleProps 上新增「会影响渲染」的字段时,必须在此补充比较逻辑,否则可能漏更新。
6
+ * - `markdownRenderConfig` / `bubbleRenderConfig` / `docListProps` / `customConfig`:按**顶层键**浅比较;
7
+ * 顶层值为普通对象时再浅比较一层;数组与函数仍按引用比较。父组件用 `useMemo` 稳定子对象引用更佳。
8
+ * - `originData`:按列出的标量与引用字段比较;`meta` 顶层浅比较;`meta.metadata` 再浅比较一层。
9
+ * 对 `extra` 等对象请勿原地 mutate,应替换引用,否则可能与 `extra !==` 不一致(若仅改嵌套且未换引用会漏更新)。
10
+ */ function _array_like_to_array(arr, len) {
11
+ if (len == null || len > arr.length) len = arr.length;
12
+ for(var i = 0, arr2 = new Array(len); i < len; i++)arr2[i] = arr[i];
13
+ return arr2;
14
+ }
15
+ function _array_without_holes(arr) {
16
+ if (Array.isArray(arr)) return _array_like_to_array(arr);
17
+ }
18
+ function _iterable_to_array(iter) {
19
+ if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter);
20
+ }
21
+ function _non_iterable_spread() {
22
+ throw new TypeError("Invalid attempt to spread non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
23
+ }
24
+ function _to_consumable_array(arr) {
25
+ return _array_without_holes(arr) || _iterable_to_array(arr) || _unsupported_iterable_to_array(arr) || _non_iterable_spread();
26
+ }
27
+ function _type_of(obj) {
28
+ "@swc/helpers - typeof";
29
+ return obj && typeof Symbol !== "undefined" && obj.constructor === Symbol ? "symbol" : typeof obj;
30
+ }
31
+ function _unsupported_iterable_to_array(o, minLen) {
32
+ if (!o) return;
33
+ if (typeof o === "string") return _array_like_to_array(o, minLen);
34
+ var n = Object.prototype.toString.call(o).slice(8, -1);
35
+ if (n === "Object" && o.constructor) n = o.constructor.name;
36
+ if (n === "Map" || n === "Set") return Array.from(n);
37
+ if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _array_like_to_array(o, minLen);
38
+ }
39
+ export var shallowEqualRecord = function shallowEqualRecord(a, b) {
40
+ if (a === b) return true;
41
+ if (!a || !b) return !a && !b;
42
+ var keysA = Object.keys(a);
43
+ var keysB = Object.keys(b);
44
+ if (keysA.length !== keysB.length) return false;
45
+ var _iteratorNormalCompletion = true, _didIteratorError = false, _iteratorError = undefined;
46
+ try {
47
+ for(var _iterator = keysA[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true){
48
+ var k = _step.value;
49
+ if (a[k] !== b[k]) {
50
+ return false;
51
+ }
52
+ }
53
+ } catch (err) {
54
+ _didIteratorError = true;
55
+ _iteratorError = err;
56
+ } finally{
57
+ try {
58
+ if (!_iteratorNormalCompletion && _iterator.return != null) {
59
+ _iterator.return();
60
+ }
61
+ } finally{
62
+ if (_didIteratorError) {
63
+ throw _iteratorError;
64
+ }
65
+ }
66
+ }
67
+ return true;
68
+ };
69
+ export var shallowEqualStyles = function shallowEqualStyles(a, b) {
70
+ if (a === b) return true;
71
+ if (!a || !b) return !a && !b;
72
+ var keys = new Set(_to_consumable_array(Object.keys(a)).concat(_to_consumable_array(Object.keys(b))));
73
+ var _iteratorNormalCompletion = true, _didIteratorError = false, _iteratorError = undefined;
74
+ try {
75
+ for(var _iterator = keys[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true){
76
+ var k = _step.value;
77
+ var va = a[k];
78
+ var vb = b[k];
79
+ if (va === vb) continue;
80
+ if (va && vb && (typeof va === "undefined" ? "undefined" : _type_of(va)) === 'object' && (typeof vb === "undefined" ? "undefined" : _type_of(vb)) === 'object' && !Array.isArray(va) && !Array.isArray(vb)) {
81
+ if (!shallowEqualRecord(va, vb)) {
82
+ return false;
83
+ }
84
+ } else {
85
+ return false;
86
+ }
87
+ }
88
+ } catch (err) {
89
+ _didIteratorError = true;
90
+ _iteratorError = err;
91
+ } finally{
92
+ try {
93
+ if (!_iteratorNormalCompletion && _iterator.return != null) {
94
+ _iterator.return();
95
+ }
96
+ } finally{
97
+ if (_didIteratorError) {
98
+ throw _iteratorError;
99
+ }
100
+ }
101
+ }
102
+ return true;
103
+ };
104
+ var shallowEqualClassNames = function shallowEqualClassNames(a, b) {
105
+ if (a === b) return true;
106
+ if (!a || !b) return !a && !b;
107
+ var keys = new Set(_to_consumable_array(Object.keys(a)).concat(_to_consumable_array(Object.keys(b))));
108
+ var _iteratorNormalCompletion = true, _didIteratorError = false, _iteratorError = undefined;
109
+ try {
110
+ for(var _iterator = keys[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true){
111
+ var k = _step.value;
112
+ if (a[k] !== b[k]) {
113
+ return false;
114
+ }
115
+ }
116
+ } catch (err) {
117
+ _didIteratorError = true;
118
+ _iteratorError = err;
119
+ } finally{
120
+ try {
121
+ if (!_iteratorNormalCompletion && _iterator.return != null) {
122
+ _iterator.return();
123
+ }
124
+ } finally{
125
+ if (_didIteratorError) {
126
+ throw _iteratorError;
127
+ }
128
+ }
129
+ }
130
+ return true;
131
+ };
132
+ /** 配置型 props:顶层浅比较;顶层值为非数组对象时再浅比较一层 */ var shallowEqualConfigObject = function shallowEqualConfigObject(a, b) {
133
+ if (a === b) return true;
134
+ if (!a || !b) return !a && !b;
135
+ var ra = a;
136
+ var rb = b;
137
+ var keys = new Set(_to_consumable_array(Object.keys(ra)).concat(_to_consumable_array(Object.keys(rb))));
138
+ var _iteratorNormalCompletion = true, _didIteratorError = false, _iteratorError = undefined;
139
+ try {
140
+ for(var _iterator = keys[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true){
141
+ var k = _step.value;
142
+ if (!(k in ra) || !(k in rb)) return false;
143
+ var va = ra[k];
144
+ var vb = rb[k];
145
+ if (va === vb) continue;
146
+ if (va && vb && (typeof va === "undefined" ? "undefined" : _type_of(va)) === 'object' && (typeof vb === "undefined" ? "undefined" : _type_of(vb)) === 'object' && !Array.isArray(va) && !Array.isArray(vb)) {
147
+ if (!shallowEqualRecord(va, vb)) {
148
+ return false;
149
+ }
150
+ } else {
151
+ return false;
152
+ }
153
+ }
154
+ } catch (err) {
155
+ _didIteratorError = true;
156
+ _iteratorError = err;
157
+ } finally{
158
+ try {
159
+ if (!_iteratorNormalCompletion && _iterator.return != null) {
160
+ _iterator.return();
161
+ }
162
+ } finally{
163
+ if (_didIteratorError) {
164
+ throw _iteratorError;
165
+ }
166
+ }
167
+ }
168
+ return true;
169
+ };
170
+ var metaAffectsBubble = function metaAffectsBubble(m) {
171
+ return Boolean((m === null || m === void 0 ? void 0 : m.avatar) || (m === null || m === void 0 ? void 0 : m.title) || (m === null || m === void 0 ? void 0 : m.name) || (m === null || m === void 0 ? void 0 : m.description) || (m === null || m === void 0 ? void 0 : m.backgroundColor) || (m === null || m === void 0 ? void 0 : m.metadata) && Object.keys(m.metadata).length > 0);
172
+ };
173
+ var metaEqualForMemo = function metaEqualForMemo(a, b) {
174
+ if (a === b) return true;
175
+ if (!shallowEqualRecord(a || {}, b || {})) {
176
+ return false;
177
+ }
178
+ var ma = a === null || a === void 0 ? void 0 : a.metadata;
179
+ var mb = b === null || b === void 0 ? void 0 : b.metadata;
180
+ if (ma === mb) return true;
181
+ if (!ma || !mb) return !ma && !mb;
182
+ return shallowEqualRecord(ma, mb);
183
+ };
184
+ var originDataEqualForMemo = function originDataEqualForMemo(a, b) {
185
+ if (a === b) return true;
186
+ if (!a || !b) return false;
187
+ if (a.id !== b.id || a.role !== b.role || a.content !== b.content || a.isFinished !== b.isFinished || a.isAborted !== b.isAborted || a.isLast !== b.isLast || a.isLatest !== b.isLatest || a.updateAt !== b.updateAt || a.createAt !== b.createAt || a.feedback !== b.feedback || a.originContent !== b.originContent || a.fileMap !== b.fileMap || a.extra !== b.extra || a.error !== b.error) {
188
+ return false;
189
+ }
190
+ if (a.meta === b.meta) return true;
191
+ if (!metaAffectsBubble(a.meta) && !metaAffectsBubble(b.meta)) return true;
192
+ return metaEqualForMemo(a.meta, b.meta);
193
+ };
194
+ var preMessageEqualForMemo = function preMessageEqualForMemo(a, b) {
195
+ if (a === b) return true;
196
+ if (!a || !b) return false;
197
+ return a.id === b.id && a.role === b.role;
198
+ };
199
+ var depsArrayEqual = function depsArrayEqual(a, b) {
200
+ if (a === b) return true;
201
+ if (!a || !b) return !a && !b;
202
+ if (a.length !== b.length) return false;
203
+ for(var i = 0; i < a.length; i++){
204
+ if (a[i] !== b[i]) return false;
205
+ }
206
+ return true;
207
+ };
208
+ /**
209
+ * Custom props comparator for Bubble memo.
210
+ * BubbleList (and callers) often pass fresh object references for styles / classNames / avatar
211
+ * while message data is unchanged; default shallow compare would still re-render every parent tick.
212
+ */ export var bubblePropsAreEqual = function bubblePropsAreEqual(prev, next) {
213
+ if (prev === next) return true;
214
+ if (prev.id !== next.id) return false;
215
+ if (prev.placement !== next.placement) return false;
216
+ if (prev.pure !== next.pure) return false;
217
+ if (prev.readonly !== next.readonly) return false;
218
+ if (prev.time !== next.time) return false;
219
+ if (prev.shouldShowVoice !== next.shouldShowVoice) return false;
220
+ if (prev.renderMode !== next.renderMode) return false;
221
+ if (prev.renderType !== next.renderType) return false;
222
+ if (prev.shouldShowCopy !== next.shouldShowCopy) return false;
223
+ if (typeof prev.shouldShowCopy === 'function' || typeof next.shouldShowCopy === 'function') {
224
+ if (prev.shouldShowCopy !== next.shouldShowCopy) return false;
225
+ }
226
+ if (!originDataEqualForMemo(prev.originData, next.originData)) return false;
227
+ if (!preMessageEqualForMemo(prev.preMessage, next.preMessage)) return false;
228
+ if (!shallowEqualConfigObject(prev.markdownRenderConfig, next.markdownRenderConfig)) {
229
+ return false;
230
+ }
231
+ if (!shallowEqualConfigObject(prev.bubbleRenderConfig, next.bubbleRenderConfig)) {
232
+ return false;
233
+ }
234
+ if (!shallowEqualConfigObject(prev.docListProps, next.docListProps)) {
235
+ return false;
236
+ }
237
+ if (!shallowEqualConfigObject(prev.customConfig, next.customConfig)) {
238
+ return false;
239
+ }
240
+ if (prev.bubbleListRef !== next.bubbleListRef) return false;
241
+ if (prev.bubbleRef !== next.bubbleRef) return false;
242
+ if (prev.avatar === next.avatar) {
243
+ // ok
244
+ } else if (!shallowEqualRecord(prev.avatar, next.avatar)) {
245
+ return false;
246
+ }
247
+ if (!shallowEqualStyles(prev.styles, next.styles)) return false;
248
+ if (!shallowEqualClassNames(prev.classNames, next.classNames)) return false;
249
+ if (prev.style !== next.style) {
250
+ if (!shallowEqualRecord(prev.style || {}, next.style || {})) {
251
+ return false;
252
+ }
253
+ }
254
+ if (prev.className !== next.className) return false;
255
+ if (prev.onReply !== next.onReply) return false;
256
+ if (prev.onDisLike !== next.onDisLike) return false;
257
+ if (prev.onDislike !== next.onDislike) return false;
258
+ if (prev.onLike !== next.onLike) return false;
259
+ if (prev.onCancelLike !== next.onCancelLike) return false;
260
+ if (prev.onLikeCancel !== next.onLikeCancel) return false;
261
+ if (prev.onAvatarClick !== next.onAvatarClick) return false;
262
+ if (prev.onDoubleClick !== next.onDoubleClick) return false;
263
+ if (prev.useSpeech !== next.useSpeech) return false;
264
+ if (prev.fileViewEvents !== next.fileViewEvents) return false;
265
+ if (prev.fileViewConfig !== next.fileViewConfig) return false;
266
+ if (prev.renderFileMoreAction !== next.renderFileMoreAction) return false;
267
+ if (prev.userBubbleProps !== next.userBubbleProps) return false;
268
+ if (prev.aiBubbleProps !== next.aiBubbleProps) return false;
269
+ if (prev.aIBubbleProps !== next.aIBubbleProps) return false;
270
+ if (!depsArrayEqual(prev.deps, next.deps)) return false;
271
+ return true;
272
+ };
@@ -16,4 +16,7 @@ export interface TypingAnimationProps extends MotionProps {
16
16
  blinkCursor?: boolean;
17
17
  cursorStyle?: 'line' | 'block' | 'underscore';
18
18
  }
19
- export declare function TypingAnimation({ children, words, className, duration, typeSpeed, deleteSpeed, delay, pauseDelay, loop, as: Component, startOnView, showCursor, blinkCursor, cursorStyle, ...props }: TypingAnimationProps): any;
19
+ export declare const TypingAnimation: React.MemoExoticComponent<{
20
+ ({ children, words, className, duration, typeSpeed, deleteSpeed, delay, pauseDelay, loop, as: Component, startOnView, showCursor, blinkCursor, cursorStyle, ...props }: TypingAnimationProps): any;
21
+ displayName: string;
22
+ }>;
@@ -112,10 +112,10 @@ import { ConfigProvider } from "antd";
112
112
  import classNames from "clsx";
113
113
  import { motion, useInView } from "framer-motion";
114
114
  import { isString } from "lodash-es";
115
- import React, { useContext, useEffect, useMemo, useRef, useState } from "react";
115
+ import React, { memo, useContext, useEffect, useMemo, useRef, useState } from "react";
116
116
  import { resolveSegments } from "../TextAnimate";
117
117
  import { useTypingAnimationStyle } from "./style";
118
- export function TypingAnimation(_0) {
118
+ var TypingAnimationBase = function TypingAnimationBase(_0) {
119
119
  var children = _0.children, words = _0.words, className = _0.className, _0_duration = _0.duration, duration = _0_duration === void 0 ? 100 : _0_duration, typeSpeed = _0.typeSpeed, deleteSpeed = _0.deleteSpeed, _0_delay = _0.delay, delay = _0_delay === void 0 ? 0 : _0_delay, _0_pauseDelay = _0.pauseDelay, pauseDelay = _0_pauseDelay === void 0 ? 1000 : _0_pauseDelay, _0_loop = _0.loop, loop = _0_loop === void 0 ? false : _0_loop, tmp = _0.as, Component = tmp === void 0 ? 'span' : tmp, _0_startOnView = _0.startOnView, startOnView = _0_startOnView === void 0 ? true : _0_startOnView, _0_showCursor = _0.showCursor, showCursor = _0_showCursor === void 0 ? true : _0_showCursor, _0_blinkCursor = _0.blinkCursor, blinkCursor = _0_blinkCursor === void 0 ? true : _0_blinkCursor, _0_cursorStyle = _0.cursorStyle, cursorStyle = _0_cursorStyle === void 0 ? 'line' : _0_cursorStyle, props = _object_without_properties(_0, [
120
120
  "children",
121
121
  "words",
@@ -233,4 +233,6 @@ export function TypingAnimation(_0) {
233
233
  }, props), displayedText, shouldShowCursor && /*#__PURE__*/ React.createElement("span", {
234
234
  className: classNames("".concat(prefixCls, "-cursor"), hashId, blinkCursor && "".concat(prefixCls, "-cursor-blinking"))
235
235
  }, getCursorChar())));
236
- }
236
+ };
237
+ TypingAnimationBase.displayName = 'TypingAnimation';
238
+ export var TypingAnimation = /*#__PURE__*/ memo(TypingAnimationBase);
@@ -231,6 +231,8 @@ var I18nBoundary = function I18nBoundary(param) {
231
231
  // markdown 编辑器实例
232
232
  var markdownEditorRef = useRef(composeEditors(withMarkdown(withReact(withHistory(createEditor()))), props.plugins || []));
233
233
  var markdownContainerRef = useRef(null);
234
+ var pluginsForInitParseRef = useRef(props.plugins);
235
+ pluginsForInitParseRef.current = props.plugins;
234
236
  // 错误捕获
235
237
  useEffect(function() {
236
238
  withErrorReporting(markdownEditorRef.current);
@@ -282,10 +284,11 @@ var I18nBoundary = function I18nBoundary(param) {
282
284
  * 初始化 schema
283
285
  */ var initSchemaValue = useMemo(function() {
284
286
  // 安全地获取解析结果,确保 list 始终是数组
285
- var parseResult = parserMdToSchema(initValue || '', props.plugins);
287
+ var parseResult = parserMdToSchema(initValue || '', pluginsForInitParseRef.current || []);
286
288
  var list = (parseResult === null || parseResult === void 0 ? void 0 : parseResult.schema) || [];
287
- // 如果不是只读模式,添加一个空段落以便编辑
288
- if (!props.readonly) {
289
+ // 非只读时保证末尾有可编辑块:解析结果常已含空段落(如空 initValue),
290
+ // 再追加会导致 Slate 根下两个空段,Paragraph 的占位符依赖 children.length===1 而失效
291
+ if (!props.readonly && list.length === 0) {
289
292
  list = _to_consumable_array(list).concat([
290
293
  EditorUtils.p
291
294
  ]);
@@ -295,7 +298,7 @@ var I18nBoundary = function I18nBoundary(param) {
295
298
  EditorUtils.p
296
299
  ])));
297
300
  // 过滤掉无效的空节点
298
- return schema === null || schema === void 0 ? void 0 : schema.filter(function(item) {
301
+ var filtered = (schema === null || schema === void 0 ? void 0 : schema.filter(function(item) {
299
302
  if (item.type === 'paragraph' && item.children.length === 0) {
300
303
  return false;
301
304
  }
@@ -309,8 +312,13 @@ var I18nBoundary = function I18nBoundary(param) {
309
312
  return false;
310
313
  }
311
314
  return true;
312
- });
313
- }, []);
315
+ })) || [];
316
+ return EditorUtils.coalesceRootAllEmptyParagraphs(filtered);
317
+ }, [
318
+ initValue,
319
+ props.readonly,
320
+ props.initSchemaValue
321
+ ]);
314
322
  // 初始化实例
315
323
  var instance = useMemo(function() {
316
324
  return {
@@ -346,6 +354,12 @@ var I18nBoundary = function I18nBoundary(param) {
346
354
  var _useState2 = _sliced_to_array(useState([]), 2), showCommentList = _useState2[0], setShowComment = _useState2[1];
347
355
  // schema 数据
348
356
  var _useState3 = _sliced_to_array(useState(initSchemaValue), 2), schema = _useState3[0], setSchema = _useState3[1];
357
+ // initSchemaValue 随 initValue / initSchemaValue prop 变化时同步到 state,供 Toc 等与编辑器树一致
358
+ useEffect(function() {
359
+ setSchema(initSchemaValue);
360
+ }, [
361
+ initSchemaValue
362
+ ]);
349
363
  var _useState4 = _sliced_to_array(useState(false), 2), openInsertCompletion = _useState4[0], setOpenInsertCompletion = _useState4[1];
350
364
  var _useState5 = _sliced_to_array(useState(false), 2), refreshFloatBar = _useState5[0], setRefreshFloatBar = _useState5[1];
351
365
  var insertCompletionText$ = useMemo(function() {
@@ -55,7 +55,6 @@ import React, { useMemo } from "react";
55
55
  import { Node } from "slate";
56
56
  import { debugInfo } from "../../../../Utils/debugUtils";
57
57
  import { useEditorStore } from "../../store";
58
- import { DragHandle } from "../../tools/DragHandle";
59
58
  export var FootnoteDefinition = function FootnoteDefinition(props) {
60
59
  debugInfo('FootnoteDefinition - 渲染脚注定义', {
61
60
  identifier: props.element.identifier,
@@ -91,7 +90,7 @@ export var FootnoteDefinition = function FootnoteDefinition(props) {
91
90
  onDragStart: function onDragStart(e) {
92
91
  store.dragStart(e, markdownContainerRef.current);
93
92
  }
94
- }), /*#__PURE__*/ React.createElement(DragHandle, null), element.identifier, ".", /*#__PURE__*/ React.createElement("span", {
93
+ }), element.identifier, ".", /*#__PURE__*/ React.createElement("span", {
95
94
  style: {
96
95
  display: 'flex',
97
96
  alignItems: 'center',
@@ -101,7 +101,6 @@ import { Node } from "slate";
101
101
  import { debugInfo } from "../../../../Utils/debugUtils";
102
102
  import { useSelStatus } from "../../../hooks/editor";
103
103
  import { useEditorStore } from "../../store";
104
- import { DragHandle } from "../../tools/DragHandle";
105
104
  export var FootnoteReference = function FootnoteReference(props) {
106
105
  debugInfo('FootnoteReference - 渲染脚注引用', {
107
106
  identifier: props.element.identifier
@@ -124,7 +123,7 @@ export var FootnoteReference = function FootnoteReference(props) {
124
123
  store.dragStart(e, markdownContainerRef.current);
125
124
  },
126
125
  "data-empty": !str && selected ? 'true' : undefined
127
- }), /*#__PURE__*/ React.createElement(DragHandle, null), props.children);
126
+ }), props.children);
128
127
  }, [
129
128
  props.element.children,
130
129
  selected
@@ -102,7 +102,6 @@ import { Node } from "slate";
102
102
  import { debugInfo } from "../../../../Utils/debugUtils";
103
103
  import { useSelStatus } from "../../../hooks/editor";
104
104
  import { useEditorStore } from "../../store";
105
- import { DragHandle } from "../../tools/DragHandle";
106
105
  import { slugify } from "../../utils/dom";
107
106
  export function Head(param) {
108
107
  var element = param.element, attributes = param.attributes, children = param.children;
@@ -125,7 +124,7 @@ export function Head(param) {
125
124
  textAlign: element.align
126
125
  }), _define_property(_obj, "className", classNames({
127
126
  empty: !str
128
- })), _obj)), /*#__PURE__*/ React.createElement(React.Fragment, null, /*#__PURE__*/ React.createElement(DragHandle, null), children));
127
+ })), _obj)), /*#__PURE__*/ React.createElement(React.Fragment, null, children));
129
128
  }, [
130
129
  element.level,
131
130
  str,
@@ -48,7 +48,6 @@ import { ConfigProvider, Skeleton } from "antd";
48
48
  import classNames from "clsx";
49
49
  import React, { useContext, useEffect, useState } from "react";
50
50
  import { AvatarList } from "../../components/ContributorAvatar";
51
- import { DragHandle } from "../../tools/DragHandle";
52
51
  export function LinkCard(param) {
53
52
  var element = param.element, attributes = param.attributes, children = param.children;
54
53
  var _element_otherProps, _element_otherProps_collaborators, _element_otherProps1, _element_otherProps2;
@@ -118,7 +117,7 @@ export function LinkCard(param) {
118
117
  minHeight: '100px',
119
118
  lineHeight: '100px'
120
119
  }
121
- }, children.at(0)), /*#__PURE__*/ React.createElement(DragHandle, null), /*#__PURE__*/ React.createElement("div", {
120
+ }, children.at(0)), /*#__PURE__*/ React.createElement("div", {
122
121
  ref: htmlRef,
123
122
  style: {
124
123
  flex: 1
@@ -8,7 +8,7 @@ import { ElementProps, ParagraphNode } from '../../../el';
8
8
  *
9
9
  * @component
10
10
  * @description 只读段落预览组件,用于预览模式下的段落渲染
11
- * @param {ElementProps<ParagraphNode>} props - 组件属性
11
+ * @param {ElementProps<ParagraphNode>} props - 段落组件属性
12
12
  * @param {ParagraphNode} props.element - 段落节点元素
13
13
  * @param {React.ReactNode} props.children - 子组件内容
14
14
  * @param {Object} props.attributes - 元素属性
@@ -23,7 +23,7 @@ import { ElementProps, ParagraphNode } from '../../../el';
23
23
  * </ReadonlyParagraph>
24
24
  * ```
25
25
  *
26
- * @returns {React.ReactElement} 渲染的只读段落组件
26
+ * @returns {React.ReactElement}
27
27
  *
28
28
  * @remarks
29
29
  * - 移除拖拽手柄(DragHandle)
@@ -52,7 +52,6 @@ function _object_spread_props(target, source) {
52
52
  }
53
53
  import classNames from "clsx";
54
54
  import React from "react";
55
- import { Node } from "slate";
56
55
  /**
57
56
  * ReadonlyParagraph 组件 - 只读段落预览组件
58
57
  *
@@ -61,7 +60,7 @@ import { Node } from "slate";
61
60
  *
62
61
  * @component
63
62
  * @description 只读段落预览组件,用于预览模式下的段落渲染
64
- * @param {ElementProps<ParagraphNode>} props - 组件属性
63
+ * @param {ElementProps<ParagraphNode>} props - 段落组件属性
65
64
  * @param {ParagraphNode} props.element - 段落节点元素
66
65
  * @param {React.ReactNode} props.children - 子组件内容
67
66
  * @param {Object} props.attributes - 元素属性
@@ -76,7 +75,7 @@ import { Node } from "slate";
76
75
  * </ReadonlyParagraph>
77
76
  * ```
78
77
  *
79
- * @returns {React.ReactElement} 渲染的只读段落组件
78
+ * @returns {React.ReactElement}
80
79
  *
81
80
  * @remarks
82
81
  * - 移除拖拽手柄(DragHandle)
@@ -86,15 +85,13 @@ import { Node } from "slate";
86
85
  * - 保持预览模式的视觉效果
87
86
  */ export var ReadonlyParagraph = /*#__PURE__*/ React.memo(function(props) {
88
87
  var _props_element_align;
89
- var _props_element_otherProps, _props_children;
90
- var str = Node.string(props.element).trim();
88
+ var _props_element_otherProps;
91
89
  var align = (_props_element_align = props.element.align) !== null && _props_element_align !== void 0 ? _props_element_align : (_props_element_otherProps = props.element.otherProps) === null || _props_element_otherProps === void 0 ? void 0 : _props_element_otherProps.align;
92
90
  return /*#__PURE__*/ React.createElement("div", _object_spread_props(_object_spread({}, props.attributes), {
93
91
  "data-be": 'paragraph',
94
92
  className: classNames({}),
95
93
  "data-align": align,
96
94
  style: {
97
- display: !!str || !!((_props_children = props.children) === null || _props_children === void 0 ? void 0 : _props_children.at(0).type) ? undefined : 'none',
98
95
  textAlign: align
99
96
  }
100
97
  }), props.children);
@@ -115,9 +115,6 @@ export var Paragraph = function Paragraph(props) {
115
115
  var _useEditorStore = useEditorStore(), store = _useEditorStore.store, markdownEditorRef = _useEditorStore.markdownEditorRef, markdownContainerRef = _useEditorStore.markdownContainerRef, readonly = _useEditorStore.readonly, editorProps = _useEditorStore.editorProps;
116
116
  var locale = useContext(I18nContext).locale;
117
117
  var _useSelStatus = _sliced_to_array(useSelStatus(props.element), 1), selected = _useSelStatus[0];
118
- // 将 store.inputComposition(可变对象属性)同步到 React state,
119
- // 使 useMemo 能在组合输入状态变化时重新评估 isEmpty,
120
- // 避免竞态导致占位符在组合结束后短暂闪现。
121
118
  var _useState = _sliced_to_array(useState(false), 2), isComposing = _useState[0], setIsComposing = _useState[1];
122
119
  useEffect(function() {
123
120
  var container = markdownContainerRef.current;
@@ -138,7 +135,7 @@ export var Paragraph = function Paragraph(props) {
138
135
  markdownContainerRef
139
136
  ]);
140
137
  return React.useMemo(function() {
141
- var _props_element_children_every, _props_element_children, _props_element, _markdownEditorRef_current, _props_children;
138
+ var _props_element_children_every, _props_element_children, _props_element, _markdownEditorRef_current;
142
139
  var str = Node.string(props.element).trim();
143
140
  debugInfo('Paragraph - useMemo 渲染', {
144
141
  strLength: str.length,
@@ -146,13 +143,9 @@ export var Paragraph = function Paragraph(props) {
146
143
  readonly: readonly,
147
144
  align: align
148
145
  });
149
- // 检查是否为空:trim 后的字符串为空(包括只包含空格的情况),且所有子节点都是纯文本节点(没有 type、code、tag)
150
- // 当只输入空格时,trim() 后为空字符串,应该显示 placeholder
151
146
  var hasOnlyTextNodes = (_props_element = props.element) === null || _props_element === void 0 ? void 0 : (_props_element_children = _props_element.children) === null || _props_element_children === void 0 ? void 0 : (_props_element_children_every = _props_element_children.every) === null || _props_element_children_every === void 0 ? void 0 : _props_element_children_every.call(_props_element_children, function(child) {
152
147
  return !child.type && !child.code && !child.tag;
153
148
  });
154
- // 组合输入进行中时,Slate 模型尚未更新(字符还在 IME 候选区),
155
- // 此时强制视为非空以隐藏占位符,避免用户输入时占位符仍然可见。
156
149
  var isEmpty = !str && !isComposing && ((_markdownEditorRef_current = markdownEditorRef.current) === null || _markdownEditorRef_current === void 0 ? void 0 : _markdownEditorRef_current.children.length) === 1 && hasOnlyTextNodes ? true : undefined;
157
150
  return /*#__PURE__*/ React.createElement("div", _object_spread_props(_object_spread({}, props.attributes), {
158
151
  "data-be": 'paragraph',
@@ -167,14 +160,12 @@ export var Paragraph = function Paragraph(props) {
167
160
  },
168
161
  "data-empty": isEmpty,
169
162
  style: {
170
- display: !!str || !!((_props_children = props.children) === null || _props_children === void 0 ? void 0 : _props_children.at(0).type) ? undefined : 'none',
171
163
  textAlign: align
172
164
  }
173
165
  }), /*#__PURE__*/ React.createElement(DragHandle, null), props.children);
174
166
  }, [
175
167
  props.element.children,
176
168
  align,
177
- readonly,
178
169
  selected,
179
170
  isComposing,
180
171
  (_markdownEditorRef_current = markdownEditorRef.current) === null || _markdownEditorRef_current === void 0 ? void 0 : _markdownEditorRef_current.children.length,
@@ -101,10 +101,10 @@ import React, { useEffect, useMemo } from "react";
101
101
  import { MOBILE_BREAKPOINT } from "../../../../Constants/mobile";
102
102
  import { TABLE_ROW_INDEX_COL_WIDTH, TableColgroup } from "./TableColgroup";
103
103
  import { TableRowIndex } from "./TableRowIndex";
104
+ import useScrollShadow from "./useScrollShadow";
104
105
  import { getEditableTableMinWidth } from "./utils/editableTableWidth";
105
106
  import { useEditableTableColWidths } from "./utils/useEditableTableColWidths";
106
107
  import { useEditableTableContentWidth } from "./utils/useEditableTableContentWidth";
107
- import useScrollShadow from "./useScrollShadow";
108
108
  var TABLE_MIN_CONTAINER_WIDTH = 200;
109
109
  export var EditableTable = function EditableTable(param) {
110
110
  var baseCls = param.baseCls, children = param.children, tablePath = param.tablePath, tableNode = param.tableNode, markdownContainerRef = param.markdownContainerRef, tableCssVariables = param.tableCssVariables;
@@ -96,9 +96,9 @@ import { debugInfo } from "../../../Utils/debugUtils";
96
96
  import { JINJA_DOLLAR_PLACEHOLDER } from "../parser/constants";
97
97
  import { useEditorStore } from "../store";
98
98
  import { EditorUtils } from "../utils/editorUtils";
99
+ import { AgenticUiFileMapBlock, ReadonlyAgenticUiFileMapBlock } from "./AgenticUiBlocks/AgenticUiFileMapBlock";
99
100
  import { AgenticUiTaskBlock, ReadonlyAgenticUiTaskBlock } from "./AgenticUiBlocks/AgenticUiTaskBlock";
100
101
  import { AgenticUiToolUseBarBlock, ReadonlyAgenticUiToolUseBarBlock } from "./AgenticUiBlocks/AgenticUiToolUseBarBlock";
101
- import { AgenticUiFileMapBlock, ReadonlyAgenticUiFileMapBlock } from "./AgenticUiBlocks/AgenticUiFileMapBlock";
102
102
  import { Blockquote } from "./Blockquote";
103
103
  import { ReadonlyBlockquote } from "./Blockquote/ReadonlyBlockquote";
104
104
  import { Break } from "./Break";
@@ -98,6 +98,7 @@ function _unsupported_iterable_to_array(o, minLen) {
98
98
  if (n === "Map" || n === "Set") return Array.from(n);
99
99
  if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _array_like_to_array(o, minLen);
100
100
  }
101
+ import { preprocessNormalizeLeafToContainerDirective } from "./constants";
101
102
  import { applyContextPropsAndConfig } from "./parse/applyContextPropsAndConfig";
102
103
  import { handleBlockquote, handleContainerDirective, handleFootnoteDefinition, handleHeading, handleList, handleListItem, handleParagraph, handleTextAndInlineElements } from "./parse/parseBlockElements";
103
104
  import { handleCode, handleYaml } from "./parse/parseCode";
@@ -108,7 +109,6 @@ import { handleHtml, preprocessNonStandardHtmlTags, preprocessThinkTags } from "
108
109
  import { handleInlineMath, handleMath } from "./parse/parseMath";
109
110
  import { handleImage } from "./parse/parseMedia";
110
111
  import { parseTableOrChart, preprocessMarkdownTableNewlines } from "./parse/parseTable";
111
- import { preprocessNormalizeLeafToContainerDirective } from "./constants";
112
112
  import mdastParser from "./remarkParse";
113
113
  // 全局解析缓存
114
114
  var parseCache = new Map();
@@ -3,8 +3,8 @@ import { withCodeTagPlugin } from "./withCodeTagPlugin";
3
3
  import { withInlineNodes } from "./withInlineNodes";
4
4
  import { withLinkAndMediaPlugin } from "./withLinkAndMediaPlugin";
5
5
  import { withListsPlugin } from "./withListsPlugin";
6
- import { withSchemaPlugin } from "./withSchemaPlugin";
7
6
  import { withSanitizeInvalidChildren } from "./withSanitizeInvalidChildren";
7
+ import { withSchemaPlugin } from "./withSchemaPlugin";
8
8
  import { withVoidNodes } from "./withVoidNodes";
9
9
  /**
10
10
  * 为Slate编辑器添加Markdown支持的插件函数