@ant-design/agentic-ui 2.30.11 → 2.30.13

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 (54) hide show
  1. package/dist/Bubble/MessagesContent/MarkdownPreview.js +3 -2
  2. package/dist/Bubble/MessagesContent/style.js +3 -1
  3. package/dist/Bubble/style.js +35 -13
  4. package/dist/ChatLayout/index.js +9 -1
  5. package/dist/History/components/HistoryList.d.ts +2 -12
  6. package/dist/History/components/HistoryList.js +48 -43
  7. package/dist/History/style.d.ts +4 -0
  8. package/dist/History/style.js +1 -0
  9. package/dist/Hooks/useAutoScroll.js +38 -14
  10. package/dist/Hooks/useLanguage.d.ts +1 -0
  11. package/dist/I18n/locales.d.ts +1 -0
  12. package/dist/I18n/locales.js +2 -0
  13. package/dist/MarkdownEditor/editor/elements/AgenticUiBlocks/AgenticUiFileMapBlock.d.ts +4 -0
  14. package/dist/MarkdownEditor/editor/elements/AgenticUiBlocks/AgenticUiFileMapBlock.js +83 -0
  15. package/dist/MarkdownEditor/editor/elements/AgenticUiBlocks/agenticUiEmbedUtils.d.ts +14 -0
  16. package/dist/MarkdownEditor/editor/elements/AgenticUiBlocks/agenticUiEmbedUtils.js +52 -0
  17. package/dist/MarkdownEditor/editor/elements/index.js +3 -0
  18. package/dist/MarkdownEditor/editor/parser/parse/parseCode.js +2 -1
  19. package/dist/MarkdownEditor/editor/parser/parserSlateNodeToMarkdown.js +1 -0
  20. package/dist/MarkdownEditor/editor/plugins/handlePaste.js +2 -1
  21. package/dist/MarkdownEditor/types.d.ts +6 -0
  22. package/dist/MarkdownInputField/AttachmentButton/AttachmentFileList/AttachmentFileListItem.js +2 -2
  23. package/dist/MarkdownInputField/AttachmentButton/AttachmentFileList/style.js +3 -1
  24. package/dist/MarkdownInputField/AttachmentButton/index.d.ts +12 -0
  25. package/dist/MarkdownInputField/AttachmentButton/index.js +23 -13
  26. package/dist/MarkdownInputField/FileMapView/index.d.ts +13 -1
  27. package/dist/MarkdownInputField/FileMapView/index.js +24 -8
  28. package/dist/MarkdownInputField/FileUploadManager/index.js +4 -26
  29. package/dist/MarkdownRenderer/MarkdownRenderer.js +16 -5
  30. package/dist/MarkdownRenderer/index.d.ts +4 -1
  31. package/dist/MarkdownRenderer/index.js +3 -0
  32. package/dist/MarkdownRenderer/renderers/AgenticUiFileMapBlockRenderer.d.ts +8 -0
  33. package/dist/MarkdownRenderer/renderers/AgenticUiFileMapBlockRenderer.js +121 -0
  34. package/dist/MarkdownRenderer/renderers/ChartRenderer.js +9 -0
  35. package/dist/MarkdownRenderer/renderers/index.d.ts +3 -0
  36. package/dist/MarkdownRenderer/renderers/index.js +3 -0
  37. package/dist/MarkdownRenderer/types.d.ts +45 -2
  38. package/dist/Plugins/chart/ChartRender.js +30 -9
  39. package/dist/Plugins/chart/HistogramChart/index.d.ts +5 -1
  40. package/dist/Plugins/chart/HistogramChart/index.js +79 -12
  41. package/dist/Plugins/chart/ScatterChart/index.d.ts +8 -0
  42. package/dist/Plugins/chart/ScatterChart/index.js +78 -8
  43. package/dist/Plugins/chart/components/ChartContainer/ChartErrorBoundary.d.ts +2 -0
  44. package/dist/Plugins/code/components/AceEditor.js +69 -8
  45. package/dist/Plugins/code/components/CodeRenderer.js +22 -7
  46. package/dist/Plugins/code/components/CodeToolbar.d.ts +2 -0
  47. package/dist/Plugins/code/components/CodeToolbar.js +11 -4
  48. package/dist/Plugins/code/hooks/useToolbarConfig.d.ts +3 -1
  49. package/dist/Plugins/code/hooks/useToolbarConfig.js +5 -3
  50. package/dist/Plugins/code/utils/index.d.ts +1 -0
  51. package/dist/Plugins/code/utils/index.js +1 -0
  52. package/dist/Plugins/code/utils/localPreview.d.ts +12 -0
  53. package/dist/Plugins/code/utils/localPreview.js +190 -0
  54. package/package.json +1 -1
@@ -652,20 +652,41 @@ import { debounce, getDataHash, isConfigEqual, isNotEmpty, toNumber } from "./ut
652
652
  var _ref8;
653
653
  var _config_rest10;
654
654
  // 直方图数据转换:提取原始值
