@ant-design/agentic-ui 2.30.25 → 2.30.26

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 (55) 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 +3 -2
  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.js +6 -3
  24. package/dist/MarkdownEditor/editor/elements/Paragraph/index.js +10 -30
  25. package/dist/MarkdownEditor/editor/elements/Table/EditableTable.js +1 -1
  26. package/dist/MarkdownEditor/editor/elements/index.js +1 -1
  27. package/dist/MarkdownEditor/editor/parser/parserMarkdownToSlateNode.js +1 -1
  28. package/dist/MarkdownEditor/editor/plugins/withMarkdown.js +1 -1
  29. package/dist/MarkdownEditor/editor/plugins/withSanitizeInvalidChildren.js +69 -38
  30. package/dist/MarkdownEditor/editor/store.d.ts +3 -0
  31. package/dist/MarkdownEditor/editor/store.js +1 -0
  32. package/dist/MarkdownEditor/editor/tools/InsertAutocomplete.js +1 -0
  33. package/dist/MarkdownEditor/style.js +0 -6
  34. package/dist/MarkdownInputField/hooks/useMarkdownInputFieldRefs.js +0 -3
  35. package/dist/MarkdownRenderer/MarkdownRenderer.js +2 -2
  36. package/dist/MarkdownRenderer/index.d.ts +2 -2
  37. package/dist/MarkdownRenderer/index.js +1 -1
  38. package/dist/MarkdownRenderer/streaming/MarkdownBlockPiece.d.ts +1 -1
  39. package/dist/MarkdownRenderer/streaming/MarkdownBlockPiece.js +15 -3
  40. package/dist/MarkdownRenderer/streaming/useStreamingMarkdownReact.d.ts +2 -1
  41. package/dist/MarkdownRenderer/streaming/useStreamingMarkdownReact.js +4 -4
  42. package/dist/Plugins/chart/BarChart/index.js +1 -1
  43. package/dist/Plugins/chart/ChartAttrToolBar/index.js +1 -1
  44. package/dist/Plugins/chart/index.d.ts +1 -1
  45. package/dist/Plugins/code/utils/index.d.ts +1 -1
  46. package/dist/Plugins/mermaid/MermaidRendererImpl.js +53 -419
  47. package/dist/Plugins/mermaid/index.js +1 -2
  48. package/dist/Plugins/mermaid/style.js +57 -59
  49. package/dist/Plugins/mermaid/utils.js +67 -8
  50. package/dist/Schema/SchemaForm/index.js +1 -1
  51. package/dist/Workspace/File/FileComponent.js +1 -1
  52. package/dist/Workspace/File/PreviewComponent.js +16 -2
  53. package/dist/Workspace/File/index.d.ts +1 -1
  54. package/dist/Workspace/File/index.js +2 -1
  55. package/package.json +2 -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);
