@ant-design/agentic-ui 2.16.0 → 2.17.0

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 (56) hide show
  1. package/dist/MarkdownEditor/editor/elements/Code.js +11 -6
  2. package/dist/MarkdownEditor/editor/elements/Image/index.js +17 -5
  3. package/dist/MarkdownEditor/editor/elements/Media.js +61 -9
  4. package/dist/MarkdownEditor/editor/elements/Table/ReadonlyTableComponent.js +15 -3
  5. package/dist/MarkdownEditor/editor/elements/Table/SimpleTable.js +17 -2
  6. package/dist/MarkdownEditor/editor/elements/Table/Table.js +131 -5
  7. package/dist/MarkdownEditor/editor/parser/parserMarkdownToSlateNode.d.ts +100 -1
  8. package/dist/MarkdownEditor/editor/parser/parserMarkdownToSlateNode.js +945 -284
  9. package/dist/MarkdownEditor/editor/style.js +5 -0
  10. package/dist/MarkdownEditor/editor/types/Table.d.ts +1 -0
  11. package/dist/MarkdownEditor/editor/utils/findMatchingClose.d.ts +36 -0
  12. package/dist/MarkdownEditor/editor/utils/findMatchingClose.js +158 -0
  13. package/dist/MarkdownEditor/editor/utils/markdownToHtml.d.ts +41 -2
  14. package/dist/MarkdownEditor/editor/utils/markdownToHtml.js +159 -7
  15. package/dist/Plugins/chart/AreaChart/index.d.ts +12 -0
  16. package/dist/Plugins/chart/AreaChart/index.js +14 -188
  17. package/dist/Plugins/chart/BarChart/index.d.ts +2 -0
  18. package/dist/Plugins/chart/BarChart/index.js +3 -12
  19. package/dist/Plugins/chart/ChartMark/Container.js +5 -2
  20. package/dist/Plugins/chart/ChartRender.d.ts +1 -0
  21. package/dist/Plugins/chart/ChartRender.js +104 -43
  22. package/dist/Plugins/chart/DonutChart/index.js +4 -2
  23. package/dist/Plugins/chart/DonutChart/types.d.ts +2 -0
  24. package/dist/Plugins/chart/FunnelChart/index.d.ts +2 -0
  25. package/dist/Plugins/chart/FunnelChart/index.js +4 -2
  26. package/dist/Plugins/chart/LineChart/index.d.ts +2 -0
  27. package/dist/Plugins/chart/LineChart/index.js +17 -162
  28. package/dist/Plugins/chart/RadarChart/index.d.ts +2 -0
  29. package/dist/Plugins/chart/RadarChart/index.js +8 -4
  30. package/dist/Plugins/chart/ScatterChart/index.d.ts +2 -0
  31. package/dist/Plugins/chart/ScatterChart/index.js +8 -4
  32. package/dist/Plugins/chart/components/ChartContainer/ChartContainer.d.ts +1 -0
  33. package/dist/Plugins/chart/components/ChartFilter/ChartFilter.d.ts +1 -1
  34. package/dist/Plugins/chart/components/ChartFilter/ChartFilter.js +210 -16
  35. package/dist/Plugins/chart/components/ChartToolBar/ChartToolBar.d.ts +2 -0
  36. package/dist/Plugins/chart/components/ChartToolBar/ChartToolBar.js +9 -2
  37. package/dist/Plugins/chart/components/ChartToolBar/style.js +3 -1
  38. package/dist/Plugins/chart/hooks/index.d.ts +10 -0
  39. package/dist/Plugins/chart/hooks/index.js +8 -0
  40. package/dist/Plugins/chart/hooks/useChartDataFilter.d.ts +46 -0
  41. package/dist/Plugins/chart/hooks/useChartDataFilter.js +182 -0
  42. package/dist/Plugins/chart/hooks/useChartStatistics.d.ts +17 -0
  43. package/dist/Plugins/chart/hooks/useChartStatistics.js +25 -0
  44. package/dist/Plugins/chart/hooks/useChartTheme.d.ts +20 -0
  45. package/dist/Plugins/chart/hooks/useChartTheme.js +30 -0
  46. package/dist/Plugins/chart/hooks/useResponsiveSize.d.ts +23 -0
  47. package/dist/Plugins/chart/hooks/useResponsiveSize.js +94 -0
  48. package/dist/Plugins/chart/index.js +92 -8
  49. package/dist/Plugins/chart/utils/registerChart.d.ts +35 -0
  50. package/dist/Plugins/chart/utils/registerChart.js +54 -0
  51. package/dist/Plugins/chart/utils.d.ts +19 -0
  52. package/dist/Plugins/chart/utils.js +27 -0
  53. package/dist/Plugins/code/components/CodeRenderer.js +53 -2
  54. package/dist/Plugins/code/components/CodeToolbar.js +22 -3
  55. package/dist/Plugins/mermaid/Mermaid.js +66 -66
  56. package/package.json +1 -1
@@ -54,18 +54,22 @@ import DOMPurify from "dompurify";
54
54
  import React from "react";
