@ant-design/agentic-ui 2.30.24 → 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 (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 +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/withListsPlugin.js +5 -4
  29. package/dist/MarkdownEditor/editor/plugins/withMarkdown.js +1 -1
  30. package/dist/MarkdownEditor/editor/plugins/withSanitizeInvalidChildren.d.ts +2 -1
  31. package/dist/MarkdownEditor/editor/plugins/withSanitizeInvalidChildren.js +174 -30
  32. package/dist/MarkdownEditor/editor/store.d.ts +4 -3
  33. package/dist/MarkdownEditor/editor/store.js +5 -0
  34. package/dist/MarkdownEditor/editor/tools/InsertAutocomplete.js +1 -0
  35. package/dist/MarkdownEditor/style.js +0 -6
  36. package/dist/MarkdownInputField/MarkdownInputField.js +1 -1
  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 +2 -1
@@ -124,6 +124,10 @@ function _object_without_properties_loose(source, excluded) {
124
124
  function _sliced_to_array(arr, i) {
125
125
  return _array_with_holes(arr) || _iterable_to_array_limit(arr, i) || _unsupported_iterable_to_array(arr, i) || _non_iterable_rest();
126
126
  }
127
+ function _type_of(obj) {
128
+ "@swc/helpers - typeof";
129
+ return obj && typeof Symbol !== "undefined" && obj.constructor === Symbol ? "symbol" : typeof obj;
130
+ }
127
131
  function _unsupported_iterable_to_array(o, minLen) {
128
132
  if (!o) return;
129
133
  if (typeof o === "string") return _array_like_to_array(o, minLen);
@@ -132,10 +136,30 @@ function _unsupported_iterable_to_array(o, minLen) {
132
136
  if (n === "Map" || n === "Set") return Array.from(n);
133
137
  if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _array_like_to_array(o, minLen);
134
138
  }
135
- import { Editor, Node, Transforms } from "slate";
139
+ import { Editor, Element, Node, Text, Transforms } from "slate";
140
+ import { HistoryEditor } from "slate-history";
141
+ import { EditorUtils } from "../utils/editorUtils";
136
142
  var isValidChild = function isValidChild(child) {
137
143
  return child !== undefined && child !== null && Node.isNode(child);
138
144
  };
145
+ /**
146
+ * `Array.prototype.some` skips sparse holes; Slate still sees missing indices and
147
+ * can pass `undefined` as `leaf` into `renderLeaf`, which then throws in `Text.isText`.
148
+ */ var childArrayHasInvalidEntries = function childArrayHasInvalidEntries(rawChildren) {
149
+ for(var i = 0; i < rawChildren.length; i += 1){
150
+ if (!(i in rawChildren) || !isValidChild(rawChildren[i])) {
151
+ return true;
152
+ }
153
+ }
154
+ return false;
155
+ };
156
+ var getChildList = function getChildList(node) {
157
+ if (!('children' in node)) {
158
+ return [];
159
+ }
160
+ var children = node.children;
161
+ return Array.isArray(children) ? children : [];
162
+ };
139
163
  var createDefaultBlock = function createDefaultBlock() {
140
164
  return {
141
165
  type: 'paragraph',
@@ -147,7 +171,7 @@ var createDefaultBlock = function createDefaultBlock() {
147
171
  };
148
172
  };
149
173
  var rebuildElement = function rebuildElement(node) {
150
- var children = node.children.filter(isValidChild);
174
+ var children = getChildList(node).filter(isValidChild);
151
175
  if (children.length === 0 && 'type' in node && node.type) {
152
176
  children = [
153
177
  {
@@ -162,52 +186,172 @@ var rebuildElement = function rebuildElement(node) {
162
186
  children: children
163
187
  });
164
188
  };
189
+ var runWithoutHistory = function runWithoutHistory(editor, fn) {
190
+ if (HistoryEditor.isHistoryEditor(editor)) {
191
+ HistoryEditor.withoutSaving(editor, fn);
192
+ } else {
193
+ fn();
194
+ }
195
+ };
196
+ /**
197
+ * Slate 的 `Node.nodes` / `Editor.normalize` 在遍历时假定非文本节点必有数组型 `children`。
198
+ * 若仅有 `type` 而缺少 `children`,会在进入自定义 `normalizeNode` 之前就抛错,必须先修树。
199
+ */ var rebuildOrDefaultBlock = function rebuildOrDefaultBlock(raw) {
200
+ if (raw && (typeof raw === "undefined" ? "undefined" : _type_of(raw)) === 'object' && !Text.isText(raw) && typeof raw.type === 'string') {
201
+ return rebuildElement(raw);
202
+ }
203
+ return createDefaultBlock();
204
+ };
205
+ /** 压缩根级子节点:去掉空洞与 null/undefined;残缺元素对象则 rebuild,不凭空多插空段落。 */ var compactEditorRootChildren = function compactEditorRootChildren(raw) {
206
+ var out = [];
207
+ for(var i = 0; i < raw.length; i += 1){
208
+ if (!(i in raw)) {
209
+ continue;
210
+ }
211
+ var c = raw[i];
212
+ if (isValidChild(c)) {
213
+ out.push(c);
214
+ continue;
215
+ }
216
+ if (c === undefined || c === null) {
217
+ continue;
218
+ }
219
+ out.push(rebuildOrDefaultBlock(c));
220
+ }
221
+ return out;
222
+ };
223
+ var repairBrokenChildArrays = function repairBrokenChildArrays(editor) {
224
+ if (!Array.isArray(editor.children)) {
225
+ /* eslint-disable no-param-reassign */ editor.children = [
226
+ createDefaultBlock()
227
+ ];
228
+ /* eslint-enable no-param-reassign */ return true;
229
+ }
230
+ if (editor.children.length === 0) {
231
+ EditorUtils.replaceEditorContent(editor, [
232
+ createDefaultBlock()
233
+ ]);
234
+ return true;
235
+ }
236
+ if (childArrayHasInvalidEntries(editor.children)) {
237
+ var fixedRoot = compactEditorRootChildren(editor.children);
238
+ if (fixedRoot.length === 0) {
239
+ EditorUtils.replaceEditorContent(editor, [
240
+ createDefaultBlock()
241
+ ]);
242
+ } else {
243
+ /* eslint-disable no-param-reassign */ editor.children = fixedRoot;
244
+ /* eslint-enable no-param-reassign */ }
245
+ return true;
246
+ }
247
+ var fixBranch = function fixBranch1(node) {
248
+ if (!node || (typeof node === "undefined" ? "undefined" : _type_of(node)) !== 'object') {
249
+ return false;
250
+ }
251
+ if (Text.isText(node)) {
252
+ if ('children' in node) {
253
+ delete node.children;
254
+ return true;
255
+ }
256
+ return false;
257
+ }
258
+ var rawChildren = node.children;
259
+ if (!Array.isArray(rawChildren)) {
260
+ Object.assign(node, rebuildElement(node));
261
+ return true;
262
+ }
263
+ if (childArrayHasInvalidEntries(rawChildren)) {
264
+ var fixedChildren = rawChildren.filter(isValidChild);
265
+ node.children = fixedChildren.length === 0 ? [
266
+ {
267
+ text: ''
268
+ }
269
+ ] : fixedChildren;
270
+ return true;
271
+ }
272
+ for(var i = 0; i < rawChildren.length; i++){
273
+ if (fixBranch(rawChildren[i])) {
274
+ return true;
275
+ }
276
+ }
277
+ return false;
278
+ };
279
+ for(var i = 0; i < editor.children.length; i++){
280
+ if (fixBranch(editor.children[i])) {
281
+ return true;
282
+ }
283
+ }
284
+ return false;
285
+ };
165
286
  /**
166
287
  * 外部或合并后的 value 可能在 `children` 中混入 `undefined` / `null`;
167
288
  * Slate 的 `Node.string` 会对每个子节点调用 `Text.isText`,遇 `undefined` 即抛错。
168
289
  * 在 normalize 最外层剔除非法子节点,避免编辑器与 toMarkdown 崩溃。
169
290
  */ export var withSanitizeInvalidChildren = function withSanitizeInvalidChildren(editor) {
170
- var normalizeNode = editor.normalizeNode;
291
+ var normalizeNode = editor.normalizeNode, normalize = editor.normalize;
292
+ editor.normalize = function(options) {
293
+ // 与 Slate 默认 `normalize` 一致:在 `withoutNormalizing` 嵌套批次末尾仍会调用
294
+ // `Editor.normalize`,此时 `isNormalizing` 为 false,文档可能短暂为空(合法中间态)。
295
+ // 若在此处 `repairBrokenChildArrays` 强行插入默认块,会与后续 `insertNodes` 叠成双段落。
296
+ if (Editor.isNormalizing(editor)) {
297
+ var guard = 0;
298
+ while(guard < 100 && repairBrokenChildArrays(editor)){
299
+ guard += 1;
300
+ }
301
+ }
302
+ return normalize.call(editor, options);
303
+ };
171
304
  editor.normalizeNode = function(entry) {
172
305
  var _entry = _sliced_to_array(entry, 2), node = _entry[0], path = _entry[1];
306
+ // Text leaves have no `children`; also strip invalid `children` on text (Slate may treat as element).
307
+ if (Text.isText(node)) {
308
+ if ('children' in node) {
309
+ delete node.children;
310
+ }
311
+ normalizeNode(entry);
312
+ return;
313
+ }
173
314
  if (Editor.isEditor(node) && path.length === 0) {
174
- var hasInvalid = node.children.some(function(c) {
175
- return !isValidChild(c);
176
- });
177
- if (hasInvalid) {
178
- var clean = node.children.filter(isValidChild);
179
- editor.children = clean.length === 0 ? [
315
+ var childList = getChildList(node);
316
+ var hasInvalid = childArrayHasInvalidEntries(childList);
317
+ if (hasInvalid || childList.length === 0) {
318
+ var fixedTop = compactEditorRootChildren(childList);
319
+ var nextNodes = fixedTop.length === 0 ? [
180
320
  createDefaultBlock()
181
- ] : clean;
321
+ ] : fixedTop;
322
+ EditorUtils.replaceEditorContent(editor, nextNodes);
182
323
  normalizeNode(entry);
183
324
  return;
184
325
  }
185
- if (node.children.length === 0) {
186
- editor.children = [
187
- createDefaultBlock()
188
- ];
326
+ normalizeNode(entry);
327
+ return;
328
+ }
329
+ if (!Editor.isEditor(node) && !Text.isText(node)) {
330
+ var rawChildren = node.children;
331
+ if (!Array.isArray(rawChildren)) {
332
+ Object.assign(node, rebuildElement(node));
189
333
  normalizeNode(entry);
190
334
  return;
191
335
  }
192
- normalizeNode(entry);
193
- return;
194
336
  }
195
- if (Node.isNode(node)) {
196
- var hasInvalid1 = node.children.some(function(c) {
197
- return !isValidChild(c);
198
- });
337
+ if (Element.isElement(node)) {
338
+ var childList1 = getChildList(node);
339
+ var hasInvalid1 = childArrayHasInvalidEntries(childList1);
199
340
  if (hasInvalid1) {
200
- Editor.withoutNormalizing(editor, function() {
201
- var rebuilt = rebuildElement(node);
202
- Transforms.removeNodes(editor, {
203
- at: path,
204
- voids: true
205
- });
206
- Transforms.insertNodes(editor, rebuilt, {
207
- at: path,
208
- voids: true
341
+ var applyRebuild = function applyRebuild() {
342
+ Editor.withoutNormalizing(editor, function() {
343
+ var rebuilt = rebuildElement(node);
344
+ Transforms.removeNodes(editor, {
345
+ at: path,
346
+ voids: true
347
+ });
348
+ Transforms.insertNodes(editor, rebuilt, {
349
+ at: path,
350
+ voids: true
351
+ });
209
352
  });
210
- });
353
+ };
354
+ runWithoutHistory(editor, applyRebuild);
211
355
  return;
212
356
  }
213
357
  }
@@ -662,9 +662,7 @@ export declare class EditorStore {
662
662
  maxResults?: number;
663
663
  }): {
664
664
  path: Path;
665
- range: import("slate").BaseRange; /**
666
- * 更新结构不同的表格
667
- */
665
+ range: import("slate").BaseRange;
668
666
  node: any;
669
667
  matchedText: string;
670
668
  offset: {
@@ -672,6 +670,9 @@ export declare class EditorStore {
672
670
  end: number;
673
671
  };
674
672
  lineContent: string;
673
+ /**
674
+ * 更新结构不同的表格
675
+ */
675
676
  nodeType?: string | undefined;
676
677
  searchVariant?: string | undefined;
677
678
  isLink?: boolean | undefined;
@@ -435,6 +435,11 @@ export var EditorStoreContext = createContext(null);
435
435
  value: function setMDContent(md, plugins, options) {
436
436
  var _ref, _ref1, _ref2, _ref3;
437
437
  if (md === undefined) return;
438
+ if (!md) {
439
+ if (this._shouldSkipSetContent('')) return;
440
+ this.clearContent();
441
+ return;
442
+ }
438
443
  if (this._shouldSkipSetContent(md)) return;
439
444
  this.cancelSetMDContent();
440
445
  var chunkSize = (_ref = options === null || options === void 0 ? void 0 : options.chunkSize) !== null && _ref !== void 0 ? _ref : 5000;
@@ -994,6 +994,7 @@ export var InsertAutocomplete = function InsertAutocomplete(props) {
994
994
  e.preventDefault();
995
995
  }
996
996
  }, !state.insertLink && !state.insertAttachment && /*#__PURE__*/ React.createElement(React.Fragment, null, /*#__PURE__*/ React.createElement(Menu, {
997
+ _internalDisableMenuItemTitleTooltip: true,
997
998
  items: (_props_optionsRender = props.optionsRender) === null || _props_optionsRender === void 0 ? void 0 : _props_optionsRender.call(props, state.filterOptions.map(function(l) {
998
999
  var _l_label, _l_children_, _l_children, _l_children1;
999
1000
  return {
@@ -580,12 +580,6 @@ var genStyle = function genStyle(token) {
580
580
  fill: '#fff'
581
581
  }
582
582
  },
583
- // 强制设置所有文字样式
584
- '& text': {
585
- // 确保文字不会被裁剪
586
- dominantBaseline: 'middle',
587
- textAnchor: 'middle'
588
- },
589
583
  // 节点标签 - 更大的字体
590
584
  '& .nodeLabel': {
591
585
  fontWeight: 500,
@@ -140,7 +140,6 @@ import { useLocale } from "../I18n";
140
140
  import { BaseMarkdownEditor } from "../MarkdownEditor";
141
141
  import { BorderBeamAnimation } from "./BorderBeamAnimation";
142
142
  import { useFileUploadManager } from "./FileUploadManager";
143
- import { resolveSendDisabled } from "./SendButton";
144
143
  import { useMarkdownInputFieldActions } from "./hooks/useMarkdownInputFieldActions";
145
144
  import { useMarkdownInputFieldHandlers } from "./hooks/useMarkdownInputFieldHandlers";
146
145
  import { useMarkdownInputFieldLayout } from "./hooks/useMarkdownInputFieldLayout";
@@ -148,6 +147,7 @@ import { useMarkdownInputFieldRefs } from "./hooks/useMarkdownInputFieldRefs";
148
147
  import { useMarkdownInputFieldState } from "./hooks/useMarkdownInputFieldState";
149
148
  import { useMarkdownInputFieldStyles } from "./hooks/useMarkdownInputFieldStyles";
150
149
  import { QuickActions } from "./QuickActions";
150
+ import { resolveSendDisabled } from "./SendButton";
151
151
  import { SkillModeBar } from "./SkillModeBar";
152
152
  import { useStyle } from "./style";
153
153
  import { Suggestion } from "./Suggestion";
@@ -138,15 +138,15 @@ import React, { forwardRef, useContext, useEffect, useImperativeHandle, useMemo,
138
138
  import { useStyle as useContentStyle } from "../MarkdownEditor/editor/style";
139
139
  import { useStyle as useEditorStyle } from "../MarkdownEditor/style";
140
140
  import { CharacterQueue } from "./CharacterQueue";
141
+ import { extractFootnoteDefinitionsFromMarkdown } from "./extractFootnoteDefinitions";
142
+ import { AgenticUiFileMapBlockRenderer } from "./renderers/AgenticUiFileMapBlockRenderer";
141
143
  import { AgenticUiTaskBlockRenderer } from "./renderers/AgenticUiTaskBlockRenderer";
142
144
  import { AgenticUiToolUseBarBlockRenderer } from "./renderers/AgenticUiToolUseBarBlockRenderer";
143
- import { AgenticUiFileMapBlockRenderer } from "./renderers/AgenticUiFileMapBlockRenderer";
144
145
  import { ChartBlockRenderer } from "./renderers/ChartRenderer";
145
146
  import { CodeBlockRenderer } from "./renderers/CodeRenderer";
146
147
  import { MermaidBlockRenderer } from "./renderers/MermaidRenderer";
147
148
  import { SchemaBlockRenderer } from "./renderers/SchemaRenderer";
148
149
  import { useRendererVarStyle } from "./style";
149
- import { extractFootnoteDefinitionsFromMarkdown } from "./extractFootnoteDefinitions";
150
150
  import { useMarkdownToReact } from "./useMarkdownToReact";
151
151
  import { useStreaming } from "./useStreaming";
152
152
  var SCHEMA_LANGUAGES = new Set([
@@ -1,6 +1,7 @@
1
1
  export { default as AnimationText } from './AnimationText';
2
2
  export type { AnimationConfig, AnimationTextProps } from './AnimationText';
3
3
  export { CharacterQueue } from './CharacterQueue';
4
+ export type { UseMarkdownToReactOptions } from './markdownReactShared';
4
5
  export { default as MarkdownRenderer } from './MarkdownRenderer';
5
6
  export { AgenticUiFileMapBlockRenderer } from './renderers/AgenticUiFileMapBlockRenderer';
6
7
  export { AgenticUiTaskBlockRenderer } from './renderers/AgenticUiTaskBlockRenderer';
@@ -9,8 +10,7 @@ export { ChartBlockRenderer } from './renderers/ChartRenderer';
9
10
  export { CodeBlockRenderer } from './renderers/CodeRenderer';
10
11
  export { MermaidBlockRenderer } from './renderers/MermaidRenderer';
11
12
  export { SchemaBlockRenderer } from './renderers/SchemaRenderer';
13
+ export { useStreamingMarkdownReact } from './streaming/useStreamingMarkdownReact';
12
14
  export type { CharacterQueueOptions, FileMapConfig, MarkdownRendererEleProps, MarkdownRendererProps, MarkdownRendererRef, RenderMode, RendererBlockProps, } from './types';
13
- export type { UseMarkdownToReactOptions } from './markdownReactShared';
14
15
  export { markdownToReactSync, useMarkdownToReact } from './useMarkdownToReact';
15
- export { useStreamingMarkdownReact } from './streaming/useStreamingMarkdownReact';
16
16
  export { useStreaming } from './useStreaming';
@@ -8,6 +8,6 @@ export { ChartBlockRenderer } from "./renderers/ChartRenderer";
8
8
  export { CodeBlockRenderer } from "./renderers/CodeRenderer";
9
9
  export { MermaidBlockRenderer } from "./renderers/MermaidRenderer";
10
10
  export { SchemaBlockRenderer } from "./renderers/SchemaRenderer";
11
- export { markdownToReactSync, useMarkdownToReact } from "./useMarkdownToReact";
12
11
  export { useStreamingMarkdownReact } from "./streaming/useStreamingMarkdownReact";
12
+ export { markdownToReactSync, useMarkdownToReact } from "./useMarkdownToReact";
13
13
  export { useStreaming } from "./useStreaming";
@@ -1,5 +1,5 @@
1
- import type { Processor } from 'unified';
2
1
  import React from 'react';
2
+ import type { Processor } from 'unified';
3
3
  export interface MarkdownBlockPieceProps {
4
4
  variant: 'sealed' | 'tail';
5
5
  blockSource: string;
@@ -9,11 +9,24 @@ import { shouldReparseLastBlock } from "./lastBlockThrottle";
9
9
  var variant = param.variant, blockSource = param.blockSource, processor = param.processor, components = param.components, streaming = param.streaming;
10
10
  var lastParsedRef = useRef(null);
11
11
  var cacheRef = useRef(new Map());
12
+ var processorRef = useRef(null);
13
+ /**
14
+ * 宿主常把 `components: { __codeBlock: X }` 内联在每次 render,引用恒变。
15
+ * 若列入 useMemo 依赖,末块晋升为 sealed 时会误触发重 parse,子树卸载重挂。
16
+ * 密封命中缓存时故意不随 components 引用抖动;需重算时由 variant / blockSource / processor 驱动。
17
+ */ var componentsRef = useRef(components);
18
+ componentsRef.current = components;
12
19
  var node = useMemo(function() {
20
+ if (processorRef.current !== processor) {
21
+ processorRef.current = processor;
22
+ cacheRef.current.clear();
23
+ lastParsedRef.current = null;
24
+ }
25
+ var comps = componentsRef.current;
13
26
  var cached = cacheRef.current.get(blockSource);
14
27
  if (cached && variant === 'sealed') return cached;
15
28
  if (variant === 'sealed' || !streaming) {
16
- var el = renderMarkdownBlock(blockSource, processor, components);
29
+ var el = renderMarkdownBlock(blockSource, processor, comps);
17
30
  cacheRef.current.set(blockSource, el);
18
31
  if (variant === 'tail') lastParsedRef.current = {
19
32
  source: blockSource,
@@ -25,7 +38,7 @@ import { shouldReparseLastBlock } from "./lastBlockThrottle";
25
38
  if (prev && !shouldReparseLastBlock(prev.source, blockSource, true)) {
26
39
  return prev.node;
27
40
  }
28
- var el1 = renderMarkdownBlock(blockSource, processor, components);
41
+ var el1 = renderMarkdownBlock(blockSource, processor, comps);
29
42
  cacheRef.current.set(blockSource, el1);
30
43
  lastParsedRef.current = {
31
44
  source: blockSource,
@@ -36,7 +49,6 @@ import { shouldReparseLastBlock } from "./lastBlockThrottle";
36
49
  variant,
37
50
  blockSource,
38
51
  processor,
39
- components,
40
52
  streaming
41
53
  ]);
42
54
  var animateBlock = variant === 'tail' && streaming;
@@ -1,6 +1,7 @@
1
1
  import React from 'react';
2
2
  import { type UseMarkdownToReactOptions } from '../markdownReactShared';
3
3
  /**
4
- * 流式优先的 Markdown → React:每块独立 memo 组件;tail sealed 共用组件类型以便块晋升时复用实例。
4
+ * 流式优先的 Markdown → React:每块独立 MarkdownBlockPiece,末块 tail、其余 sealed
5
+ * 块 key 仅用修订代 + 下标,使「末块晋升为 sealed」时外层组件类型不变,避免子树卸载重挂。
5
6
  */
6
7
  export declare const useStreamingMarkdownReact: (content: string, options?: UseMarkdownToReactOptions) => React.ReactNode;
@@ -1,11 +1,12 @@
1
- import { JINJA_DOLLAR_PLACEHOLDER, preprocessNormalizeLeafToContainerDirective } from "../../MarkdownEditor/editor/parser/constants";
2
1
  import React, { useMemo, useRef } from "react";
3
2
  import { Fragment, jsx, jsxs } from "react/jsx-runtime";
3
+ import { JINJA_DOLLAR_PLACEHOLDER, preprocessNormalizeLeafToContainerDirective } from "../../MarkdownEditor/editor/parser/constants";
4
4
  import { buildEditorAlignedComponents, createHastProcessor, splitMarkdownBlocks } from "../markdownReactShared";
5
5
  import { MarkdownBlockPiece } from "./MarkdownBlockPiece";
6
6
  import { shouldResetRevisionProgress } from "./revisionPolicy";
7
7
  /**
8
- * 流式优先的 Markdown → React:每块独立 memo 组件;tail sealed 共用组件类型以便块晋升时复用实例。
8
+ * 流式优先的 Markdown → React:每块独立 MarkdownBlockPiece,末块 tail、其余 sealed
9
+ * 块 key 仅用修订代 + 下标,使「末块晋升为 sealed」时外层组件类型不变,避免子树卸载重挂。
9
10
  */ export var useStreamingMarkdownReact = function useStreamingMarkdownReact(content, options) {
10
11
  var revisionSource = (options === null || options === void 0 ? void 0 : options.contentRevisionSource) !== undefined ? options.contentRevisionSource : content;
11
12
  var prevRevisionRef = useRef(undefined);
@@ -45,14 +46,13 @@ import { shouldResetRevisionProgress } from "./revisionPolicy";
45
46
  var gen = revisionGenerationRef.current;
46
47
  var elements = blocks.map(function(blockSource, index) {
47
48
  var isLast = index === blocks.length - 1;
48
- // 仅用修订代 + 块下标作 key,避免末块随文本增长导致 identity 变化而整段 remount
49
49
  var key = "b-".concat(gen, "-").concat(index);
50
50
  return jsx(MarkdownBlockPiece, {
51
51
  variant: isLast ? 'tail' : 'sealed',
52
52
  blockSource: blockSource,
53
53
  processor: processor,
54
54
  components: components,
55
- streaming: !!((options === null || options === void 0 ? void 0 : options.streaming) && isLast)
55
+ streaming: !!(options === null || options === void 0 ? void 0 : options.streaming)
56
56
  }, key);
57
57
  });
58
58
  return jsxs(Fragment, {
@@ -120,8 +120,8 @@ import React, { useContext, useEffect, useMemo, useRef, useState } from "react";
120
120
  import { Bar } from "react-chartjs-2";
121
121
  import { ChartContainer, ChartFilter, ChartStatistic, ChartToolBar, downloadChart } from "../components";
122
122
  import { defaultColorList } from "../const";
123
- import { extractAndSortXValues, findDataPointByXValue, hexToRgba, resolveCssVariable, toNumber } from "../utils";
124
123
  import { useChartTheme } from "../hooks";
124
+ import { extractAndSortXValues, findDataPointByXValue, hexToRgba, resolveCssVariable, toNumber } from "../utils";
125
125
  import { useStyle } from "./style";
126
126
  /**
127
127
  * @fileoverview 柱状图组件文件
@@ -1,7 +1,7 @@
1
1
  import { DeleteOutlined } from "@ant-design/icons";
2
2
  import { ConfigProvider, Tooltip } from "antd";
3
- import React, { useContext, useRef } from "react";
4
3
  import clsx from "clsx";
4
+ import React, { useContext, useRef } from "react";
5
5
  import { Transforms } from "slate";
6
6
  import { ReactEditor } from "slate-react";
7
7
  import { I18nContext } from "../../../I18n";
@@ -29,7 +29,7 @@ export { default as RadarChart } from './RadarChart';
29
29
  export { default as ScatterChart } from './ScatterChart';
30
30
  export type { AreaChartConfigItem, AreaChartDataItem, AreaChartProps, } from './AreaChart';
31
31
  export type { BarChartConfigItem, BarChartDataItem, BarChartProps, } from './BarChart';
32
- export type { BoxPlotChartDataItem, BoxPlotChartProps, } from './BoxPlotChart';
32
+ export type { BoxPlotChartDataItem, BoxPlotChartProps } from './BoxPlotChart';
33
33
  export type { ChartStatisticClassNames, ChartStatisticProps, ChartStatisticStyles, } from './ChartStatistic';
34
34
  export type { DonutChartConfig, DonutChartData, DonutChartProps, } from './DonutChart';
35
35
  export type { FunnelChartDataItem, FunnelChartProps } from './FunnelChart';
@@ -4,4 +4,4 @@
4
4
  * @author Code Plugin Team
5
5
  */
6
6
  export { langOptions } from './langOptions';
7
- export { openHtmlLocalPreview, openMarkdownLocalPreview, } from './localPreview';
7
+ export { openHtmlLocalPreview, openMarkdownLocalPreview } from './localPreview';