@ant-design/agentic-ui 2.29.41 → 2.29.43
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/Constants/mobile.d.ts +2 -0
- package/dist/Constants/mobile.js +1 -0
- package/dist/MarkdownEditor/editor/elements/Table/ReadonlyTableComponent.js +12 -8
- package/dist/MarkdownEditor/editor/elements/Table/Table.js +12 -8
- package/dist/MarkdownEditor/editor/elements/Table/TableRowIndex/index.d.ts +3 -1
- package/dist/MarkdownEditor/editor/elements/Table/TableRowIndex/index.js +5 -2
- package/dist/MarkdownEditor/style.js +4 -6
- package/package.json +2 -1
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
/** 表格列宽计算的列数阈值,少于该列数不设置 col 元素,使用浏览器默认布局 */
|
|
2
|
+
export declare const TABLE_COL_WIDTH_MIN_COLUMNS = 3;
|
|
1
3
|
export declare const MOBILE_PADDING = "clamp(4px, 2vw, 12px)";
|
|
2
4
|
export declare const MOBILE_BREAKPOINT = "768px";
|
|
3
5
|
export declare const MOBILE_TABLE_MIN_COLUMN_WIDTH = 96;
|
package/dist/Constants/mobile.js
CHANGED
|
@@ -2,6 +2,7 @@ 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
|
+
/** 表格列宽计算的列数阈值,少于该列数不设置 col 元素,使用浏览器默认布局 */ export var TABLE_COL_WIDTH_MIN_COLUMNS = 3;
|
|
5
6
|
export var MOBILE_PADDING = "clamp(".concat(MOBILE_PADDING_MIN, ", ").concat(MOBILE_PADDING_SCALE, ", ").concat(MOBILE_PADDING_MAX, ")");
|
|
6
7
|
export var MOBILE_BREAKPOINT = '768px';
|
|
7
8
|
export var MOBILE_TABLE_MIN_COLUMN_WIDTH = MOBILE_TABLE_MIN_CELL_WIDTH;
|
|
@@ -64,6 +64,7 @@ import classNames from "clsx";
|
|
|
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 { TABLE_COL_WIDTH_MIN_COLUMNS } from "../../../../Constants/mobile";
|
|
67
68
|
import { I18nContext } from "../../../../I18n";
|
|
68
69
|
import { useEditorStore } from "../../store";
|
|
69
70
|
import { parserSlateNodeToMarkdown } from "../../utils";
|
|
@@ -84,15 +85,15 @@ 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);
|
|
87
|
-
// 简化的列宽计算 - 只为 readonly
|
|
88
|
+
// 简化的列宽计算 - 只为 readonly 模式设计,少于 3 列不设置 col
|
|
88
89
|
var colWidths = useMemo(function() {
|
|
89
90
|
var _element_children__children, _element_children_, _element_children;
|
|
91
|
+
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;
|
|
92
|
+
if (columnCount === 0 || columnCount < TABLE_COL_WIDTH_MIN_COLUMNS) return [];
|
|
90
93
|
var otherProps = element === null || element === void 0 ? void 0 : element.otherProps;
|
|
91
94
|
if (otherProps === null || otherProps === void 0 ? void 0 : otherProps.colWidths) {
|
|
92
95
|
return otherProps.colWidths;
|
|
93
96
|
}
|
|
94
|
-
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;
|
|
95
|
-
if (columnCount === 0) return [];
|
|
96
97
|
// 使用固定宽度避免复杂计算
|
|
97
98
|
var defaultWidth = 80;
|
|
98
99
|
return Array(columnCount).fill(defaultWidth);
|
|
@@ -147,7 +148,7 @@ import { parserSlateNodeToMarkdown } from "../../utils";
|
|
|
147
148
|
return /*#__PURE__*/ React.createElement("table", {
|
|
148
149
|
ref: tableTargetRef,
|
|
149
150
|
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))
|
|
150
|
-
}, /*#__PURE__*/ React.createElement("colgroup", null, colWidths.map(function(colWidth, index) {
|
|
151
|
+
}, colWidths.length > 0 && /*#__PURE__*/ React.createElement("colgroup", null, colWidths.map(function(colWidth, index) {
|
|
151
152
|
var isLastCol = index === colWidths.length - 1;
|
|
152
153
|
return /*#__PURE__*/ React.createElement("col", {
|
|
153
154
|
key: index,
|
|
@@ -194,6 +195,12 @@ import { parserSlateNodeToMarkdown } from "../../utils";
|
|
|
194
195
|
afterClose: handleModalClose,
|
|
195
196
|
width: "80vw",
|
|
196
197
|
onCancel: handleModalClose
|
|
198
|
+
}, /*#__PURE__*/ React.createElement("div", {
|
|
199
|
+
className: getPrefixCls('agentic-md-editor'),
|
|
200
|
+
style: {
|
|
201
|
+
flex: 1,
|
|
202
|
+
minWidth: 0
|
|
203
|
+
}
|
|
197
204
|
}, /*#__PURE__*/ React.createElement("div", {
|
|
198
205
|
className: classNames(baseCls, getPrefixCls('agentic-md-editor-content')),
|
|
199
206
|
style: {
|
|
@@ -204,15 +211,12 @@ import { parserSlateNodeToMarkdown } from "../../utils";
|
|
|
204
211
|
},
|
|
205
212
|
ref: modelTargetRef,
|
|
206
213
|
onMouseDown: function onMouseDown(e) {
|
|
207
|
-
// 阻止默认的文字选择行为
|
|
208
214
|
e.preventDefault();
|
|
209
215
|
},
|
|
210
216
|
onDragStart: function onDragStart(e) {
|
|
211
|
-
// 阻止拖拽开始时的文字选择
|
|
212
217
|
e.preventDefault();
|
|
213
218
|
},
|
|
214
219
|
onDoubleClick: function onDoubleClick(e) {
|
|
215
|
-
// 阻止双击选择文字
|
|
216
220
|
e.preventDefault();
|
|
217
221
|
}
|
|
218
222
|
}, /*#__PURE__*/ React.createElement(ConfigProvider, {
|
|
@@ -222,6 +226,6 @@ import { parserSlateNodeToMarkdown } from "../../utils";
|
|
|
222
226
|
getTargetContainer: function getTargetContainer() {
|
|
223
227
|
return modelTargetRef.current || document.body;
|
|
224
228
|
}
|
|
225
|
-
}, tableDom))));
|
|
229
|
+
}, tableDom)))));
|
|
226
230
|
});
|
|
227
231
|
ReadonlyTableComponent.displayName = 'ReadonlyTableComponent';
|
|
@@ -149,7 +149,7 @@ 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 } from "../../../../Constants/mobile";
|
|
152
|
+
import { MOBILE_BREAKPOINT, MOBILE_TABLE_MIN_COLUMN_WIDTH, TABLE_COL_WIDTH_MIN_COLUMNS } from "../../../../Constants/mobile";
|
|
153
153
|
import { useEditorStore } from "../../store";
|
|
154
154
|
import { ReadonlyTableComponent } from "./ReadonlyTableComponent";
|
|
155
155
|
import { TablePropsContext } from "./TableContext";
|
|
@@ -197,18 +197,20 @@ import useScrollShadow from "./useScrollShadow";
|
|
|
197
197
|
// 只在编辑模式下进行复杂的列宽计算
|
|
198
198
|
var colWidths = useMemo(function() {
|
|
199
199
|
var _props_element_otherProps, _props_element, _props_element_children, _props_element1, _tableRows__children, _tableRows_, _markdownContainerRef_current_querySelector, _markdownContainerRef_current;
|
|
200
|
-
// readonly
|
|
200
|
+
// readonly 模式下使用简化计算,少于 3 列不设置 col
|
|
201
201
|
if (readonly) {
|
|
202
|
-
var
|
|
203
|
-
var
|
|
202
|
+
var _props_element_children__children, _props_element_children_, _props_element_children1, _props_element2, _props_element3;
|
|
203
|
+
var colCount = ((_props_element2 = props.element) === null || _props_element2 === void 0 ? void 0 : (_props_element_children1 = _props_element2.children) === null || _props_element_children1 === void 0 ? void 0 : (_props_element_children_ = _props_element_children1[0]) === null || _props_element_children_ === void 0 ? void 0 : (_props_element_children__children = _props_element_children_.children) === null || _props_element_children__children === void 0 ? void 0 : _props_element_children__children.length) || 0;
|
|
204
|
+
if (colCount === 0 || colCount < TABLE_COL_WIDTH_MIN_COLUMNS) return [];
|
|
205
|
+
var otherProps = (_props_element3 = props.element) === null || _props_element3 === void 0 ? void 0 : _props_element3.otherProps;
|
|
204
206
|
if (otherProps === null || otherProps === void 0 ? void 0 : otherProps.colWidths) {
|
|
205
207
|
return otherProps.colWidths;
|
|
206
208
|
}
|
|
207
|
-
|
|
208
|
-
if (columnCount1 === 0) return [];
|
|
209
|
-
return Array(columnCount1).fill(80); // 固定宽度
|
|
209
|
+
return Array(colCount).fill(80); // 固定宽度
|
|
210
210
|
}
|
|
211
|
-
//
|
|
211
|
+
// 少于 3 列不设置 col,使用浏览器默认布局
|
|
212
|
+
if (columnCount < TABLE_COL_WIDTH_MIN_COLUMNS) return [];
|
|
213
|
+
// 如果在 props 中存在,直接使用以避免计算
|
|
212
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) {
|
|
213
215
|
var _props_element_otherProps1, _props_element4;
|
|
214
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;
|
|
@@ -333,10 +335,12 @@ import useScrollShadow from "./useScrollShadow";
|
|
|
333
335
|
});
|
|
334
336
|
}) || null), /*#__PURE__*/ React.createElement("tbody", null, readonly ? null : /*#__PURE__*/ React.createElement(TableRowIndex, {
|
|
335
337
|
colWidths: colWidths,
|
|
338
|
+
columnCount: columnCount,
|
|
336
339
|
tablePath: tablePath
|
|
337
340
|
}), children));
|
|
338
341
|
}, [
|
|
339
342
|
colWidths,
|
|
343
|
+
columnCount,
|
|
340
344
|
children,
|
|
341
345
|
baseCls
|
|
342
346
|
]);
|
|
@@ -3,8 +3,10 @@ import React from 'react';
|
|
|
3
3
|
* TableRowIndex 组件的属性接口
|
|
4
4
|
*/
|
|
5
5
|
export interface TableRowIndexProps {
|
|
6
|
-
/**
|
|
6
|
+
/** 列宽度数组,为空时使用 columnCount 渲染占位单元格 */
|
|
7
7
|
colWidths?: number[];
|
|
8
|
+
/** 数据列数,colWidths 为空时用于渲染占位单元格数量 */
|
|
9
|
+
columnCount?: number;
|
|
8
10
|
/** 自定义样式 */
|
|
9
11
|
style?: React.CSSProperties;
|
|
10
12
|
/** 自定义类名 */
|
|
@@ -34,7 +34,8 @@ import { TableCellIndexSpacer } from "../TableCellIndexSpacer";
|
|
|
34
34
|
* - 根据列宽度数组生成对应的间隔单元格
|
|
35
35
|
* - 包含行索引单元格和列间隔单元格
|
|
36
36
|
*/ export var TableRowIndex = function TableRowIndex(param) {
|
|
37
|
-
var _param_colWidths = param.colWidths, colWidths = _param_colWidths === void 0 ? [] : _param_colWidths, style = param.style, className = param.className, tablePath = param.tablePath;
|
|
37
|
+
var _param_colWidths = param.colWidths, colWidths = _param_colWidths === void 0 ? [] : _param_colWidths, _param_columnCount = param.columnCount, columnCount = _param_columnCount === void 0 ? 0 : _param_columnCount, style = param.style, className = param.className, tablePath = param.tablePath;
|
|
38
|
+
var spacerCount = colWidths.length > 0 ? colWidths.length : columnCount;
|
|
38
39
|
var context = useContext(ConfigProvider.ConfigContext);
|
|
39
40
|
var baseClassName = context === null || context === void 0 ? void 0 : context.getPrefixCls('agentic-md-editor-table-row-index');
|
|
40
41
|
return /*#__PURE__*/ React.createElement("tr", {
|
|
@@ -51,7 +52,9 @@ import { TableCellIndexSpacer } from "../TableCellIndexSpacer";
|
|
|
51
52
|
columnIndex: -1,
|
|
52
53
|
key: -1,
|
|
53
54
|
tablePath: tablePath
|
|
54
|
-
}),
|
|
55
|
+
}), Array.from({
|
|
56
|
+
length: spacerCount
|
|
57
|
+
}).map(function(_, index) {
|
|
55
58
|
return /*#__PURE__*/ React.createElement(TableCellIndexSpacer, {
|
|
56
59
|
key: index,
|
|
57
60
|
columnIndex: index,
|
|
@@ -415,12 +415,10 @@ var genStyle = function genStyle(token) {
|
|
|
415
415
|
width: 'max-content',
|
|
416
416
|
tableLayout: 'fixed',
|
|
417
417
|
margin: '16px 0',
|
|
418
|
-
maxWidth: '100%'
|
|
419
|
-
|
|
420
|
-
|
|
421
|
-
|
|
422
|
-
border: '1px solid var(--table-border-color)'
|
|
423
|
-
}, _define_property(_obj1, "&".concat(token.componentCls, "-content-table-readonly-pure"), {
|
|
418
|
+
maxWidth: '100%'
|
|
419
|
+
}, _define_property(_obj1, "&".concat(token.componentCls, "-content-table-readonly-table"), {
|
|
420
|
+
width: '100%'
|
|
421
|
+
}), _define_property(_obj1, "position", 'relative'), _define_property(_obj1, "fontVariant", 'tabular-nums'), _define_property(_obj1, "borderRadius", 'var(--table-border-radius)'), _define_property(_obj1, "border", '1px solid var(--table-border-color)'), _define_property(_obj1, "&".concat(token.componentCls, "-content-table-readonly-pure"), {
|
|
424
422
|
border: 'none',
|
|
425
423
|
borderRadius: 'none',
|
|
426
424
|
'tr:not(.config-tr) td:not(.config-td)': {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ant-design/agentic-ui",
|
|
3
|
-
"version": "2.29.
|
|
3
|
+
"version": "2.29.43",
|
|
4
4
|
"description": "面向智能体的 UI 组件库,提供多步推理可视化、工具调用展示、任务执行协同等 Agentic UI 能力",
|
|
5
5
|
"repository": "git@github.com:ant-design/agentic-ui.git",
|
|
6
6
|
"license": "MIT",
|
|
@@ -24,6 +24,7 @@
|
|
|
24
24
|
"lint:css": "stylelint \"{src,test}/**/*.{css,less}\"",
|
|
25
25
|
"lint:es": "eslint \"{src,test}/**/*.{js,jsx,ts,tsx}\"",
|
|
26
26
|
"prepare": "husky install && dumi setup",
|
|
27
|
+
"prepublishOnly": "father doctor && pnpm run test && pnpm run build",
|
|
27
28
|
"prettier": "prettier --write \"{src,docs,test}/**/*.{js,jsx,ts,tsx,css,less,json,md}\"",
|
|
28
29
|
"preview": "pnpm dumi preview",
|
|
29
30
|
"report:demo": "node scripts/generateDemoReport.js",
|