@ant-design/agentic-ui 2.28.0 → 2.28.2
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.
- package/dist/MarkdownEditor/editor/elements/CommentLeaf/index.d.ts +11 -0
- package/dist/MarkdownEditor/editor/elements/CommentLeaf/index.js +69 -0
- package/dist/MarkdownEditor/editor/elements/FncLeaf/index.d.ts +15 -0
- package/dist/MarkdownEditor/editor/elements/FncLeaf/index.js +208 -0
- package/dist/MarkdownEditor/editor/elements/Paragraph/index.js +2 -2
- package/dist/MarkdownEditor/editor/elements/Table/SimpleTable.js +43 -88
- package/dist/MarkdownEditor/editor/elements/index.d.ts +12 -0
- package/dist/MarkdownEditor/editor/elements/index.js +44 -102
- package/dist/MarkdownEditor/editor/parser/parse/parseTable.js +9 -2
- package/dist/MarkdownEditor/editor/plugins/useHighlight.js +160 -186
- package/dist/Plugins/chart/AreaChart/index.js +3 -0
- package/dist/Plugins/chart/BarChart/index.js +3 -0
- package/dist/Plugins/chart/DonutChart/index.js +1 -1
- package/dist/Plugins/chart/FunnelChart/index.js +3 -0
- package/dist/Plugins/chart/LineChart/index.js +3 -0
- package/dist/Plugins/chart/RadarChart/index.js +3 -0
- package/dist/Plugins/chart/ScatterChart/index.js +3 -0
- package/dist/Plugins/code/components/ThinkBlock.js +66 -5
- package/package.json +1 -1
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { RenderLeafProps } from 'slate-react';
|
|
3
|
+
import { MarkdownEditorProps } from '../../../types';
|
|
4
|
+
interface CommentLeafProps {
|
|
5
|
+
children: React.ReactNode;
|
|
6
|
+
leaf: RenderLeafProps['leaf'];
|
|
7
|
+
hashId: string;
|
|
8
|
+
comment: MarkdownEditorProps['comment'];
|
|
9
|
+
}
|
|
10
|
+
export declare const CommentLeaf: React.MemoExoticComponent<({ children, leaf, hashId, comment, }: CommentLeafProps) => React.JSX.Element>;
|
|
11
|
+
export {};
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
import React, { useMemo } from "react";
|
|
2
|
+
import { debugInfo } from "../../../../Utils/debugUtils";
|
|
3
|
+
import { useEditorStore } from "../../store";
|
|
4
|
+
import { CommentView } from "../Comment";
|
|
5
|
+
/**
|
|
6
|
+
* 比较函数,用于优化 CommentLeaf 组件的渲染性能
|
|
7
|
+
*/ var areCommentLeafPropsEqual = function(prevProps, nextProps) {
|
|
8
|
+
// 首先进行快速引用比较
|
|
9
|
+
if (prevProps.leaf === nextProps.leaf && prevProps.children === nextProps.children && prevProps.hashId === nextProps.hashId && prevProps.comment === nextProps.comment) {
|
|
10
|
+
return true;
|
|
11
|
+
}
|
|
12
|
+
// 比较基本 props
|
|
13
|
+
if (prevProps.hashId !== nextProps.hashId || prevProps.children !== nextProps.children || prevProps.comment !== nextProps.comment) {
|
|
14
|
+
return false;
|
|
15
|
+
}
|
|
16
|
+
// 比较 leaf 对象的关键属性
|
|
17
|
+
if (prevProps.leaf !== nextProps.leaf) {
|
|
18
|
+
var prevLeaf = prevProps.leaf;
|
|
19
|
+
var nextLeaf = nextProps.leaf;
|
|
20
|
+
// 比较 comment 相关的关键属性
|
|
21
|
+
if (prevLeaf.comment !== nextLeaf.comment || prevLeaf.id !== nextLeaf.id || prevLeaf.selection !== nextLeaf.selection || prevLeaf.data !== nextLeaf.data) {
|
|
22
|
+
return false;
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
return true;
|
|
26
|
+
};
|
|
27
|
+
/**
|
|
28
|
+
* CommentLeaf 组件:专门处理 comment(评论)类型的叶子节点
|
|
29
|
+
* 这是一个包装器组件,用于包裹需要显示评论的 DOM 元素
|
|
30
|
+
*/ var CommentLeafComponent = function(param) {
|
|
31
|
+
var children = param.children, leaf = param.leaf, hashId = param.hashId, comment = param.comment;
|
|
32
|
+
var setShowComment = useEditorStore().setShowComment;
|
|
33
|
+
// 使用 useMemo 优化计算逻辑(必须在所有条件返回之前调用)
|
|
34
|
+
var commentId = useMemo(function() {
|
|
35
|
+
return "comment-".concat(leaf === null || leaf === void 0 ? void 0 : leaf.id);
|
|
36
|
+
}, [
|
|
37
|
+
leaf === null || leaf === void 0 ? void 0 : leaf.id
|
|
38
|
+
]);
|
|
39
|
+
var commentItem = useMemo(function() {
|
|
40
|
+
return (leaf === null || leaf === void 0 ? void 0 : leaf.comment) ? leaf.data : null;
|
|
41
|
+
}, [
|
|
42
|
+
leaf === null || leaf === void 0 ? void 0 : leaf.comment,
|
|
43
|
+
leaf === null || leaf === void 0 ? void 0 : leaf.data
|
|
44
|
+
]);
|
|
45
|
+
debugInfo('CommentLeaf - 渲染评论节点', {
|
|
46
|
+
hasComment: !!leaf.comment,
|
|
47
|
+
commentId: leaf === null || leaf === void 0 ? void 0 : leaf.id
|
|
48
|
+
});
|
|
49
|
+
// 如果没有评论,直接返回子元素
|
|
50
|
+
if (!leaf.comment) {
|
|
51
|
+
debugInfo('CommentLeaf - 无评论,直接返回子元素');
|
|
52
|
+
return /*#__PURE__*/ React.createElement(React.Fragment, null, children);
|
|
53
|
+
}
|
|
54
|
+
debugInfo('CommentLeaf - 返回带评论的 DOM', {
|
|
55
|
+
commentId: leaf === null || leaf === void 0 ? void 0 : leaf.id,
|
|
56
|
+
hasCommentItem: !!(leaf === null || leaf === void 0 ? void 0 : leaf.comment)
|
|
57
|
+
});
|
|
58
|
+
// 如果有评论,用 CommentView 包裹
|
|
59
|
+
return /*#__PURE__*/ React.createElement(CommentView, {
|
|
60
|
+
id: commentId,
|
|
61
|
+
comment: comment,
|
|
62
|
+
hashId: hashId,
|
|
63
|
+
selection: leaf === null || leaf === void 0 ? void 0 : leaf.selection,
|
|
64
|
+
commentItem: commentItem,
|
|
65
|
+
setShowComment: setShowComment
|
|
66
|
+
}, children);
|
|
67
|
+
};
|
|
68
|
+
// 使用 React.memo 优化 CommentLeaf 组件的性能
|
|
69
|
+
export var CommentLeaf = /*#__PURE__*/ React.memo(CommentLeafComponent, areCommentLeafPropsEqual);
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import React, { CSSProperties } from 'react';
|
|
2
|
+
import { RenderLeafProps } from 'slate-react';
|
|
3
|
+
import { MarkdownEditorProps } from '../../../types';
|
|
4
|
+
interface FncLeafProps extends RenderLeafProps {
|
|
5
|
+
hashId: string;
|
|
6
|
+
fncProps: MarkdownEditorProps['fncProps'];
|
|
7
|
+
linkConfig?: MarkdownEditorProps['linkConfig'];
|
|
8
|
+
style?: CSSProperties;
|
|
9
|
+
prefixClassName?: string;
|
|
10
|
+
}
|
|
11
|
+
/**
|
|
12
|
+
* FncLeaf 组件:专门处理 fnc(函数调用)和 fnd(函数定义)类型的叶子节点
|
|
13
|
+
*/
|
|
14
|
+
export declare const FncLeaf: ({ attributes, children, leaf, hashId, fncProps, linkConfig, style, prefixClassName, }: FncLeafProps) => React.JSX.Element;
|
|
15
|
+
export {};
|
|
@@ -0,0 +1,208 @@
|
|
|
1
|
+
function _define_property(obj, key, value) {
|
|
2
|
+
if (key in obj) {
|
|
3
|
+
Object.defineProperty(obj, key, {
|
|
4
|
+
value: value,
|
|
5
|
+
enumerable: true,
|
|
6
|
+
configurable: true,
|
|
7
|
+
writable: true
|
|
8
|
+
});
|
|
9
|
+
} else {
|
|
10
|
+
obj[key] = value;
|
|
11
|
+
}
|
|
12
|
+
return obj;
|
|
13
|
+
}
|
|
14
|
+
function _object_spread(target) {
|
|
15
|
+
for(var i = 1; i < arguments.length; i++){
|
|
16
|
+
var source = arguments[i] != null ? arguments[i] : {};
|
|
17
|
+
var ownKeys = Object.keys(source);
|
|
18
|
+
if (typeof Object.getOwnPropertySymbols === "function") {
|
|
19
|
+
ownKeys = ownKeys.concat(Object.getOwnPropertySymbols(source).filter(function(sym) {
|
|
20
|
+
return Object.getOwnPropertyDescriptor(source, sym).enumerable;
|
|
21
|
+
}));
|
|
22
|
+
}
|
|
23
|
+
ownKeys.forEach(function(key) {
|
|
24
|
+
_define_property(target, key, source[key]);
|
|
25
|
+
});
|
|
26
|
+
}
|
|
27
|
+
return target;
|
|
28
|
+
}
|
|
29
|
+
function ownKeys(object, enumerableOnly) {
|
|
30
|
+
var keys = Object.keys(object);
|
|
31
|
+
if (Object.getOwnPropertySymbols) {
|
|
32
|
+
var symbols = Object.getOwnPropertySymbols(object);
|
|
33
|
+
if (enumerableOnly) {
|
|
34
|
+
symbols = symbols.filter(function(sym) {
|
|
35
|
+
return Object.getOwnPropertyDescriptor(object, sym).enumerable;
|
|
36
|
+
});
|
|
37
|
+
}
|
|
38
|
+
keys.push.apply(keys, symbols);
|
|
39
|
+
}
|
|
40
|
+
return keys;
|
|
41
|
+
}
|
|
42
|
+
function _object_spread_props(target, source) {
|
|
43
|
+
source = source != null ? source : {};
|
|
44
|
+
if (Object.getOwnPropertyDescriptors) {
|
|
45
|
+
Object.defineProperties(target, Object.getOwnPropertyDescriptors(source));
|
|
46
|
+
} else {
|
|
47
|
+
ownKeys(Object(source)).forEach(function(key) {
|
|
48
|
+
Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key));
|
|
49
|
+
});
|
|
50
|
+
}
|
|
51
|
+
return target;
|
|
52
|
+
}
|
|
53
|
+
import { ConfigProvider } from "antd";
|
|
54
|
+
import classNames from "classnames";
|
|
55
|
+
import React, { useCallback, useContext, useMemo } from "react";
|
|
56
|
+
import { isMobileDevice } from "../../../../MarkdownInputField/AttachmentButton/utils";
|
|
57
|
+
import { debugInfo } from "../../../../Utils/debugUtils";
|
|
58
|
+
import { dragStart } from "../index";
|
|
59
|
+
/**
|
|
60
|
+
* FncLeaf 组件:专门处理 fnc(函数调用)和 fnd(函数定义)类型的叶子节点
|
|
61
|
+
*/ export var FncLeaf = function(param) {
|
|
62
|
+
var attributes = param.attributes, children = param.children, leaf = param.leaf, hashId = param.hashId, fncProps = param.fncProps, linkConfig = param.linkConfig, _param_style = param.style, style = _param_style === void 0 ? {} : _param_style, _param_prefixClassName = param.prefixClassName, prefixClassName = _param_prefixClassName === void 0 ? '' : _param_prefixClassName;
|
|
63
|
+
var _leaf_text;
|
|
64
|
+
var context = useContext(ConfigProvider.ConfigContext);
|
|
65
|
+
var mdEditorBaseClass = context === null || context === void 0 ? void 0 : context.getPrefixCls('agentic-md-editor-content');
|
|
66
|
+
var isMobile = isMobileDevice();
|
|
67
|
+
var hasFnc = leaf.fnc || leaf.identifier;
|
|
68
|
+
debugInfo('FncLeaf - 渲染 fnc 节点', {
|
|
69
|
+
hasFnc: !!leaf.fnc,
|
|
70
|
+
hasIdentifier: !!leaf.identifier,
|
|
71
|
+
hasFnd: !!leaf.fnd,
|
|
72
|
+
text: (_leaf_text = leaf.text) === null || _leaf_text === void 0 ? void 0 : _leaf_text.substring(0, 50)
|
|
73
|
+
});
|
|
74
|
+
// 使用 useMemo 优化 className 计算
|
|
75
|
+
var fncClassName = useMemo(function() {
|
|
76
|
+
var _obj;
|
|
77
|
+
return classNames(prefixClassName === null || prefixClassName === void 0 ? void 0 : prefixClassName.trim(), hashId, (_obj = {}, _define_property(_obj, "".concat(mdEditorBaseClass, "-fnc"), leaf.fnc), _define_property(_obj, "".concat(mdEditorBaseClass, "-fnd"), leaf.fnd), _obj));
|
|
78
|
+
}, [
|
|
79
|
+
prefixClassName,
|
|
80
|
+
hashId,
|
|
81
|
+
mdEditorBaseClass,
|
|
82
|
+
leaf.fnc,
|
|
83
|
+
leaf.fnd
|
|
84
|
+
]);
|
|
85
|
+
// 使用 useMemo 优化文本格式化计算
|
|
86
|
+
var formattedText = useMemo(function() {
|
|
87
|
+
if (leaf.fnc || leaf.identifier) {
|
|
88
|
+
var _leaf_text_replaceAll_replaceAll, _leaf_text_replaceAll, _leaf_text;
|
|
89
|
+
return ((_leaf_text = leaf.text) === null || _leaf_text === void 0 ? void 0 : (_leaf_text_replaceAll = _leaf_text.replaceAll(']', '')) === null || _leaf_text_replaceAll === void 0 ? void 0 : (_leaf_text_replaceAll_replaceAll = _leaf_text_replaceAll.replaceAll('[^DOC_', '')) === null || _leaf_text_replaceAll_replaceAll === void 0 ? void 0 : _leaf_text_replaceAll_replaceAll.replaceAll('[^', '')) || '';
|
|
90
|
+
}
|
|
91
|
+
return children;
|
|
92
|
+
}, [
|
|
93
|
+
leaf.fnc,
|
|
94
|
+
leaf.identifier,
|
|
95
|
+
leaf.text,
|
|
96
|
+
children
|
|
97
|
+
]);
|
|
98
|
+
// 使用 useMemo 优化 data-fnc-name 和 data-fnd-name 计算
|
|
99
|
+
var dataFncName = useMemo(function() {
|
|
100
|
+
var _leaf_text;
|
|
101
|
+
return leaf.fnc ? (_leaf_text = leaf.text) === null || _leaf_text === void 0 ? void 0 : _leaf_text.replace(/\[\^(.+)]:?/g, '$1') : undefined;
|
|
102
|
+
}, [
|
|
103
|
+
leaf.fnc,
|
|
104
|
+
leaf.text
|
|
105
|
+
]);
|
|
106
|
+
var dataFndName = useMemo(function() {
|
|
107
|
+
var _leaf_text;
|
|
108
|
+
return leaf.fnd ? (_leaf_text = leaf.text) === null || _leaf_text === void 0 ? void 0 : _leaf_text.replace(/\[\^(.+)]:?/g, '$1') : undefined;
|
|
109
|
+
}, [
|
|
110
|
+
leaf.fnd,
|
|
111
|
+
leaf.text
|
|
112
|
+
]);
|
|
113
|
+
// 使用 useMemo 优化 style 对象
|
|
114
|
+
var mergedStyle = useMemo(function() {
|
|
115
|
+
return _object_spread({
|
|
116
|
+
fontSize: leaf.fnc ? 10 : undefined
|
|
117
|
+
}, style);
|
|
118
|
+
}, [
|
|
119
|
+
leaf.fnc,
|
|
120
|
+
style
|
|
121
|
+
]);
|
|
122
|
+
// 使用 useCallback 优化 onClick 处理函数
|
|
123
|
+
var handleClick = useCallback(function(e) {
|
|
124
|
+
debugInfo('FncLeaf - onClick 事件', {
|
|
125
|
+
isMobile: isMobile,
|
|
126
|
+
hasFnc: hasFnc,
|
|
127
|
+
detail: e.detail,
|
|
128
|
+
hasUrl: !!leaf.url
|
|
129
|
+
});
|
|
130
|
+
// 在手机上,如果是 fnc,阻止点击事件(使用长按代替)
|
|
131
|
+
if (isMobile && hasFnc) {
|
|
132
|
+
debugInfo('FncLeaf - 移动端阻止 fnc 点击');
|
|
133
|
+
e.preventDefault();
|
|
134
|
+
return;
|
|
135
|
+
}
|
|
136
|
+
if (hasFnc) {
|
|
137
|
+
e.preventDefault();
|
|
138
|
+
e.stopPropagation();
|
|
139
|
+
if (fncProps === null || fncProps === void 0 ? void 0 : fncProps.onOriginUrlClick) {
|
|
140
|
+
debugInfo('FncLeaf - 触发 fnc 点击');
|
|
141
|
+
fncProps.onOriginUrlClick(leaf === null || leaf === void 0 ? void 0 : leaf.identifier);
|
|
142
|
+
}
|
|
143
|
+
// 如果同时有 URL,也要处理 URL 打开逻辑
|
|
144
|
+
if (leaf.url) {
|
|
145
|
+
if (linkConfig === null || linkConfig === void 0 ? void 0 : linkConfig.onClick) {
|
|
146
|
+
var res = linkConfig.onClick(leaf.url);
|
|
147
|
+
debugInfo('FncLeaf - 链接点击处理', {
|
|
148
|
+
result: res
|
|
149
|
+
});
|
|
150
|
+
if (res === false) {
|
|
151
|
+
return false;
|
|
152
|
+
}
|
|
153
|
+
}
|
|
154
|
+
if ((linkConfig === null || linkConfig === void 0 ? void 0 : linkConfig.openInNewTab) !== false) {
|
|
155
|
+
debugInfo('FncLeaf - 新标签页打开链接', {
|
|
156
|
+
url: leaf.url
|
|
157
|
+
});
|
|
158
|
+
window.open(leaf.url, '_blank');
|
|
159
|
+
} else {
|
|
160
|
+
debugInfo('FncLeaf - 当前窗口打开链接', {
|
|
161
|
+
url: leaf.url
|
|
162
|
+
});
|
|
163
|
+
window.location.href = leaf.url;
|
|
164
|
+
}
|
|
165
|
+
}
|
|
166
|
+
return false;
|
|
167
|
+
}
|
|
168
|
+
}, [
|
|
169
|
+
isMobile,
|
|
170
|
+
hasFnc,
|
|
171
|
+
fncProps,
|
|
172
|
+
leaf === null || leaf === void 0 ? void 0 : leaf.identifier,
|
|
173
|
+
leaf === null || leaf === void 0 ? void 0 : leaf.url,
|
|
174
|
+
linkConfig
|
|
175
|
+
]);
|
|
176
|
+
// 使用 useMemo 优化自定义渲染的 children 计算
|
|
177
|
+
var customRenderChildren = useMemo(function() {
|
|
178
|
+
var _leaf_text_toLocaleUpperCase, _leaf_text;
|
|
179
|
+
return ((_leaf_text = leaf.text) === null || _leaf_text === void 0 ? void 0 : (_leaf_text_toLocaleUpperCase = _leaf_text.toLocaleUpperCase()) === null || _leaf_text_toLocaleUpperCase === void 0 ? void 0 : _leaf_text_toLocaleUpperCase.replaceAll('[^', '').replaceAll(']', '')) || '';
|
|
180
|
+
}, [
|
|
181
|
+
leaf.text
|
|
182
|
+
]);
|
|
183
|
+
var dom = /*#__PURE__*/ React.createElement("span", _object_spread_props(_object_spread({}, attributes), {
|
|
184
|
+
"data-be": "text",
|
|
185
|
+
draggable: false,
|
|
186
|
+
onDragStart: dragStart,
|
|
187
|
+
onClick: handleClick,
|
|
188
|
+
contentEditable: leaf.fnc ? false : undefined,
|
|
189
|
+
"data-fnc": leaf.fnc || leaf.identifier ? 'fnc' : undefined,
|
|
190
|
+
"data-fnd": leaf.fnd ? 'fnd' : undefined,
|
|
191
|
+
"data-fnc-name": dataFncName,
|
|
192
|
+
"data-fnd-name": dataFndName,
|
|
193
|
+
className: fncClassName ? fncClassName : undefined,
|
|
194
|
+
style: mergedStyle
|
|
195
|
+
}), formattedText);
|
|
196
|
+
// 如果提供了自定义渲染函数,使用它
|
|
197
|
+
if ((fncProps === null || fncProps === void 0 ? void 0 : fncProps.render) && (leaf.fnc || leaf.identifier)) {
|
|
198
|
+
var _fncProps_render;
|
|
199
|
+
debugInfo('FncLeaf - 使用 fnc 自定义渲染', {
|
|
200
|
+
hasFnc: !!leaf.fnc,
|
|
201
|
+
hasIdentifier: !!leaf.identifier
|
|
202
|
+
});
|
|
203
|
+
dom = /*#__PURE__*/ React.createElement(React.Fragment, null, (_fncProps_render = fncProps.render) === null || _fncProps_render === void 0 ? void 0 : _fncProps_render.call(fncProps, _object_spread_props(_object_spread({}, leaf), {
|
|
204
|
+
children: customRenderChildren
|
|
205
|
+
}), dom));
|
|
206
|
+
}
|
|
207
|
+
return dom;
|
|
208
|
+
};
|
|
@@ -105,10 +105,10 @@ import { useSelStatus } from "../../../hooks/editor";
|
|
|
105
105
|
import { useEditorStore } from "../../store";
|
|
106
106
|
import { DragHandle } from "../../tools/DragHandle";
|
|
107
107
|
export var Paragraph = function(props) {
|
|
108
|
-
var
|
|
108
|
+
var _markdownEditorRef_current;
|
|
109
109
|
debugInfo('Paragraph - 渲染段落', {
|
|
110
110
|
align: props.element.align,
|
|
111
|
-
|
|
111
|
+
children: props.element.children
|
|
112
112
|
});
|
|
113
113
|
var _useEditorStore = useEditorStore(), store = _useEditorStore.store, markdownEditorRef = _useEditorStore.markdownEditorRef, markdownContainerRef = _useEditorStore.markdownContainerRef, readonly = _useEditorStore.readonly, editorProps = _useEditorStore.editorProps;
|
|
114
114
|
var locale = useContext(I18nContext).locale;
|
|
@@ -1,11 +1,3 @@
|
|
|
1
|
-
function _array_like_to_array(arr, len) {
|
|
2
|
-
if (len == null || len > arr.length) len = arr.length;
|
|
3
|
-
for(var i = 0, arr2 = new Array(len); i < len; i++)arr2[i] = arr[i];
|
|
4
|
-
return arr2;
|
|
5
|
-
}
|
|
6
|
-
function _array_with_holes(arr) {
|
|
7
|
-
if (Array.isArray(arr)) return arr;
|
|
8
|
-
}
|
|
9
1
|
function _define_property(obj, key, value) {
|
|
10
2
|
if (key in obj) {
|
|
11
3
|
Object.defineProperty(obj, key, {
|
|
@@ -19,33 +11,6 @@ function _define_property(obj, key, value) {
|
|
|
19
11
|
}
|
|
20
12
|
return obj;
|
|
21
13
|
}
|
|
22
|
-
function _iterable_to_array_limit(arr, i) {
|
|
23
|
-
var _i = arr == null ? null : typeof Symbol !== "undefined" && arr[Symbol.iterator] || arr["@@iterator"];
|
|
24
|
-
if (_i == null) return;
|
|
25
|
-
var _arr = [];
|
|
26
|
-
var _n = true;
|
|
27
|
-
var _d = false;
|
|
28
|
-
var _s, _e;
|
|
29
|
-
try {
|
|
30
|
-
for(_i = _i.call(arr); !(_n = (_s = _i.next()).done); _n = true){
|
|
31
|
-
_arr.push(_s.value);
|
|
32
|
-
if (i && _arr.length === i) break;
|
|
33
|
-
}
|
|
34
|
-
} catch (err) {
|
|
35
|
-
_d = true;
|
|
36
|
-
_e = err;
|
|
37
|
-
} finally{
|
|
38
|
-
try {
|
|
39
|
-
if (!_n && _i["return"] != null) _i["return"]();
|
|
40
|
-
} finally{
|
|
41
|
-
if (_d) throw _e;
|
|
42
|
-
}
|
|
43
|
-
}
|
|
44
|
-
return _arr;
|
|
45
|
-
}
|
|
46
|
-
function _non_iterable_rest() {
|
|
47
|
-
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
|
-
}
|
|
49
14
|
function _object_spread(target) {
|
|
50
15
|
for(var i = 1; i < arguments.length; i++){
|
|
51
16
|
var source = arguments[i] != null ? arguments[i] : {};
|
|
@@ -85,20 +50,9 @@ function _object_spread_props(target, source) {
|
|
|
85
50
|
}
|
|
86
51
|
return target;
|
|
87
52
|
}
|
|
88
|
-
|
|
89
|
-
return _array_with_holes(arr) || _iterable_to_array_limit(arr, i) || _unsupported_iterable_to_array(arr, i) || _non_iterable_rest();
|
|
90
|
-
}
|
|
91
|
-
function _unsupported_iterable_to_array(o, minLen) {
|
|
92
|
-
if (!o) return;
|
|
93
|
-
if (typeof o === "string") return _array_like_to_array(o, minLen);
|
|
94
|
-
var n = Object.prototype.toString.call(o).slice(8, -1);
|
|
95
|
-
if (n === "Object" && o.constructor) n = o.constructor.name;
|
|
96
|
-
if (n === "Map" || n === "Set") return Array.from(n);
|
|
97
|
-
if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _array_like_to_array(o, minLen);
|
|
98
|
-
}
|
|
99
|
-
import { ConfigProvider, Skeleton } from "antd";
|
|
53
|
+
import { ConfigProvider } from "antd";
|
|
100
54
|
import classNames from "classnames";
|
|
101
|
-
import React, { useContext,
|
|
55
|
+
import React, { useContext, useMemo } from "react";
|
|
102
56
|
import { ReactEditor, useSlate } from "slate-react";
|
|
103
57
|
import { useTableStyle } from "./style";
|
|
104
58
|
import { SlateTable } from "./Table";
|
|
@@ -111,51 +65,52 @@ import { TablePropsProvider } from "./TableContext";
|
|
|
111
65
|
var baseCls = getPrefixCls('agentic-md-editor-content-table');
|
|
112
66
|
var editor = useSlate();
|
|
113
67
|
var _useTableStyle = useTableStyle(baseCls, {}), wrapSSR = _useTableStyle.wrapSSR, hashId = _useTableStyle.hashId;
|
|
114
|
-
var _useState = _sliced_to_array(useState(false), 2), showAsText = _useState[0], setShowAsText = _useState[1];
|
|
115
|
-
var tableNode = props.element;
|
|
116
68
|
var tablePath = useMemo(function() {
|
|
117
69
|
return ReactEditor.findPath(editor, props.element);
|
|
118
70
|
}, [
|
|
119
71
|
props.element
|
|
120
72
|
]);
|
|
121
|
-
// 如果 finished 为 false,设置 5 秒超时,超时后显示为文本
|
|
122
|
-
useEffect(
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
}, [
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
//
|
|
138
|
-
if (
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
}
|
|
73
|
+
// // 如果 finished 为 false,设置 5 秒超时,超时后显示为文本
|
|
74
|
+
// useEffect(() => {
|
|
75
|
+
// if (tableNode.finished === false) {
|
|
76
|
+
// setShowAsText(false);
|
|
77
|
+
// const timer = setTimeout(() => {
|
|
78
|
+
// setShowAsText(true);
|
|
79
|
+
// }, 5000);
|
|
80
|
+
// return () => {
|
|
81
|
+
// clearTimeout(timer);
|
|
82
|
+
// };
|
|
83
|
+
// } else {
|
|
84
|
+
// setShowAsText(false);
|
|
85
|
+
// }
|
|
86
|
+
// }, [tableNode.finished]);
|
|
87
|
+
// // 如果是不完整状态
|
|
88
|
+
// if (tableNode.finished === false) {
|
|
89
|
+
// // 如果 5 秒后仍未完成,显示为文本
|
|
90
|
+
// if (showAsText) {
|
|
91
|
+
// return (
|
|
92
|
+
// <div {...props.attributes}>
|
|
93
|
+
// <div
|
|
94
|
+
// style={{
|
|
95
|
+
// padding: '8px 12px',
|
|
96
|
+
// border: '1px solid #d9d9d9',
|
|
97
|
+
// borderRadius: '4px',
|
|
98
|
+
// color: 'rgba(0, 0, 0, 0.65)',
|
|
99
|
+
// wordBreak: 'break-all',
|
|
100
|
+
// }}
|
|
101
|
+
// ></div>
|
|
102
|
+
// {props.children}
|
|
103
|
+
// </div>
|
|
104
|
+
// );
|
|
105
|
+
// }
|
|
106
|
+
// // 5 秒内显示加载骨架屏
|
|
107
|
+
// return (
|
|
108
|
+
// <div {...props.attributes}>
|
|
109
|
+
// <Skeleton active paragraph={{ rows: 3 }} />
|
|
110
|
+
// {props.children}
|
|
111
|
+
// </div>
|
|
112
|
+
// );
|
|
113
|
+
// }
|
|
159
114
|
return wrapSSR(/*#__PURE__*/ React.createElement(TablePropsProvider, {
|
|
160
115
|
tablePath: tablePath,
|
|
161
116
|
tableNode: props.element
|
|
@@ -13,6 +13,18 @@ import { Media } from './Media';
|
|
|
13
13
|
import { Mermaid } from './Mermaid';
|
|
14
14
|
import { Paragraph } from './Paragraph';
|
|
15
15
|
import { Schema } from './Schema';
|
|
16
|
+
/**
|
|
17
|
+
* 性能优化说明:
|
|
18
|
+
*
|
|
19
|
+
* 本文件中的 MElement 和 MLeaf 组件使用了 React.memo 进行性能优化:
|
|
20
|
+
*
|
|
21
|
+
* 1. **避免不必要的重新渲染**:使用自定义比较函数确保只有在 props 真正变化时才重新渲染
|
|
22
|
+
* 2. **快速引用比较**:首先进行引用比较,这是最快的比较方式
|
|
23
|
+
* 4. **批量属性检查**:对 MLeaf 组件使用数组批量检查关键属性
|
|
24
|
+
*
|
|
25
|
+
* 性能测试结果显示约 43% 的渲染性能提升,在相同 props 的情况下避免了重复渲染。
|
|
26
|
+
*/
|
|
27
|
+
export declare const dragStart: (e: React.DragEvent) => void;
|
|
16
28
|
export declare const MElement: React.MemoExoticComponent<(props: RenderElementProps & {
|
|
17
29
|
readonly?: boolean;
|
|
18
30
|
}) => React.JSX.Element>;
|