655
+ // 同时支持预分箱格式:groupKey.DIM_LEFT / groupKey.DIM_RIGHT + MEASURE_PROB[0].actualValue
655
656
  var histogramData = (chartData || []).map(function(row) {
657
+ var _row_groupKey, _row_groupKey1, _row_MEASURE_PROB_;
658
+ var dimLeft = row === null || row === void 0 ? void 0 : (_row_groupKey = row.groupKey) === null || _row_groupKey === void 0 ? void 0 : _row_groupKey.DIM_LEFT;
659
+ var dimRight = row === null || row === void 0 ? void 0 : (_row_groupKey1 = row.groupKey) === null || _row_groupKey1 === void 0 ? void 0 : _row_groupKey1.DIM_RIGHT;
660
+ var measureProb = Array.isArray(row === null || row === void 0 ? void 0 : row.MEASURE_PROB) ? (_row_MEASURE_PROB_ = row.MEASURE_PROB[0]) === null || _row_MEASURE_PROB_ === void 0 ? void 0 : _row_MEASURE_PROB_.actualValue : undefined;
661
+ if (typeof dimLeft === 'number' && typeof dimRight === 'number' && typeof measureProb === 'number') {
662
+ var type = getFieldValue(row, colorLegend);
663
+ var category = getFieldValue(row, groupBy);
664
+ var filterLabel = getFieldValue(row, filterBy);
665
+ return _object_spread({
666
+ value: measureProb,
667
+ left: dimLeft,
668
+ right: dimRight
669
+ }, type ? {
670
+ type: type
671
+ } : {}, category ? {
672
+ category: category
673
+ } : {}, filterLabel ? {
674
+ filterLabel: filterLabel
675
+ } : {});
676
+ }
656
677
  var value = getFieldValueSafely(row, config === null || config === void 0 ? void 0 : config.y);
657
- var type = getFieldValue(row, colorLegend);
658
- var category = getFieldValue(row, groupBy);
659
- var filterLabel = getFieldValue(row, filterBy);
678
+ var type1 = getFieldValue(row, colorLegend);
679
+ var category1 = getFieldValue(row, groupBy);
680
+ var filterLabel1 = getFieldValue(row, filterBy);
660
681
  var numValue = typeof value === 'number' ? value : toNumber(value, Number.NaN);
661
682
  return _object_spread({
662
683
  value: Number.isFinite(numValue) ? numValue : 0
663
- }, type ? {
664
- type: type
665
- } : {}, category ? {
666
- category: category
667
- } : {}, filterLabel ? {
668
- filterLabel: filterLabel
684
+ }, type1 ? {
685
+ type: type1
686
+ } : {}, category1 ? {
687
+ category: category1
688
+ } : {}, filterLabel1 ? {
689
+ filterLabel: filterLabel1
669
690
  } : {});
670
691
  });
