@ant-design/agentic-ui 2.29.15 → 2.29.17
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/README.md +93 -205
- package/dist/Bubble/List/PureBubbleList.js +2 -4
- package/dist/Components/LayoutHeader/index.js +1 -1
- package/dist/Hooks/useLanguage.d.ts +2 -0
- package/dist/I18n/locales.d.ts +2 -0
- package/dist/I18n/locales.js +4 -0
- 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/parser/parse/parseHtml.js +11 -3
- package/dist/MarkdownEditor/editor/parser/parserMarkdownToSlateNode.d.ts +8 -0
- package/dist/MarkdownEditor/editor/parser/parserMarkdownToSlateNode.js +206 -144
- package/dist/MarkdownEditor/editor/plugins/elements.js +53 -2
- package/dist/MarkdownEditor/editor/plugins/hotKeyCommands/match.d.ts +1 -1
- package/dist/MarkdownEditor/editor/plugins/hotKeyCommands/match.js +4 -3
- package/dist/MarkdownEditor/editor/plugins/useKeyboard.js +1 -2
- package/dist/MarkdownEditor/types.d.ts +9 -0
- package/dist/MarkdownInputField/MarkdownInputField.js +4 -2
- package/dist/MarkdownInputField/SendActions/index.d.ts +2 -0
- package/dist/MarkdownInputField/SendActions/index.js +5 -3
- package/dist/MarkdownInputField/SendButton/index.d.ts +4 -0
- package/dist/MarkdownInputField/SendButton/index.js +3 -3
- package/dist/MarkdownInputField/hooks/useMarkdownInputFieldHandlers.d.ts +1 -1
- package/dist/MarkdownInputField/hooks/useMarkdownInputFieldHandlers.js +23 -10
- package/dist/MarkdownInputField/types/MarkdownInputFieldProps.d.ts +3 -3
- package/dist/MarkdownInputField/utils/renderHelpers.d.ts +1 -1
- package/dist/MarkdownInputField/utils/renderHelpers.js +3 -1
- package/dist/Workspace/Browser/index.d.ts +4 -0
- package/dist/Workspace/Browser/index.js +25 -7
- package/dist/Workspace/File/style.js +4 -1
- package/guidelines/Guidelines.md +31 -0
- package/guidelines/components/bubble.md +41 -0
- package/guidelines/components/chat-layout.md +45 -0
- package/guidelines/components/input.md +52 -0
- package/guidelines/components/loading.md +33 -0
- package/guidelines/components/markdown-editor.md +30 -0
- package/guidelines/components/robot.md +26 -0
- package/guidelines/components/task-list.md +22 -0
- package/guidelines/components/thought-chain.md +30 -0
- package/guidelines/components/tool-use-bar.md +22 -0
- package/guidelines/components/welcome-message.md +27 -0
- package/guidelines/components/workspace.md +63 -0
- package/guidelines/design-tokens/colors.md +51 -0
- package/guidelines/design-tokens/spacing.md +29 -0
- package/guidelines/design-tokens/typography.md +46 -0
- package/guidelines/overview-components.md +30 -0
- package/guidelines/overview-icons.md +15 -0
- package/package.json +20 -17
|
@@ -30,6 +30,14 @@ export declare class MarkdownToSlateParser {
|
|
|
30
30
|
private config;
|
|
31
31
|
private readonly plugins;
|
|
32
32
|
constructor(config?: ParserMarkdownToSlateNodeConfig, plugins?: MarkdownEditorPlugin[]);
|
|
33
|
+
private preprocessMarkdown;
|
|
34
|
+
private buildMarkdownRoot;
|
|
35
|
+
private filterTopLevelSchema;
|
|
36
|
+
private createEmptyParagraph;
|
|
37
|
+
private createParseContext;
|
|
38
|
+
private parseHtmlCommentProps;
|
|
39
|
+
private resolveConfig;
|
|
40
|
+
private parseWithPlugins;
|
|
33
41
|
/**
|
|
34
42
|
* 解析 Markdown 字符串并返回解析后的结构和链接信息
|
|
35
43
|
*
|
|
@@ -218,24 +218,26 @@ var removeAnswerTags = function(text) {
|
|
|
218
218
|
}
|
|
219
219
|
_create_class(MarkdownToSlateParser, [
|
|
220
220
|
{
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
*
|
|
224
|
-
* @param md - 要解析的 Markdown 字符串
|
|
225
|
-
* @returns 一个包含解析后的元素数组和链接信息的对象
|
|
226
|
-
*/ key: "parse",
|
|
227
|
-
value: function parse(md) {
|
|
228
|
-
// 先预处理 <think> 标签,然后预处理其他非标准 HTML 标签、<p align>,最后处理表格换行
|
|
221
|
+
key: "preprocessMarkdown",
|
|
222
|
+
value: function preprocessMarkdown(md) {
|
|
229
223
|
var thinkProcessed = removeAnswerTags(preprocessThinkTags(md || ''));
|
|
230
224
|
var nonStandardProcessed = removeAnswerTags(preprocessNonStandardHtmlTags(thinkProcessed));
|
|
231
|
-
|
|
232
|
-
|
|
225
|
+
return preprocessMarkdownTableNewlines(nonStandardProcessed);
|
|
226
|
+
}
|
|
227
|
+
},
|
|
228
|
+
{
|
|
229
|
+
key: "buildMarkdownRoot",
|
|
230
|
+
value: function buildMarkdownRoot(md) {
|
|
231
|
+
var preprocessedMarkdown = this.preprocessMarkdown(md);
|
|
233
232
|
var ast = mdastParser.parse(preprocessedMarkdown);
|
|
234
233
|
var processedMarkdown = mdastParser.runSync(ast);
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
234
|
+
return processedMarkdown.children;
|
|
235
|
+
}
|
|
236
|
+
},
|
|
237
|
+
{
|
|
238
|
+
key: "filterTopLevelSchema",
|
|
239
|
+
value: function filterTopLevelSchema(schema) {
|
|
240
|
+
return schema === null || schema === void 0 ? void 0 : schema.filter(function(item) {
|
|
239
241
|
var _item_children, _item_children1;
|
|
240
242
|
if (item.type === 'paragraph' && !((_item_children = item.children) === null || _item_children === void 0 ? void 0 : _item_children.length)) {
|
|
241
243
|
return false;
|
|
@@ -248,6 +250,123 @@ var removeAnswerTags = function(text) {
|
|
|
248
250
|
}
|
|
249
251
|
return true;
|
|
250
252
|
});
|
|
253
|
+
}
|
|
254
|
+
},
|
|
255
|
+
{
|
|
256
|
+
key: "createEmptyParagraph",
|
|
257
|
+
value: function createEmptyParagraph() {
|
|
258
|
+
return {
|
|
259
|
+
type: 'paragraph',
|
|
260
|
+
children: [
|
|
261
|
+
{
|
|
262
|
+
text: ''
|
|
263
|
+
}
|
|
264
|
+
]
|
|
265
|
+
};
|
|
266
|
+
}
|
|
267
|
+
},
|
|
268
|
+
{
|
|
269
|
+
key: "createParseContext",
|
|
270
|
+
value: function createParseContext() {
|
|
271
|
+
return {
|
|
272
|
+
preNode: null,
|
|
273
|
+
preElement: null,
|
|
274
|
+
htmlTag: [],
|
|
275
|
+
contextProps: {}
|
|
276
|
+
};
|
|
277
|
+
}
|
|
278
|
+
},
|
|
279
|
+
{
|
|
280
|
+
key: "parseHtmlCommentProps",
|
|
281
|
+
value: function parseHtmlCommentProps(currentElement) {
|
|
282
|
+
var htmlValue = currentElement === null || currentElement === void 0 ? void 0 : currentElement.value;
|
|
283
|
+
var isHtmlComment = currentElement.type === 'html' && typeof htmlValue === 'string' && htmlValue.trim().startsWith('<!--') && htmlValue.trim().endsWith('-->');
|
|
284
|
+
if (!isHtmlComment) {
|
|
285
|
+
return null;
|
|
286
|
+
}
|
|
287
|
+
try {
|
|
288
|
+
var commentContent = htmlValue.replace('<!--', '').replace('-->', '').trim();
|
|
289
|
+
var parsed = JSON.parse(commentContent);
|
|
290
|
+
if (Array.isArray(parsed)) {
|
|
291
|
+
return {
|
|
292
|
+
config: parsed
|
|
293
|
+
};
|
|
294
|
+
}
|
|
295
|
+
if (parsed && Object.keys(parsed).length > 0) {
|
|
296
|
+
return parsed;
|
|
297
|
+
}
|
|
298
|
+
return null;
|
|
299
|
+
} catch (e) {
|
|
300
|
+
return null;
|
|
301
|
+
}
|
|
302
|
+
}
|
|
303
|
+
},
|
|
304
|
+
{
|
|
305
|
+
key: "resolveConfig",
|
|
306
|
+
value: function resolveConfig(preElement, contextProps) {
|
|
307
|
+
var baseConfig = (preElement === null || preElement === void 0 ? void 0 : preElement.type) === 'code' && (preElement === null || preElement === void 0 ? void 0 : preElement.language) === 'html' && (preElement === null || preElement === void 0 ? void 0 : preElement.otherProps) ? preElement === null || preElement === void 0 ? void 0 : preElement.otherProps : {};
|
|
308
|
+
if (contextProps && Object.keys(contextProps).length > 0) {
|
|
309
|
+
return _object_spread({}, baseConfig, contextProps);
|
|
310
|
+
}
|
|
311
|
+
return baseConfig;
|
|
312
|
+
}
|
|
313
|
+
},
|
|
314
|
+
{
|
|
315
|
+
key: "parseWithPlugins",
|
|
316
|
+
value: function parseWithPlugins(currentElement) {
|
|
317
|
+
var _iteratorNormalCompletion = true, _didIteratorError = false, _iteratorError = undefined;
|
|
318
|
+
try {
|
|
319
|
+
for(var _iterator = this.plugins[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true){
|
|
320
|
+
var plugin = _step.value;
|
|
321
|
+
var _plugin_parseMarkdown;
|
|
322
|
+
var rule = (_plugin_parseMarkdown = plugin.parseMarkdown) === null || _plugin_parseMarkdown === void 0 ? void 0 : _plugin_parseMarkdown.find(function(r) {
|
|
323
|
+
return r.match(currentElement);
|
|
324
|
+
});
|
|
325
|
+
if (rule) {
|
|
326
|
+
var converted = rule.convert(currentElement);
|
|
327
|
+
if (Array.isArray(converted) && converted.length === 2) {
|
|
328
|
+
return {
|
|
329
|
+
handled: true,
|
|
330
|
+
el: converted[0]
|
|
331
|
+
};
|
|
332
|
+
}
|
|
333
|
+
return {
|
|
334
|
+
handled: true,
|
|
335
|
+
el: converted
|
|
336
|
+
};
|
|
337
|
+
}
|
|
338
|
+
}
|
|
339
|
+
} catch (err) {
|
|
340
|
+
_didIteratorError = true;
|
|
341
|
+
_iteratorError = err;
|
|
342
|
+
} finally{
|
|
343
|
+
try {
|
|
344
|
+
if (!_iteratorNormalCompletion && _iterator.return != null) {
|
|
345
|
+
_iterator.return();
|
|
346
|
+
}
|
|
347
|
+
} finally{
|
|
348
|
+
if (_didIteratorError) {
|
|
349
|
+
throw _iteratorError;
|
|
350
|
+
}
|
|
351
|
+
}
|
|
352
|
+
}
|
|
353
|
+
return {
|
|
354
|
+
handled: false,
|
|
355
|
+
el: null
|
|
356
|
+
};
|
|
357
|
+
}
|
|
358
|
+
},
|
|
359
|
+
{
|
|
360
|
+
/**
|
|
361
|
+
* 解析 Markdown 字符串并返回解析后的结构和链接信息
|
|
362
|
+
*
|
|
363
|
+
* @param md - 要解析的 Markdown 字符串
|
|
364
|
+
* @returns 一个包含解析后的元素数组和链接信息的对象
|
|
365
|
+
*/ key: "parse",
|
|
366
|
+
value: function parse(md) {
|
|
367
|
+
var markdownRoot = this.buildMarkdownRoot(md);
|
|
368
|
+
var schema = this.parseNodes(markdownRoot, true, undefined);
|
|
369
|
+
var filteredSchema = this.filterTopLevelSchema(schema);
|
|
251
370
|
return {
|
|
252
371
|
schema: filteredSchema,
|
|
253
372
|
links: []
|
|
@@ -261,139 +380,76 @@ var removeAnswerTags = function(text) {
|
|
|
261
380
|
* - 当有插件时,优先使用插件处理
|
|
262
381
|
* - 插件未处理时,使用默认处理逻辑
|
|
263
382
|
*/ function parseNodes(nodes) {
|
|
264
|
-
var
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
}
|
|
282
|
-
} catch (e) {
|
|
283
|
-
// 解析失败,不是 JSON 格式的注释,保持为空对象
|
|
383
|
+
var top = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : false, parent = arguments.length > 2 ? arguments[2] : void 0;
|
|
384
|
+
if (!(nodes === null || nodes === void 0 ? void 0 : nodes.length)) {
|
|
385
|
+
return [
|
|
386
|
+
this.createEmptyParagraph()
|
|
387
|
+
];
|
|
388
|
+
}
|
|
389
|
+
var els = [];
|
|
390
|
+
var context = this.createParseContext();
|
|
391
|
+
var _iteratorNormalCompletion = true, _didIteratorError = false, _iteratorError = undefined;
|
|
392
|
+
try {
|
|
393
|
+
for(var _iterator = nodes[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true){
|
|
394
|
+
var currentElement = _step.value;
|
|
395
|
+
var htmlCommentProps = this.parseHtmlCommentProps(currentElement);
|
|
396
|
+
if (htmlCommentProps) {
|
|
397
|
+
// 将注释属性存储到 contextProps 中,供下一个元素使用
|
|
398
|
+
context.contextProps = _object_spread({}, context.contextProps, htmlCommentProps);
|
|
399
|
+
continue;
|
|
284
400
|
}
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
// continue 后不会 push 任何 el,也不会执行 preNode=currentElement、preElement=el。
|
|
299
|
-
// 下一轮处理表格时,preElement 仍是「注释前」的节点(如 paragraph/heading),
|
|
300
|
-
// 不可能是 type='code' 且 language='html' 的节点,parseTableOrChart 里
|
|
301
|
-
// 从 preNode(实为 preElement)取 otherProps 会得到 {}。
|
|
302
|
-
// 因此图表配置必须通过 contextProps → config,由 table handler 以
|
|
303
|
-
// contextChartConfig 传入 parseTableOrChart。
|
|
304
|
-
return "continue";
|
|
305
|
-
}
|
|
306
|
-
// 如果当前元素应该使用 contextProps 中的属性作为 config(用于设置 otherProps)
|
|
307
|
-
// 这主要针对对齐注释等场景,需要同时设置 contextProps 和 otherProps
|
|
308
|
-
if (contextProps && Object.keys(contextProps).length > 0) {
|
|
309
|
-
config = _object_spread({}, config, contextProps);
|
|
310
|
-
}
|
|
311
|
-
var _iteratorNormalCompletion = true, _didIteratorError = false, _iteratorError = undefined;
|
|
312
|
-
try {
|
|
313
|
-
// 首先尝试使用插件处理,使用 this.plugins
|
|
314
|
-
for(var _iterator = _this.plugins[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true){
|
|
315
|
-
var plugin = _step.value;
|
|
316
|
-
var _plugin_parseMarkdown;
|
|
317
|
-
var rule = (_plugin_parseMarkdown = plugin.parseMarkdown) === null || _plugin_parseMarkdown === void 0 ? void 0 : _plugin_parseMarkdown.find(function(r) {
|
|
318
|
-
return r.match(currentElement);
|
|
401
|
+
var config = this.resolveConfig(context.preElement, context.contextProps);
|
|
402
|
+
var pluginResult = this.parseWithPlugins(currentElement);
|
|
403
|
+
var el = pluginResult.el;
|
|
404
|
+
if (Object.keys(config).length > 0) {
|
|
405
|
+
this.config = _object_spread({}, this.config, config);
|
|
406
|
+
}
|
|
407
|
+
if (!pluginResult.handled) {
|
|
408
|
+
var result = this.handleSingleElement({
|
|
409
|
+
currentElement: currentElement,
|
|
410
|
+
config: config,
|
|
411
|
+
parent: parent,
|
|
412
|
+
htmlTag: context.htmlTag,
|
|
413
|
+
preElement: context.preElement
|
|
319
414
|
});
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
if (Array.isArray(converted) && converted.length === 2) {
|
|
324
|
-
// NodeEntry<Text> 格式: [node, path]
|
|
325
|
-
el = converted[0];
|
|
326
|
-
} else {
|
|
327
|
-
// Elements 格式
|
|
328
|
-
el = converted;
|
|
329
|
-
}
|
|
330
|
-
pluginHandled = true;
|
|
331
|
-
break;
|
|
415
|
+
el = result.el;
|
|
416
|
+
if (result.contextProps) {
|
|
417
|
+
context.contextProps = _object_spread({}, context.contextProps, result.contextProps);
|
|
332
418
|
}
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
_iteratorError = err;
|
|
337
|
-
} finally{
|
|
338
|
-
try {
|
|
339
|
-
if (!_iteratorNormalCompletion && _iterator.return != null) {
|
|
340
|
-
_iterator.return();
|
|
419
|
+
// 更新 htmlTag 数组,以便后续节点可以使用
|
|
420
|
+
if (result.htmlTag) {
|
|
421
|
+
context.htmlTag = result.htmlTag;
|
|
341
422
|
}
|
|
342
|
-
}
|
|
343
|
-
|
|
344
|
-
|
|
423
|
+
}
|
|
424
|
+
els = addEmptyLinesIfNeeded(els, context.preNode, currentElement, top);
|
|
425
|
+
if (el) {
|
|
426
|
+
var appliedElement = applyContextPropsAndConfig(el, context.contextProps, config);
|
|
427
|
+
// 使用 if-else 而不是条件表达式,避免类型错误
|
|
428
|
+
if (Array.isArray(appliedElement)) {
|
|
429
|
+
els = _to_consumable_array(els).concat(_to_consumable_array(appliedElement));
|
|
430
|
+
} else {
|
|
431
|
+
els = _to_consumable_array(els).concat([
|
|
432
|
+
appliedElement
|
|
433
|
+
]);
|
|
345
434
|
}
|
|
346
435
|
}
|
|
436
|
+
context.preNode = currentElement;
|
|
437
|
+
context.preElement = el;
|
|
347
438
|
}
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
if (result.contextProps) {
|
|
356
|
-
contextProps = _object_spread({}, contextProps, result.contextProps);
|
|
357
|
-
}
|
|
358
|
-
// 更新 htmlTag 数组,以便后续节点可以使用
|
|
359
|
-
if (result.htmlTag) {
|
|
360
|
-
htmlTag = result.htmlTag;
|
|
439
|
+
} catch (err) {
|
|
440
|
+
_didIteratorError = true;
|
|
441
|
+
_iteratorError = err;
|
|
442
|
+
} finally{
|
|
443
|
+
try {
|
|
444
|
+
if (!_iteratorNormalCompletion && _iterator.return != null) {
|
|
445
|
+
_iterator.return();
|
|
361
446
|
}
|
|
362
|
-
}
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
el = applyContextPropsAndConfig(el, contextProps, config);
|
|
366
|
-
// 使用 if-else 而不是条件表达式,避免类型错误
|
|
367
|
-
if (Array.isArray(el)) {
|
|
368
|
-
els = _to_consumable_array(els).concat(_to_consumable_array(el));
|
|
369
|
-
} else {
|
|
370
|
-
els = _to_consumable_array(els).concat([
|
|
371
|
-
el
|
|
372
|
-
]);
|
|
447
|
+
} finally{
|
|
448
|
+
if (_didIteratorError) {
|
|
449
|
+
throw _iteratorError;
|
|
373
450
|
}
|
|
374
451
|
}
|
|
375
|
-
preNode = currentElement;
|
|
376
|
-
preElement = el;
|
|
377
|
-
};
|
|
378
|
-
var top = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : false, parent = arguments.length > 2 ? arguments[2] : void 0;
|
|
379
|
-
if (!(nodes === null || nodes === void 0 ? void 0 : nodes.length)) {
|
|
380
|
-
return [
|
|
381
|
-
{
|
|
382
|
-
type: 'paragraph',
|
|
383
|
-
children: [
|
|
384
|
-
{
|
|
385
|
-
text: ''
|
|
386
|
-
}
|
|
387
|
-
]
|
|
388
|
-
}
|
|
389
|
-
];
|
|
390
452
|
}
|
|
391
|
-
var els = [];
|
|
392
|
-
var preNode = null;
|
|
393
|
-
var preElement = null;
|
|
394
|
-
var htmlTag = [];
|
|
395
|
-
var contextProps = {};
|
|
396
|
-
for(var i = 0; i < nodes.length; i++)_this = this, _loop(i);
|
|
397
453
|
return els;
|
|
398
454
|
}
|
|
399
455
|
},
|
|
@@ -449,8 +505,8 @@ var removeAnswerTags = function(text) {
|
|
|
449
505
|
}
|
|
450
506
|
},
|
|
451
507
|
code: {
|
|
452
|
-
handler: function(el,
|
|
453
|
-
return handleCode(el, config);
|
|
508
|
+
handler: function(el, context) {
|
|
509
|
+
return handleCode(el, context.config);
|
|
454
510
|
}
|
|
455
511
|
},
|
|
456
512
|
yaml: {
|
|
@@ -489,15 +545,15 @@ var removeAnswerTags = function(text) {
|
|
|
489
545
|
}
|
|
490
546
|
},
|
|
491
547
|
paragraph: {
|
|
492
|
-
handler: function(el,
|
|
493
|
-
return handleParagraph(el, config, parseNodesFn);
|
|
548
|
+
handler: function(el, context) {
|
|
549
|
+
return handleParagraph(el, context.config, parseNodesFn);
|
|
494
550
|
}
|
|
495
551
|
},
|
|
496
552
|
table: {
|
|
497
553
|
// 传入 config:当上一条是图表注释且被 continue 掉时,config 来自 contextProps,
|
|
498
554
|
// 作为 contextChartConfig 供 parseTableOrChart 在 preNode 无 html 配置时使用
|
|
499
|
-
handler: function(el,
|
|
500
|
-
return parseTableOrChart(el, preElement || parent, _this.plugins, parseNodesForTable, _this.config, config);
|
|
555
|
+
handler: function(el, context) {
|
|
556
|
+
return parseTableOrChart(el, context.preElement || context.parent, _this.plugins, parseNodesForTable, _this.config, context.config);
|
|
501
557
|
}
|
|
502
558
|
}
|
|
503
559
|
};
|
|
@@ -505,8 +561,9 @@ var removeAnswerTags = function(text) {
|
|
|
505
561
|
},
|
|
506
562
|
{
|
|
507
563
|
key: "handleSingleElement",
|
|
508
|
-
value: function handleSingleElement(
|
|
564
|
+
value: function handleSingleElement(params) {
|
|
509
565
|
var _this = this;
|
|
566
|
+
var currentElement = params.currentElement, config = params.config, parent = params.parent, htmlTag = params.htmlTag, preElement = params.preElement;
|
|
510
567
|
var elementType = currentElement.type;
|
|
511
568
|
var elementHandlers = this.getElementHandlers();
|
|
512
569
|
var handlerInfo = elementHandlers[elementType];
|
|
@@ -534,7 +591,12 @@ var removeAnswerTags = function(text) {
|
|
|
534
591
|
}, this.config)
|
|
535
592
|
};
|
|
536
593
|
}
|
|
537
|
-
var handlerResult = handlerInfo.handler(currentElement,
|
|
594
|
+
var handlerResult = handlerInfo.handler(currentElement, {
|
|
595
|
+
config: config,
|
|
596
|
+
parent: parent,
|
|
597
|
+
htmlTag: htmlTag,
|
|
598
|
+
preElement: preElement
|
|
599
|
+
});
|
|
538
600
|
return {
|
|
539
601
|
el: handlerResult
|
|
540
602
|
};
|
|
@@ -170,6 +170,27 @@ export var MdElements = {
|
|
|
170
170
|
}
|
|
171
171
|
},
|
|
172
172
|
code: {
|
|
173
|
+
matchKey: ' ',
|
|
174
|
+
reg: /^\s*(```|···)([\w#\-+*]{1,30})?\s*$/,
|
|
175
|
+
run: function(param) {
|
|
176
|
+
var editor = param.editor, path = param.path, match = param.match;
|
|
177
|
+
var lang = match[2];
|
|
178
|
+
Transforms.delete(editor, {
|
|
179
|
+
at: path
|
|
180
|
+
});
|
|
181
|
+
Transforms.insertNodes(editor, {
|
|
182
|
+
type: 'code',
|
|
183
|
+
language: lang,
|
|
184
|
+
value: ''
|
|
185
|
+
}, {
|
|
186
|
+
at: path,
|
|
187
|
+
select: true
|
|
188
|
+
});
|
|
189
|
+
return true;
|
|
190
|
+
}
|
|
191
|
+
},
|
|
192
|
+
codeSpace: {
|
|
193
|
+
matchKey: ' ',
|
|
173
194
|
reg: /^\s*(```|···)([\w#\-+*]{1,30})?\s*$/,
|
|
174
195
|
run: function(param) {
|
|
175
196
|
var editor = param.editor, path = param.path, match = param.match;
|
|
@@ -362,7 +383,34 @@ export var MdElements = {
|
|
|
362
383
|
}
|
|
363
384
|
},
|
|
364
385
|
hr: {
|
|
365
|
-
|
|
386
|
+
matchKey: ' ',
|
|
387
|
+
reg: /^\s*(\*\*\*|___|---)\s*$/,
|
|
388
|
+
checkAllow: function(ctx) {
|
|
389
|
+
var _ctx_node_, _ctx_node;
|
|
390
|
+
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;
|
|
391
|
+
},
|
|
392
|
+
run: function(param) {
|
|
393
|
+
var editor = param.editor, path = param.path;
|
|
394
|
+
Transforms.delete(editor, {
|
|
395
|
+
at: path
|
|
396
|
+
});
|
|
397
|
+
Transforms.insertNodes(editor, {
|
|
398
|
+
type: 'hr',
|
|
399
|
+
children: [
|
|
400
|
+
{
|
|
401
|
+
text: ''
|
|
402
|
+
}
|
|
403
|
+
]
|
|
404
|
+
}, {
|
|
405
|
+
at: path
|
|
406
|
+
});
|
|
407
|
+
insertAfter(editor, path);
|
|
408
|
+
return true;
|
|
409
|
+
}
|
|
410
|
+
},
|
|
411
|
+
hrSpace: {
|
|
412
|
+
matchKey: ' ',
|
|
413
|
+
reg: /^\s*(\*\*\*|___|---)\s*/,
|
|
366
414
|
checkAllow: function(ctx) {
|
|
367
415
|
var _ctx_node_, _ctx_node;
|
|
368
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;
|
|
@@ -520,7 +568,10 @@ export var MdElements = {
|
|
|
520
568
|
}
|
|
521
569
|
};
|
|
522
570
|
export var BlockMathNodes = Object.entries(MdElements).filter(function(c) {
|
|
523
|
-
return !c[1].matchKey
|
|
571
|
+
return !c[1].matchKey || [
|
|
572
|
+
'code',
|
|
573
|
+
'hr'
|
|
574
|
+
].includes(c[0]);
|
|
524
575
|
}).map(function(c) {
|
|
525
576
|
return Object.assign(c[1], {
|
|
526
577
|
type: c[0]
|
|
@@ -115,9 +115,9 @@ export var MatchKey = /*#__PURE__*/ function() {
|
|
|
115
115
|
}), 1), node = _Editor_nodes[0];
|
|
116
116
|
if (!node || [
|
|
117
117
|
'code'
|
|
118
|
-
].includes(node === null || node === void 0 ? void 0 : (_node_ = node[0]) === null || _node_ === void 0 ? void 0 : _node_.type)) return;
|
|
118
|
+
].includes(node === null || node === void 0 ? void 0 : (_node_ = node[0]) === null || _node_ === void 0 ? void 0 : _node_.type)) return false;
|
|
119
119
|
var sel = this.editor.selection;
|
|
120
|
-
if (!sel || !Range.isCollapsed(sel)) return;
|
|
120
|
+
if (!sel || !Range.isCollapsed(sel)) return false;
|
|
121
121
|
var _iteratorNormalCompletion = true, _didIteratorError = false, _iteratorError = undefined;
|
|
122
122
|
try {
|
|
123
123
|
for(var _iterator = TextMatchNodes[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true){
|
|
@@ -133,7 +133,7 @@ export var MatchKey = /*#__PURE__*/ function() {
|
|
|
133
133
|
if (m) {
|
|
134
134
|
if (n.run(this.createParams(node, m))) {
|
|
135
135
|
e.preventDefault();
|
|
136
|
-
|
|
136
|
+
return true;
|
|
137
137
|
}
|
|
138
138
|
}
|
|
139
139
|
}
|
|
@@ -152,6 +152,7 @@ export var MatchKey = /*#__PURE__*/ function() {
|
|
|
152
152
|
}
|
|
153
153
|
}
|
|
154
154
|
}
|
|
155
|
+
return false;
|
|
155
156
|
}
|
|
156
157
|
}
|
|
157
158
|
]);
|
|
@@ -146,8 +146,7 @@ import { useEditorStore } from "../store";
|
|
|
146
146
|
e.preventDefault();
|
|
147
147
|
}
|
|
148
148
|
if (props === null || props === void 0 ? void 0 : (_props_markdown = props.markdown) === null || _props_markdown === void 0 ? void 0 : _props_markdown.matchInputToNode) {
|
|
149
|
-
match.run(e);
|
|
150
|
-
return;
|
|
149
|
+
if (match.run(e)) return;
|
|
151
150
|
}
|
|
152
151
|
if (e.key.toLowerCase().startsWith('arrow')) {
|
|
153
152
|
if ([
|
|
@@ -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;
|
|
@@ -266,7 +266,8 @@ import { useVoiceInputManager } from "./VoiceInputManager";
|
|
|
266
266
|
onSend: props.onSend,
|
|
267
267
|
allowEmptySubmit: props.allowEmptySubmit,
|
|
268
268
|
markdownProps: markdownProps,
|
|
269
|
-
attachment: props.attachment
|
|
269
|
+
attachment: props.attachment,
|
|
270
|
+
triggerSendKey: props.triggerSendKey
|
|
270
271
|
},
|
|
271
272
|
markdownEditorRef: markdownEditorRef,
|
|
272
273
|
inputRef: inputRef,
|
|
@@ -306,7 +307,8 @@ import { useVoiceInputManager } from "./VoiceInputManager";
|
|
|
306
307
|
allowEmptySubmit: props.allowEmptySubmit,
|
|
307
308
|
actionsRender: props.actionsRender,
|
|
308
309
|
toolsRender: props.toolsRender,
|
|
309
|
-
sendButtonProps: props.sendButtonProps
|
|
310
|
+
sendButtonProps: props.sendButtonProps,
|
|
311
|
+
triggerSendKey: props.triggerSendKey
|
|
310
312
|
},
|
|
311
313
|
fileMap: fileMap,
|
|
312
314
|
setFileMap: setFileMap,
|
|
@@ -65,7 +65,7 @@ import { VoiceInputButton } from "../VoiceInput";
|
|
|
65
65
|
*
|
|
66
66
|
* @description 封装发送操作相关的按钮,包括附件上传、语音输入、发送按钮等
|
|
67
67
|
*/ export var SendActions = function(param) {
|
|
68
|
-
var attachment = param.attachment, voiceRecognizer = param.voiceRecognizer, value = param.value, disabled = param.disabled, typing = param.typing, isLoading = param.isLoading, _param_fileUploadDone = param.fileUploadDone, fileUploadDone = _param_fileUploadDone === void 0 ? true : _param_fileUploadDone, _param_recording = param.recording, recording = _param_recording === void 0 ? false : _param_recording, _param_collapseSendActions = param.collapseSendActions, collapseSendActions = _param_collapseSendActions === void 0 ? false : _param_collapseSendActions, _param_allowEmptySubmit = param.allowEmptySubmit, allowEmptySubmit = _param_allowEmptySubmit === void 0 ? false : _param_allowEmptySubmit, uploadImage = param.uploadImage, onStartRecording = param.onStartRecording, onStopRecording = param.onStopRecording, onSend = param.onSend, onStop = param.onStop, actionsRender = param.actionsRender, _param_prefixCls = param.prefixCls, prefixCls = _param_prefixCls === void 0 ? 'ant-agentic-md-input-field' : _param_prefixCls, _param_hashId = param.hashId, hashId = _param_hashId === void 0 ? '' : _param_hashId, _param_hasTools = param.hasTools, hasTools = _param_hasTools === void 0 ? false : _param_hasTools, onResize = param.onResize, sendButtonProps = param.sendButtonProps;
|
|
68
|
+
var attachment = param.attachment, voiceRecognizer = param.voiceRecognizer, value = param.value, disabled = param.disabled, typing = param.typing, isLoading = param.isLoading, _param_fileUploadDone = param.fileUploadDone, fileUploadDone = _param_fileUploadDone === void 0 ? true : _param_fileUploadDone, _param_recording = param.recording, recording = _param_recording === void 0 ? false : _param_recording, _param_collapseSendActions = param.collapseSendActions, collapseSendActions = _param_collapseSendActions === void 0 ? false : _param_collapseSendActions, _param_allowEmptySubmit = param.allowEmptySubmit, allowEmptySubmit = _param_allowEmptySubmit === void 0 ? false : _param_allowEmptySubmit, uploadImage = param.uploadImage, onStartRecording = param.onStartRecording, onStopRecording = param.onStopRecording, onSend = param.onSend, onStop = param.onStop, actionsRender = param.actionsRender, _param_prefixCls = param.prefixCls, prefixCls = _param_prefixCls === void 0 ? 'ant-agentic-md-input-field' : _param_prefixCls, _param_hashId = param.hashId, hashId = _param_hashId === void 0 ? '' : _param_hashId, _param_hasTools = param.hasTools, hasTools = _param_hasTools === void 0 ? false : _param_hasTools, onResize = param.onResize, sendButtonProps = param.sendButtonProps, triggerSendKey = param.triggerSendKey;
|
|
69
69
|
var fileMap = attachment === null || attachment === void 0 ? void 0 : attachment.fileMap;
|
|
70
70
|
var defaultActionsLen = [
|
|
71
71
|
(attachment === null || attachment === void 0 ? void 0 : attachment.enable) ? '()' : null,
|
|
@@ -114,7 +114,8 @@ import { VoiceInputButton } from "../VoiceInput";
|
|
|
114
114
|
return;
|
|
115
115
|
}
|
|
116
116
|
onSend === null || onSend === void 0 ? void 0 : onSend();
|
|
117
|
-
}
|
|
117
|
+
},
|
|
118
|
+
triggerSendKey: triggerSendKey
|
|
118
119
|
}, sendButtonProps))
|
|
119
120
|
].filter(Boolean);
|
|
120
121
|
}, [
|
|
@@ -134,7 +135,8 @@ import { VoiceInputButton } from "../VoiceInput";
|
|
|
134
135
|
onSend,
|
|
135
136
|
onStop,
|
|
136
137
|
fileMap,
|
|
137
|
-
sendButtonProps
|
|
138
|
+
sendButtonProps,
|
|
139
|
+
triggerSendKey
|
|
138
140
|
]);
|
|
139
141
|
var actionsList = actionsRender ? actionsRender({
|
|
140
142
|
attachment: attachment,
|