@@ -284,8 +284,9 @@ var I18nBoundary = function I18nBoundary(param) {
284
284
  // 安全地获取解析结果,确保 list 始终是数组
285
285
  var parseResult = parserMdToSchema(initValue || '', props.plugins);
286
286
  var list = (parseResult === null || parseResult === void 0 ? void 0 : parseResult.schema) || [];
287
- // 如果不是只读模式,添加一个空段落以便编辑
288
- if (!props.readonly) {
287
+ // 非只读时保证末尾有可编辑块:解析结果常已含空段落(如空 initValue),
288
+ // 再追加会导致 Slate 根下两个空段,Paragraph 的占位符依赖 children.length===1 而失效
289
+ if (!props.readonly && list.length === 0) {
289
290
  list = _to_consumable_array(list).concat([
290
291
  EditorUtils.p
291
292
  ]);
@@ -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
@@ -52,7 +52,7 @@ 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";
55
+ import { Element, Node } from "slate";
56
56
  /**
57
57
  * ReadonlyParagraph 组件 - 只读段落预览组件
58
58
  *
@@ -86,15 +86,18 @@ import { Node } from "slate";
86
86
  * - 保持预览模式的视觉效果
87
87
  */ export var ReadonlyParagraph = /*#__PURE__*/ React.memo(function(props) {
88
88
  var _props_element_align;
89
- var _props_element_otherProps, _props_children;
89
+ var _props_element_otherProps;
90
90
  var str = Node.string(props.element).trim();
91
91
  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
+ var hasNestedElement = props.element.children.some(function(child) {
93
+ return Element.isElement(child);
94
+ });
92
95
  return /*#__PURE__*/ React.createElement("div", _object_spread_props(_object_spread({}, props.attributes), {
93
96
  "data-be": 'paragraph',
94
97
  className: classNames({}),
95
98
  "data-align": align,
96
99
  style: {
97
- display: !!str || !!((_props_children = props.children) === null || _props_children === void 0 ? void 0 : _props_children.at(0).type) ? undefined : 'none',
100
+ display: str || hasNestedElement ? undefined : 'none',
98
101
  textAlign: align
99
102
  }
100
103
  }), props.children);
@@ -97,13 +97,12 @@ function _unsupported_iterable_to_array(o, minLen) {
97
97
  if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _array_like_to_array(o, minLen);
98
98
  }
99
99
  import classNames from "clsx";
100
- import React, { useContext, useEffect, useState } from "react";
101
- import { Node } from "slate";
100
+ import React, { useContext } from "react";
101
+ import { Element, Node } from "slate";
102
102
  import { I18nContext } from "../../../../I18n";
103
103
  import { debugInfo } from "../../../../Utils/debugUtils";
104
104
  import { useSelStatus } from "../../../hooks/editor";
105
105
  import { useEditorStore } from "../../store";
106
- import { DragHandle } from "../../tools/DragHandle";
107
106
  export var Paragraph = function Paragraph(props) {
108
107
  var _props_element_align;
109
108
  var _props_element_otherProps, _markdownEditorRef_current;
@@ -115,30 +114,8 @@ export var Paragraph = function Paragraph(props) {
115
114
  var _useEditorStore = useEditorStore(), store = _useEditorStore.store, markdownEditorRef = _useEditorStore.markdownEditorRef, markdownContainerRef = _useEditorStore.markdownContainerRef, readonly = _useEditorStore.readonly, editorProps = _useEditorStore.editorProps;
116
115
  var locale = useContext(I18nContext).locale;
117
116
  var _useSelStatus = _sliced_to_array(useSelStatus(props.element), 1), selected = _useSelStatus[0];
118
- // 将 store.inputComposition(可变对象属性)同步到 React state,
119
- // 使 useMemo 能在组合输入状态变化时重新评估 isEmpty,
120
- // 避免竞态导致占位符在组合结束后短暂闪现。
121
- var _useState = _sliced_to_array(useState(false), 2), isComposing = _useState[0], setIsComposing = _useState[1];
122
- useEffect(function() {
123
- var container = markdownContainerRef.current;
124
- if (!container) return;
125
- var observer = new MutationObserver(function() {
126
- setIsComposing(container.hasAttribute('data-composition'));
127
- });
128
- observer.observe(container, {
129
- attributes: true,
130
- attributeFilter: [
131
- 'data-composition'
132
- ]
133
- });
134
- return function() {
135
- return observer.disconnect();
136
- };
137
- }, [
138
- markdownContainerRef
139
- ]);
140
117
  return React.useMemo(function() {
141
- var _props_element_children_every, _props_element_children, _props_element, _markdownEditorRef_current, _props_children;
118
+ var _props_element_children_every, _props_element_children, _props_element, _markdownEditorRef_current;
142
119
  var str = Node.string(props.element).trim();
143
120
  debugInfo('Paragraph - useMemo 渲染', {
144
121
  strLength: str.length,
@@ -151,9 +128,12 @@ export var Paragraph = function Paragraph(props) {
151
128
  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
129
  return !child.type && !child.code && !child.tag;
153
130
  });
131
+ var hasNestedElement = props.element.children.some(function(child) {
132
+ return Element.isElement(child);
133
+ });
154
134
  // 组合输入进行中时,Slate 模型尚未更新(字符还在 IME 候选区),
155
135
  // 此时强制视为非空以隐藏占位符,避免用户输入时占位符仍然可见。
156
- var isEmpty = !str && !isComposing && ((_markdownEditorRef_current = markdownEditorRef.current) === null || _markdownEditorRef_current === void 0 ? void 0 : _markdownEditorRef_current.children.length) === 1 && hasOnlyTextNodes ? true : undefined;
136
+ var isEmpty = !str && ((_markdownEditorRef_current = markdownEditorRef.current) === null || _markdownEditorRef_current === void 0 ? void 0 : _markdownEditorRef_current.children.length) === 1 && hasOnlyTextNodes ? true : undefined;
157
137
  return /*#__PURE__*/ React.createElement("div", _object_spread_props(_object_spread({}, props.attributes), {
158
138
  "data-be": 'paragraph',
159
139
  "data-drag-el": true,
@@ -167,16 +147,16 @@ export var Paragraph = function Paragraph(props) {
167
147
  },
168
148
  "data-empty": isEmpty,
169
149
  style: {
170
- display: !!str || !!((_props_children = props.children) === null || _props_children === void 0 ? void 0 : _props_children.at(0).type) ? undefined : 'none',
150
+ display: str || hasNestedElement ? undefined : 'none',
171
151
  textAlign: align
172
152
  }
173
- }), /*#__PURE__*/ React.createElement(DragHandle, null), props.children);
153
+ }), props.children);
174
154
  }, [
155
+ props.element,
175
156
  props.element.children,
176
157
  align,
177
158
  readonly,
178
159
  selected,
179
- isComposing,
180
160
  (_markdownEditorRef_current = markdownEditorRef.current) === null || _markdownEditorRef_current === void 0 ? void 0 : _markdownEditorRef_current.children.length,
181
161
  editorProps.titlePlaceholderContent
182
162
  ]);
@@ -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支持的插件函数