@ant-design/agentic-ui 2.29.16 → 2.29.18
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/MarkdownEditor/editor/Editor.js +9 -3
- package/dist/MarkdownEditor/editor/elements/Hr/index.js +1 -0
- package/dist/MarkdownEditor/editor/elements/Schema/ReadonlySchema.js +79 -53
- package/dist/MarkdownEditor/editor/elements/Schema/index.js +19 -1
- package/dist/MarkdownEditor/editor/plugins/elements.js +45 -0
- package/dist/MarkdownEditor/editor/plugins/insertParsedHtmlNodes.js +39 -34
- package/dist/MarkdownEditor/types.d.ts +10 -1
- package/package.json +16 -16
|
@@ -764,7 +764,7 @@ var defaultAllowedTypes = [
|
|
|
764
764
|
* 实际的粘贴处理逻辑
|
|
765
765
|
*/ var handlePasteEvent = function(event) {
|
|
766
766
|
return _async_to_generator(function() {
|
|
767
|
-
var _props_onPaste, _event_clipboardData, pasteConfig, currentTextSelection, nodeList, curNode, types, allowedTypes, _event_clipboardData_getData, _event_clipboardData_getData1, _event_clipboardData1, text, _event_clipboardData_getData2, _event_clipboardData_getData3, _event_clipboardData2, text1, selection, e;
|
|
767
|
+
var _props_onPaste, _event_clipboardData, pasteConfig, currentTextSelection, nodeList, curNode, result, types, allowedTypes, result1, _event_clipboardData_getData, _event_clipboardData_getData1, _event_clipboardData1, text, _event_clipboardData_getData2, _event_clipboardData_getData3, _event_clipboardData2, text1, selection, e;
|
|
768
768
|
return _ts_generator(this, function(_state) {
|
|
769
769
|
switch(_state.label){
|
|
770
770
|
case 0:
|
|
@@ -793,7 +793,12 @@ var defaultAllowedTypes = [
|
|
|
793
793
|
];
|
|
794
794
|
}
|
|
795
795
|
}
|
|
796
|
-
(_props_onPaste = props.onPaste) === null || _props_onPaste === void 0 ? void 0 : _props_onPaste.call(props, event);
|
|
796
|
+
result = (_props_onPaste = props.onPaste) === null || _props_onPaste === void 0 ? void 0 : _props_onPaste.call(props, event);
|
|
797
|
+
if (result === false) {
|
|
798
|
+
return [
|
|
799
|
+
2
|
|
800
|
+
];
|
|
801
|
+
}
|
|
797
802
|
types = ((_event_clipboardData = event.clipboardData) === null || _event_clipboardData === void 0 ? void 0 : _event_clipboardData.types) || [
|
|
798
803
|
'text/plain'
|
|
799
804
|
];
|
|
@@ -816,7 +821,8 @@ var defaultAllowedTypes = [
|
|
|
816
821
|
handleHtmlPaste(markdownEditorRef.current, event.clipboardData, props)
|
|
817
822
|
];
|
|
818
823
|
case 1:
|
|
819
|
-
|
|
824
|
+
result1 = _state.sent();
|
|
825
|
+
if (result1 === false) {
|
|
820
826
|
return [
|
|
821
827
|
2
|
|
822
828
|
];
|
|
@@ -54,6 +54,7 @@ import React from "react";
|
|
|
54
54
|
export var Hr = function(param) {
|
|
55
55
|
var attributes = param.attributes, children = param.children;
|
|
56
56
|
return /*#__PURE__*/ React.createElement("div", _object_spread_props(_object_spread({}, attributes), {
|
|
57
|
+
"data-be": "hr",
|
|
57
58
|
contentEditable: false,
|
|
58
59
|
className: 'select-none',
|
|
59
60
|
style: {
|
|
@@ -50,9 +50,10 @@ function _object_spread_props(target, source) {
|
|
|
50
50
|
}
|
|
51
51
|
return target;
|
|
52
52
|
}
|
|
53
|
-
import React, { useContext } from "react";
|
|
53
|
+
import React, { useContext, useMemo } from "react";
|
|
54
54
|
import { BubbleConfigContext } from "../../../../Bubble/BubbleConfigProvide";
|
|
55
55
|
import { SchemaRenderer } from "../../../../Schema";
|
|
56
|
+
import { debugInfo } from "../../../../Utils/debugUtils";
|
|
56
57
|
import { useEditorStore } from "../../store";
|
|
57
58
|
/**
|
|
58
59
|
* ReadonlySchema 组件 - 只读模式渲染组件
|
|
@@ -84,67 +85,92 @@ import { useEditorStore } from "../../store";
|
|
|
84
85
|
* - 使用 React.memo 优化性能
|
|
85
86
|
* - 保持预览模式的视觉效果
|
|
86
87
|
*/ export var ReadonlySchema = /*#__PURE__*/ React.memo(function(props) {
|
|
88
|
+
var _editorProps_codeProps;
|
|
87
89
|
var node = props.element;
|
|
88
90
|
var editorProps = useEditorStore().editorProps;
|
|
89
91
|
var apaasify = (editorProps === null || editorProps === void 0 ? void 0 : editorProps.apaasify) || (editorProps === null || editorProps === void 0 ? void 0 : editorProps.apassify);
|
|
90
92
|
var bubble = (useContext(BubbleConfigContext) || {}).bubble;
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
93
|
+
var defaultDom = useMemo(function() {
|
|
94
|
+
if ((apaasify === null || apaasify === void 0 ? void 0 : apaasify.enable) && apaasify.render) {
|
|
95
|
+
var renderedContent = apaasify.render(props, bubble === null || bubble === void 0 ? void 0 : bubble.originData);
|
|
96
|
+
return /*#__PURE__*/ React.createElement("div", _object_spread_props(_object_spread({}, node.attributes), {
|
|
97
|
+
"data-testid": "schema-container",
|
|
98
|
+
contentEditable: false,
|
|
99
|
+
style: {
|
|
100
|
+
display: 'flex',
|
|
101
|
+
flexDirection: 'column',
|
|
102
|
+
userSelect: 'text',
|
|
103
|
+
WebkitUserSelect: 'text'
|
|
104
|
+
}
|
|
105
|
+
}), renderedContent, /*#__PURE__*/ React.createElement("div", {
|
|
106
|
+
"data-testid": "schema-hidden-json",
|
|
107
|
+
style: {
|
|
108
|
+
height: 1,
|
|
109
|
+
opacity: 0,
|
|
110
|
+
userSelect: 'none',
|
|
111
|
+
pointerEvents: 'none',
|
|
112
|
+
overflow: 'hidden'
|
|
113
|
+
}
|
|
114
|
+
}, JSON.stringify(props.element.value, null, 2)));
|
|
115
|
+
}
|
|
116
|
+
if (node.language === 'agentar-card') {
|
|
117
|
+
var _props_element_value;
|
|
118
|
+
return /*#__PURE__*/ React.createElement("div", {
|
|
119
|
+
"data-testid": "agentar-card-container",
|
|
120
|
+
style: {
|
|
121
|
+
padding: '0.5em'
|
|
122
|
+
},
|
|
123
|
+
"data-agentar-card": true
|
|
124
|
+
}, /*#__PURE__*/ React.createElement(SchemaRenderer, {
|
|
125
|
+
schema: props.element.value,
|
|
126
|
+
values: ((_props_element_value = props.element.value) === null || _props_element_value === void 0 ? void 0 : _props_element_value.initialValues) || {},
|
|
127
|
+
useDefaultValues: false,
|
|
128
|
+
debug: false,
|
|
129
|
+
fallbackContent: null
|
|
130
|
+
}));
|
|
131
|
+
}
|
|
132
|
+
return /*#__PURE__*/ React.createElement("pre", _object_spread_props(_object_spread({}, props.attributes), {
|
|
96
133
|
style: {
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
134
|
+
background: 'rgb(242, 241, 241)',
|
|
135
|
+
color: 'rgb(27, 27, 27)',
|
|
136
|
+
padding: '1em',
|
|
137
|
+
borderRadius: '0.5em',
|
|
138
|
+
margin: '1em 0',
|
|
139
|
+
fontSize: '0.8em',
|
|
140
|
+
fontFamily: 'monospace',
|
|
141
|
+
lineHeight: '1.5',
|
|
142
|
+
overflowX: 'auto',
|
|
143
|
+
whiteSpace: 'pre-wrap',
|
|
144
|
+
wordBreak: 'break-all',
|
|
145
|
+
wordWrap: 'break-word'
|
|
101
146
|
}
|
|
102
|
-
}),
|
|
103
|
-
"data-testid": "schema-hidden-json",
|
|
147
|
+
}), /*#__PURE__*/ React.createElement("code", null, JSON.stringify(props.element.value, null, 2)), /*#__PURE__*/ React.createElement("div", {
|
|
104
148
|
style: {
|
|
105
|
-
|
|
106
|
-
opacity: 0,
|
|
107
|
-
userSelect: 'none',
|
|
108
|
-
pointerEvents: 'none',
|
|
109
|
-
overflow: 'hidden'
|
|
149
|
+
display: 'none'
|
|
110
150
|
}
|
|
111
|
-
},
|
|
112
|
-
}
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
}, /*#__PURE__*/ React.createElement(SchemaRenderer, {
|
|
122
|
-
schema: props.element.value,
|
|
123
|
-
values: ((_props_element_value = props.element.value) === null || _props_element_value === void 0 ? void 0 : _props_element_value.initialValues) || {},
|
|
124
|
-
useDefaultValues: false,
|
|
125
|
-
debug: false,
|
|
126
|
-
fallbackContent: null
|
|
127
|
-
}));
|
|
151
|
+
}, props.children));
|
|
152
|
+
}, [
|
|
153
|
+
node.value,
|
|
154
|
+
node.language,
|
|
155
|
+
bubble,
|
|
156
|
+
apaasify
|
|
157
|
+
]);
|
|
158
|
+
var customRender = editorProps === null || editorProps === void 0 ? void 0 : (_editorProps_codeProps = editorProps.codeProps) === null || _editorProps_codeProps === void 0 ? void 0 : _editorProps_codeProps.render;
|
|
159
|
+
if (!customRender) {
|
|
160
|
+
return defaultDom;
|
|
128
161
|
}
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
borderRadius: '0.5em',
|
|
135
|
-
margin: '1em 0',
|
|
136
|
-
fontSize: '0.8em',
|
|
137
|
-
fontFamily: 'monospace',
|
|
138
|
-
lineHeight: '1.5',
|
|
139
|
-
overflowX: 'auto',
|
|
140
|
-
whiteSpace: 'pre-wrap',
|
|
141
|
-
wordBreak: 'break-all',
|
|
142
|
-
wordWrap: 'break-word'
|
|
143
|
-
}
|
|
144
|
-
}), /*#__PURE__*/ React.createElement("code", null, JSON.stringify(props.element.value, null, 2)), /*#__PURE__*/ React.createElement("div", {
|
|
145
|
-
style: {
|
|
146
|
-
display: 'none'
|
|
162
|
+
try {
|
|
163
|
+
var renderContent = customRender(props, defaultDom, editorProps === null || editorProps === void 0 ? void 0 : editorProps.codeProps);
|
|
164
|
+
// 返回 undefined 表示“不覆盖”,回退内部默认渲染
|
|
165
|
+
if (renderContent === undefined) {
|
|
166
|
+
return defaultDom;
|
|
147
167
|
}
|
|
148
|
-
|
|
168
|
+
return renderContent;
|
|
169
|
+
} catch (error) {
|
|
170
|
+
debugInfo('ReadonlySchema - codeProps.render 执行异常,回退默认渲染', {
|
|
171
|
+
error: (error === null || error === void 0 ? void 0 : error.message) || String(error)
|
|
172
|
+
});
|
|
173
|
+
return defaultDom;
|
|
174
|
+
}
|
|
149
175
|
});
|
|
150
176
|
ReadonlySchema.displayName = 'ReadonlySchema';
|
|
@@ -96,6 +96,7 @@ import { useEditorStore } from "../../store";
|
|
|
96
96
|
* 2. AgentAR 卡片渲染
|
|
97
97
|
* 3. 默认 JSON 字符串渲染
|
|
98
98
|
*/ export var Schema = function(props) {
|
|
99
|
+
var _editorProps_codeProps;
|
|
99
100
|
debugInfo('Schema - 渲染 Schema', {
|
|
100
101
|
language: props.element.language,
|
|
101
102
|
valueType: _type_of(props.element.value),
|
|
@@ -105,7 +106,7 @@ import { useEditorStore } from "../../store";
|
|
|
105
106
|
var editorProps = useEditorStore().editorProps;
|
|
106
107
|
var apaasify = (editorProps === null || editorProps === void 0 ? void 0 : editorProps.apaasify) || (editorProps === null || editorProps === void 0 ? void 0 : editorProps.apassify);
|
|
107
108
|
var bubble = (useContext(BubbleConfigContext) || {}).bubble;
|
|
108
|
-
|
|
109
|
+
var defaultDom = useMemo(function() {
|
|
109
110
|
if ((apaasify === null || apaasify === void 0 ? void 0 : apaasify.enable) && apaasify.render) {
|
|
110
111
|
var renderedContent = apaasify.render(props, bubble === null || bubble === void 0 ? void 0 : bubble.originData);
|
|
111
112
|
return /*#__PURE__*/ React.createElement("div", _object_spread_props(_object_spread({}, node.attributes), {
|
|
@@ -185,4 +186,21 @@ import { useEditorStore } from "../../store";
|
|
|
185
186
|
bubble,
|
|
186
187
|
apaasify
|
|
187
188
|
]);
|
|
189
|
+
var customRender = editorProps === null || editorProps === void 0 ? void 0 : (_editorProps_codeProps = editorProps.codeProps) === null || _editorProps_codeProps === void 0 ? void 0 : _editorProps_codeProps.render;
|
|
190
|
+
if (!customRender) {
|
|
191
|
+
return defaultDom;
|
|
192
|
+
}
|
|
193
|
+
try {
|
|
194
|
+
var renderContent = customRender(props, defaultDom, editorProps === null || editorProps === void 0 ? void 0 : editorProps.codeProps);
|
|
195
|
+
// 返回 undefined 表示“不覆盖”,回退内部默认渲染
|
|
196
|
+
if (renderContent === undefined) {
|
|
197
|
+
return defaultDom;
|
|
198
|
+
}
|
|
199
|
+
return renderContent;
|
|
200
|
+
} catch (error) {
|
|
201
|
+
debugInfo('Schema - codeProps.render 执行异常,回退默认渲染', {
|
|
202
|
+
error: (error === null || error === void 0 ? void 0 : error.message) || String(error)
|
|
203
|
+
});
|
|
204
|
+
return defaultDom;
|
|
205
|
+
}
|
|
188
206
|
};
|
|
@@ -189,6 +189,26 @@ export var MdElements = {
|
|
|
189
189
|
return true;
|
|
190
190
|
}
|
|
191
191
|
},
|
|
192
|
+
codeSpace: {
|
|
193
|
+
matchKey: ' ',
|
|
194
|
+
reg: /^\s*(```|···)([\w#\-+*]{1,30})?\s*$/,
|
|
195
|
+
run: function(param) {
|
|
196
|
+
var editor = param.editor, path = param.path, match = param.match;
|
|
197
|
+
var lang = match[2];
|
|
198
|
+
Transforms.delete(editor, {
|
|
199
|
+
at: path
|
|
200
|
+
});
|
|
201
|
+
Transforms.insertNodes(editor, {
|
|
202
|
+
type: 'code',
|
|
203
|
+
language: lang,
|
|
204
|
+
value: ''
|
|
205
|
+
}, {
|
|
206
|
+
at: path,
|
|
207
|
+
select: true
|
|
208
|
+
});
|
|
209
|
+
return true;
|
|
210
|
+
}
|
|
211
|
+
},
|
|
192
212
|
head: {
|
|
193
213
|
matchKey: ' ',
|
|
194
214
|
checkAllow: function(ctx) {
|
|
@@ -388,6 +408,31 @@ export var MdElements = {
|
|
|
388
408
|
return true;
|
|
389
409
|
}
|
|
390
410
|
},
|
|
411
|
+
hrSpace: {
|
|
412
|
+
matchKey: ' ',
|
|
413
|
+
reg: /^\s*(\*\*\*|___|---)\s*/,
|
|
414
|
+
checkAllow: function(ctx) {
|
|
415
|
+
var _ctx_node_, _ctx_node;
|
|
416
|
+
return ((_ctx_node = ctx.node) === null || _ctx_node === void 0 ? void 0 : (_ctx_node_ = _ctx_node[0]) === null || _ctx_node_ === void 0 ? void 0 : _ctx_node_.type) === 'paragraph' && ctx.node[1][0] !== 0;
|
|
417
|
+
},
|
|
418
|
+
run: function(param) {
|
|
419
|
+
var editor = param.editor, path = param.path;
|
|
420
|
+
Transforms.delete(editor, {
|
|
421
|
+
at: path
|
|
422
|
+
});
|
|
423
|
+
Transforms.insertNodes(editor, {
|
|
424
|
+
type: 'hr',
|
|
425
|
+
children: [
|
|
426
|
+
{
|
|
427
|
+
text: ''
|
|
428
|
+
}
|
|
429
|
+
]
|
|
430
|
+
}, {
|
|
431
|
+
at: path
|
|
432
|
+
});
|
|
433
|
+
insertAfter(editor, path);
|
|
434
|
+
}
|
|
435
|
+
},
|
|
391
436
|
frontmatter: {
|
|
392
437
|
reg: /^\s*---\s*/,
|
|
393
438
|
checkAllow: function(ctx) {
|
|
@@ -240,13 +240,32 @@ function _ts_generator(thisArg, body) {
|
|
|
240
240
|
import { Editor, Element, Node, Path, Range, Transforms } from "slate";
|
|
241
241
|
import { jsx } from "slate-hyperscript";
|
|
242
242
|
import { debugInfo } from "../../../Utils/debugUtils";
|
|
243
|
-
import {
|
|
243
|
+
import { EditorUtils } from "../utils";
|
|
244
244
|
import { docxDeserializer } from "../utils/docx/docxDeserializer";
|
|
245
245
|
import { BackspaceKey } from "./hotKeyCommands/backspace";
|
|
246
246
|
// 性能优化常量
|
|
247
247
|
var BATCH_SIZE = 10; // 每批处理的节点数量
|
|
248
248
|
var BATCH_DELAY = 16; // 每批之间的延迟时间(ms),约60fps
|
|
249
249
|
var MAX_SYNC_SIZE = 1000; // 同步处理的最大字符数
|
|
250
|
+
/** 文件上传时排除的片段类型 */ var UPLOAD_EXCLUDED_FRAGMENT_TYPES = [
|
|
251
|
+
'media',
|
|
252
|
+
'image'
|
|
253
|
+
];
|
|
254
|
+
/** card 的第二个子节点为 media/image 时排除上传 */ var CARD_CONTENT_EXCLUDED_TYPES = [
|
|
255
|
+
'media',
|
|
256
|
+
'image'
|
|
257
|
+
];
|
|
258
|
+
var shouldExcludeFromUpload = function(fragment) {
|
|
259
|
+
if (UPLOAD_EXCLUDED_FRAGMENT_TYPES.includes(fragment === null || fragment === void 0 ? void 0 : fragment.type)) {
|
|
260
|
+
return true;
|
|
261
|
+
}
|
|
262
|
+
if ((fragment === null || fragment === void 0 ? void 0 : fragment.type) === 'card') {
|
|
263
|
+
var _fragment_children;
|
|
264
|
+
var secondNode = fragment === null || fragment === void 0 ? void 0 : (_fragment_children = fragment.children) === null || _fragment_children === void 0 ? void 0 : _fragment_children[1];
|
|
265
|
+
return CARD_CONTENT_EXCLUDED_TYPES.includes(secondNode === null || secondNode === void 0 ? void 0 : secondNode.type);
|
|
266
|
+
}
|
|
267
|
+
return false;
|
|
268
|
+
};
|
|
250
269
|
var findElementByNode = function(node) {
|
|
251
270
|
var index = Array.prototype.indexOf.call(node.parentNode.childNodes, node);
|
|
252
271
|
return node.parentElement.children[index];
|
|
@@ -1002,7 +1021,7 @@ var blobToFile = function(blobUrl, fileName) {
|
|
|
1002
1021
|
};
|
|
1003
1022
|
export var insertParsedHtmlNodes = function(editor, html, editorProps, rtl) {
|
|
1004
1023
|
return _async_to_generator(function() {
|
|
1005
|
-
var
|
|
1024
|
+
var fragmentList, fragmentsToUpload, _Editor_nodes, node, selection, processedNodes, back, _Editor_nodes1, specialNode, parsed, inner, hasCodeTags, textContent, children, _Editor_nodes2, p, parent, nextPath, texts, text, processedNodes1, error;
|
|
1006
1025
|
return _ts_generator(this, function(_state) {
|
|
1007
1026
|
switch(_state.label){
|
|
1008
1027
|
case 0:
|
|
@@ -1020,8 +1039,6 @@ export var insertParsedHtmlNodes = function(editor, html, editorProps, rtl) {
|
|
|
1020
1039
|
false
|
|
1021
1040
|
];
|
|
1022
1041
|
}
|
|
1023
|
-
// 2. 显示解析提示
|
|
1024
|
-
hideLoading = message.loading('parsing...', 0);
|
|
1025
1042
|
_state.label = 1;
|
|
1026
1043
|
case 1:
|
|
1027
1044
|
_state.trys.push([
|
|
@@ -1030,39 +1047,28 @@ export var insertParsedHtmlNodes = function(editor, html, editorProps, rtl) {
|
|
|
1030
1047
|
,
|
|
1031
1048
|
18
|
|
1032
1049
|
]);
|
|
1033
|
-
// 3. 异步解析 HTML
|
|
1034
|
-
debugInfo('insertParsedHtmlNodes - 开始解析 HTML');
|
|
1035
1050
|
return [
|
|
1036
1051
|
4,
|
|
1037
1052
|
parseHtmlOptimized(html, rtl)
|
|
1038
1053
|
];
|
|
1039
1054
|
case 2:
|
|
1040
1055
|
fragmentList = _state.sent();
|
|
1041
|
-
debugInfo('insertParsedHtmlNodes - HTML 解析完成', {
|
|
1042
|
-
fragmentListLength: fragmentList === null || fragmentList === void 0 ? void 0 : fragmentList.length,
|
|
1043
|
-
fragmentTypes: fragmentList === null || fragmentList === void 0 ? void 0 : fragmentList.map(function(f) {
|
|
1044
|
-
return f === null || f === void 0 ? void 0 : f.type;
|
|
1045
|
-
})
|
|
1046
|
-
});
|
|
1047
1056
|
if (!(fragmentList === null || fragmentList === void 0 ? void 0 : fragmentList.length)) {
|
|
1048
|
-
debugInfo('insertParsedHtmlNodes - 解析结果为空');
|
|
1049
|
-
hideLoading();
|
|
1050
1057
|
return [
|
|
1051
1058
|
2,
|
|
1052
1059
|
false
|
|
1053
1060
|
];
|
|
1054
1061
|
}
|
|
1055
|
-
// 4.
|
|
1056
|
-
|
|
1062
|
+
// 4. 异步处理文件上传(排除 media、image;card 需判断第二个节点类型)
|
|
1063
|
+
fragmentsToUpload = fragmentList.filter(function(f) {
|
|
1064
|
+
return !shouldExcludeFromUpload(f);
|
|
1065
|
+
});
|
|
1057
1066
|
return [
|
|
1058
1067
|
4,
|
|
1059
|
-
upLoadFileBatch(
|
|
1068
|
+
upLoadFileBatch(fragmentsToUpload, editorProps)
|
|
1060
1069
|
];
|
|
1061
1070
|
case 3:
|
|
1062
1071
|
_state.sent();
|
|
1063
|
-
debugInfo('insertParsedHtmlNodes - 文件上传完成');
|
|
1064
|
-
debugLog('wordFragmentList', fragmentList);
|
|
1065
|
-
hideLoading();
|
|
1066
1072
|
// 5. 获取当前节点
|
|
1067
1073
|
_Editor_nodes = _sliced_to_array(Editor.nodes(editor, {
|
|
1068
1074
|
match: function(n) {
|
|
@@ -1075,7 +1081,7 @@ export var insertParsedHtmlNodes = function(editor, html, editorProps, rtl) {
|
|
|
1075
1081
|
5
|
|
1076
1082
|
];
|
|
1077
1083
|
debugInfo('insertParsedHtmlNodes - 无有效选区,直接插入');
|
|
1078
|
-
processedNodes =
|
|
1084
|
+
processedNodes = fragmentsToUpload === null || fragmentsToUpload === void 0 ? void 0 : fragmentsToUpload.map(function(item) {
|
|
1079
1085
|
if (!item.type) {
|
|
1080
1086
|
return {
|
|
1081
1087
|
type: 'paragraph',
|
|
@@ -1189,15 +1195,15 @@ export var insertParsedHtmlNodes = function(editor, html, editorProps, rtl) {
|
|
|
1189
1195
|
true
|
|
1190
1196
|
];
|
|
1191
1197
|
}
|
|
1192
|
-
if (!((node === null || node === void 0 ? void 0 : node[0].type) === 'list-item' && (
|
|
1198
|
+
if (!((node === null || node === void 0 ? void 0 : node[0].type) === 'list-item' && (fragmentsToUpload[0].type === 'list' || fragmentsToUpload[0].type === 'bulleted-list' || fragmentsToUpload[0].type === 'numbered-list'))) return [
|
|
1193
1199
|
3,
|
|
1194
1200
|
12
|
|
1195
1201
|
];
|
|
1196
1202
|
debugInfo('insertParsedHtmlNodes - 处理列表项', {
|
|
1197
1203
|
currentNodeType: node[0].type,
|
|
1198
|
-
fragmentListType:
|
|
1204
|
+
fragmentListType: fragmentsToUpload[0].type
|
|
1199
1205
|
});
|
|
1200
|
-
children =
|
|
1206
|
+
children = fragmentsToUpload[0].children || [];
|
|
1201
1207
|
debugInfo('insertParsedHtmlNodes - 列表项子节点', {
|
|
1202
1208
|
childrenCount: children.length
|
|
1203
1209
|
});
|
|
@@ -1269,13 +1275,13 @@ export var insertParsedHtmlNodes = function(editor, html, editorProps, rtl) {
|
|
|
1269
1275
|
_state.sent();
|
|
1270
1276
|
_state.label = 9;
|
|
1271
1277
|
case 9:
|
|
1272
|
-
if (!(
|
|
1278
|
+
if (!(fragmentsToUpload.length > 1)) return [
|
|
1273
1279
|
3,
|
|
1274
1280
|
11
|
|
1275
1281
|
];
|
|
1276
1282
|
return [
|
|
1277
1283
|
4,
|
|
1278
|
-
insertNodesBatch(editor,
|
|
1284
|
+
insertNodesBatch(editor, fragmentsToUpload.slice(1), selection.anchor.path, {
|
|
1279
1285
|
select: true
|
|
1280
1286
|
})
|
|
1281
1287
|
];
|
|
@@ -1290,7 +1296,7 @@ export var insertParsedHtmlNodes = function(editor, html, editorProps, rtl) {
|
|
|
1290
1296
|
case 12:
|
|
1291
1297
|
// 11. 处理表格单元格
|
|
1292
1298
|
if ((node === null || node === void 0 ? void 0 : node[0].type) === 'table-cell') {
|
|
1293
|
-
Transforms.insertFragment(editor, getTextsNode(
|
|
1299
|
+
Transforms.insertFragment(editor, getTextsNode(fragmentsToUpload), {
|
|
1294
1300
|
at: selection
|
|
1295
1301
|
});
|
|
1296
1302
|
return [
|
|
@@ -1302,8 +1308,8 @@ export var insertParsedHtmlNodes = function(editor, html, editorProps, rtl) {
|
|
|
1302
1308
|
3,
|
|
1303
1309
|
15
|
|
1304
1310
|
];
|
|
1305
|
-
if (
|
|
1306
|
-
if (
|
|
1311
|
+
if (fragmentsToUpload[0].type) {
|
|
1312
|
+
if (fragmentsToUpload[0].type !== 'paragraph') {
|
|
1307
1313
|
Transforms.insertNodes(editor, {
|
|
1308
1314
|
type: 'paragraph',
|
|
1309
1315
|
children: [
|
|
@@ -1325,7 +1331,7 @@ export var insertParsedHtmlNodes = function(editor, html, editorProps, rtl) {
|
|
|
1325
1331
|
false
|
|
1326
1332
|
];
|
|
1327
1333
|
}
|
|
1328
|
-
texts =
|
|
1334
|
+
texts = fragmentsToUpload.filter(function(c) {
|
|
1329
1335
|
return c.text;
|
|
1330
1336
|
});
|
|
1331
1337
|
if (!texts.length) return [
|
|
@@ -1349,8 +1355,8 @@ export var insertParsedHtmlNodes = function(editor, html, editorProps, rtl) {
|
|
|
1349
1355
|
];
|
|
1350
1356
|
case 15:
|
|
1351
1357
|
// 13. 处理单个段落的特殊情况
|
|
1352
|
-
if (
|
|
1353
|
-
text = Node.string(
|
|
1358
|
+
if (fragmentsToUpload.length === 1 && (fragmentsToUpload[0].type === 'paragraph' || !fragmentsToUpload[0].type) && node) {
|
|
1359
|
+
text = Node.string(fragmentsToUpload[0]);
|
|
1354
1360
|
if (text) {
|
|
1355
1361
|
Transforms.insertText(editor, text, {
|
|
1356
1362
|
at: selection
|
|
@@ -1363,7 +1369,7 @@ export var insertParsedHtmlNodes = function(editor, html, editorProps, rtl) {
|
|
|
1363
1369
|
}
|
|
1364
1370
|
// 14. 默认情况:替换选中节点
|
|
1365
1371
|
debugInfo('insertParsedHtmlNodes - 使用默认处理方式');
|
|
1366
|
-
processedNodes1 =
|
|
1372
|
+
processedNodes1 = fragmentsToUpload === null || fragmentsToUpload === void 0 ? void 0 : fragmentsToUpload.map(function(item) {
|
|
1367
1373
|
if (!item.type) {
|
|
1368
1374
|
return {
|
|
1369
1375
|
type: 'paragraph',
|
|
@@ -1401,7 +1407,6 @@ export var insertParsedHtmlNodes = function(editor, html, editorProps, rtl) {
|
|
|
1401
1407
|
case 17:
|
|
1402
1408
|
error = _state.sent();
|
|
1403
1409
|
console.error('插入HTML节点失败:', error);
|
|
1404
|
-
hideLoading();
|
|
1405
1410
|
message.error('Content parsing failed, please try again');
|
|
1406
1411
|
return [
|
|
1407
1412
|
2,
|
|
@@ -202,6 +202,15 @@ export type MarkdownEditorProps = {
|
|
|
202
202
|
* @property {boolean} [wrap] - 是否自动换行,默认 true
|
|
203
203
|
*/
|
|
204
204
|
codeProps?: {
|
|
205
|
+
render?: (props: CustomLeaf<Record<string, any>> & {
|
|
206
|
+
children: React.ReactNode;
|
|
207
|
+
}, defaultDom: React.ReactNode, codeProps?: MarkdownEditorProps['codeProps']) => React.ReactNode;
|
|
208
|
+
/**
|
|
209
|
+
* 自定义节点渲染函数
|
|
210
|
+
*
|
|
211
|
+
* 约定:当 `render` 返回 `undefined` 时,表示“不覆盖默认渲染”,组件会回退到内部默认的卡片/渲染逻辑;
|
|
212
|
+
* 若需要“不渲染任何内容”,请显式返回 `null`。
|
|
213
|
+
*/
|
|
205
214
|
Languages?: string[];
|
|
206
215
|
hideToolBar?: boolean;
|
|
207
216
|
alwaysExpandedDeepThink?: boolean;
|
|
@@ -386,7 +395,7 @@ export type MarkdownEditorProps = {
|
|
|
386
395
|
};
|
|
387
396
|
onFocus?: (value: string, schema: Elements[], e: React.FocusEvent<HTMLDivElement, Element>) => void;
|
|
388
397
|
onBlur?: (value: string, schema: Elements[], e: React.MouseEvent<HTMLDivElement, Element>) => void;
|
|
389
|
-
onPaste?: (e: React.ClipboardEvent<HTMLDivElement>) => void;
|
|
398
|
+
onPaste?: (e: React.ClipboardEvent<HTMLDivElement>) => boolean | void;
|
|
390
399
|
/**
|
|
391
400
|
* 自定义 markdown 转 HTML 的 remark 插件配置,格式类似 Babel 插件数组
|
|
392
401
|
*/
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ant-design/agentic-ui",
|
|
3
|
-
"version": "2.29.
|
|
3
|
+
"version": "2.29.18",
|
|
4
4
|
"description": "面向智能体的 UI 组件库,提供多步推理可视化、工具调用展示、任务执行协同等 Agentic UI 能力",
|
|
5
5
|
"repository": "git@github.com:ant-design/agentic-ui.git",
|
|
6
6
|
"license": "MIT",
|
|
@@ -61,13 +61,13 @@
|
|
|
61
61
|
"@better-scroll/mouse-wheel": "^2.5.1",
|
|
62
62
|
"@better-scroll/observe-dom": "^2.5.1",
|
|
63
63
|
"@better-scroll/scroll-bar": "^2.5.1",
|
|
64
|
-
"@galacean/effects": "^2.8.
|
|
64
|
+
"@galacean/effects": "^2.8.6",
|
|
65
65
|
"@juggle/resize-observer": "^3.4.0",
|
|
66
66
|
"@react-three/fiber": "^8.18.0",
|
|
67
67
|
"@schema-element-editor/host-sdk": "^2.2.1",
|
|
68
68
|
"@sofa-design/icons": "^1.6.2",
|
|
69
69
|
"@types/three": "^0.182.0",
|
|
70
|
-
"ace-builds": "^1.43.
|
|
70
|
+
"ace-builds": "^1.43.6",
|
|
71
71
|
"ajv": "^8.17.1",
|
|
72
72
|
"ajv-formats": "^3.0.1",
|
|
73
73
|
"antd": "^5.29.3",
|
|
@@ -86,9 +86,9 @@
|
|
|
86
86
|
"framer-motion": "^11.18.2",
|
|
87
87
|
"is-hotkey": "^0.2.0",
|
|
88
88
|
"json5": "^2.2.3",
|
|
89
|
-
"katex": "^0.16.
|
|
90
|
-
"lodash": "^4.17.
|
|
91
|
-
"lodash-es": "^4.17.
|
|
89
|
+
"katex": "^0.16.28",
|
|
90
|
+
"lodash": "^4.17.23",
|
|
91
|
+
"lodash-es": "^4.17.23",
|
|
92
92
|
"lottie-react": "^2.4.1",
|
|
93
93
|
"mermaid": "^11.12.2",
|
|
94
94
|
"mustache": "^4.2.0",
|
|
@@ -121,18 +121,18 @@
|
|
|
121
121
|
"slate-hyperscript": "0.100.0",
|
|
122
122
|
"slate-react": "0.120.0",
|
|
123
123
|
"string-width": "^7.2.0",
|
|
124
|
-
"styled-components": "^6.3.
|
|
124
|
+
"styled-components": "^6.3.8",
|
|
125
125
|
"tailwind-merge": "^3.4.0",
|
|
126
126
|
"three": "^0.182.0",
|
|
127
127
|
"unified": "^11.0.5",
|
|
128
|
-
"unist-util-visit": "^5.
|
|
128
|
+
"unist-util-visit": "^5.1.0"
|
|
129
129
|
},
|
|
130
130
|
"devDependencies": {
|
|
131
131
|
"@mlc-ai/web-llm": "^0.2.80",
|
|
132
|
-
"@playwright/test": "^1.
|
|
133
|
-
"@swc/core": "^1.15.
|
|
132
|
+
"@playwright/test": "^1.58.0",
|
|
133
|
+
"@swc/core": "^1.15.10",
|
|
134
134
|
"@testing-library/jest-dom": "^6.9.1",
|
|
135
|
-
"@testing-library/react": "^16.3.
|
|
135
|
+
"@testing-library/react": "^16.3.2",
|
|
136
136
|
"@testing-library/user-event": "^14.6.1",
|
|
137
137
|
"@types/classnames": "^2.3.4",
|
|
138
138
|
"@types/diacritics": "^1.3.3",
|
|
@@ -151,7 +151,7 @@
|
|
|
151
151
|
"@types/reveal.js": "^5.2.2",
|
|
152
152
|
"@types/styled-components": "^5.1.36",
|
|
153
153
|
"@types/uuid": "^10.0.0",
|
|
154
|
-
"@umijs/lint": "^4.6.
|
|
154
|
+
"@umijs/lint": "^4.6.25",
|
|
155
155
|
"@vitejs/plugin-react": "^4.7.0",
|
|
156
156
|
"@vitest/coverage-istanbul": "^2.1.9",
|
|
157
157
|
"@vitest/ui": "2.1.9",
|
|
@@ -166,14 +166,14 @@
|
|
|
166
166
|
"lint-staged": "^13.3.0",
|
|
167
167
|
"mockdate": "^3.0.5",
|
|
168
168
|
"nwsapi": "2.2.13",
|
|
169
|
-
"playwright": "^1.
|
|
169
|
+
"playwright": "^1.58.0",
|
|
170
170
|
"postcss": "^8.5.6",
|
|
171
|
-
"prettier": "^3.8.
|
|
171
|
+
"prettier": "^3.8.1",
|
|
172
172
|
"prettier-plugin-organize-imports": "^4.3.0",
|
|
173
|
-
"prettier-plugin-packagejson": "^2.5.
|
|
173
|
+
"prettier-plugin-packagejson": "^2.5.22",
|
|
174
174
|
"react": "^18.3.1",
|
|
175
175
|
"react-dom": "^18.3.1",
|
|
176
|
-
"recharts": "^3.
|
|
176
|
+
"recharts": "^3.7.0",
|
|
177
177
|
"sast": "^0.8.1",
|
|
178
178
|
"stylelint": "^14.16.1",
|
|
179
179
|
"typescript": "^5.9.3",
|