671
692
  return /*#__PURE__*/ React.createElement(HistogramChart, {
@@ -6,8 +6,12 @@ import type { ChartClassNames, ChartStyles } from '../types/classNames';
6
6
  * 直方图数据项接口
7
7
  */
8
8
  export interface HistogramChartDataItem {
9
- /** 原始数据值 */
9
+ /** 原始数据值(自动分箱时为原始数值;预分箱时为该箱的 y 轴值) */
10
10
  value: number;
11
+ /** 预分箱左边界(设置后与 right 一起跳过自动分箱) */
12
+ left?: number;
13
+ /** 预分箱右边界 */
14
+ right?: number;
11
15
  /** 数据系列(用于分组显示) */
12
16
  type?: string;
13
17
  /** 分类(用于筛选) */
@@ -200,13 +200,18 @@ var histogramChartComponentsRegistered = false;
200
200
  };
201
201
  }
202
202
  /**
203
- * 格式化分箱标签
203
+ * 格式化分箱标签,对超出范围的数字使用普通计数格式而非科学记数法
204
204
  */ function formatBinLabel(start, end) {
205
205
  var formatNum = function formatNum(n) {
206
- if (Math.abs(n) >= 1000 || Math.abs(n) < 0.01 && n !== 0) {
207
- return n.toExponential(1);
206
+ if (Math.abs(n) < 0.01 && n !== 0) {
207
+ return n.toFixed(4);
208
208
  }
209
- return n.toFixed(2);
209
+ if (Number.isInteger(n)) {
210
+ return n.toLocaleString('en-US', {
211
+ useGrouping: false
212
+ });
213
+ }
214
+ return parseFloat(n.toFixed(2)).toString();
210
215
  };
211
216
  return "".concat(formatNum(start), " - ").concat(formatNum(end));
212
217
  }
@@ -345,6 +350,14 @@ var HistogramChart = function HistogramChart(_0) {
345
350
  }, [
346
351
  filteredData
347
352
  ]);
353
+ // 判断是否为预分箱数据(所有项都有 left 和 right 字段)
354
+ var isPreBinned = useMemo(function() {
355
+ return filteredData.length > 0 && filteredData.every(function(item) {
356
+ return typeof item.left === 'number' && typeof item.right === 'number';
357
+ });
358
+ }, [
359
+ filteredData
360
+ ]);
348
361
  // 计算分箱
349
362
  var binning = useMemo(function() {
350
363
  if (filteredData.length === 0) {
@@ -354,24 +367,57 @@ var HistogramChart = function HistogramChart(_0) {
354
367
  binCount: 0
355
368
  };
356
369
  }
370
+ if (isPreBinned) {
371
+ // 预分箱模式:按 left 排序,直接生成区间标签
372
+ var sorted = _to_consumable_array(filteredData).sort(function(a, b) {
373
+ return a.left - b.left;
374
+ });
375
+ var uniqueEdgePairs = sorted.reduce(function(acc, item) {
376
+ var l = item.left;
377
+ var r = item.right;
378
+ if (!acc.some(function(p) {
379
+ return p.left === l && p.right === r;
380
+ })) {
381
+ acc.push({
382
+ left: l,
383
+ right: r
384
+ });
385
+ }
386
+ return acc;
387
+ }, []);
388
+ var edges = _to_consumable_array(uniqueEdgePairs.map(function(p) {
389
+ return p.left;
390
+ })).concat([
391
+ uniqueEdgePairs[uniqueEdgePairs.length - 1].right
392
+ ]);
393
+ var labels = uniqueEdgePairs.map(function(p) {
394
+ return formatBinLabel(p.left, p.right);
395
+ });
396
+ return {
397
+ edges: edges,
398
+ labels: labels,
399
+ binCount: labels.length
400
+ };
401
+ }
357
402
  var allValues = filteredData.map(function(item) {
358
403
  return item.value;
359
404
  });
360
405
  var autoBinCount = customBinCount || calculateBinCount(allValues.length);
361
- var edges = calculateBinEdges(allValues, autoBinCount).edges;
406
+ var edges1 = calculateBinEdges(allValues, autoBinCount).edges;
362
407
  // 生成分箱标签
363
- var labels = [];
364
- for(var i = 0; i < edges.length - 1; i++){
365
- labels.push(formatBinLabel(edges[i], edges[i + 1]));
408
+ var labels1 = [];
409
+ for(var i = 0; i < edges1.length - 1; i++){
410
+ labels1.push(formatBinLabel(edges1[i], edges1[i + 1]));
366
411
  }
367
412
  return {
368
- edges: edges,
369
- labels: labels,
413
+ edges: edges1,
414
+ labels: labels1,
370
415
  binCount: autoBinCount
371
416
  };
372
417
  }, [
373
418
  filteredData,
374
- customBinCount
419
+ customBinCount,
420
+ isPreBinned
375
421
  ]);
376
422
  // 计算每个分箱的频率/计数
377
423
  var histogramData = useMemo(function() {
@@ -380,6 +426,26 @@ var HistogramChart = function HistogramChart(_0) {
380
426
  return {};
381
427
  }
382
428
  var result = {};
429
+ if (isPreBinned) {
430
+ // 预分箱模式:直接将 value 映射到对应区间
431
+ types.forEach(function(type) {
432
+ if (!type) return;
433
+ var typeData = filteredData.filter(function(item) {
434
+ return (item.type || '默认') === type;
435
+ });
436
+ var counts = new Array(labels.length).fill(0);
437
+ typeData.forEach(function(item) {
438
+ var l = item.left;
439
+ var r = item.right;
440
+ var idx = labels.indexOf(formatBinLabel(l, r));
441
+ if (idx !== -1) {
442
+ counts[idx] += showFrequency ? item.value : item.value;
443
+ }
444
+ });
445
+ result[type] = counts;
446
+ });
447
+ return result;
448
+ }
383
449
  types.forEach(function(type) {
384
450
  if (!type) return; // Skip undefined types
385
451
  var typeData = filteredData.filter(function(item) {
@@ -411,7 +477,8 @@ var HistogramChart = function HistogramChart(_0) {
411
477
  filteredData,
412
478
  types,
413
479
  binning,
414
- showFrequency
480
+ showFrequency,
481
+ isPreBinned
415
482
  ]);
416
483
  // 构建 Chart.js 数据结构
417
484
  var processedData = useMemo(function() {
@@ -58,6 +58,14 @@ export interface ScatterChartProps extends ChartContainerProps {
58
58
  loading?: boolean;
59
59
  /** 自定义样式对象(支持对象格式,为每层DOM设置样式) */
60
60
  styles?: ChartStyles;
61
+ /** X 轴最小值,不传则从数据自动计算 */
62
+ xMin?: number;
63
+ /** X 轴最大值,不传则从数据自动计算 */
64
+ xMax?: number;
65
+ /** Y 轴最小值,不传则从数据自动计算 */
66
+ yMin?: number;
67
+ /** Y 轴最大值,不传则从数据自动计算 */
68
+ yMax?: number;
61
69
  }
62
70
  declare const ScatterChart: React.FC<ScatterChartProps>;
63
71
  export default ScatterChart;
@@ -6,6 +6,9 @@ function _array_like_to_array(arr, len) {
6
6
  function _array_with_holes(arr) {
7
7
  if (Array.isArray(arr)) return arr;
8
8
  }
9
+ function _array_without_holes(arr) {
10
+ if (Array.isArray(arr)) return _array_like_to_array(arr);
11
+ }
9
12
  function _define_property(obj, key, value) {
10
13
  if (key in obj) {
11
14
  Object.defineProperty(obj, key, {
@@ -19,6 +22,9 @@ function _define_property(obj, key, value) {
19
22
  }
20
23
  return obj;
21
24
  }
25
+ function _iterable_to_array(iter) {
26
+ if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter);
27
+ }
22
28
  function _iterable_to_array_limit(arr, i) {
23
29
  var _i = arr == null ? null : typeof Symbol !== "undefined" && arr[Symbol.iterator] || arr["@@iterator"];
24
30
  if (_i == null) return;
@@ -46,6 +52,9 @@ function _iterable_to_array_limit(arr, i) {
46
52
  function _non_iterable_rest() {
47
53
  throw new TypeError("Invalid attempt to destructure non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
48
54
  }
55
+ function _non_iterable_spread() {
56
+ throw new TypeError("Invalid attempt to spread non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
57
+ }
49
58
  function _object_spread(target) {
50
59
  for(var i = 1; i < arguments.length; i++){
51
60
  var source = arguments[i] != null ? arguments[i] : {};
@@ -124,6 +133,9 @@ function _object_without_properties_loose(source, excluded) {
124
133
  function _sliced_to_array(arr, i) {
125
134
  return _array_with_holes(arr) || _iterable_to_array_limit(arr, i) || _unsupported_iterable_to_array(arr, i) || _non_iterable_rest();
126
135
  }
136
+ function _to_consumable_array(arr) {
137
+ return _array_without_holes(arr) || _iterable_to_array(arr) || _unsupported_iterable_to_array(arr) || _non_iterable_spread();
138
+ }
127
139
  function _type_of(obj) {
128
140
  "@swc/helpers - typeof";
129
141
  return obj && typeof Symbol !== "undefined" && obj.constructor === Symbol ? "symbol" : typeof obj;
@@ -149,7 +161,7 @@ import { hexToRgba, resolveCssVariable } from "../utils";
149
161
  import { useStyle } from "./style";
150
162
  var scatterChartComponentsRegistered = false;
151
163
  var ScatterChart = function ScatterChart(_0) {
152
- var data = _0.data, _0_width = _0.width, width = _0_width === void 0 ? 600 : _0_width, _0_height = _0.height, height = _0_height === void 0 ? 400 : _0_height, className = _0.className, classNamesProp = _0.classNames, title = _0.title, toolbarExtra = _0.toolbarExtra, _0_renderFilterInToolbar = _0.renderFilterInToolbar, renderFilterInToolbar = _0_renderFilterInToolbar === void 0 ? false : _0_renderFilterInToolbar, dataTime = _0.dataTime, _0_xUnit = _0.xUnit, xUnit = _0_xUnit === void 0 ? '月' : _0_xUnit, yUnit = _0.yUnit, xAxisLabel = _0.xAxisLabel, yAxisLabel = _0.yAxisLabel, _0_xPosition = _0.xPosition, xPosition = _0_xPosition === void 0 ? 'bottom' : _0_xPosition, _0_yPosition = _0.yPosition, yPosition = _0_yPosition === void 0 ? 'left' : _0_yPosition, _0_hiddenX = _0.hiddenX, hiddenX = _0_hiddenX === void 0 ? false : _0_hiddenX, _0_hiddenY = _0.hiddenY, hiddenY = _0_hiddenY === void 0 ? false : _0_hiddenY, _0_showGrid = _0.showGrid, showGrid = _0_showGrid === void 0 ? true : _0_showGrid, _0_theme = _0.theme, theme = _0_theme === void 0 ? 'light' : _0_theme, color = _0.color, statisticConfig = _0.statistic, _0_textMaxWidth = _0.textMaxWidth, textMaxWidth = _0_textMaxWidth === void 0 ? 80 : _0_textMaxWidth, _0_loading = _0.loading, loading = _0_loading === void 0 ? false : _0_loading, props = _object_without_properties(_0, [
164
+ var data = _0.data, _0_width = _0.width, width = _0_width === void 0 ? 600 : _0_width, _0_height = _0.height, height = _0_height === void 0 ? 400 : _0_height, className = _0.className, classNamesProp = _0.classNames, title = _0.title, toolbarExtra = _0.toolbarExtra, _0_renderFilterInToolbar = _0.renderFilterInToolbar, renderFilterInToolbar = _0_renderFilterInToolbar === void 0 ? false : _0_renderFilterInToolbar, dataTime = _0.dataTime, _0_xUnit = _0.xUnit, xUnit = _0_xUnit === void 0 ? '月' : _0_xUnit, yUnit = _0.yUnit, xAxisLabel = _0.xAxisLabel, yAxisLabel = _0.yAxisLabel, _0_xPosition = _0.xPosition, xPosition = _0_xPosition === void 0 ? 'bottom' : _0_xPosition, _0_yPosition = _0.yPosition, yPosition = _0_yPosition === void 0 ? 'left' : _0_yPosition, _0_hiddenX = _0.hiddenX, hiddenX = _0_hiddenX === void 0 ? false : _0_hiddenX, _0_hiddenY = _0.hiddenY, hiddenY = _0_hiddenY === void 0 ? false : _0_hiddenY, _0_showGrid = _0.showGrid, showGrid = _0_showGrid === void 0 ? true : _0_showGrid, _0_theme = _0.theme, theme = _0_theme === void 0 ? 'light' : _0_theme, color = _0.color, statisticConfig = _0.statistic, _0_textMaxWidth = _0.textMaxWidth, textMaxWidth = _0_textMaxWidth === void 0 ? 80 : _0_textMaxWidth, _0_loading = _0.loading, loading = _0_loading === void 0 ? false : _0_loading, xMinProp = _0.xMin, xMaxProp = _0.xMax, yMinProp = _0.yMin, yMaxProp = _0.yMax, props = _object_without_properties(_0, [
153
165
  "data",
154
166
  "width",
155
167
  "height",
@@ -172,7 +184,11 @@ var ScatterChart = function ScatterChart(_0) {
172
184
  "color",
173
185
  "statistic",
174
186
  "textMaxWidth",
175
- "loading"
187
+ "loading",
188
+ "xMin",
189
+ "xMax",
190
+ "yMin",
191
+ "yMax"
176
192
  ]);
177
193
  useMemo(function() {
178
194
  if (scatterChartComponentsRegistered) {
@@ -304,6 +320,60 @@ var ScatterChart = function ScatterChart(_0) {
304
320
  }
305
321
  }, "暂无有效数据")));
306
322
  }
323
+ // 从数据中自动计算坐标轴范围,加 10% 边距,方便查看边界点
324
+ var computeAxisBounds = function computeAxisBounds(values, overrideMin, overrideMax, fallbackMin, fallbackMax) {
325
+ var _Math, _Math1;
326
+ if (overrideMin !== undefined && overrideMax !== undefined) {
327
+ return {
328
+ min: overrideMin,
329
+ max: overrideMax
330
+ };
331
+ }
332
+ if (values.length === 0) {
333
+ return {
334
+ min: fallbackMin,
335
+ max: fallbackMax
336
+ };
337
+ }
338
+ var dataMin = (_Math = Math).min.apply(_Math, _to_consumable_array(values));
339
+ var dataMax = (_Math1 = Math).max.apply(_Math1, _to_consumable_array(values));
340
+ var range = dataMax - dataMin || 1;
341
+ var padding = range * 0.1;
342
+ return {
343
+ min: overrideMin !== undefined ? overrideMin : Math.floor(dataMin - padding),
344
+ max: overrideMax !== undefined ? overrideMax : Math.ceil(dataMax + padding)
345
+ };
346
+ };
347
+ var allXValues = filteredData.map(function(item) {
348
+ var v = typeof item.x === 'number' ? item.x : Number(item.x);
349
+ return Number.isFinite(v) ? v : null;
350
+ }).filter(function(v) {
351
+ return v !== null;
352
+ });
353
+ var allYValues = filteredData.map(function(item) {
354
+ var v = typeof item.y === 'number' ? item.y : Number(item.y);
355
+ return Number.isFinite(v) ? v : null;
356
+ }).filter(function(v) {
357
+ return v !== null;
358
+ });
359
+ var xBounds = computeAxisBounds(allXValues, xMinProp, xMaxProp, 1, 12);
360
+ var yBounds = computeAxisBounds(allYValues, yMinProp, yMaxProp, 0, 100);
361
+ var computeStepSize = function computeStepSize(min, max) {
362
+ var targetTicks = arguments.length > 2 && arguments[2] !== void 0 ? arguments[2] : 10;
363
+ var range = max - min;
364
+ if (range <= 0) return 1;
365
+ var rawStep = range / targetTicks;
366
+ var magnitude = Math.pow(10, Math.floor(Math.log10(rawStep)));
367
+ var normalized = rawStep / magnitude;
368
+ var step;
369
+ if (normalized <= 1) step = magnitude;
370
+ else if (normalized <= 2) step = 2 * magnitude;
371
+ else if (normalized <= 5) step = 5 * magnitude;
372
+ else step = 10 * magnitude;
373
+ return step;
374
+ };
375
+ var xStepSize = computeStepSize(xBounds.min, xBounds.max);
376
+ var yStepSize = computeStepSize(yBounds.min, yBounds.max);
307
377
  // 构建数据集,添加更强的安全检查
308
378
  var datasets = datasetTypes.map(function(type, index) {
309
379
  var typeData = filteredData.filter(function(item) {
@@ -546,10 +616,10 @@ var ScatterChart = function ScatterChart(_0) {
546
616
  weight: 500
547
617
  }
548
618
  },
549
- min: 1,
550
- max: 12,
619
+ min: xBounds.min,
620
+ max: xBounds.max,
551
621
  ticks: {
552
- stepSize: 1,
622
+ stepSize: xStepSize,
553
623
  color: axisTextColor,
554
624
  font: {
555
625
  size: isMobile ? 8 : 10
@@ -579,10 +649,10 @@ var ScatterChart = function ScatterChart(_0) {
579
649
  },
580
650
  align: 'center'
581
651
  },
582
- min: 0,
583
- max: 100,
652
+ min: yBounds.min,
653
+ max: yBounds.max,
584
654
  ticks: {
585
- stepSize: 10,
655
+ stepSize: yStepSize,
586
656
  color: axisTextColor,
587
657
  font: {
588
658
  family: 'PingFang SC',
@@ -393,6 +393,7 @@ declare class ChartErrorBoundary extends React.Component<ChartErrorBoundaryProps
393
393
  'browser.searching': string;
394
394
  'layout.header.title': string;
395
395
  theme: string;
396
+ localPreview: string;
396
397
  expandCollapse: string;
397
398
  moreActions: string;
398
399
  clickToRetry: string;
@@ -786,6 +787,7 @@ declare class ChartErrorBoundary extends React.Component<ChartErrorBoundaryProps
786
787
  'browser.searching': string;
787
788
  'layout.header.title': string;
788
789
  theme: string;
790
+ localPreview: string;
789
791
  expandCollapse: string;
790
792
  moreActions: string;
791
793
  clickToRetry: string;
@@ -305,6 +305,8 @@ import { loadAceEditor, loadAceTheme } from "../loadAceEditor";
305
305
  var debounceTimer = useRef(0);
306
306
  var editorRef = useRef();
307
307
  var dom = useRef(null);
308
+ // 记录 Ace 会话当前使用的语言,用于语言变更时动态切换而不是销毁重建
309
+ var aceLanguageRef = useRef(element.language);
308
310
  // Ace Editor 异步加载状态
309
311
  var _useState = _sliced_to_array(useState(false), 2), aceLoaded = _useState[0], setAceLoaded = _useState[1];
310
312
  var aceModuleRef = useRef(null);
@@ -493,6 +495,8 @@ import { loadAceEditor, loadAceTheme } from "../loadAceEditor";
493
495
  // 初始化 Ace 编辑器(仅在库加载完成后)
494
496
  // 注意: intentionally 不将 editorProps.codeProps 列入依赖,因其对象引用在父组件内容更新时会频繁变化,
495
497
  // 导致编辑器被不必要地销毁重建。codeProps 的配置在初始化时已应用,主题等动态变更由独立 effect 处理。
498
+ // element.language 同样不列为依赖,语言切换由独立的 effect 处理,避免流式渲染中 language
499
+ // 逐字符变化时触发编辑器销毁重建。
496
500
  useEffect(function() {
497
501
  if (process.env.NODE_ENV === 'test') return;
498
502
  if (!aceLoaded || !aceModuleRef.current || !dom.current) return;
@@ -521,6 +525,7 @@ import { loadAceEditor, loadAceTheme } from "../loadAceEditor";
521
525
  showGutter: true
522
526
  }, codeProps));
523
527
  editorRef.current = codeEditor;
528
+ aceLanguageRef.current = element.language;
524
529
  // 设置主题
525
530
  var theme = codeProps.theme || props.theme || 'github';
526
531
  codeEditor.setTheme("ace/theme/".concat(theme));
@@ -551,19 +556,59 @@ import { loadAceEditor, loadAceTheme } from "../loadAceEditor";
551
556
  });
552
557
  })();
553
558
  }, 16);
554
- if (readonly) return;
555
- // 配置编辑器事件
556
- setupEditorEvents(codeEditor);
559
+ if (!readonly) {
560
+ // 配置编辑器事件
561
+ setupEditorEvents(codeEditor);
562
+ }
557
563
  return function() {
558
564
  clearTimeout(debounceTimer.current);
559
565
  codeEditor.destroy();
560
566
  };
567
+ // eslint-disable-next-line react-hooks/exhaustive-deps
561
568
  }, [
562
569
  aceLoaded,
563
- element.language,
564
570
  readonly,
565
571
  setupEditorEvents
566
572
  ]);
573
+ // 语言切换时动态更新 Ace 会话模式,无需销毁重建编辑器
574
+ useEffect(function() {
575
+ if (!editorRef.current || !aceLoaded) return;
576
+ if (aceLanguageRef.current === element.language) return;
577
+ aceLanguageRef.current = element.language;
578
+ (function() {
579
+ return _async_to_generator(function() {
580
+ var lang, aceLangs, _editorRef_current, _editorRef_current1;
581
+ return _ts_generator(this, function(_state) {
582
+ switch(_state.label){
583
+ case 0:
584
+ lang = element.language || '';
585
+ if (modeMap.has(lang)) {
586
+ lang = modeMap.get(lang);
587
+ }
588
+ return [
589
+ 4,
590
+ getAceLangs()
591
+ ];
592
+ case 1:
593
+ aceLangs = _state.sent();
594
+ if (aceLangs.has(lang)) {
595
+ ;
596
+ (_editorRef_current = editorRef.current) === null || _editorRef_current === void 0 ? void 0 : _editorRef_current.session.setMode("ace/mode/".concat(lang));
597
+ } else {
598
+ ;
599
+ (_editorRef_current1 = editorRef.current) === null || _editorRef_current1 === void 0 ? void 0 : _editorRef_current1.session.setMode("ace/mode/text");
600
+ }
601
+ return [
602
+ 2
603
+ ];
604
+ }
605
+ });
606
+ })();
607
+ })();
608
+ }, [
609
+ element.language,
610
+ aceLoaded
611
+ ]);
567
612
  // 监听外部值变化
568
613
  useEffect(function() {
569
614
  var value = element.value || '';
@@ -572,10 +617,26 @@ import { loadAceEditor, loadAceTheme } from "../loadAceEditor";
572
617
  value = JSON.stringify(partialParse(value), null, 2);
573
618
  } catch (e) {}
574
619
  }
575
- if (value !== codeRef.current || readonly) {
576
- var _editorRef_current, _editorRef_current1;
577
- if (element) (_editorRef_current = editorRef.current) === null || _editorRef_current === void 0 ? void 0 : _editorRef_current.setValue(value);
578
- (_editorRef_current1 = editorRef.current) === null || _editorRef_current1 === void 0 ? void 0 : _editorRef_current1.clearSelection();
620
+ if (value === codeRef.current) return;
621
+ var editor = editorRef.current;
622
+ var prev = codeRef.current;
623
+ codeRef.current = value;
624
+ if (!editor) return;
625
+ // 流式渲染时内容只会在末尾追加。通过检测 value.startsWith(prev) 来判断是否为纯追加,
626
+ // 若是则调用 session.insert 在末尾插入增量内容,避免 setValue 清空重写导致的闪动。
627
+ var isAppend = value.startsWith(prev);
628
+ if (isAppend) {
629
+ var delta = value.slice(prev.length);
630
+ var doc = editor.session.getDocument();
631
+ var lastRow = doc.getLength() - 1;
632
+ var lastCol = doc.getLine(lastRow).length;
633
+ editor.session.insert({
634
+ row: lastRow,
635
+ column: lastCol
636
+ }, delta);
637
+ } else {
638
+ editor.setValue(value);
639
+ editor.clearSelection();
579
640
  }
580
641
  }, [
581
642
  element.value
@@ -100,10 +100,11 @@ function _unsupported_iterable_to_array(o, minLen) {
100
100
  * @fileoverview 代码渲染器组件
101
101
  * 封装代码编辑器的所有渲染逻辑
102
102
  */ import { ConfigProvider, Skeleton, theme as antdTheme } from "antd";
103
- import React, { useEffect, useMemo, useState } from "react";
103
+ import React, { useCallback, useEffect, useMemo, useState } from "react";
104
104
  import { MarkdownEditor } from "../../../MarkdownEditor";
105
105
  import { useEditorStore } from "../../../MarkdownEditor/editor/store";
106
106
  import { useCodeEditorState, useRenderConditions, useToolbarConfig } from "../hooks";
107
+ import { openHtmlLocalPreview, openMarkdownLocalPreview } from "../utils/localPreview";
107
108
  import { AceEditor, AceEditorContainer, CodeContainer, CodeToolbar, HtmlPreview, ThinkBlock } from "./index";
108
109
  /**
109
110
  * 检测 HTML 代码中是否包含 JavaScript
@@ -154,7 +155,7 @@ import { AceEditor, AceEditorContainer, CodeContainer, CodeToolbar, HtmlPreview,
154
155
  * - 支持代码框选中状态管理
155
156
  */ export function CodeRenderer(props) {
156
157
  var _ref;
157
- var _editorProps_codeProps, _props_element_language, _props_element, _props_element1, _props_element_otherProps, _props_element2, _props_element_otherProps1, _props_element3, _editorProps_codeProps1, _editorProps_codeProps2;
158
+ var _editorProps_codeProps, _props_element_language, _props_element, _props_element1, _props_element2, _props_element_otherProps, _props_element3, _props_element_otherProps1, _props_element4, _editorProps_codeProps1, _editorProps_codeProps2;
158
159
  var _useEditorStore = useEditorStore(), editorProps = _useEditorStore.editorProps, readonly = _useEditorStore.readonly;
159
160
  // 使用状态管理Hook
160
161
  var _useCodeEditorState = useCodeEditorState(props.element), state = _useCodeEditorState.state, update = _useCodeEditorState.update, path = _useCodeEditorState.path, handleCloseClick = _useCodeEditorState.handleCloseClick, handleHtmlPreviewClose = _useCodeEditorState.handleHtmlPreviewClose, handleShowBorderChange = _useCodeEditorState.handleShowBorderChange, handleHideChange = _useCodeEditorState.handleHideChange;
@@ -203,6 +204,19 @@ import { AceEditor, AceEditorContainer, CodeContainer, CodeToolbar, HtmlPreview,
203
204
  return prev === 'preview' ? 'code' : 'preview';
204
205
  });
205
206
  };
207
+ // 本地预览处理函数
208
+ var handleLocalPreview = useCallback(function() {
209
+ var _props_element;
210
+ var value = ((_props_element = props.element) === null || _props_element === void 0 ? void 0 : _props_element.value) || '';
211
+ if (language === 'markdown') {
212
+ openMarkdownLocalPreview(value);
213
+ } else if (language === 'html') {
214
+ openHtmlLocalPreview(value);
215
+ }
216
+ }, [
217
+ language,
218
+ (_props_element2 = props.element) === null || _props_element2 === void 0 ? void 0 : _props_element2.value
219
+ ]);
206
220
  // 使用工具栏配置Hook
207
221
  var toolbarProps = useToolbarConfig({
208
222
  element: props.element,
@@ -211,10 +225,11 @@ import { AceEditor, AceEditorContainer, CodeContainer, CodeToolbar, HtmlPreview,
211
225
  setLanguage: setLanguage,
212
226
  onSelectionChange: setIsSelected,
213
227
  onViewModeToggle: handleViewModeToggle,
214
- viewMode: viewMode
228
+ viewMode: viewMode,
229
+ onLocalPreview: handleLocalPreview
215
230
  }).toolbarProps;
216
231
  // 检查代码块是否未闭合
217
- var isUnclosed = ((_props_element2 = props.element) === null || _props_element2 === void 0 ? void 0 : (_props_element_otherProps = _props_element2.otherProps) === null || _props_element_otherProps === void 0 ? void 0 : _props_element_otherProps.finished) === false;
232
+ var isUnclosed = ((_props_element3 = props.element) === null || _props_element3 === void 0 ? void 0 : (_props_element_otherProps = _props_element3.otherProps) === null || _props_element_otherProps === void 0 ? void 0 : _props_element_otherProps.finished) === false;
218
233
  // 5 秒超时机制:如果代码块未闭合,5 秒后自动设置为完成
219
234
  useEffect(function() {
220
235
  if (isUnclosed && !readonly) {
@@ -237,7 +252,7 @@ import { AceEditor, AceEditorContainer, CodeContainer, CodeToolbar, HtmlPreview,
237
252
  }, [
238
253
  isUnclosed,
239
254
  readonly,
240
- (_props_element3 = props.element) === null || _props_element3 === void 0 ? void 0 : (_props_element_otherProps1 = _props_element3.otherProps) === null || _props_element_otherProps1 === void 0 ? void 0 : _props_element_otherProps1.finished,
255
+ (_props_element4 = props.element) === null || _props_element4 === void 0 ? void 0 : (_props_element_otherProps1 = _props_element4.otherProps) === null || _props_element_otherProps1 === void 0 ? void 0 : _props_element_otherProps1.finished,
241
256
  update
242
257
  ]);
243
258
  // 如果禁用了 HTML 预览或包含 JavaScript,强制使用代码模式
@@ -331,7 +346,6 @@ import { AceEditor, AceEditorContainer, CodeContainer, CodeToolbar, HtmlPreview,
331
346
  props.children,
332
347
  state.showBorder,
333
348
  state.hide,
334
- state.htmlStr,
335
349
  isSelected,
336
350
  (_editorProps_codeProps1 = editorProps.codeProps) === null || _editorProps_codeProps1 === void 0 ? void 0 : _editorProps_codeProps1.hideToolBar,
337
351
  (_editorProps_codeProps2 = editorProps.codeProps) === null || _editorProps_codeProps2 === void 0 ? void 0 : _editorProps_codeProps2.disableHtmlPreview,
@@ -342,6 +356,7 @@ import { AceEditor, AceEditorContainer, CodeContainer, CodeToolbar, HtmlPreview,
342
356
  handleHtmlPreviewClose,
343
357
  viewMode,
344
358
  handleViewModeToggle,
345
- disableHtmlPreview
359
+ disableHtmlPreview,
360
+ handleLocalPreview
346
361
  ]);
347
362
  }
@@ -31,6 +31,8 @@ export interface CodeToolbarProps {
31
31
  viewMode?: 'preview' | 'code';
32
32
  /** 展开/收起回调 */
33
33
  onExpandToggle?: () => void;
34
+ /** 本地预览回调(在新标签页打开 HTML/Markdown 预览) */
35
+ onLocalPreview?: () => void;
34
36
  }
35
37
  /**
36
38
  * 代码编辑器工具栏组件
@@ -3,7 +3,7 @@
3
3
  * 提供代码块的各种操作功能,包括语言切换、复制、运行等
4
4
  * @author Code Plugin Team
5
5
  */ import { CloseCircleOutlined } from "@ant-design/icons";
6
- import { ChevronsUpDown, Copy, Moon } from "@sofa-design/icons";
6
+ import { ArrowUpRight, ChevronsUpDown, Copy, Moon } from "@sofa-design/icons";
7
7
  import { Segmented } from "antd";
8
8
  import copy from "copy-to-clipboard";
9
9
  import React, { useContext, useMemo } from "react";
@@ -77,14 +77,14 @@ import { LoadImage } from "./LoadImage";
77
77
  * ```
78
78
  */ export var CodeToolbar = function CodeToolbar(props) {
79
79
  var _ref;
80
- var _editorProps_codeProps, _editorProps_codeProps1, _element_language, _element_language1, _i18n_locale, _i18n_locale1, _i18n_locale2, _i18n_locale3;
80
+ var _editorProps_codeProps, _editorProps_codeProps1, _element_language, _element_language1, _i18n_locale, _i18n_locale1, _i18n_locale2, _i18n_locale3, _i18n_locale4;
81
81
  // 获取国际化上下文
82
82
  var i18n = useContext(I18nContext);
83
83
  // 获取编辑器配置
84
84
  var editorProps = useEditorStore().editorProps;
85
85
  var disableHtmlPreview = (_ref = (_editorProps_codeProps = editorProps.codeProps) === null || _editorProps_codeProps === void 0 ? void 0 : _editorProps_codeProps.disableHtmlPreview) !== null && _ref !== void 0 ? _ref : false;
86
86
  var viewModeLabels = (_editorProps_codeProps1 = editorProps.codeProps) === null || _editorProps_codeProps1 === void 0 ? void 0 : _editorProps_codeProps1.viewModeLabels;
87
- var element = props.element, readonly = props.readonly, onCloseClick = props.onCloseClick, languageSelectorProps = props.languageSelectorProps, onViewModeToggle = props.onViewModeToggle, theme = props.theme, isExpanded = props.isExpanded, onExpandToggle = props.onExpandToggle, setTheme = props.setTheme, _props_viewMode = props.viewMode, viewMode = _props_viewMode === void 0 ? 'code' : _props_viewMode;
87
+ var element = props.element, readonly = props.readonly, onCloseClick = props.onCloseClick, languageSelectorProps = props.languageSelectorProps, onViewModeToggle = props.onViewModeToggle, theme = props.theme, isExpanded = props.isExpanded, onExpandToggle = props.onExpandToggle, setTheme = props.setTheme, _props_viewMode = props.viewMode, viewMode = _props_viewMode === void 0 ? 'code' : _props_viewMode, onLocalPreview = props.onLocalPreview;
88
88
  // 检测 HTML 代码中是否包含 JavaScript
89
89
  var hasJavaScript = useMemo(function() {
90
90
  var _element_language;
@@ -216,5 +216,12 @@ import { LoadImage } from "./LoadImage";
216
216
  onClick: function onClick() {
217
217
  onExpandToggle === null || onExpandToggle === void 0 ? void 0 : onExpandToggle();
218
218
  }
219
- }, /*#__PURE__*/ React.createElement(ChevronsUpDown, null))));
219
+ }, /*#__PURE__*/ React.createElement(ChevronsUpDown, null)), ((element === null || element === void 0 ? void 0 : element.language) === 'html' || (element === null || element === void 0 ? void 0 : element.language) === 'markdown') && onLocalPreview && /*#__PURE__*/ React.createElement(ActionIconBox, {
220
+ title: (i18n === null || i18n === void 0 ? void 0 : (_i18n_locale4 = i18n.locale) === null || _i18n_locale4 === void 0 ? void 0 : _i18n_locale4.localPreview) || '本地预览',
221
+ theme: theme === 'chaos' ? 'dark' : 'light',
222
+ onClick: function onClick(e) {
223
+ e.stopPropagation();
224
+ onLocalPreview();
225
+ }
226
+ }, /*#__PURE__*/ React.createElement(ArrowUpRight, null))));
220
227
  };