55
55
  export var Code = function(param) {
56
56
  var attributes = param.attributes, children = param.children, element = param.element;
57
- var _element_otherProps, _element_value;
57
+ var _element_otherProps, _element_otherProps1, _element_value;
58
58
  if ((element === null || element === void 0 ? void 0 : element.language) === 'html') {
59
- var _element_otherProps1, _element_otherProps2, _element_value1;
59
+ var _element_otherProps2, _element_otherProps3, _element_value1;
60
60
  return /*#__PURE__*/ React.createElement("div", _object_spread_props(_object_spread({}, attributes), {
61
61
  style: {
62
- display: (element === null || element === void 0 ? void 0 : (_element_otherProps1 = element.otherProps) === null || _element_otherProps1 === void 0 ? void 0 : _element_otherProps1.isConfig) ? 'none' : 'block'
62
+ display: (element === null || element === void 0 ? void 0 : (_element_otherProps2 = element.otherProps) === null || _element_otherProps2 === void 0 ? void 0 : _element_otherProps2.isConfig) ? 'none' : 'block'
63
63
  }
64
- }), (element === null || element === void 0 ? void 0 : (_element_otherProps2 = element.otherProps) === null || _element_otherProps2 === void 0 ? void 0 : _element_otherProps2.isConfig) ? '' : DOMPurify.sanitize(element === null || element === void 0 ? void 0 : (_element_value1 = element.value) === null || _element_value1 === void 0 ? void 0 : _element_value1.trim()));
64
+ }), (element === null || element === void 0 ? void 0 : (_element_otherProps3 = element.otherProps) === null || _element_otherProps3 === void 0 ? void 0 : _element_otherProps3.isConfig) ? '' : DOMPurify.sanitize(element === null || element === void 0 ? void 0 : (_element_value1 = element.value) === null || _element_value1 === void 0 ? void 0 : _element_value1.trim()));
65
65
  }
66
+ // 检查代码块是否未闭合
67
+ var isUnclosed = (element === null || element === void 0 ? void 0 : (_element_otherProps = element.otherProps) === null || _element_otherProps === void 0 ? void 0 : _element_otherProps.finish) === false;
66
68
  return /*#__PURE__*/ React.createElement("div", _object_spread_props(_object_spread({}, attributes), {
69
+ "data-is-unclosed": isUnclosed,
70
+ "data-language": element === null || element === void 0 ? void 0 : element.language,
67
71
  style: (element === null || element === void 0 ? void 0 : element.language) === 'html' ? {
68
- display: (element === null || element === void 0 ? void 0 : (_element_otherProps = element.otherProps) === null || _element_otherProps === void 0 ? void 0 : _element_otherProps.isConfig) ? 'none' : 'block'
72
+ display: (element === null || element === void 0 ? void 0 : (_element_otherProps1 = element.otherProps) === null || _element_otherProps1 === void 0 ? void 0 : _element_otherProps1.isConfig) ? 'none' : 'block'
69
73
  } : {
70
74
  height: '240px',
71
75
  minWidth: '398px',
@@ -88,7 +92,8 @@ export var Code = function(param) {
88
92
  wordWrap: 'break-word',
89
93
  borderRadius: '12px',
90
94
  background: '#FFFFFF',
91
- boxShadow: 'var(--shadow-control-base)'
95
+ boxShadow: 'var(--shadow-control-base)',
96
+ position: 'relative'
92
97
  }
93
98
  }), (element === null || element === void 0 ? void 0 : (_element_value = element.value) === null || _element_value === void 0 ? void 0 : _element_value.trim()) || children);
94
99
  };
@@ -248,7 +248,7 @@ function _ts_generator(thisArg, body) {
248
248
  }
249
249
  }
250
250
  import { BlockOutlined, DeleteFilled, ExclamationCircleOutlined, LoadingOutlined } from "@ant-design/icons";
251
- import { Image, Modal, Popover, Space } from "antd";
251
+ import { Image, Modal, Popover, Skeleton, Space } from "antd";
252
252
  import React, { useCallback, useContext, useLayoutEffect, useMemo, useRef } from "react";
253
253
  import { useDebounceFn } from "@ant-design/pro-components";
254
254
  import { Rnd } from "react-rnd";
@@ -315,7 +315,8 @@ import { getMediaType } from "../../utils/dom";
315
315
  })));
316
316
  }
