@ant-design/agentic-ui 2.10.0 → 2.10.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/ChatLayout/style.js +4 -1
- package/dist/MarkdownInputField/AttachmentButton/AttachmentButtonPopover.js +6 -12
- package/dist/MarkdownInputField/FileUploadManager/index.js +1 -1
- package/dist/Plugins/code/components/AceEditor.js +23 -23
- package/dist/Plugins/code/components/LanguageSelector.js +40 -5
- package/dist/Plugins/code/index.js +4 -2
- package/package.json +1 -1
package/dist/ChatLayout/style.js
CHANGED
|
@@ -166,7 +166,10 @@ var genStyle = function(token) {
|
|
|
166
166
|
flex: 1,
|
|
167
167
|
overflowY: 'auto',
|
|
168
168
|
overflowX: 'hidden',
|
|
169
|
-
|
|
169
|
+
paddingTop: 'var(--padding-2x)',
|
|
170
|
+
paddingLeft: 'var(--padding-2x)',
|
|
171
|
+
paddingRight: 'var(--padding-2x)',
|
|
172
|
+
paddingBottom: '144px',
|
|
170
173
|
'&::-webkit-scrollbar': {
|
|
171
174
|
width: '6px'
|
|
172
175
|
},
|
|
@@ -47,11 +47,12 @@ function _unsupported_iterable_to_array(o, minLen) {
|
|
|
47
47
|
import { AudioOutlined, FileImageOutlined, FileTextFilled, FolderOpenOutlined, PictureOutlined, VideoCameraOutlined } from "@ant-design/icons";
|
|
48
48
|
import { Button, Modal, Tooltip } from "antd";
|
|
49
49
|
import React, { useCallback, useContext, useMemo, useState } from "react";
|
|
50
|
+
import { useRefFunction } from "../../Hooks/useRefFunction";
|
|
50
51
|
import { I18nContext } from "../../I18n";
|
|
51
52
|
import { isMobileDevice, isVivoOrOppoDevice, kbToSize } from "./utils";
|
|
52
53
|
/**
|
|
53
54
|
* 移动设备默认的文件类型 accept 值
|
|
54
|
-
*/ var MOBILE_DEFAULT_ACCEPT = 'application/vnd.ms-excel,application/vnd.openxmlformats-officedocument.spreadsheetml.sheet,application/vnd.ms-powerpoint,application/vnd.openxmlformats-officedocument.presentationml.presentation,application/msword,application/vnd.openxmlformats-officedocument.wordprocessingml.document,application/pdf,.csv,
|
|
55
|
+
*/ var MOBILE_DEFAULT_ACCEPT = 'application/vnd.ms-excel,application/vnd.openxmlformats-officedocument.spreadsheetml.sheet,application/vnd.ms-powerpoint,application/vnd.openxmlformats-officedocument.presentationml.presentation,application/msword,application/vnd.openxmlformats-officedocument.wordprocessingml.document,application/pdf,.csv,text/plain,application/x-zip-compressed';
|
|
55
56
|
var FILE_SIZE_UNITS = {
|
|
56
57
|
KB: 1024,
|
|
57
58
|
MB: 1024 * 1024
|
|
@@ -155,7 +156,7 @@ export var AttachmentButtonPopover = function(param) {
|
|
|
155
156
|
var extensions = format.extensions || [];
|
|
156
157
|
/**
|
|
157
158
|
* 根据支持的格式获取 accept 属性值
|
|
158
|
-
*/ var getAcceptValue =
|
|
159
|
+
*/ var getAcceptValue = useRefFunction(function(forGallery) {
|
|
159
160
|
// 如果是移动设备,返回默认的 accept 值
|
|
160
161
|
if (isMobile || forGallery) {
|
|
161
162
|
return MOBILE_DEFAULT_ACCEPT;
|
|
@@ -164,13 +165,10 @@ export var AttachmentButtonPopover = function(param) {
|
|
|
164
165
|
return extensions.length > 0 ? extensions.map(function(ext) {
|
|
165
166
|
return ".".concat(ext);
|
|
166
167
|
}).join(',') : MOBILE_DEFAULT_ACCEPT;
|
|
167
|
-
}
|
|
168
|
-
extensions,
|
|
169
|
-
isMobile
|
|
170
|
-
]);
|
|
168
|
+
});
|
|
171
169
|
/**
|
|
172
170
|
* 创建文件输入并触发选择
|
|
173
|
-
*/ var triggerFileInput =
|
|
171
|
+
*/ var triggerFileInput = useRefFunction(function(forGallery) {
|
|
174
172
|
var accept = getAcceptValue(forGallery);
|
|
175
173
|
var input = document.createElement('input');
|
|
176
174
|
input.type = 'file';
|
|
@@ -188,11 +186,7 @@ export var AttachmentButtonPopover = function(param) {
|
|
|
188
186
|
document.body.appendChild(input);
|
|
189
187
|
input.click();
|
|
190
188
|
setModalOpen(false);
|
|
191
|
-
}
|
|
192
|
-
getAcceptValue,
|
|
193
|
-
onFileSelect,
|
|
194
|
-
allowMultiple
|
|
195
|
-
]);
|
|
189
|
+
});
|
|
196
190
|
var handleClick = useCallback(function(e) {
|
|
197
191
|
if (isVivoOrOppo) {
|
|
198
192
|
e.stopPropagation();
|
|
@@ -183,7 +183,7 @@ import { SupportedFileFormats } from "../AttachmentButton/AttachmentButtonPopove
|
|
|
183
183
|
import { isMobileDevice, isVivoOrOppoDevice } from "../AttachmentButton/utils";
|
|
184
184
|
/**
|
|
185
185
|
* 移动设备默认的文件类型 accept 值
|
|
186
|
-
*/ var MOBILE_DEFAULT_ACCEPT = 'application/vnd.ms-excel,application/vnd.openxmlformats-officedocument.spreadsheetml.sheet,application/vnd.ms-powerpoint,application/vnd.openxmlformats-officedocument.presentationml.presentation,application/msword,application/vnd.openxmlformats-officedocument.wordprocessingml.document,application/pdf,.csv,image/*,text/plain,
|
|
186
|
+
*/ var MOBILE_DEFAULT_ACCEPT = 'application/vnd.ms-excel,application/vnd.openxmlformats-officedocument.spreadsheetml.sheet,application/vnd.ms-powerpoint,application/vnd.openxmlformats-officedocument.presentationml.presentation,application/msword,application/vnd.openxmlformats-officedocument.wordprocessingml.document,application/pdf,.csv,image/*,text/plain,application/x-zip-compressed';
|
|
187
187
|
/**
|
|
188
188
|
* 文件上传管理器
|
|
189
189
|
*
|
|
@@ -71,7 +71,7 @@ import "ace-builds/src-noconflict/theme-github";
|
|
|
71
71
|
import isHotkey from "is-hotkey";
|
|
72
72
|
import { useCallback, useEffect, useRef } from "react";
|
|
73
73
|
import { Editor, Path, Transforms } from "slate";
|
|
74
|
-
import {
|
|
74
|
+
import { useRefFunction } from "../../../Hooks/useRefFunction";
|
|
75
75
|
import partialParse from "../../../MarkdownEditor/editor/parser/json-parse";
|
|
76
76
|
import { useEditorStore } from "../../../MarkdownEditor/editor/store";
|
|
77
77
|
import { aceLangs, modeMap } from "../../../MarkdownEditor/editor/utils/ace";
|
|
@@ -131,26 +131,29 @@ import { EditorUtils } from "../../../MarkdownEditor/editor/utils/editorUtils";
|
|
|
131
131
|
path
|
|
132
132
|
]);
|
|
133
133
|
// 键盘事件处理
|
|
134
|
-
var handleKeyDown =
|
|
134
|
+
var handleKeyDown = useRefFunction(function(e) {
|
|
135
135
|
// 删除空代码块
|
|
136
136
|
if (isHotkey('backspace', e)) {
|
|
137
|
-
if (
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
137
|
+
if (codeRef.current.trim() === '') {
|
|
138
|
+
Editor.withoutNormalizing(store.editor, function() {
|
|
139
|
+
Transforms.delete(store.editor, {
|
|
140
|
+
at: pathRef.current
|
|
141
|
+
});
|
|
142
|
+
// 如果这是最后一个节点,使用替换而不是删除+插入,避免文档为空
|
|
143
|
+
Transforms.insertNodes(store.editor, {
|
|
144
|
+
type: 'paragraph',
|
|
145
|
+
children: [
|
|
146
|
+
{
|
|
147
|
+
text: ''
|
|
148
|
+
}
|
|
149
|
+
]
|
|
150
|
+
}, {
|
|
151
|
+
at: pathRef.current,
|
|
152
|
+
select: true
|
|
153
|
+
});
|
|
154
|
+
Transforms.select(store.editor, Editor.start(store.editor, pathRef.current));
|
|
141
155
|
});
|
|
142
|
-
|
|
143
|
-
type: 'paragraph',
|
|
144
|
-
children: [
|
|
145
|
-
{
|
|
146
|
-
text: ''
|
|
147
|
-
}
|
|
148
|
-
]
|
|
149
|
-
}, {
|
|
150
|
-
at: currentPath
|
|
151
|
-
});
|
|
152
|
-
Transforms.select(store.editor, Editor.start(store.editor, currentPath));
|
|
153
|
-
ReactEditor.focus(store.editor);
|
|
156
|
+
return;
|
|
154
157
|
}
|
|
155
158
|
}
|
|
156
159
|
// Cmd/Ctrl + Enter: 插入新段落
|
|
@@ -173,10 +176,7 @@ import { EditorUtils } from "../../../MarkdownEditor/editor/utils/editorUtils";
|
|
|
173
176
|
// 转发键盘事件
|
|
174
177
|
var newEvent = new KeyboardEvent(e.type, e);
|
|
175
178
|
window.dispatchEvent(newEvent);
|
|
176
|
-
}
|
|
177
|
-
element,
|
|
178
|
-
store.editor
|
|
179
|
-
]);
|
|
179
|
+
});
|
|
180
180
|
// 配置编辑器事件
|
|
181
181
|
var setupEditorEvents = useCallback(function(codeEditor) {
|
|
182
182
|
// 禁用默认查找快捷键
|
|
@@ -302,7 +302,7 @@ import { EditorUtils } from "../../../MarkdownEditor/editor/utils/editorUtils";
|
|
|
302
302
|
}
|
|
303
303
|
if (value !== codeRef.current) {
|
|
304
304
|
var _editorRef_current, _editorRef_current1;
|
|
305
|
-
if (element) (_editorRef_current = editorRef.current) === null || _editorRef_current === void 0 ? void 0 : _editorRef_current.setValue(value
|
|
305
|
+
if (element) (_editorRef_current = editorRef.current) === null || _editorRef_current === void 0 ? void 0 : _editorRef_current.setValue(value);
|
|
306
306
|
(_editorRef_current1 = editorRef.current) === null || _editorRef_current1 === void 0 ? void 0 : _editorRef_current1.clearSelection();
|
|
307
307
|
}
|
|
308
308
|
}, [
|
|
@@ -50,7 +50,7 @@ function _unsupported_iterable_to_array(o, minLen) {
|
|
|
50
50
|
}
|
|
51
51
|
import { SearchOutlined } from "@ant-design/icons";
|
|
52
52
|
import { AutoComplete, Button, Input, Popover } from "antd";
|
|
53
|
-
import React, { useContext, useState } from "react";
|
|
53
|
+
import React, { useContext, useEffect, useRef, useState } from "react";
|
|
54
54
|
import { I18nContext } from "../../../I18n";
|
|
55
55
|
import { langIconMap } from "../langIconMap";
|
|
56
56
|
import { langOptions } from "../utils/langOptions";
|
|
@@ -87,13 +87,38 @@ import { LoadImage } from "./LoadImage";
|
|
|
87
87
|
var i18n = useContext(I18nContext);
|
|
88
88
|
// 搜索关键字状态
|
|
89
89
|
var _useState = _sliced_to_array(useState(''), 2), keyword = _useState[0], setKeyword = _useState[1];
|
|
90
|
+
// Popover 打开状态
|
|
91
|
+
var _useState1 = _sliced_to_array(useState(false), 2), open = _useState1[0], setOpen = _useState1[1];
|
|
92
|
+
// 跟踪用户是否手动关闭过弹层
|
|
93
|
+
var hasUserClosedRef = useRef(false);
|
|
94
|
+
// 跟踪上一次的语言值
|
|
95
|
+
var prevLanguageRef = useRef(undefined);
|
|
90
96
|
// 处理未定义的 element
|
|
91
97
|
var safeElement = props.element || {
|
|
92
98
|
language: undefined,
|
|
93
99
|
katex: false
|
|
94
100
|
};
|
|
101
|
+
// 如果语言为空且用户未手动关闭过,自动打开下拉框
|
|
102
|
+
useEffect(function() {
|
|
103
|
+
var currentLanguage = safeElement.language;
|
|
104
|
+
var prevLanguage = prevLanguageRef.current;
|
|
105
|
+
// 如果语言从有值变为空,重置关闭标记
|
|
106
|
+
if (prevLanguage && !currentLanguage && !safeElement.katex) {
|
|
107
|
+
hasUserClosedRef.current = false;
|
|
108
|
+
}
|
|
109
|
+
// 如果语言为空且用户未手动关闭过,自动打开下拉框
|
|
110
|
+
if (!currentLanguage && !safeElement.katex && !hasUserClosedRef.current) {
|
|
111
|
+
setOpen(true);
|
|
112
|
+
}
|
|
113
|
+
// 更新上一次的语言值
|
|
114
|
+
prevLanguageRef.current = currentLanguage;
|
|
115
|
+
}, [
|
|
116
|
+
safeElement.language,
|
|
117
|
+
safeElement.katex
|
|
118
|
+
]);
|
|
95
119
|
return /*#__PURE__*/ React.createElement(Popover, {
|
|
96
120
|
arrow: false,
|
|
121
|
+
open: open,
|
|
97
122
|
styles: {
|
|
98
123
|
body: {
|
|
99
124
|
padding: 8
|
|
@@ -104,6 +129,7 @@ import { LoadImage } from "./LoadImage";
|
|
|
104
129
|
],
|
|
105
130
|
placement: 'bottomLeft',
|
|
106
131
|
onOpenChange: function(visible) {
|
|
132
|
+
setOpen(visible);
|
|
107
133
|
if (visible) {
|
|
108
134
|
// 弹层打开时,延时聚焦到搜索框
|
|
109
135
|
setTimeout(function() {
|
|
@@ -111,11 +137,17 @@ import { LoadImage } from "./LoadImage";
|
|
|
111
137
|
props === null || props === void 0 ? void 0 : (_props_containerRef = props.containerRef) === null || _props_containerRef === void 0 ? void 0 : (_props_containerRef_current = _props_containerRef.current) === null || _props_containerRef_current === void 0 ? void 0 : (_props_containerRef_current_querySelector = _props_containerRef_current.querySelector('.lang-select input')) === null || _props_containerRef_current_querySelector === void 0 ? void 0 : _props_containerRef_current_querySelector.focus();
|
|
112
138
|
});
|
|
113
139
|
} else {
|
|
114
|
-
//
|
|
140
|
+
// 弹层关闭时清空搜索关键字,并标记用户已手动关闭
|
|
115
141
|
setKeyword('');
|
|
142
|
+
hasUserClosedRef.current = true;
|
|
116
143
|
}
|
|
117
144
|
},
|
|
118
|
-
content: /*#__PURE__*/ React.createElement(
|
|
145
|
+
content: /*#__PURE__*/ React.createElement("div", {
|
|
146
|
+
onClick: function(e) {
|
|
147
|
+
e.stopPropagation();
|
|
148
|
+
e.preventDefault();
|
|
149
|
+
}
|
|
150
|
+
}, /*#__PURE__*/ React.createElement(AutoComplete, {
|
|
119
151
|
value: keyword,
|
|
120
152
|
options: langOptions,
|
|
121
153
|
autoFocus: true,
|
|
@@ -127,9 +159,12 @@ import { LoadImage } from "./LoadImage";
|
|
|
127
159
|
return (item === null || item === void 0 ? void 0 : item.value.includes(text)) || false;
|
|
128
160
|
},
|
|
129
161
|
onSelect: function(selectedLanguage) {
|
|
130
|
-
var //
|
|
162
|
+
var // 选择语言后执行回调并关闭弹层
|
|
131
163
|
_props_setLanguage;
|
|
132
164
|
(_props_setLanguage = props.setLanguage) === null || _props_setLanguage === void 0 ? void 0 : _props_setLanguage.call(props, selectedLanguage);
|
|
165
|
+
setOpen(false);
|
|
166
|
+
// 重置关闭标记,以便下次语言为空时能再次自动打开
|
|
167
|
+
hasUserClosedRef.current = false;
|
|
133
168
|
},
|
|
134
169
|
onChange: function(inputValue) {
|
|
135
170
|
// 更新搜索关键字
|
|
@@ -146,7 +181,7 @@ import { LoadImage } from "./LoadImage";
|
|
|
146
181
|
}, /*#__PURE__*/ React.createElement(Input, {
|
|
147
182
|
prefix: /*#__PURE__*/ React.createElement(SearchOutlined, null),
|
|
148
183
|
placeholder: 'Search'
|
|
149
|
-
}))
|
|
184
|
+
})))
|
|
150
185
|
}, /*#__PURE__*/ React.createElement(Button, {
|
|
151
186
|
type: "text",
|
|
152
187
|
title: (i18n === null || i18n === void 0 ? void 0 : (_i18n_locale = i18n.locale) === null || _i18n_locale === void 0 ? void 0 : _i18n_locale.switchLanguage) || '切换语言',
|
|
@@ -130,8 +130,10 @@ function csvToMarkdownTable(csv) {
|
|
|
130
130
|
if (!props.element) {
|
|
131
131
|
return null;
|
|
132
132
|
}
|
|
133
|
-
|
|
134
|
-
if (props.element.value
|
|
133
|
+
// readonly 模式下,空代码块不展示
|
|
134
|
+
if (readonly && !props.element.value) {
|
|
135
|
+
return null;
|
|
136
|
+
}
|
|
135
137
|
if (readonly && props.element.language === 'csv') {
|
|
136
138
|
var _props_element;
|
|
137
139
|
return /*#__PURE__*/ React.createElement(BaseMarkdownEditor, {
|