@ant-design/agentic-ui 2.29.48 → 2.29.52
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/Bubble/List/PureBubbleList.d.ts +1 -1
- package/dist/Bubble/List/PureBubbleList.js +9 -6
- package/dist/Bubble/MessagesContent/index.js +2 -2
- package/dist/ChatLayout/style.js +2 -1
- package/dist/Components/ActionItemBox/style.js +1 -1
- package/dist/Constants/mobile.d.ts +12 -2
- package/dist/Constants/mobile.js +8 -1
- package/dist/History/hooks/useHistory.js +33 -31
- package/dist/History/menu.js +4 -0
- package/dist/MarkdownEditor/BaseMarkdownEditor.js +1 -1
- package/dist/MarkdownEditor/editor/Editor.js +22 -0
- package/dist/MarkdownEditor/editor/elements/Table/ReadonlyTableComponent.js +36 -34
- package/dist/MarkdownEditor/editor/elements/Table/Table.js +19 -44
- package/dist/MarkdownEditor/editor/elements/Table/TableColgroup.d.ts +8 -0
- package/dist/MarkdownEditor/editor/elements/Table/TableColgroup.js +37 -0
- package/dist/MarkdownEditor/editor/elements/Table/utils/getTableColWidths.d.ts +12 -0
- package/dist/MarkdownEditor/editor/elements/Table/utils/getTableColWidths.js +186 -0
- package/dist/MarkdownEditor/editor/elements/Table/utils/useReadonlyTableColWidths.d.ts +13 -0
- package/dist/MarkdownEditor/editor/elements/Table/utils/useReadonlyTableColWidths.js +96 -0
- package/dist/MarkdownEditor/editor/parser/parse/parseTable.js +21 -0
- package/dist/MarkdownEditor/editor/plugins/withLinkAndMediaPlugin.js +28 -0
- package/dist/MarkdownEditor/editor/style.js +12 -12
- package/dist/MarkdownEditor/style.js +37 -37
- package/dist/MarkdownEditor/types.d.ts +29 -0
- package/dist/MarkdownInputField/AttachmentButton/AttachmentFileList/AttachmentFileListItem.d.ts +4 -4
- package/dist/MarkdownInputField/AttachmentButton/AttachmentFileList/AttachmentFileListItem.js +3 -3
- package/dist/MarkdownInputField/AttachmentButton/AttachmentFileList/index.js +4 -24
- package/dist/MarkdownInputField/FileMapView/index.js +1 -1
- package/dist/MarkdownInputField/MarkdownInputField.js +20 -9
- package/dist/MarkdownInputField/hooks/useMarkdownInputFieldHandlers.js +4 -3
- package/dist/MarkdownInputField/types/MarkdownInputFieldProps.d.ts +14 -1
- package/dist/Plugins/chart/ChartRender.js +78 -14
- package/dist/ThoughtChainList/index.js +17 -17
- package/dist/ToolUseBar/style.js +3 -0
- package/dist/Workspace/index.js +5 -1
- package/dist/index.d.ts +0 -1
- package/dist/index.js +1 -1
- package/package.json +1 -1
|
@@ -79,5 +79,5 @@ export interface PureBubbleListProps {
|
|
|
79
79
|
shouldLazyLoad?: (index: number, total: number) => boolean;
|
|
80
80
|
};
|
|
81
81
|
}
|
|
82
|
-
export declare const PureBubbleList: React.
|
|
82
|
+
export declare const PureBubbleList: React.NamedExoticComponent<PureBubbleListProps>;
|
|
83
83
|
export default PureBubbleList;
|
|
@@ -61,7 +61,7 @@ import { BubbleConfigContext } from "../BubbleConfigProvide";
|
|
|
61
61
|
import { LOADING_FLAT } from "../MessagesContent";
|
|
62
62
|
import { PureAIBubble, PureUserBubble } from "../PureBubble";
|
|
63
63
|
import { useStyle } from "./style";
|
|
64
|
-
export var PureBubbleList =
|
|
64
|
+
export var PureBubbleList = /*#__PURE__*/ React.memo(function(props) {
|
|
65
65
|
var bubbleList = props.bubbleList, bubbleListRef = props.bubbleListRef, bubbleRenderConfig = props.bubbleRenderConfig, className = props.className, classNames = props.classNames, docListProps = props.docListProps, isLoading = props.isLoading, markdownRenderConfig = props.markdownRenderConfig, onAvatarClick = props.onAvatarClick, onCancelLike = props.onCancelLike, onLikeCancel = props.onLikeCancel, onDisLike = props.onDisLike, onDislike = props.onDislike, onDoubleClick = props.onDoubleClick, onLike = props.onLike, onReply = props.onReply, onScroll = props.onScroll, onTouchMove = props.onTouchMove, onWheel = props.onWheel, shouldShowCopy = props.shouldShowCopy, shouldShowVoice = props.shouldShowVoice, style = props.style, styles = props.styles, userMeta = props.userMeta, assistantMeta = props.assistantMeta;
|
|
66
66
|
var getPrefixCls = useContext(ConfigProvider.ConfigContext).getPrefixCls;
|
|
67
67
|
var compact = (useContext(BubbleConfigContext) || {}).compact;
|
|
@@ -72,7 +72,7 @@ export var PureBubbleList = function PureBubbleList(props) {
|
|
|
72
72
|
props.style
|
|
73
73
|
];
|
|
74
74
|
}, [
|
|
75
|
-
|
|
75
|
+
props.style
|
|
76
76
|
]);
|
|
77
77
|
// 为 loading 项生成唯一的 key,使用 ref 缓存以确保稳定性
|
|
78
78
|
var loadingKeysRef = useRef(new Map());
|
|
@@ -84,8 +84,10 @@ export var PureBubbleList = function PureBubbleList(props) {
|
|
|
84
84
|
var placement = item.role === 'user' ? 'right' : 'left';
|
|
85
85
|
var BubbleComponent = placement === 'right' ? PureUserBubble : PureAIBubble;
|
|
86
86
|
var isLast = index === bubbleList.length - 1;
|
|
87
|
-
|
|
88
|
-
|
|
87
|
+
var originDataWithFlags = _object_spread_props(_object_spread({}, item), {
|
|
88
|
+
isLatest: isLast,
|
|
89
|
+
isLast: isLast
|
|
90
|
+
});
|
|
89
91
|
// 如果 id 是 LOADING_FLAT,使用 uuid 作为 key
|
|
90
92
|
// 使用 index 和 createAt 的组合作为缓存 key,确保同一项在重新渲染时保持相同的 key
|
|
91
93
|
var itemKey = item.id;
|
|
@@ -103,7 +105,7 @@ export var PureBubbleList = function PureBubbleList(props) {
|
|
|
103
105
|
preMessage: bubbleList[index - 1],
|
|
104
106
|
id: item.id,
|
|
105
107
|
style: _object_spread({}, styles === null || styles === void 0 ? void 0 : styles.bubbleListItemStyle),
|
|
106
|
-
originData:
|
|
108
|
+
originData: originDataWithFlags,
|
|
107
109
|
placement: placement,
|
|
108
110
|
time: item.updateAt || item.createAt,
|
|
109
111
|
deps: deps,
|
|
@@ -188,5 +190,6 @@ export var PureBubbleList = function PureBubbleList(props) {
|
|
|
188
190
|
return onTouchMove === null || onTouchMove === void 0 ? void 0 : onTouchMove(event, (bubbleListRef === null || bubbleListRef === void 0 ? void 0 : bubbleListRef.current) || null);
|
|
189
191
|
}
|
|
190
192
|
}, listDom));
|
|
191
|
-
};
|
|
193
|
+
});
|
|
194
|
+
PureBubbleList.displayName = 'PureBubbleList';
|
|
192
195
|
export default PureBubbleList;
|
|
@@ -363,7 +363,7 @@ export var LOADING_FLAT = '...';
|
|
|
363
363
|
(_props_originData4 = props.originData) === null || _props_originData4 === void 0 ? void 0 : _props_originData4.isLast,
|
|
364
364
|
contentAfterDom
|
|
365
365
|
]);
|
|
366
|
-
var
|
|
366
|
+
var messageContent = useMemo(function() {
|
|
367
367
|
var _props_originData, _props_bubbleRenderConfig, _props_bubbleRenderConfig1, _props_bubbleRenderConfig2, _props_bubbleRenderConfig3, _props_bubbleRenderConfig_extraRender, _props_bubbleRenderConfig4, _props_originData_extra_tags_includes, _props_originData_extra_tags, _props_originData_extra, _props_originData1, _props_originData2, _props_originData_extra1, _props_originData3, _props_originData_extra2, _props_originData4, _props_originData5, _props_originData_extra3, _props_originData6, _props_docListProps, _props_originData7, _props_markdownRenderConfig, _props_originData8, _props_originData9, _props_originData10;
|
|
368
368
|
if (content === LOADING_FLAT || !((_props_originData = props.originData) === null || _props_originData === void 0 ? void 0 : _props_originData.isFinished) && !content) {
|
|
369
369
|
var _context_thoughtChain;
|
|
@@ -649,5 +649,5 @@ export var LOADING_FLAT = '...';
|
|
|
649
649
|
(_props_bubbleRenderConfig2 = props.bubbleRenderConfig) === null || _props_bubbleRenderConfig2 === void 0 ? void 0 : _props_bubbleRenderConfig2.beforeMessageRender,
|
|
650
650
|
(_props_bubbleRenderConfig3 = props.bubbleRenderConfig) === null || _props_bubbleRenderConfig3 === void 0 ? void 0 : _props_bubbleRenderConfig3.afterMessageRender
|
|
651
651
|
]);
|
|
652
|
-
return
|
|
652
|
+
return messageContent;
|
|
653
653
|
};
|
package/dist/ChatLayout/style.js
CHANGED
|
@@ -213,7 +213,8 @@ var genStyle = function genStyle(token) {
|
|
|
213
213
|
width: '100%',
|
|
214
214
|
height: 146,
|
|
215
215
|
pointerEvents: 'none',
|
|
216
|
-
overflow: 'hidden'
|
|
216
|
+
overflow: 'hidden',
|
|
217
|
+
borderRadius: 'inherit'
|
|
217
218
|
}
|
|
218
219
|
}, "@media (max-width: ".concat(MOBILE_BREAKPOINT, ")"), {
|
|
219
220
|
'&-header': {
|
|
@@ -65,7 +65,7 @@ var genStyle = function genStyle(token) {
|
|
|
65
65
|
transition: 'all 0.3s cubic-bezier(0.4, 0, 0.2, 1)',
|
|
66
66
|
backgroundColor: '#FFF',
|
|
67
67
|
boxShadow: 'var(--shadow-border-base)',
|
|
68
|
-
|
|
68
|
+
minHeight: 32,
|
|
69
69
|
'&-overflow-container': {
|
|
70
70
|
position: 'absolute',
|
|
71
71
|
right: 0,
|
|
@@ -1,5 +1,15 @@
|
|
|
1
|
-
/**
|
|
2
|
-
|
|
1
|
+
/**
|
|
2
|
+
* 表格列宽阈值
|
|
3
|
+
* - 列数 < 5:使用百分比平分
|
|
4
|
+
* - 列数 >= 5:使用 TABLE_DEFAULT_COL_WIDTH 固定宽度
|
|
5
|
+
*/
|
|
6
|
+
export declare const TABLE_COL_WIDTH_MIN_COLUMNS = 5;
|
|
7
|
+
/** 编辑模式表格:列数 >= 此值时才计算并渲染 data col 元素,否则仅渲染行号列 */
|
|
8
|
+
export declare const TABLE_EDIT_COL_WIDTH_MIN_COLUMNS = 3;
|
|
9
|
+
/** 表格默认列宽 (px),与 style.ts 中 --agentic-ui-table-cell-min-width (120px) 保持一致 */
|
|
10
|
+
export declare const TABLE_DEFAULT_COL_WIDTH = 120;
|
|
11
|
+
/** 表格最后一列最小宽度 (px),弹性列用于吸收剩余空间 */
|
|
12
|
+
export declare const TABLE_LAST_COL_MIN_WIDTH = 80;
|
|
3
13
|
export declare const MOBILE_PADDING = "clamp(4px, 2vw, 12px)";
|
|
4
14
|
export declare const MOBILE_BREAKPOINT = "768px";
|
|
5
15
|
export declare const MOBILE_TABLE_MIN_COLUMN_WIDTH = 96;
|
package/dist/Constants/mobile.js
CHANGED
|
@@ -2,7 +2,14 @@ var MOBILE_PADDING_MIN = '4px';
|
|
|
2
2
|
var MOBILE_PADDING_MAX = '12px';
|
|
3
3
|
var MOBILE_PADDING_SCALE = '2vw';
|
|
4
4
|
var MOBILE_TABLE_MIN_CELL_WIDTH = 96;
|
|
5
|
-
/**
|
|
5
|
+
/**
|
|
6
|
+
* 表格列宽阈值
|
|
7
|
+
* - 列数 < 5:使用百分比平分
|
|
8
|
+
* - 列数 >= 5:使用 TABLE_DEFAULT_COL_WIDTH 固定宽度
|
|
9
|
+
*/ export var TABLE_COL_WIDTH_MIN_COLUMNS = 5;
|
|
10
|
+
/** 编辑模式表格:列数 >= 此值时才计算并渲染 data col 元素,否则仅渲染行号列 */ export var TABLE_EDIT_COL_WIDTH_MIN_COLUMNS = 3;
|
|
11
|
+
/** 表格默认列宽 (px),与 style.ts 中 --agentic-ui-table-cell-min-width (120px) 保持一致 */ export var TABLE_DEFAULT_COL_WIDTH = 120;
|
|
12
|
+
/** 表格最后一列最小宽度 (px),弹性列用于吸收剩余空间 */ export var TABLE_LAST_COL_MIN_WIDTH = 80;
|
|
6
13
|
export var MOBILE_PADDING = "clamp(".concat(MOBILE_PADDING_MIN, ", ").concat(MOBILE_PADDING_SCALE, ", ").concat(MOBILE_PADDING_MAX, ")");
|
|
7
14
|
export var MOBILE_BREAKPOINT = '768px';
|
|
8
15
|
export var MOBILE_TABLE_MIN_COLUMN_WIDTH = MOBILE_TABLE_MIN_CELL_WIDTH;
|
|
@@ -236,18 +236,32 @@ function _ts_generator(thisArg, body) {
|
|
|
236
236
|
};
|
|
237
237
|
}
|
|
238
238
|
}
|
|
239
|
-
import { useEffect, useState } from "react";
|
|
239
|
+
import { useEffect, useMemo, useRef, useState } from "react";
|
|
240
240
|
import { useRefFunction } from "../../index";
|
|
241
|
+
/**
|
|
242
|
+
* 根据关键词从列表中过滤
|
|
243
|
+
*/ function filterListByKeyword(list, keyword) {
|
|
244
|
+
if (!keyword.trim()) return list;
|
|
245
|
+
var lower = keyword.toLowerCase();
|
|
246
|
+
return list.filter(function(item) {
|
|
247
|
+
var title = typeof item.sessionTitle === 'string' ? item.sessionTitle : String(item.sessionTitle || '');
|
|
248
|
+
return title.toLowerCase().includes(lower);
|
|
249
|
+
});
|
|
250
|
+
}
|
|
241
251
|
/**
|
|
242
252
|
* 历史记录状态管理 Hook
|
|
243
253
|
*/ export var useHistory = function useHistory(props) {
|
|
244
254
|
var _useState = _sliced_to_array(useState(false), 2), open = _useState[0], setOpen = _useState[1];
|
|
245
|
-
var
|
|
246
|
-
|
|
247
|
-
}), 2), chatList = _useState1[0], setChatList = _useState1[1];
|
|
255
|
+
var chatListRef = useRef([]);
|
|
256
|
+
var _useState1 = _sliced_to_array(useState(0), 2), listVersion = _useState1[0], setListVersion = _useState1[1];
|
|
248
257
|
var _useState2 = _sliced_to_array(useState(''), 2), searchKeyword = _useState2[0], setSearchKeyword = _useState2[1];
|
|
249
258
|
var _useState3 = _sliced_to_array(useState([]), 2), selectedIds = _useState3[0], setSelectedIds = _useState3[1];
|
|
250
|
-
var
|
|
259
|
+
var filteredList = useMemo(function() {
|
|
260
|
+
return filterListByKeyword(chatListRef.current, searchKeyword);
|
|
261
|
+
}, [
|
|
262
|
+
searchKeyword,
|
|
263
|
+
listVersion
|
|
264
|
+
]);
|
|
251
265
|
var loadHistory = useRefFunction(function() {
|
|
252
266
|
return _async_to_generator(function() {
|
|
253
267
|
var _props_request, msg;
|
|
@@ -258,13 +272,16 @@ import { useRefFunction } from "../../index";
|
|
|
258
272
|
4,
|
|
259
273
|
props === null || props === void 0 ? void 0 : (_props_request = props.request) === null || _props_request === void 0 ? void 0 : _props_request.call(props, {
|
|
260
274
|
agentId: props.agentId
|
|
261
|
-
}).then(function(
|
|
262
|
-
return
|
|
275
|
+
}).then(function(m) {
|
|
276
|
+
return m;
|
|
263
277
|
})
|
|
264
278
|
];
|
|
265
279
|
case 1:
|
|
266
280
|
msg = _state.sent();
|
|
267
|
-
|
|
281
|
+
chatListRef.current = msg || [];
|
|
282
|
+
setListVersion(function(v) {
|
|
283
|
+
return v + 1;
|
|
284
|
+
});
|
|
268
285
|
return [
|
|
269
286
|
2
|
|
270
287
|
];
|
|
@@ -300,21 +317,6 @@ import { useRefFunction } from "../../index";
|
|
|
300
317
|
props.request,
|
|
301
318
|
loadHistory
|
|
302
319
|
]);
|
|
303
|
-
// 搜索过滤逻辑
|
|
304
|
-
useEffect(function() {
|
|
305
|
-
if (!searchKeyword.trim()) {
|
|
306
|
-
setFilteredList(chatList);
|
|
307
|
-
} else {
|
|
308
|
-
var filtered = chatList.filter(function(item) {
|
|
309
|
-
var title = typeof item.sessionTitle === 'string' ? item.sessionTitle : String(item.sessionTitle || '');
|
|
310
|
-
return title.toLowerCase().includes(searchKeyword.toLowerCase());
|
|
311
|
-
});
|
|
312
|
-
setFilteredList(filtered);
|
|
313
|
-
}
|
|
314
|
-
}, [
|
|
315
|
-
chatList,
|
|
316
|
-
searchKeyword
|
|
317
|
-
]);
|
|
318
320
|
// 处理收藏
|
|
319
321
|
var handleFavorite = useRefFunction(function(sessionId, isFavorite) {
|
|
320
322
|
return _async_to_generator(function() {
|
|
@@ -328,13 +330,13 @@ import { useRefFunction } from "../../index";
|
|
|
328
330
|
];
|
|
329
331
|
case 1:
|
|
330
332
|
_state.sent();
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
333
|
+
chatListRef.current = chatListRef.current.map(function(item) {
|
|
334
|
+
return item.sessionId === sessionId ? _object_spread_props(_object_spread({}, item), {
|
|
335
|
+
isFavorite: isFavorite
|
|
336
|
+
}) : item;
|
|
337
|
+
});
|
|
338
|
+
setListVersion(function(v) {
|
|
339
|
+
return v + 1;
|
|
338
340
|
});
|
|
339
341
|
return [
|
|
340
342
|
2
|
|
@@ -404,7 +406,7 @@ import { useRefFunction } from "../../index";
|
|
|
404
406
|
return {
|
|
405
407
|
open: open,
|
|
406
408
|
setOpen: setOpen,
|
|
407
|
-
chatList:
|
|
409
|
+
chatList: chatListRef.current,
|
|
408
410
|
searchKeyword: searchKeyword,
|
|
409
411
|
selectedIds: selectedIds,
|
|
410
412
|
filteredList: filteredList,
|
package/dist/History/menu.js
CHANGED
|
@@ -78,6 +78,10 @@ var MenuItem = function MenuItem1(param) {
|
|
|
78
78
|
(_item_onClick = item.onClick) === null || _item_onClick === void 0 ? void 0 : _item_onClick.call(item);
|
|
79
79
|
}
|
|
80
80
|
});
|
|
81
|
+
// 分组类型但子项为空时不展示
|
|
82
|
+
if (item.type === 'group' && (!item.children || !item.children.length)) {
|
|
83
|
+
return null;
|
|
84
|
+
}
|
|
81
85
|
// 如果是分组且有子项,并且嵌套层级小于2
|
|
82
86
|
if (item.type === 'group' && item.children && level < 2) {
|
|
83
87
|
return /*#__PURE__*/ React.createElement("div", {
|
|
@@ -461,7 +461,7 @@ var I18nBoundary = function I18nBoundary(param) {
|
|
|
461
461
|
style: _object_spread({
|
|
462
462
|
height: !readonly && (toolBar === null || toolBar === void 0 ? void 0 : toolBar.enable) ? "calc(100% - 56px)" : '100%'
|
|
463
463
|
}, (contentStyle === null || contentStyle === void 0 ? void 0 : contentStyle.padding) !== undefined ? {
|
|
464
|
-
'--content-padding': "".concat(typeof contentStyle.padding === 'number' ? "".concat(contentStyle.padding, "px") : contentStyle.padding),
|
|
464
|
+
'--agentic-ui-content-padding': "".concat(typeof contentStyle.padding === 'number' ? "".concat(contentStyle.padding, "px") : contentStyle.padding),
|
|
465
465
|
padding: contentStyle.padding
|
|
466
466
|
} : {}, contentStyle),
|
|
467
467
|
ref: function ref(dom) {
|
|
@@ -874,6 +874,28 @@ var defaultAllowedTypes = [
|
|
|
874
874
|
2
|
|
875
875
|
];
|
|
876
876
|
selection = markdownEditorRef.current.selection;
|
|
877
|
+
// plainTextOnly 时仅插入纯文本,不做 HTML/Markdown/链接解析
|
|
878
|
+
if (pasteConfig === null || pasteConfig === void 0 ? void 0 : pasteConfig.plainTextOnly) {
|
|
879
|
+
if (selection) {
|
|
880
|
+
Transforms.insertText(markdownEditorRef.current, text1, {
|
|
881
|
+
at: selection
|
|
882
|
+
});
|
|
883
|
+
} else {
|
|
884
|
+
Transforms.insertNodes(markdownEditorRef.current, [
|
|
885
|
+
{
|
|
886
|
+
type: 'paragraph',
|
|
887
|
+
children: [
|
|
888
|
+
{
|
|
889
|
+
text: text1
|
|
890
|
+
}
|
|
891
|
+
]
|
|
892
|
+
}
|
|
893
|
+
]);
|
|
894
|
+
}
|
|
895
|
+
return [
|
|
896
|
+
2
|
|
897
|
+
];
|
|
898
|
+
}
|
|
877
899
|
// 如果是表格或者代码块,直接插入文本
|
|
878
900
|
if (shouldInsertTextDirectly(markdownEditorRef.current, selection)) {
|
|
879
901
|
Transforms.insertText(markdownEditorRef.current, text1);
|
|
@@ -46,6 +46,21 @@ function _iterable_to_array_limit(arr, i) {
|
|
|
46
46
|
function _non_iterable_rest() {
|
|
47
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
48
|
}
|
|
49
|
+
function _object_spread(target) {
|
|
50
|
+
for(var i = 1; i < arguments.length; i++){
|
|
51
|
+
var source = arguments[i] != null ? arguments[i] : {};
|
|
52
|
+
var ownKeys = Object.keys(source);
|
|
53
|
+
if (typeof Object.getOwnPropertySymbols === "function") {
|
|
54
|
+
ownKeys = ownKeys.concat(Object.getOwnPropertySymbols(source).filter(function(sym) {
|
|
55
|
+
return Object.getOwnPropertyDescriptor(source, sym).enumerable;
|
|
56
|
+
}));
|
|
57
|
+
}
|
|
58
|
+
ownKeys.forEach(function(key) {
|
|
59
|
+
_define_property(target, key, source[key]);
|
|
60
|
+
});
|
|
61
|
+
}
|
|
62
|
+
return target;
|
|
63
|
+
}
|
|
49
64
|
function _sliced_to_array(arr, i) {
|
|
50
65
|
return _array_with_holes(arr) || _iterable_to_array_limit(arr, i) || _unsupported_iterable_to_array(arr, i) || _non_iterable_rest();
|
|
51
66
|
}
|
|
@@ -64,10 +79,11 @@ import classNames from "clsx";
|
|
|
64
79
|
import copy from "copy-to-clipboard";
|
|
65
80
|
import React, { useCallback, useContext, useMemo, useRef, useState } from "react";
|
|
66
81
|
import { ActionIconBox } from "../../../../Components/ActionIconBox";
|
|
67
|
-
import { TABLE_COL_WIDTH_MIN_COLUMNS } from "../../../../Constants/mobile";
|
|
68
82
|
import { I18nContext } from "../../../../I18n";
|
|
69
83
|
import { useEditorStore } from "../../store";
|
|
70
84
|
import { parserSlateNodeToMarkdown } from "../../utils";
|
|
85
|
+
import { TableColgroup } from "./TableColgroup";
|
|
86
|
+
import { useReadonlyTableColWidths } from "./utils/useReadonlyTableColWidths";
|
|
71
87
|
/**
|
|
72
88
|
* 专门针对 readonly 模式优化的表格组件
|
|
73
89
|
* 移除了不必要的滚动监听和复杂的宽度计算
|
|
@@ -80,27 +96,21 @@ import { parserSlateNodeToMarkdown } from "../../utils";
|
|
|
80
96
|
download: 'csv',
|
|
81
97
|
fullScreen: 'modal',
|
|
82
98
|
copy: 'md'
|
|
83
|
-
} : _ref_actions;
|
|
99
|
+
} : _ref_actions, tableCssVariables = _ref.cssVariables;
|
|
84
100
|
var tableTargetRef = useRef(null);
|
|
101
|
+
var containerRef = useRef(null);
|
|
85
102
|
var modelTargetRef = useRef(null);
|
|
86
103
|
var _useState = _sliced_to_array(useState(false), 2), previewOpen = _useState[0], setPreviewOpen = _useState[1];
|
|
87
104
|
var i18n = useContext(I18nContext);
|
|
88
|
-
|
|
89
|
-
var
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
// 使用固定宽度避免复杂计算
|
|
98
|
-
var defaultWidth = 80;
|
|
99
|
-
return Array(columnCount).fill(defaultWidth);
|
|
100
|
-
}, [
|
|
101
|
-
element === null || element === void 0 ? void 0 : element.otherProps,
|
|
102
|
-
element === null || element === void 0 ? void 0 : (_element_children = element.children) === null || _element_children === void 0 ? void 0 : (_element_children_ = _element_children[0]) === null || _element_children_ === void 0 ? void 0 : (_element_children__children = _element_children_.children) === null || _element_children__children === void 0 ? void 0 : _element_children__children.length
|
|
103
|
-
]);
|
|
105
|
+
var columnCount = (element === null || element === void 0 ? void 0 : (_element_children = element.children) === null || _element_children === void 0 ? void 0 : (_element_children_ = _element_children[0]) === null || _element_children_ === void 0 ? void 0 : (_element_children__children = _element_children_.children) === null || _element_children__children === void 0 ? void 0 : _element_children__children.length) || 0;
|
|
106
|
+
var otherProps = element === null || element === void 0 ? void 0 : element.otherProps;
|
|
107
|
+
var colWidths = useReadonlyTableColWidths({
|
|
108
|
+
columnCount: columnCount,
|
|
109
|
+
otherProps: otherProps,
|
|
110
|
+
containerRef: containerRef,
|
|
111
|
+
tableRef: tableTargetRef,
|
|
112
|
+
element: element
|
|
113
|
+
});
|
|
104
114
|
// 缓存复制处理函数
|
|
105
115
|
var handleCopy = useCallback(function() {
|
|
106
116
|
try {
|
|
@@ -148,19 +158,9 @@ import { parserSlateNodeToMarkdown } from "../../utils";
|
|
|
148
158
|
return /*#__PURE__*/ React.createElement("table", {
|
|
149
159
|
ref: tableTargetRef,
|
|
150
160
|
className: classNames("".concat(baseCls, "-editor-table"), 'readonly', "".concat(baseCls, "-readonly-table"), _define_property({}, "".concat(baseCls, "-readonly-pure"), editorProps === null || editorProps === void 0 ? void 0 : (_editorProps_tableConfig = editorProps.tableConfig) === null || _editorProps_tableConfig === void 0 ? void 0 : _editorProps_tableConfig.pure))
|
|
151
|
-
},
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
key: index,
|
|
155
|
-
style: isLastCol ? {
|
|
156
|
-
minWidth: 60
|
|
157
|
-
} : {
|
|
158
|
-
width: colWidth,
|
|
159
|
-
minWidth: colWidth,
|
|
160
|
-
maxWidth: colWidth
|
|
161
|
-
}
|
|
162
|
-
});
|
|
163
|
-
})), /*#__PURE__*/ React.createElement("tbody", null, children));
|
|
161
|
+
}, /*#__PURE__*/ React.createElement(TableColgroup, {
|
|
162
|
+
colWidths: colWidths
|
|
163
|
+
}), /*#__PURE__*/ React.createElement("tbody", null, children));
|
|
164
164
|
}, [
|
|
165
165
|
colWidths,
|
|
166
166
|
children,
|
|
@@ -186,7 +186,9 @@ import { parserSlateNodeToMarkdown } from "../../utils";
|
|
|
186
186
|
handleCopy
|
|
187
187
|
]);
|
|
188
188
|
return /*#__PURE__*/ React.createElement(React.Fragment, null, /*#__PURE__*/ React.createElement("div", {
|
|
189
|
-
|
|
189
|
+
ref: containerRef,
|
|
190
|
+
className: classNames(baseCls),
|
|
191
|
+
style: tableCssVariables
|
|
190
192
|
}, tableDom), popoverContent, previewOpen && /*#__PURE__*/ React.createElement(Modal, {
|
|
191
193
|
title: (editorProps === null || editorProps === void 0 ? void 0 : (_editorProps_tableConfig = editorProps.tableConfig) === null || _editorProps_tableConfig === void 0 ? void 0 : _editorProps_tableConfig.previewTitle) || (i18n === null || i18n === void 0 ? void 0 : (_i18n_locale = i18n.locale) === null || _i18n_locale === void 0 ? void 0 : _i18n_locale.previewTable) || '预览表格',
|
|
192
194
|
open: previewOpen,
|
|
@@ -203,12 +205,12 @@ import { parserSlateNodeToMarkdown } from "../../utils";
|
|
|
203
205
|
}
|
|
204
206
|
}, /*#__PURE__*/ React.createElement("div", {
|
|
205
207
|
className: classNames(baseCls, getPrefixCls('agentic-md-editor-content')),
|
|
206
|
-
style: {
|
|
208
|
+
style: _object_spread({
|
|
207
209
|
flex: 1,
|
|
208
210
|
minWidth: 0,
|
|
209
211
|
overflow: 'auto',
|
|
210
212
|
width: 'calc(80vw - 64px)'
|
|
211
|
-
},
|
|
213
|
+
}, tableCssVariables),
|
|
212
214
|
ref: modelTargetRef,
|
|
213
215
|
onMouseDown: function onMouseDown(e) {
|
|
214
216
|
e.preventDefault();
|
|
@@ -149,7 +149,8 @@ import classNames from "clsx";
|
|
|
149
149
|
import React, { useContext, useEffect, useMemo, useRef } from "react";
|
|
150
150
|
import { Node } from "slate";
|
|
151
151
|
import stringWidth from "string-width";
|
|
152
|
-
import { MOBILE_BREAKPOINT, MOBILE_TABLE_MIN_COLUMN_WIDTH,
|
|
152
|
+
import { MOBILE_BREAKPOINT, MOBILE_TABLE_MIN_COLUMN_WIDTH, TABLE_EDIT_COL_WIDTH_MIN_COLUMNS } from "../../../../Constants/mobile";
|
|
153
|
+
import { TableColgroup, TABLE_ROW_INDEX_COL_WIDTH } from "./TableColgroup";
|
|
153
154
|
import { useEditorStore } from "../../store";
|
|
154
155
|
import { ReadonlyTableComponent } from "./ReadonlyTableComponent";
|
|
155
156
|
import { TablePropsContext } from "./TableContext";
|
|
@@ -184,8 +185,9 @@ import useScrollShadow from "./useScrollShadow";
|
|
|
184
185
|
var children = _0.children, props = _object_without_properties(_0, [
|
|
185
186
|
"children"
|
|
186
187
|
]);
|
|
187
|
-
var _props_element_children__children, _props_element_children_, _props_element_children, _props_element, _props_element_otherProps, _props_element1, _props_element_children1, _props_element2;
|
|
188
|
-
var _useEditorStore = useEditorStore(), readonly = _useEditorStore.readonly, markdownContainerRef = _useEditorStore.markdownContainerRef;
|
|
188
|
+
var _editorProps_tableConfig, _props_element_children__children, _props_element_children_, _props_element_children, _props_element, _props_element_otherProps, _props_element1, _props_element_children1, _props_element2;
|
|
189
|
+
var _useEditorStore = useEditorStore(), readonly = _useEditorStore.readonly, markdownContainerRef = _useEditorStore.markdownContainerRef, editorProps = _useEditorStore.editorProps;
|
|
190
|
+
var tableCssVariables = editorProps === null || editorProps === void 0 ? void 0 : (_editorProps_tableConfig = editorProps.tableConfig) === null || _editorProps_tableConfig === void 0 ? void 0 : _editorProps_tableConfig.cssVariables;
|
|
189
191
|
var getPrefixCls = useContext(ConfigProvider.ConfigContext).getPrefixCls;
|
|
190
192
|
var tablePath = useContext(TablePropsContext).tablePath;
|
|
191
193
|
var baseCls = getPrefixCls('agentic-md-editor-content-table');
|
|
@@ -194,26 +196,15 @@ import useScrollShadow from "./useScrollShadow";
|
|
|
194
196
|
var mobileBreakpointValue = parseInt(MOBILE_BREAKPOINT, 10) || 768;
|
|
195
197
|
// 总是调用 hooks,避免条件调用
|
|
196
198
|
var _useScrollShadow = _sliced_to_array(useScrollShadow(), 2), tableRef = _useScrollShadow[0], scrollState = _useScrollShadow[1];
|
|
197
|
-
//
|
|
199
|
+
// 编辑模式下列宽计算(readonly 时走 ReadonlyTableComponent,跳过计算)
|
|
198
200
|
var colWidths = useMemo(function() {
|
|
199
|
-
var _props_element_otherProps, _props_element, _props_element_children, _props_element1, _tableRows__children, _tableRows_, _markdownContainerRef_current_querySelector, _markdownContainerRef_current;
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
if (otherProps === null || otherProps === void 0 ? void 0 : otherProps.colWidths) {
|
|
207
|
-
return otherProps.colWidths;
|
|
208
|
-
}
|
|
209
|
-
return Array(colCount).fill(80); // 固定宽度
|
|
210
|
-
}
|
|
211
|
-
// 少于 3 列不设置 col,使用浏览器默认布局
|
|
212
|
-
if (columnCount < TABLE_COL_WIDTH_MIN_COLUMNS) return [];
|
|
213
|
-
// 如果在 props 中存在,直接使用以避免计算
|
|
214
|
-
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.colWidths) {
|
|
215
|
-
var _props_element_otherProps1, _props_element4;
|
|
216
|
-
return (_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.colWidths;
|
|
201
|
+
var _props_element_otherProps_colWidths, _props_element_otherProps, _props_element, _props_element_children, _props_element1, _tableRows__children, _tableRows_, _markdownContainerRef_current_querySelector, _markdownContainerRef_current;
|
|
202
|
+
if (readonly) return [];
|
|
203
|
+
// 少于 TABLE_EDIT_COL_WIDTH_MIN_COLUMNS 列不设置 data col,仅行号列(显式 colWidths 也忽略)
|
|
204
|
+
if (columnCount < TABLE_EDIT_COL_WIDTH_MIN_COLUMNS) return [];
|
|
205
|
+
// 显式传入 colWidths 时优先使用
|
|
206
|
+
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_colWidths = _props_element_otherProps.colWidths) === null || _props_element_otherProps_colWidths === void 0 ? void 0 : _props_element_otherProps_colWidths.length) {
|
|
207
|
+
return props.element.otherProps.colWidths;
|
|
217
208
|
}
|
|
218
209
|
if (typeof window === 'undefined' || !((_props_element1 = props.element) === null || _props_element1 === void 0 ? void 0 : (_props_element_children = _props_element1.children) === null || _props_element_children === void 0 ? void 0 : _props_element_children.length)) return [];
|
|
219
210
|
var tableRows = props.element.children;
|
|
@@ -315,26 +306,10 @@ import useScrollShadow from "./useScrollShadow";
|
|
|
315
306
|
e.preventDefault();
|
|
316
307
|
return false;
|
|
317
308
|
}
|
|
318
|
-
}, /*#__PURE__*/ React.createElement(
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
maxWidth: 12
|
|
323
|
-
}
|
|
324
|
-
}), (colWidths || []).map(function(colWidth, index) {
|
|
325
|
-
var _ref;
|
|
326
|
-
var isLastCol = index === ((_ref = colWidths === null || colWidths === void 0 ? void 0 : colWidths.length) !== null && _ref !== void 0 ? _ref : 0) - 1;
|
|
327
|
-
return /*#__PURE__*/ React.createElement("col", {
|
|
328
|
-
key: index,
|
|
329
|
-
style: isLastCol ? {
|
|
330
|
-
minWidth: 60
|
|
331
|
-
} : {
|
|
332
|
-
width: colWidth,
|
|
333
|
-
minWidth: colWidth,
|
|
334
|
-
maxWidth: colWidth
|
|
335
|
-
}
|
|
336
|
-
});
|
|
337
|
-
}) || null), /*#__PURE__*/ React.createElement("tbody", null, readonly ? null : /*#__PURE__*/ React.createElement(TableRowIndex, {
|
|
309
|
+
}, /*#__PURE__*/ React.createElement(TableColgroup, {
|
|
310
|
+
colWidths: colWidths !== null && colWidths !== void 0 ? colWidths : [],
|
|
311
|
+
prefixColWidth: TABLE_ROW_INDEX_COL_WIDTH
|
|
312
|
+
}), /*#__PURE__*/ React.createElement("tbody", null, readonly ? null : /*#__PURE__*/ React.createElement(TableRowIndex, {
|
|
338
313
|
colWidths: colWidths,
|
|
339
314
|
columnCount: columnCount,
|
|
340
315
|
tablePath: tablePath
|
|
@@ -367,9 +342,9 @@ import useScrollShadow from "./useScrollShadow";
|
|
|
367
342
|
return /*#__PURE__*/ React.createElement("div", {
|
|
368
343
|
className: classNames(baseCls),
|
|
369
344
|
ref: tableRef,
|
|
370
|
-
style: _object_spread_props(_object_spread({}, boxShadowStyle), {
|
|
345
|
+
style: _object_spread(_object_spread_props(_object_spread({}, boxShadowStyle), {
|
|
371
346
|
position: 'relative'
|
|
372
|
-
}),
|
|
347
|
+
}), tableCssVariables),
|
|
373
348
|
onDragStart: function onDragStart(e) {
|
|
374
349
|
// 阻止拖拽开始时的文字选择
|
|
375
350
|
e.preventDefault();
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import type { ColWidthValue } from './utils/getTableColWidths';
|
|
3
|
+
export interface TableColgroupProps {
|
|
4
|
+
colWidths: ColWidthValue[];
|
|
5
|
+
prefixColWidth?: number;
|
|
6
|
+
}
|
|
7
|
+
export declare const TableColgroup: React.FC<TableColgroupProps>;
|
|
8
|
+
export declare const TABLE_ROW_INDEX_COL_WIDTH = 12;
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
import { TABLE_DEFAULT_COL_WIDTH, TABLE_LAST_COL_MIN_WIDTH } from "../../../../Constants/mobile";
|
|
3
|
+
var ROW_INDEX_COL_WIDTH = 12;
|
|
4
|
+
var isPercent = function isPercent(v) {
|
|
5
|
+
return typeof v === 'string' && v.endsWith('%');
|
|
6
|
+
};
|
|
7
|
+
export var TableColgroup = function TableColgroup(param) {
|
|
8
|
+
var colWidths = param.colWidths, prefixColWidth = param.prefixColWidth;
|
|
9
|
+
var showPrefix = (prefixColWidth !== null && prefixColWidth !== void 0 ? prefixColWidth : 0) > 0;
|
|
10
|
+
if (!showPrefix && !colWidths.length) return null;
|
|
11
|
+
return /*#__PURE__*/ React.createElement("colgroup", null, showPrefix && /*#__PURE__*/ React.createElement("col", {
|
|
12
|
+
style: {
|
|
13
|
+
width: prefixColWidth,
|
|
14
|
+
minWidth: prefixColWidth,
|
|
15
|
+
maxWidth: prefixColWidth
|
|
16
|
+
}
|
|
17
|
+
}), colWidths.map(function(w, i) {
|
|
18
|
+
var last = i === colWidths.length - 1;
|
|
19
|
+
var style = isPercent(w) ? {
|
|
20
|
+
width: w,
|
|
21
|
+
minWidth: TABLE_DEFAULT_COL_WIDTH,
|
|
22
|
+
maxWidth: w
|
|
23
|
+
} : last ? {
|
|
24
|
+
minWidth: TABLE_LAST_COL_MIN_WIDTH
|
|
25
|
+
} : {
|
|
26
|
+
width: w,
|
|
27
|
+
minWidth: w,
|
|
28
|
+
maxWidth: w
|
|
29
|
+
};
|
|
30
|
+
return /*#__PURE__*/ React.createElement("col", {
|
|
31
|
+
key: i,
|
|
32
|
+
style: style
|
|
33
|
+
});
|
|
34
|
+
}));
|
|
35
|
+
};
|
|
36
|
+
TableColgroup.displayName = 'TableColgroup';
|
|
37
|
+
export var TABLE_ROW_INDEX_COL_WIDTH = ROW_INDEX_COL_WIDTH;
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import type { TableNode } from '../../../types/Table';
|
|
2
|
+
export type ColWidthValue = number | string;
|
|
3
|
+
export interface ReadonlyTableColWidthsInput {
|
|
4
|
+
columnCount: number;
|
|
5
|
+
otherProps?: {
|
|
6
|
+
colWidths?: ColWidthValue[];
|
|
7
|
+
} | null;
|
|
8
|
+
element?: TableNode | null;
|
|
9
|
+
containerWidth?: number;
|
|
10
|
+
}
|
|
11
|
+
/** 只读表格列宽:显式 colWidths > 智能算法(6+列) > 内容比例 > 平分 */
|
|
12
|
+
export declare function getReadonlyTableColWidths(input: ReadonlyTableColWidthsInput): ColWidthValue[];
|