317
317
  return /*#__PURE__*/ React.createElement("div", {
318
- "data-testid": "image-container"
318
+ "data-testid": "image-container",
319
+ "data-be": "image-container"
319
320
  }, /*#__PURE__*/ React.createElement(Image, _object_spread_props(_object_spread({}, props), {
320
321
  width: Number(props.width) || props.width || 400,
321
322
  onError: function() {
@@ -477,7 +478,7 @@ import { getMediaType } from "../../utils/dom";
477
478
  };
478
479
  export function EditorImage(param) {
479
480
  var element = param.element, attributes = param.attributes, children = param.children;
480
- var _state;
481
+ var _state, _element_otherProps;
481
482
  // eslint-disable-next-line @typescript-eslint/no-unused-vars
482
483
  var _useSelStatus = _sliced_to_array(useSelStatus(element), 2), _ = _useSelStatus[0], path = _useSelStatus[1];
483
484
  var _useEditorStore = useEditorStore(), markdownEditorRef = _useEditorStore.markdownEditorRef, readonly = _useEditorStore.readonly;
@@ -550,7 +551,15 @@ export function EditorImage(param) {
550
551
  element === null || element === void 0 ? void 0 : element.url
551
552
  ]);
552
553
  var imageDom = useMemo(function() {
553
- var _state, _state1;
554
+ var _element_otherProps, _state, _state1;
555
+ // 检查是否为不完整的图片(loading 状态)
556
+ var isLoading = (element === null || element === void 0 ? void 0 : element.loading) || (element === null || element === void 0 ? void 0 : (_element_otherProps = element.otherProps) === null || _element_otherProps === void 0 ? void 0 : _element_otherProps.loading);
557
+ if (isLoading) {
558
+ // 显示 loading 状态的占位符
559
+ return /*#__PURE__*/ React.createElement(Skeleton.Image, {
560
+ active: true
561
+ });
562
+ }
554
563
  // 如果图片加载失败,显示为链接
555
564
  if (!state().loadSuccess) {
556
565
  var _state2, _state3;
@@ -622,7 +631,10 @@ export function EditorImage(param) {
622
631
  (_state = state()) === null || _state === void 0 ? void 0 : _state.url,
623
632
  readonly,
624
633
  state().selected,
625
- state().loadSuccess
634
+ state().loadSuccess,
635
+ element === null || element === void 0 ? void 0 : element.loading,
636
+ element === null || element === void 0 ? void 0 : (_element_otherProps = element.otherProps) === null || _element_otherProps === void 0 ? void 0 : _element_otherProps.loading,
637
+ element === null || element === void 0 ? void 0 : element.rawMarkdown
626
638
  ]);
627
639
  return /*#__PURE__*/ React.createElement("div", _object_spread_props(_object_spread({}, attributes), {
628
640
  "data-be": "image",
@@ -224,7 +224,7 @@ function _ts_generator(thisArg, body) {
224
224
  }
225
225
  }
226
226
  import { DeleteFilled, ExclamationCircleOutlined, EyeOutlined, LoadingOutlined } from "@ant-design/icons";
227
- import { Modal, Popover } from "antd";
227
+ import { Modal, Popover, Skeleton } from "antd";
228
228
  import React, { useCallback, useContext, useLayoutEffect, useMemo, useRef } from "react";
229
229
  import { useDebounceFn } from "@ant-design/pro-components";
230
230
  import { Rnd } from "react-rnd";
@@ -379,7 +379,7 @@ import { ImageAndError } from "./Image";
379
379
  };
380
380
  export function Media(param) {
381
381
  var element = param.element, attributes = param.attributes, children = param.children;
382
- var _state, _state1;
382
+ var _state, _element_otherProps, _state1, _element_otherProps1;
383
383
  // eslint-disable-next-line @typescript-eslint/no-unused-vars
384
384
  var _useSelStatus = _sliced_to_array(useSelStatus(element), 2), _ = _useSelStatus[0], path = _useSelStatus[1];
385
385
  var _useEditorStore = useEditorStore(), markdownEditorRef = _useEditorStore.markdownEditorRef, readonly = _useEditorStore.readonly;
@@ -483,8 +483,16 @@ export function Media(param) {
483
483
  element === null || element === void 0 ? void 0 : element.url
484
484
  ]);
485
485
  var imageDom = useMemo(function() {
486
- var _state, _state1;
486
+ var _element_otherProps, _state, _state1;
487
487
  if (state().type !== 'image' && state().type !== 'other') return null;
488
+ // 检查是否为不完整的图片(loading 状态)
489
+ var isLoading = (element === null || element === void 0 ? void 0 : element.loading) || (element === null || element === void 0 ? void 0 : (_element_otherProps = element.otherProps) === null || _element_otherProps === void 0 ? void 0 : _element_otherProps.loading);
490
+ if (isLoading) {
491
+ // 显示 loading 状态的占位符
492
+ return /*#__PURE__*/ React.createElement(Skeleton.Image, {
493
+ active: true
494
+ });
495
+ }
488
496
  return !readonly ? /*#__PURE__*/ React.createElement(ResizeImage, {
489
497
  defaultSize: {
490
498
  width: element.width,
@@ -528,11 +536,24 @@ export function Media(param) {
528
536
  state().type,
529
537
  (_state = state()) === null || _state === void 0 ? void 0 : _state.url,
530
538
  readonly,
531
- state().selected
539
+ state().selected,
540
+ element === null || element === void 0 ? void 0 : element.loading,
541
+ element === null || element === void 0 ? void 0 : (_element_otherProps = element.otherProps) === null || _element_otherProps === void 0 ? void 0 : _element_otherProps.loading,
542
+ element === null || element === void 0 ? void 0 : element.rawMarkdown
532
543
  ]);
533
544
  var mediaElement = useMemo(function() {
545
+ var _element_otherProps, _element_otherProps1;
546
+ // 检查是否为不完整的媒体(loading 状态)
547
+ var isLoading = (element === null || element === void 0 ? void 0 : element.loading) || (element === null || element === void 0 ? void 0 : (_element_otherProps = element.otherProps) === null || _element_otherProps === void 0 ? void 0 : _element_otherProps.loading);
548
+ var rawMarkdown = (element === null || element === void 0 ? void 0 : element.rawMarkdown) || (element === null || element === void 0 ? void 0 : (_element_otherProps1 = element.otherProps) === null || _element_otherProps1 === void 0 ? void 0 : _element_otherProps1.rawMarkdown);
534
549
  if (state().type === 'video') {
535
550
  var _state;
551
+ // 如果是 loading 状态,显示 loading 占位符
552
+ if (isLoading) {
553
+ return /*#__PURE__*/ React.createElement(Skeleton.Image, {
554
+ active: true
555
+ });
556
+ }
536
557
  if (!state().loadSuccess) {
537
558
  var _state1, _state2;
538
559
  return /*#__PURE__*/ React.createElement("a", {
@@ -586,6 +607,34 @@ export function Media(param) {
586
607
  }
587
608
  if (state().type === 'audio') {
588
609
  var _state3;
610
+ // 如果是 loading 状态,显示 loading 占位符
611
+ if (isLoading) {
612
+ return /*#__PURE__*/ React.createElement("div", {
613
+ style: {
614
+ display: 'inline-flex',
615
+ alignItems: 'center',
616
+ gap: '8px',
617
+ padding: '12px 16px',
618
+ border: '1px dashed #d9d9d9',
619
+ borderRadius: '6px',
620
+ backgroundColor: '#fafafa',
621
+ minWidth: '200px',
622
+ justifyContent: 'center'
623
+ }
624
+ }, /*#__PURE__*/ React.createElement(LoadingOutlined, {
625
+ style: {
626
+ color: '#1890ff',
627
+ fontSize: '16px'
628
+ },
629
+ spin: true
630
+ }), /*#__PURE__*/ React.createElement("span", {
631
+ style: {
632
+ color: '#666',
633
+ fontSize: '13px',
634
+ wordBreak: 'break-all'
635
+ }
636
+ }, rawMarkdown || (element === null || element === void 0 ? void 0 : element.alt) || '音频加载中...'));
637
+ }
589
638
  if (!state().loadSuccess) {
590
639
  var _state4, _state5;
591
640
  return /*#__PURE__*/ React.createElement("a", {
@@ -629,7 +678,7 @@ export function Media(param) {
629
678
  }, "Your browser does not support the", /*#__PURE__*/ React.createElement("code", null, "audio"), " element.");
630
679
  }
631
680
  if (state().type === 'attachment') {
632
- var _state6, _element_alt, _element_alt1, _element_otherProps, _element_otherProps_collaborators, _element_otherProps1, _element_otherProps2;
681
+ var _state6, _element_alt, _element_alt1, _element_otherProps2, _element_otherProps_collaborators, _element_otherProps3, _element_otherProps4;
633
682
  return /*#__PURE__*/ React.createElement("div", {
634
683
  style: {
635
684
  padding: 12,
@@ -678,15 +727,15 @@ export function Media(param) {
678
727
  display: 'flex',
679
728
  justifyContent: 'space-between'
680
729
  }
681
- }, ((_element_otherProps = element.otherProps) === null || _element_otherProps === void 0 ? void 0 : _element_otherProps.collaborators) ? /*#__PURE__*/ React.createElement("div", null, /*#__PURE__*/ React.createElement(AvatarList, {
682
- displayList: ((_element_otherProps1 = element.otherProps) === null || _element_otherProps1 === void 0 ? void 0 : (_element_otherProps_collaborators = _element_otherProps1.collaborators) === null || _element_otherProps_collaborators === void 0 ? void 0 : _element_otherProps_collaborators.map(function(item) {
730
+ }, ((_element_otherProps2 = element.otherProps) === null || _element_otherProps2 === void 0 ? void 0 : _element_otherProps2.collaborators) ? /*#__PURE__*/ React.createElement("div", null, /*#__PURE__*/ React.createElement(AvatarList, {
731
+ displayList: ((_element_otherProps3 = element.otherProps) === null || _element_otherProps3 === void 0 ? void 0 : (_element_otherProps_collaborators = _element_otherProps3.collaborators) === null || _element_otherProps_collaborators === void 0 ? void 0 : _element_otherProps_collaborators.map(function(item) {
683
732
  var _Object_keys, _Object_values;
684
733
  return {
685
734
  name: (_Object_keys = Object.keys(item)) === null || _Object_keys === void 0 ? void 0 : _Object_keys.at(0),
686
735
  collaboratorNumber: ((_Object_values = Object.values(item)) === null || _Object_values === void 0 ? void 0 : _Object_values.at(0)) || 0
687
736
  };
688
737
  }).slice(0, 5)) || []
689
- })) : /*#__PURE__*/ React.createElement("div", null), ((_element_otherProps2 = element.otherProps) === null || _element_otherProps2 === void 0 ? void 0 : _element_otherProps2.updateTime) ? /*#__PURE__*/ React.createElement("div", {
738
+ })) : /*#__PURE__*/ React.createElement("div", null), ((_element_otherProps4 = element.otherProps) === null || _element_otherProps4 === void 0 ? void 0 : _element_otherProps4.updateTime) ? /*#__PURE__*/ React.createElement("div", {
690
739
  style: {
691
740
  color: 'rgba(0,0,0,0.45)',
692
741
  fontSize: 12
@@ -711,7 +760,10 @@ export function Media(param) {
711
760
  return null;
712
761
  }, [
713
762
  state().type,
714
- (_state1 = state()) === null || _state1 === void 0 ? void 0 : _state1.url
763
+ (_state1 = state()) === null || _state1 === void 0 ? void 0 : _state1.url,
764
+ element === null || element === void 0 ? void 0 : element.loading,
765
+ element === null || element === void 0 ? void 0 : (_element_otherProps1 = element.otherProps) === null || _element_otherProps1 === void 0 ? void 0 : _element_otherProps1.loading,
766
+ element === null || element === void 0 ? void 0 : element.rawMarkdown
715
767
  ]);
716
768
  return /*#__PURE__*/ React.createElement("div", attributes, /*#__PURE__*/ React.createElement("div", {
717
769
  "data-be": "media",
@@ -64,6 +64,7 @@ import classNames from "classnames";
64
64
  import copy from "copy-to-clipboard";
65
65
  import React, { useCallback, useContext, useMemo, useRef, useState } from "react";
66
66
  import { ActionIconBox } from "../../../../Components/ActionIconBox";
67
+ import { Loading } from "../../../../Components/Loading";
67
68
  import { I18nContext } from "../../../../I18n";
68
69
  import { useEditorStore } from "../../store";
69
70
  import { parserSlateNodeToMarkdown } from "../../utils";
@@ -72,7 +73,7 @@ import { parserSlateNodeToMarkdown } from "../../utils";
72
73
  * 移除了不必要的滚动监听和复杂的宽度计算
73
74
  */ export var ReadonlyTableComponent = /*#__PURE__*/ React.memo(function(param) {
74
75
  var hashId = param.hashId, children = param.children, element = param.element, baseCls = param.baseCls;
75
- var _element_children__children, _element_children_, _element_children, _editorProps_tableConfig;
76
+ var _element_otherProps, _element_children__children, _element_children_, _element_children, _editorProps_tableConfig;
76
77
  var editorProps = useEditorStore().editorProps;
77
78
  var getPrefixCls = useContext(ConfigProvider.ConfigContext).getPrefixCls;
78
79
  var _ref = (editorProps === null || editorProps === void 0 ? void 0 : editorProps.tableConfig) || {}, _ref_actions = _ref.actions, actions = _ref_actions === void 0 ? {
@@ -84,6 +85,8 @@ import { parserSlateNodeToMarkdown } from "../../utils";
84
85
  var modelTargetRef = useRef(null);
85
86
  var _useState = _sliced_to_array(useState(false), 2), previewOpen = _useState[0], setPreviewOpen = _useState[1];
86
87
  var i18n = useContext(I18nContext);
88
+ // 检查表格是否未闭合
89
+ var isUnclosed = (element === null || element === void 0 ? void 0 : (_element_otherProps = element.otherProps) === null || _element_otherProps === void 0 ? void 0 : _element_otherProps.finish) === false;
87
90
  // 简化的列宽计算 - 只为 readonly 模式设计
88
91
  var colWidths = useMemo(function() {
89
92
  var _element_children__children, _element_children_, _element_children;
@@ -190,9 +193,18 @@ import { parserSlateNodeToMarkdown } from "../../utils";
190
193
  className: classNames(baseCls, hashId),
191
194
  style: {
192
195
  flex: 1,
193
- minWidth: 0
196
+ minWidth: 0,
197
+ position: 'relative'
198
+ },
199
+ "data-is-unclosed": isUnclosed
200
+ }, isUnclosed && /*#__PURE__*/ React.createElement("div", {
201
+ style: {
202
+ position: 'absolute',
203
+ top: '8px',
204
+ right: '8px',
205
+ zIndex: 10
194
206
  }
195
- }, tableDom, popoverContent), previewOpen && /*#__PURE__*/ React.createElement(Modal, {
207
+ }, /*#__PURE__*/ React.createElement(Loading, null)), tableDom, popoverContent), previewOpen && /*#__PURE__*/ React.createElement(Modal, {
196
208
  title: (editorProps === null || editorProps === void 0 ? void 0 : (_editorProps_tableConfig = editorProps.tableConfig) === null || _editorProps_tableConfig === void 0 ? void 0 : _editorProps_tableConfig.previewTitle) || '预览表格',
197
209
  open: previewOpen,
198
210
  closable: true,
@@ -54,6 +54,7 @@ import { ConfigProvider } from "antd";
54
54
  import classNames from "classnames";
55
55
  import React, { useContext, useMemo } from "react";
56
56
  import { ReactEditor, useSlate } from "slate-react";
57
+ import { Loading } from "../../../../Components/Loading";
57
58
  import { useTableStyle } from "./style";
58
59
  import { SlateTable } from "./Table";
59
60
  import { TablePropsProvider } from "./TableContext";
@@ -61,6 +62,7 @@ import { TablePropsProvider } from "./TableContext";
61
62
  * 简单表格组件 - 仅支持只读显示
62
63
  * 用于替代复杂的 Handsontable 实现,提供基础的表格功能
63
64
  */ export var SimpleTable = function(props) {
65
+ var _props_element_otherProps, _props_element;
64
66
  var getPrefixCls = useContext(ConfigProvider.ConfigContext).getPrefixCls;
65
67
  var baseCls = getPrefixCls('agentic-md-editor-content-table');
66
68
  var editor = useSlate();
@@ -70,14 +72,27 @@ import { TablePropsProvider } from "./TableContext";
70
72
  }, [
71
73
  props.element
72
74
  ]);
75
+ // 检查表格是否未闭合
76
+ var isUnclosed = ((_props_element = props.element) === null || _props_element === void 0 ? void 0 : (_props_element_otherProps = _props_element.otherProps) === null || _props_element_otherProps === void 0 ? void 0 : _props_element_otherProps.finish) === false;
73
77
  return wrapSSR(/*#__PURE__*/ React.createElement(TablePropsProvider, {
74
78
  tablePath: tablePath,
75
79
  tableNode: props.element
76
80
  }, /*#__PURE__*/ React.createElement("div", _object_spread_props(_object_spread({}, props.attributes), {
77
81
  "data-be": 'table',
82
+ "data-is-unclosed": isUnclosed,
78
83
  draggable: false,
79
- className: classNames("".concat(baseCls, "-container"), hashId)
80
- }), /*#__PURE__*/ React.createElement(SlateTable, _object_spread_props(_object_spread({}, props), {
84
+ className: classNames("".concat(baseCls, "-container"), hashId),
85
+ style: {
86
+ position: 'relative'
87
+ }
88
+ }), isUnclosed && /*#__PURE__*/ React.createElement("div", {
89
+ style: {
90
+ position: 'absolute',
91
+ top: '8px',
92
+ right: '8px',
93
+ zIndex: 10
94
+ }
95
+ }, /*#__PURE__*/ React.createElement(Loading, null)), /*#__PURE__*/ React.createElement(SlateTable, _object_spread_props(_object_spread({}, props), {
81
96
  hashId: hashId
82
97
  }), props.children))));
83
98
  };
@@ -9,6 +9,19 @@ function _array_with_holes(arr) {
9
9
  function _array_without_holes(arr) {
10
10
  if (Array.isArray(arr)) return _array_like_to_array(arr);
11
11
  }
12
+ function _define_property(obj, key, value) {
13
+ if (key in obj) {
14
+ Object.defineProperty(obj, key, {
15
+ value: value,
16
+ enumerable: true,
17
+ configurable: true,
18
+ writable: true
19
+ });
20
+ } else {
21
+ obj[key] = value;
22
+ }
23
+ return obj;
24
+ }
12
25
  function _iterable_to_array(iter) {
13
26
  if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter);
14
27
  }
@@ -42,6 +55,45 @@ function _non_iterable_rest() {
42
55
  function _non_iterable_spread() {
43
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.");
44
57
  }
58
+ function _object_spread(target) {
59
+ for(var i = 1; i < arguments.length; i++){
60
+ var source = arguments[i] != null ? arguments[i] : {};
61
+ var ownKeys = Object.keys(source);
62
+ if (typeof Object.getOwnPropertySymbols === "function") {
63
+ ownKeys = ownKeys.concat(Object.getOwnPropertySymbols(source).filter(function(sym) {
64
+ return Object.getOwnPropertyDescriptor(source, sym).enumerable;
65
+ }));
66
+ }
67
+ ownKeys.forEach(function(key) {
68
+ _define_property(target, key, source[key]);
69
+ });
70
+ }
71
+ return target;
72
+ }
73
+ function ownKeys(object, enumerableOnly) {
74
+ var keys = Object.keys(object);
75
+ if (Object.getOwnPropertySymbols) {
76
+ var symbols = Object.getOwnPropertySymbols(object);
77
+ if (enumerableOnly) {
78
+ symbols = symbols.filter(function(sym) {
79
+ return Object.getOwnPropertyDescriptor(object, sym).enumerable;
80
+ });
81
+ }
82
+ keys.push.apply(keys, symbols);
83
+ }
84
+ return keys;
85
+ }
86
+ function _object_spread_props(target, source) {
87
+ source = source != null ? source : {};
88
+ if (Object.getOwnPropertyDescriptors) {
89
+ Object.defineProperties(target, Object.getOwnPropertyDescriptors(source));
90
+ } else {
91
+ ownKeys(Object(source)).forEach(function(key) {
92
+ Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key));
93
+ });
94
+ }
95
+ return target;
96
+ }
45
97
  function _object_without_properties(source, excluded) {
46
98
  if (source == null) return {};
47
99
  var target = _object_without_properties_loose(source, excluded);
@@ -88,7 +140,9 @@ import classNames from "classnames";
88
140
  import React, { useContext, useEffect, useMemo, useRef } from "react";
89
141
  import { Node } from "slate";
90
142
  import stringWidth from "string-width";
143
+ import { Loading } from "../../../../Components/Loading";
91
144
  import { MOBILE_BREAKPOINT, MOBILE_TABLE_MIN_COLUMN_WIDTH } from "../../../../Constants/mobile";
145
+ import { useMEditor } from "../../../hooks/editor";
92
146
  import { useEditorStore } from "../../store";
93
147
  import { ReadonlyTableComponent } from "./ReadonlyTableComponent";
94
148
  import { TablePropsContext } from "./TableContext";
@@ -124,8 +178,8 @@ import useScrollShadow from "./useScrollShadow";
124
178
  "hashId",
125
179
  "children"
126
180
  ]);
127
- var _props_element_children__children, _props_element_children_, _props_element_children, _props_element, _props_element_otherProps, _props_element1, _props_element_children1, _props_element2;
128
- var _useEditorStore = useEditorStore(), readonly = _useEditorStore.readonly, markdownContainerRef = _useEditorStore.markdownContainerRef;
181
+ var _props_element_children__children, _props_element_children_, _props_element_children, _props_element, _props_element_otherProps, _props_element1, _props_element_children1, _props_element2, _props_element_otherProps1, _props_element3;
182
+ var _useEditorStore = useEditorStore(), readonly = _useEditorStore.readonly, markdownContainerRef = _useEditorStore.markdownContainerRef, store = _useEditorStore.store;
129
183
  var getPrefixCls = useContext(ConfigProvider.ConfigContext).getPrefixCls;
130
184
  var tablePath = useContext(TablePropsContext).tablePath;
131
185
  var baseCls = getPrefixCls('agentic-md-editor-content-table');
@@ -288,7 +342,69 @@ import useScrollShadow from "./useScrollShadow";
288
342
  scrollState,
289
343
  readonly
290
344
  ]);
291
- // readonly 模式渲染 - 使用优化的组件
345
+ // 检查表格是否未闭合
346
+ var isUnclosed = ((_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.finish) === false;
347
+ // 获取编辑器更新函数 - 必须在早期返回之前调用 hooks
348
+ var _useMEditor = _sliced_to_array(useMEditor(props.element), 2), update = _useMEditor[1];
349
+ // 判断是否是最后一个节点 - 必须在早期返回之前调用 hooks
350
+ var isLastNode = useMemo(function() {
351
+ try {
352
+ return store.isLatestNode(props.element);
353
+ } catch (e) {
354
+ return false;
355
+ }
356
+ }, [
357
+ store,
358
+ props.element
359
+ ]);
360
+ // 如果不是最后一个节点,且未闭合,立即设置为完成 - 必须在早期返回之前调用 hooks
361
+ useEffect(function() {
362
+ if (isUnclosed && !readonly && !isLastNode) {
363
+ var _props_element_otherProps, _props_element;
364
+ // 检查 finish 是否仍然是 false(可能已经被其他逻辑更新)
365
+ if (((_props_element = props.element) === null || _props_element === void 0 ? void 0 : (_props_element_otherProps = _props_element.otherProps) === null || _props_element_otherProps === void 0 ? void 0 : _props_element_otherProps.finish) === false) {
366
+ var _props_element1;
367
+ update({
368
+ otherProps: _object_spread_props(_object_spread({}, (_props_element1 = props.element) === null || _props_element1 === void 0 ? void 0 : _props_element1.otherProps), {
369
+ finish: true
370
+ })
371
+ }, props.element);
372
+ }
373
+ }
374
+ }, [
375
+ isUnclosed,
376
+ readonly,
377
+ isLastNode,
378
+ props.element,
379
+ update
380
+ ]);
381
+ // 5 秒超时机制:如果是最后一个节点且未闭合,5 秒后自动设置为完成 - 必须在早期返回之前调用 hooks
382
+ useEffect(function() {
383
+ if (isUnclosed && !readonly && isLastNode) {
384
+ var timer = setTimeout(function() {
385
+ var _props_element_otherProps, _props_element;
386
+ // 检查 finish 是否仍然是 false(可能已经被其他逻辑更新)
387
+ if (((_props_element = props.element) === null || _props_element === void 0 ? void 0 : (_props_element_otherProps = _props_element.otherProps) === null || _props_element_otherProps === void 0 ? void 0 : _props_element_otherProps.finish) === false) {
388
+ var _props_element1;
389
+ update({
390
+ otherProps: _object_spread_props(_object_spread({}, (_props_element1 = props.element) === null || _props_element1 === void 0 ? void 0 : _props_element1.otherProps), {
391
+ finish: true
392
+ })
393
+ }, props.element);
394
+ }
395
+ }, 5000); // 5 秒超时
396
+ return function() {
397
+ clearTimeout(timer);
398
+ };
399
+ }
400
+ }, [
401
+ isUnclosed,
402
+ readonly,
403
+ isLastNode,
404
+ props.element,
405
+ update
406
+ ]);
407
+ // readonly 模式渲染 - 使用优化的组件(早期返回)
292
408
  if (readonly) {
293
409
  return /*#__PURE__*/ React.createElement(ReadonlyTableComponent, {
294
410
  hashId: hashId,
@@ -300,7 +416,10 @@ import useScrollShadow from "./useScrollShadow";
300
416
  return /*#__PURE__*/ React.createElement("div", {
301
417
  className: classNames(baseCls, hashId),
302
418
  ref: tableRef,
303
- style: boxShadowStyle,
419
+ style: _object_spread_props(_object_spread({}, boxShadowStyle), {
420
+ position: 'relative'
421
+ }),
422
+ "data-is-unclosed": isUnclosed,
304
423
  onDragStart: function(e) {
305
424
  // 阻止拖拽开始时的文字选择
306
425
  e.preventDefault();
@@ -309,5 +428,12 @@ import useScrollShadow from "./useScrollShadow";
309
428
  // 阻止双击选择文字
310
429
  e.preventDefault();
311
430
  }
312
- }, tableDom);
431
+ }, isUnclosed && /*#__PURE__*/ React.createElement("div", {
432
+ style: {
433
+ position: 'absolute',
434
+ top: '8px',
435
+ right: '8px',
436
+ zIndex: 10
437
+ }
438
+ }, /*#__PURE__*/ React.createElement(Loading, null)), tableDom);
313
439
  };
@@ -5,17 +5,116 @@
5
5
  import { Elements } from '../../el';
6
6
  import { MarkdownEditorPlugin } from '../../plugin';
7
7
  export declare const decodeURIComponentUrl: (url: string) => string;
8
+ /**
9
+ * 解析Markdown字符串的配置选项
10
+ */
11
+ export interface ParserMarkdownToSlateNodeConfig {
12
+ /** 是否在新标签页打开链接 */
13
+ openLinksInNewTab?: boolean;
14
+ /** 自定义段落标签(在 Slate 中可能不适用,保留用于兼容性) */
15
+ paragraphTag?: string;
16
+ /** 是否正在输入中(打字机模式) */
17
+ typing?: boolean;
18
+ }
19
+ /**
20
+ * Markdown 到 Slate 节点解析器类
21
+ *
22
+ * 将 Markdown 字符串解析为 Slate 编辑器节点,支持配置选项和插件。
23
+ * 使用类形式可以避免在函数调用链中传递配置参数和插件。
24
+ */
25
+ export declare class MarkdownToSlateParser {
26
+ private readonly config;
27
+ private readonly plugins;
28
+ constructor(config?: ParserMarkdownToSlateNodeConfig, plugins?: MarkdownEditorPlugin[]);
29
+ /**
30
+ * 解析 Markdown 字符串并返回解析后的结构和链接信息
31
+ *
32
+ * @param md - 要解析的 Markdown 字符串
33
+ * @returns 一个包含解析后的元素数组和链接信息的对象
34
+ */
35
+ parse(md: string): {
36
+ schema: Elements[];
37
+ links: {
38
+ path: number[];
39
+ target: string;
40
+ }[];
41
+ };
42
+ /**
43
+ * 解析 Markdown AST 节点为 Slate 节点(类方法版本)
44
+ * - 当有插件时,优先使用插件处理
45
+ * - 插件未处理时,使用默认处理逻辑
46
+ */
47
+ private parseNodes;
48
+ /**
49
+ * 处理单个元素(类方法版本)
50
+ */
51
+ private handleSingleElement;
52
+ /**
53
+ * 处理标题节点(类方法版本)
54
+ */
55
+ private handleHeading;
56
+ /**
57
+ * 处理列表节点(类方法版本)
58
+ */
59
+ private handleList;
60
+ /**
61
+ * 处理脚注定义节点(类方法版本)
62
+ */
63
+ private handleFootnoteDefinition;
64
+ /**
65
+ * 处理列表项节点(类方法版本)
66
+ */
67
+ private handleListItem;
68
+ /**
69
+ * 处理段落子节点(类方法版本)
70
+ */
71
+ private processParagraphChildren;
72
+ /**
73
+ * 处理段落节点(类方法版本)
74
+ */
75
+ private handleParagraph;
76
+ /**
77
+ * 处理引用块节点(类方法版本)
78
+ */
79
+ private handleBlockquote;
80
+ /**
81
+ * 处理文本和内联元素节点(类方法版本)
82
+ */
83
+ private handleTextAndInlineElements;
84
+ /**
85
+ * 应用内联格式到叶子节点(类方法版本)
86
+ */
87
+ private applyInlineFormatting;
88
+ /**
89
+ * 解析表格或图表(类方法版本)
90
+ */
91
+ private parseTableOrChart;
92
+ }
8
93
  /**
9
94
  * 解析Markdown字符串并返回解析后的结构和链接信息。
10
95
  *
11
96
  * @param md - 要解析的Markdown字符串。
12
97
  * @param plugins - 可选的Markdown编辑器插件数组,用于扩展解析功能。
98
+ * @param config - 可选的解析配置选项。
13
99
  * @returns 一个包含解析后的元素数组和链接信息的对象。
14
100
  *
15
101
  * @property schema - 解析后的元素数组。
16
102
  * @property links - 包含路径和目标链接的对象数组。
103
+ *
104
+ * @example
105
+ * ```typescript
106
+ * // 使用函数形式(向后兼容)
107
+ * const result = parserMarkdownToSlateNode(markdown, plugins, { openLinksInNewTab: true });
108
+ *
109
+ * // 使用类形式(推荐,避免配置传递问题)
110
+ * const parser = new MarkdownToSlateParser(
111
+ * { openLinksInNewTab: true },
112
+ * plugins
113
+ * );
114
+ * const result = parser.parse(markdown);
115
+ * ```
17
116
  */
18
- export declare const parserMarkdownToSlateNode: (md: string, plugins?: MarkdownEditorPlugin[]) => {
117
+ export declare const parserMarkdownToSlateNode: (md: string, plugins?: MarkdownEditorPlugin[], config?: ParserMarkdownToSlateNodeConfig) => {
19
118
  schema: Elements[];
20
119
  links: {
21
120
  path: number[];