@ant-design/agentic-ui 2.30.11 → 2.30.13
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/MessagesContent/MarkdownPreview.js +3 -2
- package/dist/Bubble/MessagesContent/style.js +3 -1
- package/dist/Bubble/style.js +35 -13
- package/dist/ChatLayout/index.js +9 -1
- package/dist/History/components/HistoryList.d.ts +2 -12
- package/dist/History/components/HistoryList.js +48 -43
- package/dist/History/style.d.ts +4 -0
- package/dist/History/style.js +1 -0
- package/dist/Hooks/useAutoScroll.js +38 -14
- package/dist/Hooks/useLanguage.d.ts +1 -0
- package/dist/I18n/locales.d.ts +1 -0
- package/dist/I18n/locales.js +2 -0
- package/dist/MarkdownEditor/editor/elements/AgenticUiBlocks/AgenticUiFileMapBlock.d.ts +4 -0
- package/dist/MarkdownEditor/editor/elements/AgenticUiBlocks/AgenticUiFileMapBlock.js +83 -0
- package/dist/MarkdownEditor/editor/elements/AgenticUiBlocks/agenticUiEmbedUtils.d.ts +14 -0
- package/dist/MarkdownEditor/editor/elements/AgenticUiBlocks/agenticUiEmbedUtils.js +52 -0
- package/dist/MarkdownEditor/editor/elements/index.js +3 -0
- package/dist/MarkdownEditor/editor/parser/parse/parseCode.js +2 -1
- package/dist/MarkdownEditor/editor/parser/parserSlateNodeToMarkdown.js +1 -0
- package/dist/MarkdownEditor/editor/plugins/handlePaste.js +2 -1
- package/dist/MarkdownEditor/types.d.ts +6 -0
- package/dist/MarkdownInputField/AttachmentButton/AttachmentFileList/AttachmentFileListItem.js +2 -2
- package/dist/MarkdownInputField/AttachmentButton/AttachmentFileList/style.js +3 -1
- package/dist/MarkdownInputField/AttachmentButton/index.d.ts +12 -0
- package/dist/MarkdownInputField/AttachmentButton/index.js +23 -13
- package/dist/MarkdownInputField/FileMapView/index.d.ts +13 -1
- package/dist/MarkdownInputField/FileMapView/index.js +24 -8
- package/dist/MarkdownInputField/FileUploadManager/index.js +4 -26
- package/dist/MarkdownRenderer/MarkdownRenderer.js +16 -5
- package/dist/MarkdownRenderer/index.d.ts +4 -1
- package/dist/MarkdownRenderer/index.js +3 -0
- package/dist/MarkdownRenderer/renderers/AgenticUiFileMapBlockRenderer.d.ts +8 -0
- package/dist/MarkdownRenderer/renderers/AgenticUiFileMapBlockRenderer.js +121 -0
- package/dist/MarkdownRenderer/renderers/ChartRenderer.js +9 -0
- package/dist/MarkdownRenderer/renderers/index.d.ts +3 -0
- package/dist/MarkdownRenderer/renderers/index.js +3 -0
- package/dist/MarkdownRenderer/types.d.ts +45 -2
- package/dist/Plugins/chart/ChartRender.js +30 -9
- package/dist/Plugins/chart/HistogramChart/index.d.ts +5 -1
- package/dist/Plugins/chart/HistogramChart/index.js +79 -12
- package/dist/Plugins/chart/ScatterChart/index.d.ts +8 -0
- package/dist/Plugins/chart/ScatterChart/index.js +78 -8
- package/dist/Plugins/chart/components/ChartContainer/ChartErrorBoundary.d.ts +2 -0
- package/dist/Plugins/code/components/AceEditor.js +69 -8
- package/dist/Plugins/code/components/CodeRenderer.js +22 -7
- package/dist/Plugins/code/components/CodeToolbar.d.ts +2 -0
- package/dist/Plugins/code/components/CodeToolbar.js +11 -4
- package/dist/Plugins/code/hooks/useToolbarConfig.d.ts +3 -1
- package/dist/Plugins/code/hooks/useToolbarConfig.js +5 -3
- package/dist/Plugins/code/utils/index.d.ts +1 -0
- package/dist/Plugins/code/utils/index.js +1 -0
- package/dist/Plugins/code/utils/localPreview.d.ts +12 -0
- package/dist/Plugins/code/utils/localPreview.js +190 -0
- package/package.json +1 -1
|
@@ -13,8 +13,9 @@ interface UseToolbarConfigProps {
|
|
|
13
13
|
onSelectionChange?: (selected: boolean) => void;
|
|
14
14
|
onViewModeToggle?: () => void;
|
|
15
15
|
viewMode?: 'preview' | 'code';
|
|
16
|
+
onLocalPreview?: () => void;
|
|
16
17
|
}
|
|
17
|
-
export declare function useToolbarConfig({ element, readonly, onCloseClick, setLanguage, isSelected, onSelectionChange, onViewModeToggle, viewMode, }: UseToolbarConfigProps): {
|
|
18
|
+
export declare function useToolbarConfig({ element, readonly, onCloseClick, setLanguage, isSelected, onSelectionChange, onViewModeToggle, viewMode, onLocalPreview, }: UseToolbarConfigProps): {
|
|
18
19
|
toolbarProps: {
|
|
19
20
|
element: CodeNode;
|
|
20
21
|
readonly: boolean;
|
|
@@ -24,6 +25,7 @@ export declare function useToolbarConfig({ element, readonly, onCloseClick, setL
|
|
|
24
25
|
onSelectionChange: ((selected: boolean) => void) | undefined;
|
|
25
26
|
onViewModeToggle: (() => void) | undefined;
|
|
26
27
|
viewMode: "code" | "preview" | undefined;
|
|
28
|
+
onLocalPreview: (() => void) | undefined;
|
|
27
29
|
};
|
|
28
30
|
};
|
|
29
31
|
export {};
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
* 负责组装工具栏的属性和事件处理
|
|
4
4
|
*/ import { useCallback } from "react";
|
|
5
5
|
export function useToolbarConfig(param) {
|
|
6
|
-
var element = param.element, readonly = param.readonly, onCloseClick = param.onCloseClick, setLanguage = param.setLanguage, isSelected = param.isSelected, onSelectionChange = param.onSelectionChange, onViewModeToggle = param.onViewModeToggle, viewMode = param.viewMode;
|
|
6
|
+
var element = param.element, readonly = param.readonly, onCloseClick = param.onCloseClick, setLanguage = param.setLanguage, isSelected = param.isSelected, onSelectionChange = param.onSelectionChange, onViewModeToggle = param.onViewModeToggle, viewMode = param.viewMode, onLocalPreview = param.onLocalPreview;
|
|
7
7
|
// 组装语言选择器属性
|
|
8
8
|
var languageSelectorProps = useCallback(function() {
|
|
9
9
|
return {
|
|
@@ -27,7 +27,8 @@ export function useToolbarConfig(param) {
|
|
|
27
27
|
isSelected: isSelected,
|
|
28
28
|
onSelectionChange: onSelectionChange,
|
|
29
29
|
onViewModeToggle: onViewModeToggle,
|
|
30
|
-
viewMode: viewMode
|
|
30
|
+
viewMode: viewMode,
|
|
31
|
+
onLocalPreview: onLocalPreview
|
|
31
32
|
};
|
|
32
33
|
}, [
|
|
33
34
|
element,
|
|
@@ -37,7 +38,8 @@ export function useToolbarConfig(param) {
|
|
|
37
38
|
isSelected,
|
|
38
39
|
onSelectionChange,
|
|
39
40
|
onViewModeToggle,
|
|
40
|
-
viewMode
|
|
41
|
+
viewMode,
|
|
42
|
+
onLocalPreview
|
|
41
43
|
])();
|
|
42
44
|
return {
|
|
43
45
|
toolbarProps: toolbarProps
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @fileoverview 本地预览工具函数
|
|
3
|
+
* 支持在新窗口打开 HTML 或 Markdown(转为 HTML 后)内容
|
|
4
|
+
*/
|
|
5
|
+
/**
|
|
6
|
+
* 在新标签页打开 HTML 内容的本地预览(允许执行 JavaScript)
|
|
7
|
+
*/
|
|
8
|
+
export declare function openHtmlLocalPreview(htmlCode: string): void;
|
|
9
|
+
/**
|
|
10
|
+
* 将 Markdown 转换为 HTML 后在新标签页打开本地预览
|
|
11
|
+
*/
|
|
12
|
+
export declare function openMarkdownLocalPreview(markdownCode: string): Promise<void>;
|
|
@@ -0,0 +1,190 @@
|
|
|
1
|
+
function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) {
|
|
2
|
+
try {
|
|
3
|
+
var info = gen[key](arg);
|
|
4
|
+
var value = info.value;
|
|
5
|
+
} catch (error) {
|
|
6
|
+
reject(error);
|
|
7
|
+
return;
|
|
8
|
+
}
|
|
9
|
+
if (info.done) {
|
|
10
|
+
resolve(value);
|
|
11
|
+
} else {
|
|
12
|
+
Promise.resolve(value).then(_next, _throw);
|
|
13
|
+
}
|
|
14
|
+
}
|
|
15
|
+
function _async_to_generator(fn) {
|
|
16
|
+
return function() {
|
|
17
|
+
var self = this, args = arguments;
|
|
18
|
+
return new Promise(function(resolve, reject) {
|
|
19
|
+
var gen = fn.apply(self, args);
|
|
20
|
+
function _next(value) {
|
|
21
|
+
asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value);
|
|
22
|
+
}
|
|
23
|
+
function _throw(err) {
|
|
24
|
+
asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err);
|
|
25
|
+
}
|
|
26
|
+
_next(undefined);
|
|
27
|
+
});
|
|
28
|
+
};
|
|
29
|
+
}
|
|
30
|
+
function _ts_generator(thisArg, body) {
|
|
31
|
+
var f, y, t, _ = {
|
|
32
|
+
label: 0,
|
|
33
|
+
sent: function() {
|
|
34
|
+
if (t[0] & 1) throw t[1];
|
|
35
|
+
return t[1];
|
|
36
|
+
},
|
|
37
|
+
trys: [],
|
|
38
|
+
ops: []
|
|
39
|
+
}, g = Object.create((typeof Iterator === "function" ? Iterator : Object).prototype), d = Object.defineProperty;
|
|
40
|
+
return d(g, "next", {
|
|
41
|
+
value: verb(0)
|
|
42
|
+
}), d(g, "throw", {
|
|
43
|
+
value: verb(1)
|
|
44
|
+
}), d(g, "return", {
|
|
45
|
+
value: verb(2)
|
|
46
|
+
}), typeof Symbol === "function" && d(g, Symbol.iterator, {
|
|
47
|
+
value: function() {
|
|
48
|
+
return this;
|
|
49
|
+
}
|
|
50
|
+
}), g;
|
|
51
|
+
function verb(n) {
|
|
52
|
+
return function(v) {
|
|
53
|
+
return step([
|
|
54
|
+
n,
|
|
55
|
+
v
|
|
56
|
+
]);
|
|
57
|
+
};
|
|
58
|
+
}
|
|
59
|
+
function step(op) {
|
|
60
|
+
if (f) throw new TypeError("Generator is already executing.");
|
|
61
|
+
while(g && (g = 0, op[0] && (_ = 0)), _)try {
|
|
62
|
+
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
|
|
63
|
+
if (y = 0, t) op = [
|
|
64
|
+
op[0] & 2,
|
|
65
|
+
t.value
|
|
66
|
+
];
|
|
67
|
+
switch(op[0]){
|
|
68
|
+
case 0:
|
|
69
|
+
case 1:
|
|
70
|
+
t = op;
|
|
71
|
+
break;
|
|
72
|
+
case 4:
|
|
73
|
+
_.label++;
|
|
74
|
+
return {
|
|
75
|
+
value: op[1],
|
|
76
|
+
done: false
|
|
77
|
+
};
|
|
78
|
+
case 5:
|
|
79
|
+
_.label++;
|
|
80
|
+
y = op[1];
|
|
81
|
+
op = [
|
|
82
|
+
0
|
|
83
|
+
];
|
|
84
|
+
continue;
|
|
85
|
+
case 7:
|
|
86
|
+
op = _.ops.pop();
|
|
87
|
+
_.trys.pop();
|
|
88
|
+
continue;
|
|
89
|
+
default:
|
|
90
|
+
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) {
|
|
91
|
+
_ = 0;
|
|
92
|
+
continue;
|
|
93
|
+
}
|
|
94
|
+
if (op[0] === 3 && (!t || op[1] > t[0] && op[1] < t[3])) {
|
|
95
|
+
_.label = op[1];
|
|
96
|
+
break;
|
|
97
|
+
}
|
|
98
|
+
if (op[0] === 6 && _.label < t[1]) {
|
|
99
|
+
_.label = t[1];
|
|
100
|
+
t = op;
|
|
101
|
+
break;
|
|
102
|
+
}
|
|
103
|
+
if (t && _.label < t[2]) {
|
|
104
|
+
_.label = t[2];
|
|
105
|
+
_.ops.push(op);
|
|
106
|
+
break;
|
|
107
|
+
}
|
|
108
|
+
if (t[2]) _.ops.pop();
|
|
109
|
+
_.trys.pop();
|
|
110
|
+
continue;
|
|
111
|
+
}
|
|
112
|
+
op = body.call(thisArg, _);
|
|
113
|
+
} catch (e) {
|
|
114
|
+
op = [
|
|
115
|
+
6,
|
|
116
|
+
e
|
|
117
|
+
];
|
|
118
|
+
y = 0;
|
|
119
|
+
} finally{
|
|
120
|
+
f = t = 0;
|
|
121
|
+
}
|
|
122
|
+
if (op[0] & 5) throw op[1];
|
|
123
|
+
return {
|
|
124
|
+
value: op[0] ? op[1] : void 0,
|
|
125
|
+
done: true
|
|
126
|
+
};
|
|
127
|
+
}
|
|
128
|
+
}
|
|
129
|
+
/**
|
|
130
|
+
* @fileoverview 本地预览工具函数
|
|
131
|
+
* 支持在新窗口打开 HTML 或 Markdown(转为 HTML 后)内容
|
|
132
|
+
*/ import { markdownToHtml } from "../../../MarkdownEditor/editor/utils/markdownToHtml";
|
|
133
|
+
var MARKDOWN_PREVIEW_STYLE = "\n body {\n font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;\n line-height: 1.6;\n color: #24292e;\n max-width: 900px;\n margin: 0 auto;\n padding: 32px 24px;\n background: #fff;\n }\n h1, h2, h3, h4, h5, h6 {\n border-bottom: 1px solid #eaecef;\n padding-bottom: 0.3em;\n margin-top: 24px;\n margin-bottom: 16px;\n font-weight: 600;\n line-height: 1.25;\n }\n pre {\n background: #f6f8fa;\n border-radius: 6px;\n padding: 16px;\n overflow: auto;\n font-size: 85%;\n line-height: 1.45;\n }\n code {\n background: rgba(175, 184, 193, 0.2);\n border-radius: 3px;\n font-size: 85%;\n padding: 0.2em 0.4em;\n }\n pre code {\n background: transparent;\n padding: 0;\n font-size: inherit;\n }\n blockquote {\n border-left: 4px solid #d0d7de;\n color: #57606a;\n margin: 0;\n padding: 0 1em;\n }\n table {\n border-collapse: collapse;\n width: 100%;\n }\n th, td {\n border: 1px solid #d0d7de;\n padding: 6px 13px;\n }\n tr:nth-child(even) {\n background: #f6f8fa;\n }\n img {\n max-width: 100%;\n }\n a {\n color: #0969da;\n text-decoration: none;\n }\n a:hover {\n text-decoration: underline;\n }\n hr {\n border: none;\n border-top: 1px solid #d0d7de;\n }\n";
|
|
134
|
+
function buildHtmlDocument(body, title) {
|
|
135
|
+
return '<!DOCTYPE html>\n<html lang="en">\n<head>\n <meta charset="UTF-8" />\n <meta name="viewport" content="width=device-width, initial-scale=1.0" />\n <title>'.concat(title, '</title>\n <link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/katex@0.16.9/dist/katex.min.css" crossorigin="anonymous" />\n</head>\n<body>\n').concat(body, "\n</body>\n</html>");
|
|
136
|
+
}
|
|
137
|
+
function openBlobInNewTab(html) {
|
|
138
|
+
var blob = new Blob([
|
|
139
|
+
html
|
|
140
|
+
], {
|
|
141
|
+
type: 'text/html'
|
|
142
|
+
});
|
|
143
|
+
var url = URL.createObjectURL(blob);
|
|
144
|
+
var win = window.open(url, '_blank');
|
|
145
|
+
if (win) {
|
|
146
|
+
// 在新窗口加载完毕后释放 Blob URL
|
|
147
|
+
win.addEventListener('load', function() {
|
|
148
|
+
return URL.revokeObjectURL(url);
|
|
149
|
+
}, {
|
|
150
|
+
once: true
|
|
151
|
+
});
|
|
152
|
+
} else {
|
|
153
|
+
// 弹窗被拦截时延迟释放
|
|
154
|
+
setTimeout(function() {
|
|
155
|
+
return URL.revokeObjectURL(url);
|
|
156
|
+
}, 10000);
|
|
157
|
+
}
|
|
158
|
+
}
|
|
159
|
+
/**
|
|
160
|
+
* 在新标签页打开 HTML 内容的本地预览(允许执行 JavaScript)
|
|
161
|
+
*/ export function openHtmlLocalPreview(htmlCode) {
|
|
162
|
+
var needsDocumentWrapper = !/<html[\s>]/i.test(htmlCode) && !/<!DOCTYPE/i.test(htmlCode);
|
|
163
|
+
var fullHtml = needsDocumentWrapper ? buildHtmlDocument(htmlCode, 'HTML Preview') : htmlCode;
|
|
164
|
+
openBlobInNewTab(fullHtml);
|
|
165
|
+
}
|
|
166
|
+
/**
|
|
167
|
+
* 将 Markdown 转换为 HTML 后在新标签页打开本地预览
|
|
168
|
+
*/ export function openMarkdownLocalPreview(markdownCode) {
|
|
169
|
+
return _async_to_generator(function() {
|
|
170
|
+
var bodyHtml, fullHtml;
|
|
171
|
+
return _ts_generator(this, function(_state) {
|
|
172
|
+
switch(_state.label){
|
|
173
|
+
case 0:
|
|
174
|
+
return [
|
|
175
|
+
4,
|
|
176
|
+
markdownToHtml(markdownCode, undefined, {
|
|
177
|
+
openLinksInNewTab: true
|
|
178
|
+
})
|
|
179
|
+
];
|
|
180
|
+
case 1:
|
|
181
|
+
bodyHtml = _state.sent();
|
|
182
|
+
fullHtml = '<!DOCTYPE html>\n<html lang="en">\n<head>\n <meta charset="UTF-8" />\n <meta name="viewport" content="width=device-width, initial-scale=1.0" />\n <title>Markdown Preview</title>\n <link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/katex@0.16.9/dist/katex.min.css" crossorigin="anonymous" />\n <style>'.concat(MARKDOWN_PREVIEW_STYLE, "</style>\n</head>\n<body>\n").concat(bodyHtml, "\n</body>\n</html>");
|
|
183
|
+
openBlobInNewTab(fullHtml);
|
|
184
|
+
return [
|
|
185
|
+
2
|
|
186
|
+
];
|
|
187
|
+
}
|
|
188
|
+
});
|
|
189
|
+
})();
|
|
190
|
+
}
|