@ant-design/agentic-ui 2.30.0 → 2.30.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/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/constants.d.ts +2 -1
- package/dist/MarkdownEditor/editor/parser/constants.js +86 -8
- 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/editor/store.d.ts +1 -2
- package/dist/MarkdownEditor/editor/tools/ToolBar/components/ToolBarItem.js +6 -4
- 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/renderers/ChartRenderer.js +13 -4
- package/dist/MarkdownRenderer/style.js +7 -6
- package/dist/MarkdownRenderer/useMarkdownToReact.js +37 -18
- package/dist/MarkdownRenderer/useStreaming.js +8 -1
- package/dist/Plugins/chart/BarChart/index.js +5 -5
- package/dist/Plugins/chart/ChartRender.js +1 -0
- package/dist/Plugins/chart/index.js +3 -1
- package/dist/Plugins/chart/utils.d.ts +14 -0
- package/dist/Plugins/chart/utils.js +49 -2
- package/dist/Schema/SchemaEditor/index.js +12 -5
- package/package.json +6 -5
|
@@ -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':
|
|
@@ -6,7 +6,8 @@ export declare const JINJA_DOLLAR_PLACEHOLDER = "\uE01A";
|
|
|
6
6
|
/**
|
|
7
7
|
* 保护时间格式(如 02:20:31)不被 remark-directive 误解析为 textDirective。
|
|
8
8
|
* remark-directive 会将 ":20"、":31" 等解析为指令,导致 "Cannot handle unknown node textDirective"。
|
|
9
|
-
*
|
|
9
|
+
* 使用反斜杠转义冒号(remark-directive 推荐:\:port 可防止 :port 被解析为指令)。
|
|
10
|
+
* 围栏代码块与行内反引号内不处理:该处为字面量,不应出现 `\:` 污染。
|
|
10
11
|
* 须在 remark-directive 解析前执行。
|
|
11
12
|
*/
|
|
12
13
|
export declare function preprocessProtectTimeFromDirective(markdown: string): string;
|
|
@@ -3,18 +3,96 @@
|
|
|
3
3
|
* 在 markdown 解析前替换,渲染与序列化时还原为 $。
|
|
4
4
|
*/ export var JINJA_DOLLAR_PLACEHOLDER = '\uE01A';
|
|
5
5
|
/** URL 协议占位符,用于保护时间格式预处理时不影响 https:// 等 */ var URL_PROTOCOL_PLACEHOLDER = '\uE01B\uE01B';
|
|
6
|
+
/** CommonMark:最多 3 个前导空白后接至少 3 个 backtick 的围栏行 */ var FENCE_DELIMITER_LINE = /^[\t \uFEFF]{0,3}`{3,}/;
|
|
7
|
+
function protectLineFromDirectiveTime(markdownLine) {
|
|
8
|
+
var withProtocolProtected = markdownLine.replace(/:\/\//g, URL_PROTOCOL_PLACEHOLDER);
|
|
9
|
+
var withTimeProtected = withProtocolProtected.replace(/:(\d)/g, function(_, d) {
|
|
10
|
+
return "\\:".concat(d);
|
|
11
|
+
});
|
|
12
|
+
return withTimeProtected.replace(/\uE01B\uE01B/g, '://');
|
|
13
|
+
}
|
|
14
|
+
/**
|
|
15
|
+
* CommonMark 行内代码:起始与结束为等长反引号串,结束串后不得紧跟反引号(避免与更长串混淆)。
|
|
16
|
+
*/ function findInlineCodeClose(line, contentStart, openCount) {
|
|
17
|
+
for(var pos = contentStart; pos < line.length; pos++){
|
|
18
|
+
if (line[pos] !== '`') continue;
|
|
19
|
+
var k = 0;
|
|
20
|
+
while(k < openCount && pos + k < line.length && line[pos + k] === '`'){
|
|
21
|
+
k++;
|
|
22
|
+
}
|
|
23
|
+
if (k !== openCount) continue;
|
|
24
|
+
if (pos + openCount < line.length && line[pos + openCount] === '`') continue;
|
|
25
|
+
return pos;
|
|
26
|
+
}
|
|
27
|
+
return -1;
|
|
28
|
+
}
|
|
29
|
+
/** 围栏外单行:跳过行内反引号包裹片段,仅对其余文本做 directive 时间保护 */ function protectLineOutsideInlineCode(markdownLine) {
|
|
30
|
+
var result = '';
|
|
31
|
+
var i = 0;
|
|
32
|
+
while(i < markdownLine.length){
|
|
33
|
+
if (markdownLine[i] !== '`') {
|
|
34
|
+
var next = markdownLine.indexOf('`', i);
|
|
35
|
+
if (next === -1) {
|
|
36
|
+
result += protectLineFromDirectiveTime(markdownLine.slice(i));
|
|
37
|
+
break;
|
|
38
|
+
}
|
|
39
|
+
result += protectLineFromDirectiveTime(markdownLine.slice(i, next));
|
|
40
|
+
i = next;
|
|
41
|
+
continue;
|
|
42
|
+
}
|
|
43
|
+
var blockStart = i;
|
|
44
|
+
var openCount = 0;
|
|
45
|
+
while(i < markdownLine.length && markdownLine[i] === '`'){
|
|
46
|
+
openCount++;
|
|
47
|
+
i++;
|
|
48
|
+
}
|
|
49
|
+
var contentStart = i;
|
|
50
|
+
var closePos = findInlineCodeClose(markdownLine, contentStart, openCount);
|
|
51
|
+
if (closePos === -1) {
|
|
52
|
+
result += markdownLine.slice(blockStart);
|
|
53
|
+
break;
|
|
54
|
+
}
|
|
55
|
+
var blockEnd = closePos + openCount;
|
|
56
|
+
result += markdownLine.slice(blockStart, blockEnd);
|
|
57
|
+
i = blockEnd;
|
|
58
|
+
}
|
|
59
|
+
return result;
|
|
60
|
+
}
|
|
6
61
|
/**
|
|
7
62
|
* 保护时间格式(如 02:20:31)不被 remark-directive 误解析为 textDirective。
|
|
8
63
|
* remark-directive 会将 ":20"、":31" 等解析为指令,导致 "Cannot handle unknown node textDirective"。
|
|
9
|
-
*
|
|
64
|
+
* 使用反斜杠转义冒号(remark-directive 推荐:\:port 可防止 :port 被解析为指令)。
|
|
65
|
+
* 围栏代码块与行内反引号内不处理:该处为字面量,不应出现 `\:` 污染。
|
|
10
66
|
* 须在 remark-directive 解析前执行。
|
|
11
67
|
*/ export function preprocessProtectTimeFromDirective(markdown) {
|
|
12
68
|
if (!markdown || markdown.length === 0) return markdown;
|
|
13
|
-
var
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
var
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
69
|
+
var lines = markdown.split('\n');
|
|
70
|
+
var inFence = false;
|
|
71
|
+
var out = [];
|
|
72
|
+
var _iteratorNormalCompletion = true, _didIteratorError = false, _iteratorError = undefined;
|
|
73
|
+
try {
|
|
74
|
+
for(var _iterator = lines[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true){
|
|
75
|
+
var line = _step.value;
|
|
76
|
+
if (FENCE_DELIMITER_LINE.test(line)) {
|
|
77
|
+
inFence = !inFence;
|
|
78
|
+
out.push(line);
|
|
79
|
+
continue;
|
|
80
|
+
}
|
|
81
|
+
out.push(inFence ? line : protectLineOutsideInlineCode(line));
|
|
82
|
+
}
|
|
83
|
+
} catch (err) {
|
|
84
|
+
_didIteratorError = true;
|
|
85
|
+
_iteratorError = err;
|
|
86
|
+
} finally{
|
|
87
|
+
try {
|
|
88
|
+
if (!_iteratorNormalCompletion && _iterator.return != null) {
|
|
89
|
+
_iterator.return();
|
|
90
|
+
}
|
|
91
|
+
} finally{
|
|
92
|
+
if (_didIteratorError) {
|
|
93
|
+
throw _iteratorError;
|
|
94
|
+
}
|
|
95
|
+
}
|
|
96
|
+
}
|
|
97
|
+
return out.join('\n');
|
|
20
98
|
}
|
|
@@ -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
|
/**
|
|
@@ -3,7 +3,6 @@ import { Subject } from 'rxjs';
|
|
|
3
3
|
import { BaseEditor, Node, NodeMatch, Path, RangeMode, Selection } from 'slate';
|
|
4
4
|
import { HistoryEditor } from 'slate-history';
|
|
5
5
|
import { ReactEditor } from 'slate-react';
|
|
6
|
-
import { T } from 'vitest/dist/chunks/environment.LoooBwUu.js';
|
|
7
6
|
import { FootnoteDefinitionNode } from '../el';
|
|
8
7
|
import type { MarkdownEditorPlugin } from '../plugin';
|
|
9
8
|
import { CommentDataType, MarkdownEditorProps } from '../types';
|
|
@@ -236,7 +235,7 @@ export declare class EditorStore {
|
|
|
236
235
|
*/
|
|
237
236
|
removeNodes: (options?: {
|
|
238
237
|
at?: Location;
|
|
239
|
-
match?: NodeMatch<
|
|
238
|
+
match?: NodeMatch<Node>;
|
|
240
239
|
mode?: RangeMode;
|
|
241
240
|
hanging?: boolean;
|
|
242
241
|
voids?: boolean;
|
|
@@ -15,9 +15,7 @@ export var ToolBarItem = /*#__PURE__*/ React.memo(function(param) {
|
|
|
15
15
|
}, [
|
|
16
16
|
onMouseDown
|
|
17
17
|
]);
|
|
18
|
-
|
|
19
|
-
title: title
|
|
20
|
-
}, /*#__PURE__*/ React.createElement("div", {
|
|
18
|
+
var content = /*#__PURE__*/ React.createElement("div", {
|
|
21
19
|
role: role,
|
|
22
20
|
className: className,
|
|
23
21
|
style: style,
|
|
@@ -25,6 +23,10 @@ export var ToolBarItem = /*#__PURE__*/ React.memo(function(param) {
|
|
|
25
23
|
onMouseDown: handleMouseDown,
|
|
26
24
|
onMouseEnter: onMouseEnter,
|
|
27
25
|
tabIndex: tabIndex
|
|
28
|
-
}, children || icon)
|
|
26
|
+
}, children || icon);
|
|
27
|
+
// 仅在有 title 时使用 Tooltip,避免 rc-resize-observer 的 findDOMNode 弃用警告
|
|
28
|
+
return title ? /*#__PURE__*/ React.createElement(Tooltip, {
|
|
29
|
+
title: title
|
|
30
|
+
}, content) : content;
|
|
29
31
|
});
|
|
30
32
|
ToolBarItem.displayName = 'ToolBarItem';
|
|
@@ -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,
|