@ant-design/agentic-ui 2.30.0 → 2.30.1
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/index.d.ts +4 -0
- package/dist/Bubble/List/index.js +8 -5
- package/dist/Bubble/MessagesContent/EXCEPTION.js +11 -2
- package/dist/Bubble/MessagesContent/MarkdownPreview.js +13 -7
- package/dist/Bubble/MessagesContent/index.js +39 -10
- package/dist/Bubble/MessagesContent/style.js +55 -22
- package/dist/Bubble/type.d.ts +4 -0
- package/dist/I18n/locales.js +2 -2
- package/dist/MarkdownEditor/BaseMarkdownEditor.js +37 -5
- package/dist/MarkdownEditor/editor/elements/AgenticUiBlocks/AgenticUiTaskBlock.d.ts +4 -0
- package/dist/MarkdownEditor/editor/elements/AgenticUiBlocks/AgenticUiTaskBlock.js +74 -0
- package/dist/MarkdownEditor/editor/elements/AgenticUiBlocks/AgenticUiToolUseBarBlock.d.ts +4 -0
- package/dist/MarkdownEditor/editor/elements/AgenticUiBlocks/AgenticUiToolUseBarBlock.js +114 -0
- package/dist/MarkdownEditor/editor/elements/AgenticUiBlocks/agenticUiEmbedUtils.d.ts +20 -0
- package/dist/MarkdownEditor/editor/elements/AgenticUiBlocks/agenticUiEmbedUtils.js +169 -0
- package/dist/MarkdownEditor/editor/elements/Table/EditableTable.d.ts +11 -0
- package/dist/MarkdownEditor/editor/elements/Table/EditableTable.js +207 -0
- package/dist/MarkdownEditor/editor/elements/Table/Table.js +10 -276
- package/dist/MarkdownEditor/editor/elements/Table/TableCellIndex/index.js +7 -227
- package/dist/MarkdownEditor/editor/elements/Table/TableCellIndexSpacer/index.js +20 -229
- package/dist/MarkdownEditor/editor/elements/Table/commands/tableCommands.d.ts +9 -0
- package/dist/MarkdownEditor/editor/elements/Table/commands/tableCommands.js +242 -0
- package/dist/MarkdownEditor/editor/elements/Table/utils/editableTableWidth.d.ts +20 -0
- package/dist/MarkdownEditor/editor/elements/Table/utils/editableTableWidth.js +60 -0
- package/dist/MarkdownEditor/editor/elements/Table/utils/useEditableTableColWidths.d.ts +6 -0
- package/dist/MarkdownEditor/editor/elements/Table/utils/useEditableTableColWidths.js +20 -0
- package/dist/MarkdownEditor/editor/elements/Table/utils/useEditableTableContentWidth.d.ts +10 -0
- package/dist/MarkdownEditor/editor/elements/Table/utils/useEditableTableContentWidth.js +103 -0
- package/dist/MarkdownEditor/editor/elements/index.js +7 -0
- package/dist/MarkdownEditor/editor/parser/parse/parseCode.js +33 -2
- package/dist/MarkdownEditor/editor/parser/parserSlateNodeToMarkdown.js +3 -0
- package/dist/MarkdownEditor/editor/plugins/handlePaste.js +4 -1
- package/dist/MarkdownEditor/style.js +109 -7
- package/dist/MarkdownEditor/types.d.ts +5 -0
- package/dist/MarkdownInputField/AttachmentButton/AttachmentFileList/AttachmentFileIcon.js +2 -2
- package/dist/MarkdownInputField/AttachmentButton/AttachmentFileList/AttachmentFileListItem.js +11 -8
- package/dist/MarkdownInputField/AttachmentButton/index.js +7 -2
- package/dist/MarkdownInputField/AttachmentButton/types.d.ts +5 -1
- package/dist/MarkdownInputField/AttachmentButton/utils.d.ts +7 -0
- package/dist/MarkdownInputField/AttachmentButton/utils.js +9 -1
- package/dist/MarkdownInputField/FileMapView/FileMapViewItem.js +10 -5
- package/dist/MarkdownInputField/FileUploadManager/index.d.ts +9 -0
- package/dist/MarkdownInputField/FileUploadManager/index.js +20 -4
- package/dist/MarkdownInputField/MarkdownInputField.js +5 -3
- package/dist/MarkdownInputField/SendActions/index.d.ts +9 -0
- package/dist/MarkdownInputField/SendActions/index.js +3 -2
- package/dist/MarkdownInputField/utils/renderHelpers.d.ts +8 -1
- package/dist/MarkdownInputField/utils/renderHelpers.js +5 -1
- package/dist/MarkdownRenderer/AnimationText.d.ts +4 -7
- package/dist/MarkdownRenderer/AnimationText.js +117 -15
- package/dist/MarkdownRenderer/MarkdownRenderer.js +15 -1
- package/dist/MarkdownRenderer/index.d.ts +2 -2
- package/dist/MarkdownRenderer/index.js +1 -1
- package/dist/MarkdownRenderer/renderers/AgenticUiTaskBlockRenderer.d.ts +6 -0
- package/dist/MarkdownRenderer/renderers/AgenticUiTaskBlockRenderer.js +66 -0
- package/dist/MarkdownRenderer/renderers/AgenticUiToolUseBarBlockRenderer.d.ts +6 -0
- package/dist/MarkdownRenderer/renderers/AgenticUiToolUseBarBlockRenderer.js +134 -0
- package/dist/MarkdownRenderer/style.js +7 -6
- package/dist/MarkdownRenderer/useMarkdownToReact.js +5 -4
- package/dist/MarkdownRenderer/useStreaming.js +8 -1
- package/dist/Plugins/chart/ChartRender.js +1 -0
- package/dist/Plugins/chart/index.js +3 -1
- package/package.json +2 -1
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { useMemo } from "react";
|
|
2
|
+
import { getEditableTableColWidths } from "./editableTableWidth";
|
|
3
|
+
export function useEditableTableColWidths(param) {
|
|
4
|
+
var readonly = param.readonly, columnCount = param.columnCount, availableTableWidth = param.availableTableWidth, mobileBreakpointValue = param.mobileBreakpointValue, element = param.element;
|
|
5
|
+
return useMemo(function() {
|
|
6
|
+
return getEditableTableColWidths({
|
|
7
|
+
readonly: readonly,
|
|
8
|
+
columnCount: columnCount,
|
|
9
|
+
availableTableWidth: availableTableWidth,
|
|
10
|
+
mobileBreakpointValue: mobileBreakpointValue,
|
|
11
|
+
element: element
|
|
12
|
+
});
|
|
13
|
+
}, [
|
|
14
|
+
readonly,
|
|
15
|
+
columnCount,
|
|
16
|
+
availableTableWidth,
|
|
17
|
+
mobileBreakpointValue,
|
|
18
|
+
element
|
|
19
|
+
]);
|
|
20
|
+
}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
export interface UseEditableTableContentWidthParams {
|
|
3
|
+
readonly: boolean;
|
|
4
|
+
markdownContainerRef?: React.RefObject<HTMLElement | null>;
|
|
5
|
+
minContainerWidth: number;
|
|
6
|
+
}
|
|
7
|
+
export declare function useEditableTableContentWidth({ readonly, markdownContainerRef, minContainerWidth, }: UseEditableTableContentWidthParams): {
|
|
8
|
+
resolvedContentWidth: number;
|
|
9
|
+
availableTableWidth: number;
|
|
10
|
+
};
|
|
@@ -0,0 +1,103 @@
|
|
|
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
|
+
function _iterable_to_array_limit(arr, i) {
|
|
10
|
+
var _i = arr == null ? null : typeof Symbol !== "undefined" && arr[Symbol.iterator] || arr["@@iterator"];
|
|
11
|
+
if (_i == null) return;
|
|
12
|
+
var _arr = [];
|
|
13
|
+
var _n = true;
|
|
14
|
+
var _d = false;
|
|
15
|
+
var _s, _e;
|
|
16
|
+
try {
|
|
17
|
+
for(_i = _i.call(arr); !(_n = (_s = _i.next()).done); _n = true){
|
|
18
|
+
_arr.push(_s.value);
|
|
19
|
+
if (i && _arr.length === i) break;
|
|
20
|
+
}
|
|
21
|
+
} catch (err) {
|
|
22
|
+
_d = true;
|
|
23
|
+
_e = err;
|
|
24
|
+
} finally{
|
|
25
|
+
try {
|
|
26
|
+
if (!_n && _i["return"] != null) _i["return"]();
|
|
27
|
+
} finally{
|
|
28
|
+
if (_d) throw _e;
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
return _arr;
|
|
32
|
+
}
|
|
33
|
+
function _non_iterable_rest() {
|
|
34
|
+
throw new TypeError("Invalid attempt to destructure non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
|
|
35
|
+
}
|
|
36
|
+
function _sliced_to_array(arr, i) {
|
|
37
|
+
return _array_with_holes(arr) || _iterable_to_array_limit(arr, i) || _unsupported_iterable_to_array(arr, i) || _non_iterable_rest();
|
|
38
|
+
}
|
|
39
|
+
function _unsupported_iterable_to_array(o, minLen) {
|
|
40
|
+
if (!o) return;
|
|
41
|
+
if (typeof o === "string") return _array_like_to_array(o, minLen);
|
|
42
|
+
var n = Object.prototype.toString.call(o).slice(8, -1);
|
|
43
|
+
if (n === "Object" && o.constructor) n = o.constructor.name;
|
|
44
|
+
if (n === "Map" || n === "Set") return Array.from(n);
|
|
45
|
+
if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _array_like_to_array(o, minLen);
|
|
46
|
+
}
|
|
47
|
+
import { useEffect, useMemo, useState } from "react";
|
|
48
|
+
import { TABLE_ROW_INDEX_COL_WIDTH } from "../TableColgroup";
|
|
49
|
+
var TABLE_HORIZONTAL_PADDING = 32;
|
|
50
|
+
var DEFAULT_CONTENT_WIDTH = 400;
|
|
51
|
+
var getEditorContentElement = function getEditorContentElement(markdownContainerRef) {
|
|
52
|
+
var _markdownContainerRef_current;
|
|
53
|
+
return (markdownContainerRef === null || markdownContainerRef === void 0 ? void 0 : (_markdownContainerRef_current = markdownContainerRef.current) === null || _markdownContainerRef_current === void 0 ? void 0 : _markdownContainerRef_current.querySelector('.ant-agentic-md-editor-content')) || null;
|
|
54
|
+
};
|
|
55
|
+
var getEditorContentWidth = function getEditorContentWidth(markdownContainerRef) {
|
|
56
|
+
var _getEditorContentElement;
|
|
57
|
+
return ((_getEditorContentElement = getEditorContentElement(markdownContainerRef)) === null || _getEditorContentElement === void 0 ? void 0 : _getEditorContentElement.clientWidth) || 0;
|
|
58
|
+
};
|
|
59
|
+
export function useEditableTableContentWidth(param) {
|
|
60
|
+
var readonly = param.readonly, markdownContainerRef = param.markdownContainerRef, minContainerWidth = param.minContainerWidth;
|
|
61
|
+
var _useState = _sliced_to_array(useState(0), 2), contentWidth = _useState[0], setContentWidth = _useState[1];
|
|
62
|
+
var resolvedContentWidth = useMemo(function() {
|
|
63
|
+
if (contentWidth > 0) return contentWidth;
|
|
64
|
+
return getEditorContentWidth(markdownContainerRef) || DEFAULT_CONTENT_WIDTH;
|
|
65
|
+
}, [
|
|
66
|
+
contentWidth,
|
|
67
|
+
markdownContainerRef
|
|
68
|
+
]);
|
|
69
|
+
var availableTableWidth = useMemo(function() {
|
|
70
|
+
return Math.max(resolvedContentWidth - TABLE_HORIZONTAL_PADDING - TABLE_ROW_INDEX_COL_WIDTH, minContainerWidth);
|
|
71
|
+
}, [
|
|
72
|
+
resolvedContentWidth,
|
|
73
|
+
minContainerWidth
|
|
74
|
+
]);
|
|
75
|
+
useEffect(function() {
|
|
76
|
+
if (readonly || typeof window === 'undefined') return;
|
|
77
|
+
var contentElement = getEditorContentElement(markdownContainerRef);
|
|
78
|
+
if (!contentElement) {
|
|
79
|
+
setContentWidth(0);
|
|
80
|
+
return;
|
|
81
|
+
}
|
|
82
|
+
var updateWidth = function updateWidth() {
|
|
83
|
+
return setContentWidth(contentElement.clientWidth || 0);
|
|
84
|
+
};
|
|
85
|
+
if (typeof ResizeObserver === 'undefined') {
|
|
86
|
+
updateWidth();
|
|
87
|
+
return;
|
|
88
|
+
}
|
|
89
|
+
var resizeObserver = new ResizeObserver(updateWidth);
|
|
90
|
+
resizeObserver.observe(contentElement);
|
|
91
|
+
updateWidth();
|
|
92
|
+
return function() {
|
|
93
|
+
return resizeObserver.disconnect();
|
|
94
|
+
};
|
|
95
|
+
}, [
|
|
96
|
+
readonly,
|
|
97
|
+
markdownContainerRef
|
|
98
|
+
]);
|
|
99
|
+
return {
|
|
100
|
+
resolvedContentWidth: resolvedContentWidth,
|
|
101
|
+
availableTableWidth: availableTableWidth
|
|
102
|
+
};
|
|
103
|
+
}
|
|
@@ -96,6 +96,8 @@ import { debugInfo } from "../../../Utils/debugUtils";
|
|
|
96
96
|
import { JINJA_DOLLAR_PLACEHOLDER } from "../parser/constants";
|
|
97
97
|
import { useEditorStore } from "../store";
|
|
98
98
|
import { EditorUtils } from "../utils/editorUtils";
|
|
99
|
+
import { AgenticUiTaskBlock, ReadonlyAgenticUiTaskBlock } from "./AgenticUiBlocks/AgenticUiTaskBlock";
|
|
100
|
+
import { AgenticUiToolUseBarBlock, ReadonlyAgenticUiToolUseBarBlock } from "./AgenticUiBlocks/AgenticUiToolUseBarBlock";
|
|
99
101
|
import { Blockquote } from "./Blockquote";
|
|
100
102
|
import { ReadonlyBlockquote } from "./Blockquote/ReadonlyBlockquote";
|
|
101
103
|
import { Break } from "./Break";
|
|
@@ -243,6 +245,11 @@ var MElementComponent = function MElementComponent(props) {
|
|
|
243
245
|
case 'apassify':
|
|
244
246
|
case 'apaasify':
|
|
245
247
|
return props.readonly ? /*#__PURE__*/ React.createElement(ReadonlySchema, readonlyElementProps) : /*#__PURE__*/ React.createElement(Schema, props);
|
|
248
|
+
case 'agentic-ui-task':
|
|
249
|
+
return props.readonly ? /*#__PURE__*/ React.createElement(ReadonlyAgenticUiTaskBlock, readonlyElementProps) : /*#__PURE__*/ React.createElement(AgenticUiTaskBlock, props);
|
|
250
|
+
case 'agentic-ui-toolusebar':
|
|
251
|
+
case 'agentic-ui-usertoolbar':
|
|
252
|
+
return props.readonly ? /*#__PURE__*/ React.createElement(ReadonlyAgenticUiToolUseBarBlock, readonlyElementProps) : /*#__PURE__*/ React.createElement(AgenticUiToolUseBarBlock, props);
|
|
246
253
|
case 'image':
|
|
247
254
|
return props.readonly ? /*#__PURE__*/ React.createElement(ReadonlyEditorImage, readonlyElementProps) : /*#__PURE__*/ React.createElement(EditorImage, props);
|
|
248
255
|
case 'media':
|
|
@@ -59,7 +59,35 @@ var NOT_SPACE_START = /^\S*/;
|
|
|
59
59
|
var ENDING_NEWLINE = /\n$/;
|
|
60
60
|
/**
|
|
61
61
|
* 处理schema类型语言的辅助函数
|
|
62
|
-
*/ var
|
|
62
|
+
*/ var processAgenticUiJsonBlock = function processAgenticUiJsonBlock(slateType) {
|
|
63
|
+
return function(element, value) {
|
|
64
|
+
var parsed = {};
|
|
65
|
+
try {
|
|
66
|
+
parsed = json5.parse(value || '{}');
|
|
67
|
+
} catch (unused) {
|
|
68
|
+
try {
|
|
69
|
+
parsed = partialJsonParse(value || '{}');
|
|
70
|
+
} catch (error) {
|
|
71
|
+
parsed = {
|
|
72
|
+
_parseError: true,
|
|
73
|
+
_raw: value
|
|
74
|
+
};
|
|
75
|
+
console.error('parse agentic-ui embed block error', error);
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
return _object_spread_props(_object_spread({}, element), {
|
|
79
|
+
type: slateType,
|
|
80
|
+
language: slateType,
|
|
81
|
+
value: parsed,
|
|
82
|
+
children: [
|
|
83
|
+
{
|
|
84
|
+
text: value
|
|
85
|
+
}
|
|
86
|
+
]
|
|
87
|
+
});
|
|
88
|
+
};
|
|
89
|
+
};
|
|
90
|
+
var processSchemaLanguage = function processSchemaLanguage(element, value) {
|
|
63
91
|
var json = [];
|
|
64
92
|
try {
|
|
65
93
|
json = json5.parse(value || '[]');
|
|
@@ -97,7 +125,10 @@ var ENDING_NEWLINE = /\n$/;
|
|
|
97
125
|
type: 'katex'
|
|
98
126
|
});
|
|
99
127
|
},
|
|
100
|
-
'agentar-card': processSchemaLanguage
|
|
128
|
+
'agentar-card': processSchemaLanguage,
|
|
129
|
+
'agentic-ui-task': processAgenticUiJsonBlock('agentic-ui-task'),
|
|
130
|
+
'agentic-ui-toolusebar': processAgenticUiJsonBlock('agentic-ui-toolusebar'),
|
|
131
|
+
/** @deprecated 使用 `agentic-ui-toolusebar`,保留解析以兼容旧内容 */ 'agentic-ui-usertoolbar': processAgenticUiJsonBlock('agentic-ui-toolusebar')
|
|
101
132
|
};
|
|
102
133
|
/**
|
|
103
134
|
* 处理代码块节点
|
|
@@ -755,7 +755,10 @@ import { parseMarkdownToNodesAndInsert } from "./parseMarkdownToNodesAndInsert";
|
|
|
755
755
|
'table',
|
|
756
756
|
'code',
|
|
757
757
|
'schema',
|
|
758
|
-
'apaasify'
|
|
758
|
+
'apaasify',
|
|
759
|
+
'agentic-ui-task',
|
|
760
|
+
'agentic-ui-toolusebar',
|
|
761
|
+
'agentic-ui-usertoolbar'
|
|
759
762
|
].includes(rangeNode.type);
|
|
760
763
|
};
|
|
761
764
|
/**
|
|
@@ -55,6 +55,9 @@ import { resetComponent, useEditorStyleRegister } from "../Hooks/useStyle";
|
|
|
55
55
|
// ── Table ──────────────────────────────────────────────────────────────────
|
|
56
56
|
var TABLE_BORDER = '1px solid var(--agentic-ui-table-border-color, #E7E9E8)';
|
|
57
57
|
var TABLE_RADIUS = 'var(--agentic-ui-table-border-radius, 8px)';
|
|
58
|
+
var TABLE_ACTION_BUTTON_SIZE = 20;
|
|
59
|
+
var TABLE_ACTION_BUTTON_GAP = '2px';
|
|
60
|
+
var TABLE_ACTION_BUTTON_ICON_SIZE = 12;
|
|
58
61
|
var TABLE_CELL = {
|
|
59
62
|
verticalAlign: 'top',
|
|
60
63
|
padding: 'var(--agentic-ui-table-cell-padding, 16px 12px)',
|
|
@@ -74,8 +77,7 @@ var genTableStyle = function genTableStyle(token, mobileBreakpoint, mobilePaddin
|
|
|
74
77
|
var _obj, _obj1;
|
|
75
78
|
return _obj1 = {}, _define_property(_obj1, tableCls, {
|
|
76
79
|
width: '100%',
|
|
77
|
-
|
|
78
|
-
flex: 1,
|
|
80
|
+
maxWidth: '100%',
|
|
79
81
|
minWidth: 0,
|
|
80
82
|
position: 'relative',
|
|
81
83
|
'&-container': _define_property({
|
|
@@ -134,20 +136,26 @@ var genTableStyle = function genTableStyle(token, mobileBreakpoint, mobilePaddin
|
|
|
134
136
|
fontWeight: 600
|
|
135
137
|
})), _define_property(_obj, 'th:not(:first-child)', {
|
|
136
138
|
borderLeft: TABLE_BORDER
|
|
137
|
-
}), _define_property(_obj,
|
|
139
|
+
}), _define_property(_obj, 'td:not(.config-td)', _object_spread_props(_object_spread({}, TABLE_CELL), {
|
|
140
|
+
position: 'relative',
|
|
138
141
|
borderBottom: TABLE_BORDER,
|
|
139
142
|
borderLeft: TABLE_BORDER,
|
|
140
143
|
'div[data-be="paragraph"]': {
|
|
141
144
|
margin: 0,
|
|
142
145
|
textWrap: 'auto'
|
|
143
146
|
}
|
|
144
|
-
})), _define_property(_obj, 'td
|
|
147
|
+
})), _define_property(_obj, 'th.config-th, td.config-td', {
|
|
148
|
+
borderBottom: TABLE_BORDER,
|
|
149
|
+
borderLeft: TABLE_BORDER
|
|
150
|
+
}), _define_property(_obj, 'tr td.config-td:first-child', {
|
|
145
151
|
borderLeft: 'none'
|
|
146
|
-
}), _define_property(_obj, '
|
|
152
|
+
}), _define_property(_obj, 'td:first-child:not(.config-td)', {
|
|
153
|
+
borderLeft: 'none'
|
|
154
|
+
}), _define_property(_obj, 'tr:last-child td:not(.config-td)', {
|
|
147
155
|
borderBottom: 'none'
|
|
148
|
-
}), _define_property(_obj, 'tr td:first-child', {
|
|
156
|
+
}), _define_property(_obj, 'tr td:first-child:not(.config-td)', {
|
|
149
157
|
fontWeight: 600
|
|
150
|
-
}), _define_property(_obj, 'tbody tr:hover', {
|
|
158
|
+
}), _define_property(_obj, 'tbody tr:not(.config-tr):hover', {
|
|
151
159
|
background: 'linear-gradient(var(--agentic-ui-table-hover-bg, rgba(0, 0, 0, 0.04)), var(--agentic-ui-table-hover-bg, rgba(0, 0, 0, 0.04))), linear-gradient(var(--agentic-ui-table-cell-bg, #ffffff), var(--agentic-ui-table-cell-bg, #ffffff))'
|
|
152
160
|
}), _define_property(_obj, "@media (max-width: ".concat(mobileBreakpoint, ")"), {
|
|
153
161
|
'th, td': {
|
|
@@ -187,12 +195,106 @@ var genTableStyle = function genTableStyle(token, mobileBreakpoint, mobilePaddin
|
|
|
187
195
|
'&:hover': {
|
|
188
196
|
backgroundColor: 'var(--color-gray-control-fill-secondary-hover)'
|
|
189
197
|
}
|
|
198
|
+
}), _define_property(_obj1, "".concat(token.componentCls, "-table-cell-index-action-buttons"), {
|
|
199
|
+
position: 'absolute',
|
|
200
|
+
top: 4,
|
|
201
|
+
left: -24,
|
|
202
|
+
zIndex: 1000,
|
|
203
|
+
alignItems: 'center',
|
|
204
|
+
flexDirection: 'column',
|
|
205
|
+
gap: TABLE_ACTION_BUTTON_GAP,
|
|
206
|
+
opacity: 0,
|
|
207
|
+
display: 'none',
|
|
208
|
+
transition: 'opacity 0.2s cubic-bezier(0.645, 0.045, 0.355, 1)'
|
|
209
|
+
}), _define_property(_obj1, "".concat(token.componentCls, "-table-cell-index-action-buttons-visible"), {
|
|
210
|
+
opacity: 1,
|
|
211
|
+
display: 'flex'
|
|
212
|
+
}), _define_property(_obj1, "".concat(token.componentCls, "-table-cell-index-action-button"), {
|
|
213
|
+
padding: 2,
|
|
214
|
+
display: 'flex',
|
|
215
|
+
alignItems: 'center',
|
|
216
|
+
zIndex: 1000,
|
|
217
|
+
justifyContent: 'center',
|
|
218
|
+
fontSize: TABLE_ACTION_BUTTON_ICON_SIZE,
|
|
219
|
+
border: TABLE_BORDER,
|
|
220
|
+
width: TABLE_ACTION_BUTTON_SIZE,
|
|
221
|
+
height: TABLE_ACTION_BUTTON_SIZE,
|
|
222
|
+
cursor: 'pointer',
|
|
223
|
+
backgroundPosition: '50%',
|
|
224
|
+
backgroundRepeat: 'no-repeat',
|
|
225
|
+
transition: 'color 0.2s cubic-bezier(0.645, 0.045, 0.355, 1), background-color 0.2s cubic-bezier(0.645, 0.045, 0.355, 1)',
|
|
226
|
+
borderRadius: '4px',
|
|
227
|
+
background: 'var(--color-gray-bg-card-white)',
|
|
228
|
+
boxShadow: 'var(--shadow-border-base)',
|
|
229
|
+
color: 'var(--color-gray-text-secondary)',
|
|
230
|
+
'&:hover': {
|
|
231
|
+
backgroundColor: '#FFF',
|
|
232
|
+
boxShadow: 'var(--shadow-control-lg)'
|
|
233
|
+
}
|
|
234
|
+
}), _define_property(_obj1, "".concat(token.componentCls, "-table-cell-index-delete-icon"), {
|
|
235
|
+
'&:hover': {
|
|
236
|
+
color: '#ff4d4f'
|
|
237
|
+
}
|
|
238
|
+
}), _define_property(_obj1, "".concat(token.componentCls, "-table-cell-index-insert-row-before"), {
|
|
239
|
+
'&:hover': {
|
|
240
|
+
color: '#52c41a'
|
|
241
|
+
}
|
|
242
|
+
}), _define_property(_obj1, "".concat(token.componentCls, "-table-cell-index-insert-row-after"), {
|
|
243
|
+
'&:hover': {
|
|
244
|
+
color: '#52c41a'
|
|
245
|
+
}
|
|
190
246
|
}), _define_property(_obj1, "".concat(token.componentCls, "-table-cell-index-spacer"), {
|
|
191
247
|
cursor: 'pointer',
|
|
192
248
|
backgroundColor: 'var(--color-gray-control-fill-secondary)',
|
|
193
249
|
'&:hover': {
|
|
194
250
|
backgroundColor: 'var(--color-gray-control-fill-secondary-hover)'
|
|
195
251
|
}
|
|
252
|
+
}), _define_property(_obj1, "".concat(token.componentCls, "-table-cell-index-spacer-action-buttons"), {
|
|
253
|
+
position: 'absolute',
|
|
254
|
+
top: -28,
|
|
255
|
+
right: '50%',
|
|
256
|
+
transform: 'translateX(50%)',
|
|
257
|
+
zIndex: 10,
|
|
258
|
+
display: 'flex',
|
|
259
|
+
alignItems: 'center',
|
|
260
|
+
gap: TABLE_ACTION_BUTTON_GAP,
|
|
261
|
+
opacity: 0,
|
|
262
|
+
transition: 'opacity 0.2s cubic-bezier(0.645, 0.045, 0.355, 1)'
|
|
263
|
+
}), _define_property(_obj1, "".concat(token.componentCls, "-table-cell-index-spacer-action-buttons-visible"), {
|
|
264
|
+
opacity: 1
|
|
265
|
+
}), _define_property(_obj1, "".concat(token.componentCls, "-table-cell-index-spacer-action-button"), {
|
|
266
|
+
padding: 2,
|
|
267
|
+
display: 'flex',
|
|
268
|
+
alignItems: 'center',
|
|
269
|
+
justifyContent: 'center',
|
|
270
|
+
fontSize: TABLE_ACTION_BUTTON_ICON_SIZE,
|
|
271
|
+
border: TABLE_BORDER,
|
|
272
|
+
width: TABLE_ACTION_BUTTON_SIZE,
|
|
273
|
+
height: TABLE_ACTION_BUTTON_SIZE,
|
|
274
|
+
cursor: 'pointer',
|
|
275
|
+
backgroundPosition: '50%',
|
|
276
|
+
backgroundRepeat: 'no-repeat',
|
|
277
|
+
transition: 'color 0.2s cubic-bezier(0.645, 0.045, 0.355, 1), background-color 0.2s cubic-bezier(0.645, 0.045, 0.355, 1)',
|
|
278
|
+
borderRadius: '4px',
|
|
279
|
+
background: 'var(--color-gray-bg-card-white)',
|
|
280
|
+
boxShadow: 'var(--shadow-border-base)',
|
|
281
|
+
color: 'var(--color-gray-text-secondary)',
|
|
282
|
+
'&:hover': {
|
|
283
|
+
backgroundColor: '#FFF',
|
|
284
|
+
boxShadow: 'var(--shadow-control-lg)'
|
|
285
|
+
}
|
|
286
|
+
}), _define_property(_obj1, "".concat(token.componentCls, "-table-cell-index-spacer-delete-icon"), {
|
|
287
|
+
'&:hover': {
|
|
288
|
+
color: '#ff4d4f'
|
|
289
|
+
}
|
|
290
|
+
}), _define_property(_obj1, "".concat(token.componentCls, "-table-cell-index-spacer-insert-column-before"), {
|
|
291
|
+
'&:hover': {
|
|
292
|
+
color: '#52c41a'
|
|
293
|
+
}
|
|
294
|
+
}), _define_property(_obj1, "".concat(token.componentCls, "-table-cell-index-spacer-insert-column-after"), {
|
|
295
|
+
'&:hover': {
|
|
296
|
+
color: '#52c41a'
|
|
297
|
+
}
|
|
196
298
|
}), _obj1;
|
|
197
299
|
};
|
|
198
300
|
var genStyle = function genStyle(token) {
|
|
@@ -261,8 +261,8 @@ var IMAGE_PREVIEW_CONFIG = {
|
|
|
261
261
|
export var AttachmentFileIcon = function AttachmentFileIcon(props) {
|
|
262
262
|
var _file_type;
|
|
263
263
|
var file = props.file, className = props.className;
|
|
264
|
-
//
|
|
265
|
-
if (file.status === 'uploading') {
|
|
264
|
+
// 上传中状态(兼容 pending)
|
|
265
|
+
if (file.status === 'uploading' || file.status === 'pending') {
|
|
266
266
|
return /*#__PURE__*/ React.createElement(FileUploadingSpin, null);
|
|
267
267
|
}
|
|
268
268
|
// 错误状态
|
package/dist/MarkdownInputField/AttachmentButton/AttachmentFileList/AttachmentFileListItem.js
CHANGED
|
@@ -17,7 +17,7 @@ import classNames from "clsx";
|
|
|
17
17
|
import { motion } from "framer-motion";
|
|
18
18
|
import React, { useContext } from "react";
|
|
19
19
|
import { I18nContext } from "../../../I18n";
|
|
20
|
-
import { isFileMetaPlaceholderState, kbToSize } from "../utils";
|
|
20
|
+
import { isAttachmentFileLoading, isFileMetaPlaceholderState, kbToSize } from "../utils";
|
|
21
21
|
import { AttachmentFileIcon, FileMetaPlaceholder } from "./AttachmentFileIcon";
|
|
22
22
|
var getFileNameWithoutExtension = function getFileNameWithoutExtension(fileName) {
|
|
23
23
|
return fileName.split('.').slice(0, -1).join('.');
|
|
@@ -27,7 +27,7 @@ var getFileExtension = function getFileExtension(fileName) {
|
|
|
27
27
|
};
|
|
28
28
|
var FileIcon = function FileIcon(param) {
|
|
29
29
|
var file = param.file, prefixCls = param.prefixCls, hashId = param.hashId;
|
|
30
|
-
var status = file.status || 'done';
|
|
30
|
+
var status = (file.status || 'done') === 'pending' ? 'uploading' : file.status || 'done';
|
|
31
31
|
var iconMap = {
|
|
32
32
|
uploading: /*#__PURE__*/ React.createElement("div", {
|
|
33
33
|
className: classNames("".concat(prefixCls, "-uploading-icon"), hashId)
|
|
@@ -50,9 +50,10 @@ var FileSizeInfo = function FileSizeInfo(param) {
|
|
|
50
50
|
var baseClassName = classNames("".concat(prefixCls, "-file-size"), hashId);
|
|
51
51
|
var statusContentMap = {
|
|
52
52
|
uploading: (locale === null || locale === void 0 ? void 0 : locale.uploading) || '上传中...',
|
|
53
|
+
pending: (locale === null || locale === void 0 ? void 0 : locale.uploading) || '上传中...',
|
|
53
54
|
error: /*#__PURE__*/ React.createElement("div", {
|
|
54
55
|
className: classNames(baseClassName, "".concat(prefixCls, "-file-size-error"))
|
|
55
|
-
}, (locale === null || locale === void 0 ? void 0 : locale.uploadFailed) || '上传失败'),
|
|
56
|
+
}, file.errorMessage || (locale === null || locale === void 0 ? void 0 : locale.uploadFailed) || '上传失败'),
|
|
56
57
|
done: function() {
|
|
57
58
|
var fileExtension = getFileExtension(file.name);
|
|
58
59
|
var fileSize = file.size ? kbToSize(file.size / 1024) : '';
|
|
@@ -104,14 +105,16 @@ export var AttachmentFileListItem = function AttachmentFileListItem(param) {
|
|
|
104
105
|
var file = param.file, prefixCls = param.prefixCls, hashId = param.hashId, onPreview = param.onPreview, onRetry = param.onRetry, onDelete = param.onDelete, className = param.className;
|
|
105
106
|
var locale = useContext(I18nContext).locale;
|
|
106
107
|
var isErrorStatus = file.status === 'error';
|
|
108
|
+
var isSizeExceededError = isErrorStatus && file.errorCode === 'FILE_SIZE_EXCEEDED';
|
|
109
|
+
var canRetry = isErrorStatus && !isSizeExceededError;
|
|
107
110
|
var isDoneStatus = file.status === 'done';
|
|
108
|
-
var canDelete = file.status
|
|
111
|
+
var canDelete = !isAttachmentFileLoading(file.status);
|
|
109
112
|
var handleFileClick = function handleFileClick() {
|
|
110
113
|
if (!isDoneStatus) return;
|
|
111
114
|
onPreview === null || onPreview === void 0 ? void 0 : onPreview(file);
|
|
112
115
|
};
|
|
113
116
|
var handleRetryClick = function handleRetryClick() {
|
|
114
|
-
if (!
|
|
117
|
+
if (!canRetry) return;
|
|
115
118
|
onRetry === null || onRetry === void 0 ? void 0 : onRetry(file);
|
|
116
119
|
};
|
|
117
120
|
var handleDeleteClick = function handleDeleteClick(e) {
|
|
@@ -119,15 +122,15 @@ export var AttachmentFileListItem = function AttachmentFileListItem(param) {
|
|
|
119
122
|
onDelete(file);
|
|
120
123
|
};
|
|
121
124
|
// 有 status 但无 url/previewUrl:文件内容未拿到,展示大小与格式占位块
|
|
122
|
-
if (file
|
|
125
|
+
if (isFileMetaPlaceholderState(file)) {
|
|
123
126
|
return /*#__PURE__*/ React.createElement(FileMetaPlaceholder, {
|
|
124
127
|
file: file,
|
|
125
128
|
className: className
|
|
126
129
|
});
|
|
127
130
|
}
|
|
128
131
|
return /*#__PURE__*/ React.createElement(Tooltip, {
|
|
129
|
-
title: (locale === null || locale === void 0 ? void 0 : locale.clickToRetry) || '点击重试',
|
|
130
|
-
open:
|
|
132
|
+
title: canRetry ? (locale === null || locale === void 0 ? void 0 : locale.clickToRetry) || '点击重试' : undefined,
|
|
133
|
+
open: canRetry ? undefined : false
|
|
131
134
|
}, /*#__PURE__*/ React.createElement(motion.div, {
|
|
132
135
|
variants: ANIMATION_VARIANTS,
|
|
133
136
|
onClick: handleFileClick,
|
|
@@ -166,7 +166,7 @@ var DEFAULT_MESSAGES = {
|
|
|
166
166
|
return "至少需要上传 ".concat(count, " 个文件");
|
|
167
167
|
},
|
|
168
168
|
fileSizeExceeded: function fileSizeExceeded(size) {
|
|
169
|
-
return "
|
|
169
|
+
return "超过 ".concat(size, " KB");
|
|
170
170
|
}
|
|
171
171
|
};
|
|
172
172
|
var waitTime = function waitTime(ms) {
|
|
@@ -271,11 +271,12 @@ var handleUploadSuccess = function handleUploadSuccess(file, url, map, props) {
|
|
|
271
271
|
};
|
|
272
272
|
var handleUploadError = function handleUploadError(file, errorMsg, map, props) {
|
|
273
273
|
file.status = 'error';
|
|
274
|
+
if (errorMsg !== null) file.errorMessage = errorMsg;
|
|
274
275
|
updateFileMap(map, file, props.onFileMapChange);
|
|
275
276
|
};
|
|
276
277
|
var processFile = function processFile(file, index, map, props) {
|
|
277
278
|
return _async_to_generator(function() {
|
|
278
|
-
var _ref, url, isSuccess, errorMsg, error, errorMessage;
|
|
279
|
+
var maxSizeKb, raw, _ref, url, isSuccess, errorMsg, error, errorMessage;
|
|
279
280
|
return _ts_generator(this, function(_state) {
|
|
280
281
|
switch(_state.label){
|
|
281
282
|
case 0:
|
|
@@ -286,6 +287,10 @@ var processFile = function processFile(file, index, map, props) {
|
|
|
286
287
|
case 1:
|
|
287
288
|
_state.sent();
|
|
288
289
|
if (!validateFileSize(file, props)) {
|
|
290
|
+
maxSizeKb = Math.round((props.maxFileSize || 0) / 1024);
|
|
291
|
+
raw = getLocaleMessage(props.locale, 'markdownInput.fileSizeExceeded', DEFAULT_MESSAGES.fileSizeExceeded(maxSizeKb));
|
|
292
|
+
file.errorMessage = raw.includes('${maxSize}') ? raw.replace(/\$\{maxSize\}/g, String(maxSizeKb)) : raw;
|
|
293
|
+
file.errorCode = 'FILE_SIZE_EXCEEDED';
|
|
289
294
|
file.status = 'error';
|
|
290
295
|
updateFileMap(map, file, props.onFileMapChange);
|
|
291
296
|
return [
|
|
@@ -13,10 +13,14 @@ export type UploadResponse = {
|
|
|
13
13
|
};
|
|
14
14
|
export type AttachmentFile = File & {
|
|
15
15
|
url?: string;
|
|
16
|
-
status?: 'error' | 'uploading' | 'done';
|
|
16
|
+
status?: 'error' | 'uploading' | 'pending' | 'done';
|
|
17
17
|
uuid?: string;
|
|
18
18
|
size?: number | null;
|
|
19
19
|
previewUrl?: string;
|
|
20
|
+
/** 错误信息(如文件超限、上传失败等),在 status 为 error 时展示 */
|
|
21
|
+
errorMessage?: string | null;
|
|
22
|
+
/** 错误类型,如 FILE_SIZE_EXCEEDED 表示因大小超限不可重试 */
|
|
23
|
+
errorCode?: string | null;
|
|
20
24
|
/** 上传响应数据(使用 uploadWithResponse 时会填充此字段) */
|
|
21
25
|
uploadResponse?: UploadResponse;
|
|
22
26
|
};
|
|
@@ -40,6 +40,13 @@ export declare const isMediaFile: (file: File) => boolean;
|
|
|
40
40
|
/**
|
|
41
41
|
* 是否为「仅元信息占位」状态:有 status 但无 url/previewUrl,内容未拿到时整行以 FileMetaPlaceholder 风格展示
|
|
42
42
|
*/
|
|
43
|
+
export declare const isAttachmentFileLoading: (status?: string | null) => boolean;
|
|
44
|
+
/**
|
|
45
|
+
* 是否应该展示 FileMetaPlaceholder:
|
|
46
|
+
* - 有状态
|
|
47
|
+
* - 非 loading(uploading/pending)
|
|
48
|
+
* - 且没有可预览 URL
|
|
49
|
+
*/
|
|
43
50
|
export declare const isFileMetaPlaceholderState: (file: File & {
|
|
44
51
|
status?: string;
|
|
45
52
|
url?: string;
|
|
@@ -109,8 +109,16 @@ var hasVideoExtension = function hasVideoExtension(pathOrName) {
|
|
|
109
109
|
};
|
|
110
110
|
/**
|
|
111
111
|
* 是否为「仅元信息占位」状态:有 status 但无 url/previewUrl,内容未拿到时整行以 FileMetaPlaceholder 风格展示
|
|
112
|
+
*/ export var isAttachmentFileLoading = function isAttachmentFileLoading(status) {
|
|
113
|
+
return status === 'uploading' || status === 'pending';
|
|
114
|
+
};
|
|
115
|
+
/**
|
|
116
|
+
* 是否应该展示 FileMetaPlaceholder:
|
|
117
|
+
* - 有状态
|
|
118
|
+
* - 非 loading(uploading/pending)
|
|
119
|
+
* - 且没有可预览 URL
|
|
112
120
|
*/ export var isFileMetaPlaceholderState = function isFileMetaPlaceholderState(file) {
|
|
113
|
-
return file.status !== undefined && file.status !== null && !file.url && !file.previewUrl;
|
|
121
|
+
return file.status !== undefined && file.status !== null && !isAttachmentFileLoading(file.status) && !file.url && !file.previewUrl;
|
|
114
122
|
};
|
|
115
123
|
/**
|
|
116
124
|
* 设备品牌匹配列表
|
|
@@ -117,14 +117,14 @@ import { isFileMetaPlaceholderState, kbToSize } from "../AttachmentButton/utils"
|
|
|
117
117
|
var lastDotIndex = fileName.lastIndexOf('.');
|
|
118
118
|
var displayName = lastDotIndex > 0 ? fileName.slice(0, lastDotIndex) : fileName;
|
|
119
119
|
var displayExtension = lastDotIndex > 0 && lastDotIndex < fileName.length - 1 ? fileName.slice(lastDotIndex + 1) : '';
|
|
120
|
-
// 有 status 但无 url/previewUrl
|
|
121
|
-
if (file
|
|
120
|
+
// 有 status 但无 url/previewUrl:文件内容未拿到,展示大小与格式占位块(loading 状态除外)
|
|
121
|
+
if (isFileMetaPlaceholderState(file)) {
|
|
122
122
|
return /*#__PURE__*/ React.createElement(FileMetaPlaceholder, {
|
|
123
123
|
file: file
|
|
124
124
|
});
|
|
125
125
|
}
|
|
126
126
|
return /*#__PURE__*/ React.createElement(Tooltip, {
|
|
127
|
-
title: /*#__PURE__*/ React.createElement("div", null, locale === null || locale === void 0 ? void 0 : locale.clickToPreview),
|
|
127
|
+
title: file.status === 'error' && file.errorMessage ? /*#__PURE__*/ React.createElement("div", null, file.errorMessage) : /*#__PURE__*/ React.createElement("div", null, locale === null || locale === void 0 ? void 0 : locale.clickToPreview),
|
|
128
128
|
placement: "topLeft",
|
|
129
129
|
arrow: false
|
|
130
130
|
}, /*#__PURE__*/ React.createElement(motion.div, {
|
|
@@ -175,7 +175,12 @@ import { isFileMetaPlaceholderState, kbToSize } from "../AttachmentButton/utils"
|
|
|
175
175
|
title: file === null || file === void 0 ? void 0 : file.name
|
|
176
176
|
}, displayName)), /*#__PURE__*/ React.createElement("div", {
|
|
177
177
|
className: classNames("".concat(props.prefixCls, "-file-name-extension-container"), props.hashId)
|
|
178
|
-
}, /*#__PURE__*/ React.createElement("span", {
|
|
178
|
+
}, file.status === 'error' && file.errorMessage ? /*#__PURE__*/ React.createElement("span", {
|
|
179
|
+
className: classNames("".concat(props.prefixCls, "-file-error-msg"), props.hashId),
|
|
180
|
+
style: {
|
|
181
|
+
color: 'var(--color-red-text-secondary)'
|
|
182
|
+
}
|
|
183
|
+
}, file.errorMessage) : /*#__PURE__*/ React.createElement(React.Fragment, null, /*#__PURE__*/ React.createElement("span", {
|
|
179
184
|
className: classNames("".concat(props.prefixCls, "-file-name-extension"), props.hashId)
|
|
180
185
|
}, displayExtension), /*#__PURE__*/ React.createElement("span", {
|
|
181
186
|
className: classNames("".concat(props.prefixCls, "-separator"), props.hashId)
|
|
@@ -183,7 +188,7 @@ import { isFileMetaPlaceholderState, kbToSize } from "../AttachmentButton/utils"
|
|
|
183
188
|
className: classNames("".concat(props.prefixCls, "-file-size"), props.hashId)
|
|
184
189
|
}, kbToSize(file.size / 1024)), /*#__PURE__*/ React.createElement("span", {
|
|
185
190
|
className: classNames("".concat(props.prefixCls, "-separator"), props.hashId)
|
|
186
|
-
}, "|"), /*#__PURE__*/ React.createElement("div", null, (file === null || file === void 0 ? void 0 : file.lastModified) ? dayjs(file === null || file === void 0 ? void 0 : file.lastModified).format('HH:mm') : ''))), hovered ? /*#__PURE__*/ React.createElement("div", {
|
|
191
|
+
}, "|"), /*#__PURE__*/ React.createElement("div", null, (file === null || file === void 0 ? void 0 : file.lastModified) ? dayjs(file === null || file === void 0 ? void 0 : file.lastModified).format('HH:mm') : '')))), hovered ? /*#__PURE__*/ React.createElement("div", {
|
|
187
192
|
className: classNames("".concat(props.prefixCls, "-action-bar"), props.hashId)
|
|
188
193
|
}, props.customSlot ? /*#__PURE__*/ React.createElement(ActionIconBox, {
|
|
189
194
|
title: '更多',
|
|
@@ -18,6 +18,15 @@ export interface FileUploadManagerReturn {
|
|
|
18
18
|
fileMap?: Map<string, AttachmentFile>;
|
|
19
19
|
/** 文件上传是否完成 */
|
|
20
20
|
fileUploadDone: boolean;
|
|
21
|
+
/** 文件上传状态 */
|
|
22
|
+
fileUploadStatus: 'uploading' | 'done' | 'error';
|
|
23
|
+
/** 文件上传状态统计 */
|
|
24
|
+
fileUploadSummary: {
|
|
25
|
+
totalCount: number;
|
|
26
|
+
doneCount: number;
|
|
27
|
+
uploadingCount: number;
|
|
28
|
+
errorCount: number;
|
|
29
|
+
};
|
|
21
30
|
/** 支持的文件格式 */
|
|
22
31
|
supportedFormat: SupportedFileFormatsType;
|
|
23
32
|
/** 上传图片 */
|