@ant-design/agentic-ui 2.29.53 → 2.29.55
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/Hooks/useElementSize.js +0 -1
- package/dist/MarkdownEditor/editor/elements/Blockquote/ReadonlyBlockquote.d.ts +2 -1
- package/dist/MarkdownEditor/editor/elements/Blockquote/ReadonlyBlockquote.js +39 -1
- package/dist/MarkdownEditor/editor/elements/Blockquote/index.d.ts +2 -2
- package/dist/MarkdownEditor/editor/elements/Blockquote/index.js +26 -7
- package/dist/MarkdownEditor/editor/parser/parse/parseBlockElements.d.ts +10 -0
- package/dist/MarkdownEditor/editor/parser/parse/parseBlockElements.js +48 -0
- package/dist/MarkdownEditor/editor/parser/parserMarkdownToSlateNode.js +25 -1
- package/dist/MarkdownEditor/editor/parser/parserSlateNodeToMarkdown.js +13 -0
- package/dist/MarkdownEditor/editor/parser/remarkContainer.d.ts +20 -0
- package/dist/MarkdownEditor/editor/parser/remarkContainer.js +183 -0
- package/dist/MarkdownEditor/editor/parser/remarkDirectiveContainer.d.ts +23 -0
- package/dist/MarkdownEditor/editor/parser/remarkDirectiveContainer.js +111 -0
- package/dist/MarkdownEditor/editor/parser/remarkParse.js +2 -0
- package/dist/MarkdownEditor/editor/style.js +32 -0
- package/dist/MarkdownEditor/editor/utils/markdownToHtml.js +26 -4
- package/dist/MarkdownEditor/utils/exportHtml.js +1 -1
- package/dist/MarkdownInputField/AttachmentButton/AttachmentFileList/index.d.ts +2 -0
- package/dist/MarkdownInputField/AttachmentButton/AttachmentFileList/index.js +3 -2
- package/dist/MarkdownInputField/MarkdownInputField.js +21 -13
- package/dist/MarkdownInputField/QuickActions/index.js +3 -1
- package/dist/MarkdownInputField/SendActions/index.js +5 -2
- package/dist/MarkdownInputField/hooks/useMarkdownInputFieldStyles.d.ts +2 -2
- package/dist/MarkdownInputField/hooks/useMarkdownInputFieldStyles.js +3 -3
- package/dist/MarkdownInputField/testIds.d.ts +28 -0
- package/dist/MarkdownInputField/testIds.js +16 -0
- package/dist/MarkdownInputField/types/MarkdownInputFieldProps.d.ts +5 -0
- package/dist/MarkdownInputField/utils/renderHelpers.js +3 -1
- package/dist/index.d.ts +1 -0
- package/dist/index.js +1 -0
- package/package.json +5 -1
|
@@ -54,7 +54,6 @@ export var useElementSize = function useElementSize(element) {
|
|
|
54
54
|
if (!element.current) return;
|
|
55
55
|
var resizeObserver = new ResizeObserver(function(entries) {
|
|
56
56
|
var entry = entries[0];
|
|
57
|
-
console.log(entry);
|
|
58
57
|
setSize({
|
|
59
58
|
width: entry.borderBoxSize[0].inlineSize,
|
|
60
59
|
height: entry.borderBoxSize[0].blockSize
|
|
@@ -4,7 +4,7 @@ import { BlockQuoteNode, ElementProps } from '../../../el';
|
|
|
4
4
|
* ReadonlyBlockquote 组件 - 只读引用块预览组件
|
|
5
5
|
*
|
|
6
6
|
* 专门针对 readonly 模式优化的引用块组件,移除了拖拽功能。
|
|
7
|
-
*
|
|
7
|
+
* 当 otherProps 含 markdownContainerType 时渲染为 div.markdown-container(提示块)。
|
|
8
8
|
*
|
|
9
9
|
* @component
|
|
10
10
|
* @description 只读引用块预览组件,用于预览模式下的引用块渲染
|
|
@@ -29,5 +29,6 @@ import { BlockQuoteNode, ElementProps } from '../../../el';
|
|
|
29
29
|
* - 移除拖拽相关事件处理
|
|
30
30
|
* - 使用 React.memo 优化性能
|
|
31
31
|
* - 保持预览模式的视觉效果
|
|
32
|
+
* - 支持 ::: 提示块(info/warning/success/error/tip)渲染为 markdown-container
|
|
32
33
|
*/
|
|
33
34
|
export declare const ReadonlyBlockquote: React.FC<ElementProps<BlockQuoteNode>>;
|
|
@@ -26,12 +26,37 @@ function _object_spread(target) {
|
|
|
26
26
|
}
|
|
27
27
|
return target;
|
|
28
28
|
}
|
|
29
|
+
function ownKeys(object, enumerableOnly) {
|
|
30
|
+
var keys = Object.keys(object);
|
|
31
|
+
if (Object.getOwnPropertySymbols) {
|
|
32
|
+
var symbols = Object.getOwnPropertySymbols(object);
|
|
33
|
+
if (enumerableOnly) {
|
|
34
|
+
symbols = symbols.filter(function(sym) {
|
|
35
|
+
return Object.getOwnPropertyDescriptor(object, sym).enumerable;
|
|
36
|
+
});
|
|
37
|
+
}
|
|
38
|
+
keys.push.apply(keys, symbols);
|
|
39
|
+
}
|
|
40
|
+
return keys;
|
|
41
|
+
}
|
|
42
|
+
function _object_spread_props(target, source) {
|
|
43
|
+
source = source != null ? source : {};
|
|
44
|
+
if (Object.getOwnPropertyDescriptors) {
|
|
45
|
+
Object.defineProperties(target, Object.getOwnPropertyDescriptors(source));
|
|
46
|
+
} else {
|
|
47
|
+
ownKeys(Object(source)).forEach(function(key) {
|
|
48
|
+
Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key));
|
|
49
|
+
});
|
|
50
|
+
}
|
|
51
|
+
return target;
|
|
52
|
+
}
|
|
53
|
+
import clsx from "clsx";
|
|
29
54
|
import React from "react";
|
|
30
55
|
/**
|
|
31
56
|
* ReadonlyBlockquote 组件 - 只读引用块预览组件
|
|
32
57
|
*
|
|
33
58
|
* 专门针对 readonly 模式优化的引用块组件,移除了拖拽功能。
|
|
34
|
-
*
|
|
59
|
+
* 当 otherProps 含 markdownContainerType 时渲染为 div.markdown-container(提示块)。
|
|
35
60
|
*
|
|
36
61
|
* @component
|
|
37
62
|
* @description 只读引用块预览组件,用于预览模式下的引用块渲染
|
|
@@ -56,7 +81,20 @@ import React from "react";
|
|
|
56
81
|
* - 移除拖拽相关事件处理
|
|
57
82
|
* - 使用 React.memo 优化性能
|
|
58
83
|
* - 保持预览模式的视觉效果
|
|
84
|
+
* - 支持 ::: 提示块(info/warning/success/error/tip)渲染为 markdown-container
|
|
59
85
|
*/ export var ReadonlyBlockquote = /*#__PURE__*/ React.memo(function(props) {
|
|
86
|
+
var _props_element_otherProps, _props_element, _props_element_otherProps1, _props_element1;
|
|
87
|
+
var containerType = (_props_element = props.element) === null || _props_element === void 0 ? void 0 : (_props_element_otherProps = _props_element.otherProps) === null || _props_element_otherProps === void 0 ? void 0 : _props_element_otherProps.markdownContainerType;
|
|
88
|
+
var containerTitle = (_props_element1 = props.element) === null || _props_element1 === void 0 ? void 0 : (_props_element_otherProps1 = _props_element1.otherProps) === null || _props_element_otherProps1 === void 0 ? void 0 : _props_element_otherProps1.markdownContainerTitle;
|
|
89
|
+
if (containerType) {
|
|
90
|
+
var _props_attributes;
|
|
91
|
+
return /*#__PURE__*/ React.createElement("div", _object_spread_props(_object_spread({}, props.attributes), {
|
|
92
|
+
"data-be": "blockquote",
|
|
93
|
+
className: clsx('markdown-container', containerType, (_props_attributes = props.attributes) === null || _props_attributes === void 0 ? void 0 : _props_attributes.className)
|
|
94
|
+
}), containerTitle ? /*#__PURE__*/ React.createElement("div", {
|
|
95
|
+
className: "markdown-container__title"
|
|
96
|
+
}, containerTitle) : null, props.children);
|
|
97
|
+
}
|
|
60
98
|
return /*#__PURE__*/ React.createElement("blockquote", _object_spread({
|
|
61
99
|
"data-be": 'blockquote'
|
|
62
100
|
}, props.attributes), props.children);
|
|
@@ -4,7 +4,7 @@ import { BlockQuoteNode, ElementProps } from '../../../el';
|
|
|
4
4
|
* Blockquote 组件 - 引用块组件
|
|
5
5
|
*
|
|
6
6
|
* 该组件用于渲染 Markdown 编辑器中的引用块元素。
|
|
7
|
-
*
|
|
7
|
+
* 当 otherProps 含 markdownContainerType 时渲染为 div.markdown-container(提示块)。
|
|
8
8
|
*
|
|
9
9
|
* @component
|
|
10
10
|
* @description 引用块组件,渲染引用内容
|
|
@@ -26,7 +26,7 @@ import { BlockQuoteNode, ElementProps } from '../../../el';
|
|
|
26
26
|
* @returns {React.ReactElement} 渲染的引用块组件
|
|
27
27
|
*
|
|
28
28
|
* @remarks
|
|
29
|
-
* - 使用 HTML blockquote
|
|
29
|
+
* - 使用 HTML blockquote 元素,提示块时为 div.markdown-container
|
|
30
30
|
* - 支持拖拽功能
|
|
31
31
|
* - 集成编辑器状态管理
|
|
32
32
|
* - 使用 memo 优化性能
|
|
@@ -50,13 +50,14 @@ function _object_spread_props(target, source) {
|
|
|
50
50
|
}
|
|
51
51
|
return target;
|
|
52
52
|
}
|
|
53
|
+
import clsx from "clsx";
|
|
53
54
|
import React from "react";
|
|
54
55
|
import { useEditorStore } from "../../store";
|
|
55
56
|
/**
|
|
56
57
|
* Blockquote 组件 - 引用块组件
|
|
57
58
|
*
|
|
58
59
|
* 该组件用于渲染 Markdown 编辑器中的引用块元素。
|
|
59
|
-
*
|
|
60
|
+
* 当 otherProps 含 markdownContainerType 时渲染为 div.markdown-container(提示块)。
|
|
60
61
|
*
|
|
61
62
|
* @component
|
|
62
63
|
* @description 引用块组件,渲染引用内容
|
|
@@ -78,22 +79,40 @@ import { useEditorStore } from "../../store";
|
|
|
78
79
|
* @returns {React.ReactElement} 渲染的引用块组件
|
|
79
80
|
*
|
|
80
81
|
* @remarks
|
|
81
|
-
* - 使用 HTML blockquote
|
|
82
|
+
* - 使用 HTML blockquote 元素,提示块时为 div.markdown-container
|
|
82
83
|
* - 支持拖拽功能
|
|
83
84
|
* - 集成编辑器状态管理
|
|
84
85
|
* - 使用 memo 优化性能
|
|
85
86
|
* - 提供 data-be 属性用于标识
|
|
86
87
|
*/ export function Blockquote(props) {
|
|
88
|
+
var _props_element_otherProps, _props_element, _props_element_otherProps1, _props_element1;
|
|
87
89
|
var _useEditorStore = useEditorStore(), store = _useEditorStore.store, markdownContainerRef = _useEditorStore.markdownContainerRef;
|
|
90
|
+
var containerType = (_props_element = props.element) === null || _props_element === void 0 ? void 0 : (_props_element_otherProps = _props_element.otherProps) === null || _props_element_otherProps === void 0 ? void 0 : _props_element_otherProps.markdownContainerType;
|
|
91
|
+
var containerTitle = (_props_element1 = props.element) === null || _props_element1 === void 0 ? void 0 : (_props_element_otherProps1 = _props_element1.otherProps) === null || _props_element_otherProps1 === void 0 ? void 0 : _props_element_otherProps1.markdownContainerTitle;
|
|
88
92
|
return React.useMemo(function() {
|
|
89
|
-
|
|
90
|
-
"data-be": 'blockquote'
|
|
91
|
-
}, props.attributes), {
|
|
93
|
+
var commonAttrs = _object_spread_props(_object_spread({}, props.attributes), {
|
|
92
94
|
onDragStart: function onDragStart(e) {
|
|
93
95
|
store.dragStart(e, markdownContainerRef.current);
|
|
94
96
|
}
|
|
95
|
-
})
|
|
97
|
+
});
|
|
98
|
+
if (containerType) {
|
|
99
|
+
var _props_attributes;
|
|
100
|
+
return /*#__PURE__*/ React.createElement("div", _object_spread_props(_object_spread({}, commonAttrs), {
|
|
101
|
+
"data-be": "blockquote",
|
|
102
|
+
"data-testid": "markdown-container",
|
|
103
|
+
className: clsx('markdown-container', containerType, (_props_attributes = props.attributes) === null || _props_attributes === void 0 ? void 0 : _props_attributes.className)
|
|
104
|
+
}), containerTitle ? /*#__PURE__*/ React.createElement("div", {
|
|
105
|
+
className: "markdown-container__title",
|
|
106
|
+
"data-testid": "markdown-container-title"
|
|
107
|
+
}, containerTitle) : null, props.children);
|
|
108
|
+
}
|
|
109
|
+
return /*#__PURE__*/ React.createElement("blockquote", _object_spread({
|
|
110
|
+
"data-be": "blockquote",
|
|
111
|
+
"data-testid": "blockquote"
|
|
112
|
+
}, commonAttrs), props.children);
|
|
96
113
|
}, [
|
|
97
|
-
props.element.children
|
|
114
|
+
props.element.children,
|
|
115
|
+
containerType,
|
|
116
|
+
containerTitle
|
|
98
117
|
]);
|
|
99
118
|
}
|
|
@@ -56,6 +56,16 @@ export declare const handleBlockquote: (currentElement: any, parseNodes: ParseNo
|
|
|
56
56
|
type: string;
|
|
57
57
|
children: any[];
|
|
58
58
|
};
|
|
59
|
+
/**
|
|
60
|
+
* 处理 remark-directive 的 containerDirective(:::info / :::tip{title="提示"} 等)
|
|
61
|
+
* 转为 blockquote 并写入 otherProps,供只读渲染为 div.markdown-container。
|
|
62
|
+
* 过滤掉被误解析为内容的闭合标记段落(仅含 ::: 的段落)。
|
|
63
|
+
*/
|
|
64
|
+
export declare const handleContainerDirective: (currentElement: any, parseNodes: ParseNodesFn) => {
|
|
65
|
+
type: string;
|
|
66
|
+
otherProps: Record<string, unknown>;
|
|
67
|
+
children: any[];
|
|
68
|
+
};
|
|
59
69
|
/**
|
|
60
70
|
* 应用内联格式到叶子节点
|
|
61
71
|
*/
|
|
@@ -317,6 +317,54 @@ import { handleTextAndInlineElementsPure, setFinishedProp } from "./parseText";
|
|
|
317
317
|
});
|
|
318
318
|
return result;
|
|
319
319
|
};
|
|
320
|
+
/** 从 mdast 段落等节点提取纯文本(用于识别闭合标记 :::) */ function getNodeText(node) {
|
|
321
|
+
if (!node) return '';
|
|
322
|
+
if (node.type === 'text' && node.value !== null && node.value !== undefined) return String(node.value);
|
|
323
|
+
if (Array.isArray(node.children)) {
|
|
324
|
+
return node.children.map(function(c) {
|
|
325
|
+
return getNodeText(c);
|
|
326
|
+
}).join('');
|
|
327
|
+
}
|
|
328
|
+
return '';
|
|
329
|
+
}
|
|
330
|
+
/**
|
|
331
|
+
* 处理 remark-directive 的 containerDirective(:::info / :::tip{title="提示"} 等)
|
|
332
|
+
* 转为 blockquote 并写入 otherProps,供只读渲染为 div.markdown-container。
|
|
333
|
+
* 过滤掉被误解析为内容的闭合标记段落(仅含 ::: 的段落)。
|
|
334
|
+
*/ export var handleContainerDirective = function handleContainerDirective(currentElement, parseNodes) {
|
|
335
|
+
var _currentElement_name, _currentElement_attributes, _currentElement_children;
|
|
336
|
+
var name = ((_currentElement_name = currentElement.name) !== null && _currentElement_name !== void 0 ? _currentElement_name : 'note').toLowerCase();
|
|
337
|
+
var attrs = (_currentElement_attributes = currentElement.attributes) !== null && _currentElement_attributes !== void 0 ? _currentElement_attributes : {};
|
|
338
|
+
var title = typeof attrs.title === 'string' ? attrs.title : attrs.title !== null && attrs.title !== undefined ? String(attrs.title) : undefined;
|
|
339
|
+
var otherProps = {
|
|
340
|
+
markdownContainerType: name
|
|
341
|
+
};
|
|
342
|
+
if (title === null || title === void 0 ? void 0 : title.trim()) {
|
|
343
|
+
otherProps.markdownContainerTitle = title.trim();
|
|
344
|
+
}
|
|
345
|
+
var rawChildren = (_currentElement_children = currentElement.children) !== null && _currentElement_children !== void 0 ? _currentElement_children : [];
|
|
346
|
+
var filteredChildren = rawChildren.filter(function(node) {
|
|
347
|
+
if (node.type === 'paragraph') {
|
|
348
|
+
var text = getNodeText(node).trim();
|
|
349
|
+
if (text === ':::') return false;
|
|
350
|
+
}
|
|
351
|
+
return true;
|
|
352
|
+
});
|
|
353
|
+
return {
|
|
354
|
+
type: 'blockquote',
|
|
355
|
+
otherProps: otherProps,
|
|
356
|
+
children: filteredChildren.length > 0 ? parseNodes(filteredChildren, false, currentElement) : [
|
|
357
|
+
{
|
|
358
|
+
type: 'paragraph',
|
|
359
|
+
children: [
|
|
360
|
+
{
|
|
361
|
+
text: ''
|
|
362
|
+
}
|
|
363
|
+
]
|
|
364
|
+
}
|
|
365
|
+
]
|
|
366
|
+
};
|
|
367
|
+
};
|
|
320
368
|
/**
|
|
321
369
|
* 应用内联格式到叶子节点
|
|
322
370
|
*/ export var applyInlineFormatting = function applyInlineFormatting(leaf, currentElement, config) {
|
|
@@ -86,6 +86,10 @@ function _object_spread_props(target, source) {
|
|
|
86
86
|
function _to_consumable_array(arr) {
|
|
87
87
|
return _array_without_holes(arr) || _iterable_to_array(arr) || _unsupported_iterable_to_array(arr) || _non_iterable_spread();
|
|
88
88
|
}
|
|
89
|
+
function _type_of(obj) {
|
|
90
|
+
"@swc/helpers - typeof";
|
|
91
|
+
return obj && typeof Symbol !== "undefined" && obj.constructor === Symbol ? "symbol" : typeof obj;
|
|
92
|
+
}
|
|
89
93
|
function _unsupported_iterable_to_array(o, minLen) {
|
|
90
94
|
if (!o) return;
|
|
91
95
|
if (typeof o === "string") return _array_like_to_array(o, minLen);
|
|
@@ -95,7 +99,7 @@ function _unsupported_iterable_to_array(o, minLen) {
|
|
|
95
99
|
if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _array_like_to_array(o, minLen);
|
|
96
100
|
}
|
|
97
101
|
import { applyContextPropsAndConfig } from "./parse/applyContextPropsAndConfig";
|
|
98
|
-
import { handleBlockquote, handleFootnoteDefinition, handleHeading, handleList, handleListItem, handleParagraph, handleTextAndInlineElements } from "./parse/parseBlockElements";
|
|
102
|
+
import { handleBlockquote, handleContainerDirective, handleFootnoteDefinition, handleHeading, handleList, handleListItem, handleParagraph, handleTextAndInlineElements } from "./parse/parseBlockElements";
|
|
99
103
|
import { handleCode, handleYaml } from "./parse/parseCode";
|
|
100
104
|
import { handleDefinition, handleInlineCode, handleThematicBreak } from "./parse/parseElements";
|
|
101
105
|
import { addEmptyLinesIfNeeded } from "./parse/parseEmptyLines";
|
|
@@ -112,6 +116,17 @@ var parseCache = new Map();
|
|
|
112
116
|
*/ export var clearParseCache = function clearParseCache() {
|
|
113
117
|
parseCache.clear();
|
|
114
118
|
};
|
|
119
|
+
/** 从 mdast 节点提取纯文本(用于识别仅含 ::: 的闭合标记段落) */ function getMdastNodeText(node) {
|
|
120
|
+
if (!node || (typeof node === "undefined" ? "undefined" : _type_of(node)) !== 'object') return '';
|
|
121
|
+
var n = node;
|
|
122
|
+
if (n.type === 'text' && n.value !== undefined && n.value !== null) return String(n.value);
|
|
123
|
+
if (Array.isArray(n.children)) {
|
|
124
|
+
return n.children.map(function(c) {
|
|
125
|
+
return getMdastNodeText(c);
|
|
126
|
+
}).join('');
|
|
127
|
+
}
|
|
128
|
+
return '';
|
|
129
|
+
}
|
|
115
130
|
/**
|
|
116
131
|
* 生成简单的字符串哈希
|
|
117
132
|
*/ export var simpleHash = function simpleHash(str) {
|
|
@@ -392,6 +407,10 @@ var removeAnswerTags = function removeAnswerTags(text) {
|
|
|
392
407
|
try {
|
|
393
408
|
for(var _iterator = nodes[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true){
|
|
394
409
|
var currentElement = _step.value;
|
|
410
|
+
// 根级仅含 ::: 的段落为 remark-directive 闭合标记,不渲染
|
|
411
|
+
if (top && currentElement.type === 'paragraph' && getMdastNodeText(currentElement).trim() === ':::') {
|
|
412
|
+
continue;
|
|
413
|
+
}
|
|
395
414
|
var htmlCommentProps = this.parseHtmlCommentProps(currentElement);
|
|
396
415
|
if (htmlCommentProps) {
|
|
397
416
|
// 将注释属性存储到 contextProps 中,供下一个元素使用
|
|
@@ -539,6 +558,11 @@ var removeAnswerTags = function removeAnswerTags(text) {
|
|
|
539
558
|
return handleBlockquote(el, parseNodesFn);
|
|
540
559
|
}
|
|
541
560
|
},
|
|
561
|
+
containerDirective: {
|
|
562
|
+
handler: function handler(el) {
|
|
563
|
+
return handleContainerDirective(el, parseNodesFn);
|
|
564
|
+
}
|
|
565
|
+
},
|
|
542
566
|
footnoteDefinition: {
|
|
543
567
|
handler: function handler(el) {
|
|
544
568
|
return handleFootnoteDefinition(el, parseNodesFn);
|
|
@@ -1192,6 +1192,19 @@ export var isMix = function isMix(t) {
|
|
|
1192
1192
|
* @param plugins - 可选的插件数组
|
|
1193
1193
|
* @returns 处理后的 Markdown 引用字符串
|
|
1194
1194
|
*/ var handleBlockquote = function handleBlockquote(node, preString, parent, plugins) {
|
|
1195
|
+
var _node_otherProps, _node_otherProps1;
|
|
1196
|
+
var containerType = (_node_otherProps = node.otherProps) === null || _node_otherProps === void 0 ? void 0 : _node_otherProps.markdownContainerType;
|
|
1197
|
+
var containerTitle = (_node_otherProps1 = node.otherProps) === null || _node_otherProps1 === void 0 ? void 0 : _node_otherProps1.markdownContainerTitle;
|
|
1198
|
+
if (containerType) {
|
|
1199
|
+
var _node_children;
|
|
1200
|
+
var innerContent = ((_node_children = node.children) === null || _node_children === void 0 ? void 0 : _node_children.length) > 0 ? node.children.map(function(child) {
|
|
1201
|
+
return parserNode(child, '', _to_consumable_array(parent).concat([
|
|
1202
|
+
node
|
|
1203
|
+
]), plugins);
|
|
1204
|
+
}).join('\n\n').trim() : '';
|
|
1205
|
+
var open = containerTitle !== null && containerTitle !== undefined && String(containerTitle).trim() ? ":::".concat(containerType, '{title="').concat(String(containerTitle).trim(), '"}') : ":::".concat(containerType);
|
|
1206
|
+
return "".concat(open, "\n\n").concat(innerContent || '', "\n\n:::");
|
|
1207
|
+
}
|
|
1195
1208
|
// Handle empty blockquotes
|
|
1196
1209
|
if (!node.children || node.children.length === 0) {
|
|
1197
1210
|
return '> ';
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* remark 插件:支持 ::: type [title] 容器语法(兼容 markdown-it-container)
|
|
3
|
+
*
|
|
4
|
+
* 语法示例:
|
|
5
|
+
* :::info
|
|
6
|
+
* 这是信息提示块。
|
|
7
|
+
* :::
|
|
8
|
+
*
|
|
9
|
+
* ::: warning 警告标题
|
|
10
|
+
* 这是带标题的警告块。
|
|
11
|
+
* :::
|
|
12
|
+
*/
|
|
13
|
+
import type { Plugin } from 'unified';
|
|
14
|
+
interface RemarkContainerOptions {
|
|
15
|
+
className?: string;
|
|
16
|
+
containerTag?: string;
|
|
17
|
+
titleElement?: Record<string, unknown> | null;
|
|
18
|
+
}
|
|
19
|
+
export declare const remarkContainer: Plugin<[RemarkContainerOptions?]>;
|
|
20
|
+
export default remarkContainer;
|
|
@@ -0,0 +1,183 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* remark 插件:支持 ::: type [title] 容器语法(兼容 markdown-it-container)
|
|
3
|
+
*
|
|
4
|
+
* 语法示例:
|
|
5
|
+
* :::info
|
|
6
|
+
* 这是信息提示块。
|
|
7
|
+
* :::
|
|
8
|
+
*
|
|
9
|
+
* ::: warning 警告标题
|
|
10
|
+
* 这是带标题的警告块。
|
|
11
|
+
* :::
|
|
12
|
+
*/ function _array_like_to_array(arr, len) {
|
|
13
|
+
if (len == null || len > arr.length) len = arr.length;
|
|
14
|
+
for(var i = 0, arr2 = new Array(len); i < len; i++)arr2[i] = arr[i];
|
|
15
|
+
return arr2;
|
|
16
|
+
}
|
|
17
|
+
function _array_with_holes(arr) {
|
|
18
|
+
if (Array.isArray(arr)) return arr;
|
|
19
|
+
}
|
|
20
|
+
function _define_property(obj, key, value) {
|
|
21
|
+
if (key in obj) {
|
|
22
|
+
Object.defineProperty(obj, key, {
|
|
23
|
+
value: value,
|
|
24
|
+
enumerable: true,
|
|
25
|
+
configurable: true,
|
|
26
|
+
writable: true
|
|
27
|
+
});
|
|
28
|
+
} else {
|
|
29
|
+
obj[key] = value;
|
|
30
|
+
}
|
|
31
|
+
return obj;
|
|
32
|
+
}
|
|
33
|
+
function _iterable_to_array_limit(arr, i) {
|
|
34
|
+
var _i = arr == null ? null : typeof Symbol !== "undefined" && arr[Symbol.iterator] || arr["@@iterator"];
|
|
35
|
+
if (_i == null) return;
|
|
36
|
+
var _arr = [];
|
|
37
|
+
var _n = true;
|
|
38
|
+
var _d = false;
|
|
39
|
+
var _s, _e;
|
|
40
|
+
try {
|
|
41
|
+
for(_i = _i.call(arr); !(_n = (_s = _i.next()).done); _n = true){
|
|
42
|
+
_arr.push(_s.value);
|
|
43
|
+
if (i && _arr.length === i) break;
|
|
44
|
+
}
|
|
45
|
+
} catch (err) {
|
|
46
|
+
_d = true;
|
|
47
|
+
_e = err;
|
|
48
|
+
} finally{
|
|
49
|
+
try {
|
|
50
|
+
if (!_n && _i["return"] != null) _i["return"]();
|
|
51
|
+
} finally{
|
|
52
|
+
if (_d) throw _e;
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
return _arr;
|
|
56
|
+
}
|
|
57
|
+
function _non_iterable_rest() {
|
|
58
|
+
throw new TypeError("Invalid attempt to destructure non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
|
|
59
|
+
}
|
|
60
|
+
function _object_spread(target) {
|
|
61
|
+
for(var i = 1; i < arguments.length; i++){
|
|
62
|
+
var source = arguments[i] != null ? arguments[i] : {};
|
|
63
|
+
var ownKeys = Object.keys(source);
|
|
64
|
+
if (typeof Object.getOwnPropertySymbols === "function") {
|
|
65
|
+
ownKeys = ownKeys.concat(Object.getOwnPropertySymbols(source).filter(function(sym) {
|
|
66
|
+
return Object.getOwnPropertyDescriptor(source, sym).enumerable;
|
|
67
|
+
}));
|
|
68
|
+
}
|
|
69
|
+
ownKeys.forEach(function(key) {
|
|
70
|
+
_define_property(target, key, source[key]);
|
|
71
|
+
});
|
|
72
|
+
}
|
|
73
|
+
return target;
|
|
74
|
+
}
|
|
75
|
+
function _sliced_to_array(arr, i) {
|
|
76
|
+
return _array_with_holes(arr) || _iterable_to_array_limit(arr, i) || _unsupported_iterable_to_array(arr, i) || _non_iterable_rest();
|
|
77
|
+
}
|
|
78
|
+
function _unsupported_iterable_to_array(o, minLen) {
|
|
79
|
+
if (!o) return;
|
|
80
|
+
if (typeof o === "string") return _array_like_to_array(o, minLen);
|
|
81
|
+
var n = Object.prototype.toString.call(o).slice(8, -1);
|
|
82
|
+
if (n === "Object" && o.constructor) n = o.constructor.name;
|
|
83
|
+
if (n === "Map" || n === "Set") return Array.from(n);
|
|
84
|
+
if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _array_like_to_array(o, minLen);
|
|
85
|
+
}
|
|
86
|
+
var REGEX_BEGIN = /^\s*:::\s*(\w+)\s*(.*)?/;
|
|
87
|
+
var REGEX_END = /^\s*:::$/;
|
|
88
|
+
var isLiteralNode = function isLiteralNode(node) {
|
|
89
|
+
return node && 'value' in node && typeof node.value === 'string';
|
|
90
|
+
};
|
|
91
|
+
var isParagraph = function isParagraph(node) {
|
|
92
|
+
return (node === null || node === void 0 ? void 0 : node.type) === 'paragraph';
|
|
93
|
+
};
|
|
94
|
+
export var remarkContainer = function remarkContainer() {
|
|
95
|
+
var options = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : {};
|
|
96
|
+
var _options_className, _options_containerTag, _options_titleElement;
|
|
97
|
+
var className = (_options_className = options.className) !== null && _options_className !== void 0 ? _options_className : 'markdown-container';
|
|
98
|
+
var containerTag = (_options_containerTag = options.containerTag) !== null && _options_containerTag !== void 0 ? _options_containerTag : 'div';
|
|
99
|
+
var titleElement = (_options_titleElement = options.titleElement) !== null && _options_titleElement !== void 0 ? _options_titleElement : {
|
|
100
|
+
className: [
|
|
101
|
+
'markdown-container__title'
|
|
102
|
+
]
|
|
103
|
+
};
|
|
104
|
+
var constructContainer = function constructContainer(children, type) {
|
|
105
|
+
return {
|
|
106
|
+
type: 'container',
|
|
107
|
+
children: children,
|
|
108
|
+
data: {
|
|
109
|
+
hName: containerTag,
|
|
110
|
+
hProperties: {
|
|
111
|
+
className: [
|
|
112
|
+
className,
|
|
113
|
+
type.toLowerCase()
|
|
114
|
+
]
|
|
115
|
+
}
|
|
116
|
+
}
|
|
117
|
+
};
|
|
118
|
+
};
|
|
119
|
+
var constructTitle = function constructTitle(title) {
|
|
120
|
+
return {
|
|
121
|
+
type: 'paragraph',
|
|
122
|
+
children: [
|
|
123
|
+
{
|
|
124
|
+
type: 'text',
|
|
125
|
+
value: title
|
|
126
|
+
}
|
|
127
|
+
],
|
|
128
|
+
data: {
|
|
129
|
+
hName: 'div',
|
|
130
|
+
hProperties: _object_spread({
|
|
131
|
+
className: [
|
|
132
|
+
"".concat(className, "__title")
|
|
133
|
+
]
|
|
134
|
+
}, titleElement && _object_spread({}, titleElement))
|
|
135
|
+
}
|
|
136
|
+
};
|
|
137
|
+
};
|
|
138
|
+
var transformChildren = function transformChildren(parent) {
|
|
139
|
+
if (!(parent === null || parent === void 0 ? void 0 : parent.children)) return;
|
|
140
|
+
var children = [];
|
|
141
|
+
var len = parent.children.length;
|
|
142
|
+
var currentIndex = -1;
|
|
143
|
+
while(currentIndex < len - 1){
|
|
144
|
+
var _currentNode_children;
|
|
145
|
+
currentIndex += 1;
|
|
146
|
+
var currentNode = parent.children[currentIndex];
|
|
147
|
+
children.push(currentNode);
|
|
148
|
+
if (!isParagraph(currentNode)) continue;
|
|
149
|
+
var firstChild = (_currentNode_children = currentNode.children) === null || _currentNode_children === void 0 ? void 0 : _currentNode_children[0];
|
|
150
|
+
if (!isLiteralNode(firstChild)) continue;
|
|
151
|
+
var match = firstChild.value.match(REGEX_BEGIN);
|
|
152
|
+
if (!match) continue;
|
|
153
|
+
children.pop();
|
|
154
|
+
var beginIndex = currentIndex;
|
|
155
|
+
var innerIndex = currentIndex - 1;
|
|
156
|
+
while(innerIndex < len - 1){
|
|
157
|
+
var _ref;
|
|
158
|
+
var _innerNode_children;
|
|
159
|
+
innerIndex += 1;
|
|
160
|
+
var innerNode = parent.children[innerIndex];
|
|
161
|
+
if (!isParagraph(innerNode)) continue;
|
|
162
|
+
var innerFirst = (_innerNode_children = innerNode.children) === null || _innerNode_children === void 0 ? void 0 : _innerNode_children[0];
|
|
163
|
+
if (!isLiteralNode(innerFirst) || !REGEX_END.test(innerFirst.value)) continue;
|
|
164
|
+
var _match = _sliced_to_array(match, 3), type = _match[1], title = _match[2];
|
|
165
|
+
var containerChildren = parent.children.slice(beginIndex + 1, innerIndex);
|
|
166
|
+
if ((title === null || title === void 0 ? void 0 : title.trim()) && titleElement !== null) {
|
|
167
|
+
containerChildren.unshift(constructTitle(title.trim()));
|
|
168
|
+
}
|
|
169
|
+
var container = constructContainer(containerChildren, (_ref = type === null || type === void 0 ? void 0 : type.toLowerCase()) !== null && _ref !== void 0 ? _ref : 'note');
|
|
170
|
+
children.push(container);
|
|
171
|
+
currentIndex = innerIndex;
|
|
172
|
+
break;
|
|
173
|
+
}
|
|
174
|
+
}
|
|
175
|
+
parent.children = children;
|
|
176
|
+
};
|
|
177
|
+
return function(tree) {
|
|
178
|
+
if ((tree === null || tree === void 0 ? void 0 : tree.type) === 'root') {
|
|
179
|
+
transformChildren(tree);
|
|
180
|
+
}
|
|
181
|
+
};
|
|
182
|
+
};
|
|
183
|
+
export default remarkContainer;
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* remark 插件:将 remark-directive 的 containerDirective 转为与 remarkContainer 相同的 HTML 结构
|
|
3
|
+
* (div.markdown-container + type 类名,可选 title 通过 attributes.title)
|
|
4
|
+
*
|
|
5
|
+
* 依赖 remark-directive 解析,语法示例:
|
|
6
|
+
* :::info
|
|
7
|
+
* 这是信息提示块。
|
|
8
|
+
* :::
|
|
9
|
+
*
|
|
10
|
+
* :::warning{title="警告标题"}
|
|
11
|
+
* 这是带标题的警告块。
|
|
12
|
+
* :::
|
|
13
|
+
*/
|
|
14
|
+
import type { Plugin } from 'unified';
|
|
15
|
+
interface RemarkDirectiveContainerOptions {
|
|
16
|
+
className?: string;
|
|
17
|
+
containerTag?: string;
|
|
18
|
+
titleElement?: Record<string, unknown> | null;
|
|
19
|
+
}
|
|
20
|
+
export declare const remarkDirectiveContainer: Plugin<[
|
|
21
|
+
RemarkDirectiveContainerOptions?
|
|
22
|
+
]>;
|
|
23
|
+
export default remarkDirectiveContainer;
|
|
@@ -0,0 +1,111 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* remark 插件:将 remark-directive 的 containerDirective 转为与 remarkContainer 相同的 HTML 结构
|
|
3
|
+
* (div.markdown-container + type 类名,可选 title 通过 attributes.title)
|
|
4
|
+
*
|
|
5
|
+
* 依赖 remark-directive 解析,语法示例:
|
|
6
|
+
* :::info
|
|
7
|
+
* 这是信息提示块。
|
|
8
|
+
* :::
|
|
9
|
+
*
|
|
10
|
+
* :::warning{title="警告标题"}
|
|
11
|
+
* 这是带标题的警告块。
|
|
12
|
+
* :::
|
|
13
|
+
*/ function _define_property(obj, key, value) {
|
|
14
|
+
if (key in obj) {
|
|
15
|
+
Object.defineProperty(obj, key, {
|
|
16
|
+
value: value,
|
|
17
|
+
enumerable: true,
|
|
18
|
+
configurable: true,
|
|
19
|
+
writable: true
|
|
20
|
+
});
|
|
21
|
+
} else {
|
|
22
|
+
obj[key] = value;
|
|
23
|
+
}
|
|
24
|
+
return obj;
|
|
25
|
+
}
|
|
26
|
+
function _object_spread(target) {
|
|
27
|
+
for(var i = 1; i < arguments.length; i++){
|
|
28
|
+
var source = arguments[i] != null ? arguments[i] : {};
|
|
29
|
+
var ownKeys = Object.keys(source);
|
|
30
|
+
if (typeof Object.getOwnPropertySymbols === "function") {
|
|
31
|
+
ownKeys = ownKeys.concat(Object.getOwnPropertySymbols(source).filter(function(sym) {
|
|
32
|
+
return Object.getOwnPropertyDescriptor(source, sym).enumerable;
|
|
33
|
+
}));
|
|
34
|
+
}
|
|
35
|
+
ownKeys.forEach(function(key) {
|
|
36
|
+
_define_property(target, key, source[key]);
|
|
37
|
+
});
|
|
38
|
+
}
|
|
39
|
+
return target;
|
|
40
|
+
}
|
|
41
|
+
function _type_of(obj) {
|
|
42
|
+
"@swc/helpers - typeof";
|
|
43
|
+
return obj && typeof Symbol !== "undefined" && obj.constructor === Symbol ? "symbol" : typeof obj;
|
|
44
|
+
}
|
|
45
|
+
import { visit } from "unist-util-visit";
|
|
46
|
+
var DEFAULT_CLASS_NAME = 'markdown-container';
|
|
47
|
+
var DEFAULT_CONTAINER_TAG = 'div';
|
|
48
|
+
var TITLE_CLASS_NAME = 'markdown-container__title';
|
|
49
|
+
function createTitleParagraph(title, titleProps) {
|
|
50
|
+
return {
|
|
51
|
+
type: 'paragraph',
|
|
52
|
+
children: [
|
|
53
|
+
{
|
|
54
|
+
type: 'text',
|
|
55
|
+
value: title
|
|
56
|
+
}
|
|
57
|
+
],
|
|
58
|
+
data: {
|
|
59
|
+
hName: 'div',
|
|
60
|
+
hProperties: _object_spread({
|
|
61
|
+
className: [
|
|
62
|
+
TITLE_CLASS_NAME
|
|
63
|
+
]
|
|
64
|
+
}, titleProps)
|
|
65
|
+
}
|
|
66
|
+
};
|
|
67
|
+
}
|
|
68
|
+
export var remarkDirectiveContainer = function remarkDirectiveContainer() {
|
|
69
|
+
var options = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : {};
|
|
70
|
+
var _options_className, _options_containerTag, _options_titleElement;
|
|
71
|
+
var className = (_options_className = options.className) !== null && _options_className !== void 0 ? _options_className : DEFAULT_CLASS_NAME;
|
|
72
|
+
var containerTag = (_options_containerTag = options.containerTag) !== null && _options_containerTag !== void 0 ? _options_containerTag : DEFAULT_CONTAINER_TAG;
|
|
73
|
+
var titleElement = (_options_titleElement = options.titleElement) !== null && _options_titleElement !== void 0 ? _options_titleElement : {
|
|
74
|
+
className: [
|
|
75
|
+
TITLE_CLASS_NAME
|
|
76
|
+
]
|
|
77
|
+
};
|
|
78
|
+
var titleProps = titleElement && (typeof titleElement === "undefined" ? "undefined" : _type_of(titleElement)) === 'object' ? titleElement : {
|
|
79
|
+
className: [
|
|
80
|
+
TITLE_CLASS_NAME
|
|
81
|
+
]
|
|
82
|
+
};
|
|
83
|
+
return function(tree) {
|
|
84
|
+
visit(tree, 'containerDirective', function(node) {
|
|
85
|
+
var _ref, _node_attributes, _node_data;
|
|
86
|
+
var _node_name;
|
|
87
|
+
var name = (_ref = (_node_name = node.name) === null || _node_name === void 0 ? void 0 : _node_name.toLowerCase()) !== null && _ref !== void 0 ? _ref : 'note';
|
|
88
|
+
var attrs = (_node_attributes = node.attributes) !== null && _node_attributes !== void 0 ? _node_attributes : {};
|
|
89
|
+
var title = typeof attrs.title === 'string' ? attrs.title : attrs.title ? String(attrs.title) : undefined;
|
|
90
|
+
var data = (_node_data = node.data) !== null && _node_data !== void 0 ? _node_data : node.data = {};
|
|
91
|
+
data.hName = containerTag;
|
|
92
|
+
data.hProperties = {
|
|
93
|
+
className: [
|
|
94
|
+
className,
|
|
95
|
+
name
|
|
96
|
+
]
|
|
97
|
+
};
|
|
98
|
+
if (title === null || title === void 0 ? void 0 : title.trim()) {
|
|
99
|
+
var titleNode = createTitleParagraph(title.trim(), titleProps);
|
|
100
|
+
if (Array.isArray(node.children)) {
|
|
101
|
+
node.children.unshift(titleNode);
|
|
102
|
+
} else {
|
|
103
|
+
node.children = [
|
|
104
|
+
titleNode
|
|
105
|
+
];
|
|
106
|
+
}
|
|
107
|
+
}
|
|
108
|
+
});
|
|
109
|
+
};
|
|
110
|
+
};
|
|
111
|
+
export default remarkDirectiveContainer;
|
|
@@ -23,6 +23,7 @@ function _unsupported_iterable_to_array(o, minLen) {
|
|
|
23
23
|
if (n === "Map" || n === "Set") return Array.from(n);
|
|
24
24
|
if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _array_like_to_array(o, minLen);
|
|
25
25
|
}
|
|
26
|
+
import remarkDirective from "remark-directive";
|
|
26
27
|
import remarkFrontmatter from "remark-frontmatter";
|
|
27
28
|
import remarkGfm from "remark-gfm";
|
|
28
29
|
import remarkHtml from "remark-html";
|
|
@@ -362,6 +363,7 @@ import { JINJA_DOLLAR_PLACEHOLDER } from "./constants";
|
|
|
362
363
|
// Markdown 解析器(用于解析 Markdown 为 mdast AST)
|
|
363
364
|
// 注意:这个解析器只用于解析,不包含 HTML 渲染相关的插件
|
|
364
365
|
var markdownParser = unified().use(remarkParse) // 解析 Markdown
|
|
366
|
+
.use(remarkDirective) // 解析 ::: 容器指令(info / warning / success / error / tip{title="..."})
|
|
365
367
|
.use(remarkHtml).use(remarkFrontmatter, [
|
|
366
368
|
'yaml'
|
|
367
369
|
]) // 处理前置元数据
|
|
@@ -405,6 +405,38 @@ var genStyle = function genStyle(token) {
|
|
|
405
405
|
zIndex: 0,
|
|
406
406
|
backgroundColor: 'var(--color-gray-control-fill-secondary)'
|
|
407
407
|
}
|
|
408
|
+
}), // markdown-it-container 风格的自定义容器(::: info / warning / success / error)
|
|
409
|
+
_define_property(_obj, '.markdown-container', {
|
|
410
|
+
padding: '12px 16px',
|
|
411
|
+
margin: '1em 0',
|
|
412
|
+
borderRadius: '6px',
|
|
413
|
+
borderLeft: '4px solid',
|
|
414
|
+
fontSize: 'var(--font-size-base)',
|
|
415
|
+
lineHeight: '160%',
|
|
416
|
+
'&__title': {
|
|
417
|
+
fontWeight: 600,
|
|
418
|
+
marginBottom: '8px'
|
|
419
|
+
},
|
|
420
|
+
'&.info': {
|
|
421
|
+
borderLeftColor: 'var(--color-info, #1677ff)',
|
|
422
|
+
backgroundColor: 'var(--color-info-bg, rgba(22, 119, 255, 0.08))'
|
|
423
|
+
},
|
|
424
|
+
'&.warning': {
|
|
425
|
+
borderLeftColor: 'var(--color-warning, #faad14)',
|
|
426
|
+
backgroundColor: 'var(--color-warning-bg, rgba(250, 173, 20, 0.08))'
|
|
427
|
+
},
|
|
428
|
+
'&.success': {
|
|
429
|
+
borderLeftColor: 'var(--color-success, #52c41a)',
|
|
430
|
+
backgroundColor: 'var(--color-success-bg, rgba(82, 196, 26, 0.08))'
|
|
431
|
+
},
|
|
432
|
+
'&.error': {
|
|
433
|
+
borderLeftColor: 'var(--color-error, #ff4d4f)',
|
|
434
|
+
backgroundColor: 'var(--color-error-bg, rgba(255, 77, 79, 0.08))'
|
|
435
|
+
},
|
|
436
|
+
'&.tip': {
|
|
437
|
+
borderLeftColor: 'var(--color-info, #1677ff)',
|
|
438
|
+
backgroundColor: 'var(--color-info-bg, rgba(22, 119, 255, 0.08))'
|
|
439
|
+
}
|
|
408
440
|
}), _define_property(_obj, '[data-be="media-container"], [data-be="image-container"]', {
|
|
409
441
|
display: 'flex',
|
|
410
442
|
minWidth: 0,
|
|
@@ -53,6 +53,10 @@ function _to_array(arr) {
|
|
|
53
53
|
function _to_consumable_array(arr) {
|
|
54
54
|
return _array_without_holes(arr) || _iterable_to_array(arr) || _unsupported_iterable_to_array(arr) || _non_iterable_spread();
|
|
55
55
|
}
|
|
56
|
+
function _type_of(obj) {
|
|
57
|
+
"@swc/helpers - typeof";
|
|
58
|
+
return obj && typeof Symbol !== "undefined" && obj.constructor === Symbol ? "symbol" : typeof obj;
|
|
59
|
+
}
|
|
56
60
|
function _unsupported_iterable_to_array(o, minLen) {
|
|
57
61
|
if (!o) return;
|
|
58
62
|
if (typeof o === "string") return _array_like_to_array(o, minLen);
|
|
@@ -163,6 +167,7 @@ function _ts_generator(thisArg, body) {
|
|
|
163
167
|
import rehypeKatex from "rehype-katex";
|
|
164
168
|
import rehypeRaw from "rehype-raw";
|
|
165
169
|
import rehypeStringify from "rehype-stringify";
|
|
170
|
+
import remarkDirective from "remark-directive";
|
|
166
171
|
import remarkFrontmatter from "remark-frontmatter";
|
|
167
172
|
import remarkGfm from "remark-gfm";
|
|
168
173
|
import remarkMath from "remark-math";
|
|
@@ -171,6 +176,7 @@ import remarkRehype from "remark-rehype";
|
|
|
171
176
|
import { unified } from "unified";
|
|
172
177
|
import { visit } from "unist-util-visit";
|
|
173
178
|
import { JINJA_DOLLAR_PLACEHOLDER } from "../parser/constants";
|
|
179
|
+
import { remarkDirectiveContainer } from "../parser/remarkDirectiveContainer";
|
|
174
180
|
import { convertParagraphToImage, fixStrongWithSpecialChars, protectJinjaDollarInText } from "../parser/remarkParse";
|
|
175
181
|
// HTML 转义相关的正则表达式和工具
|
|
176
182
|
var ESCAPE_TEST_NO_ENCODE = /[<>"']|&(?!(#\d{1,7}|#[Xx][a-fA-F0-9]{1,6}|\w+);)/;
|
|
@@ -296,6 +302,14 @@ var remarkRehypePlugin = remarkRehype;
|
|
|
296
302
|
};
|
|
297
303
|
};
|
|
298
304
|
}
|
|
305
|
+
/** 内置容器插件配置:remark-directive 容器转 div.markdown-container(兼容 markdown-it-container 风格) */ var REMARK_DIRECTIVE_CONTAINER_OPTIONS = {
|
|
306
|
+
className: 'markdown-container',
|
|
307
|
+
titleElement: {
|
|
308
|
+
className: [
|
|
309
|
+
'markdown-container__title'
|
|
310
|
+
]
|
|
311
|
+
}
|
|
312
|
+
};
|
|
299
313
|
export var DEFAULT_MARKDOWN_REMARK_PLUGINS = [
|
|
300
314
|
remarkParse,
|
|
301
315
|
[
|
|
@@ -315,6 +329,11 @@ export var DEFAULT_MARKDOWN_REMARK_PLUGINS = [
|
|
|
315
329
|
remarkFrontmatter,
|
|
316
330
|
FRONTMATTER_LANGUAGES
|
|
317
331
|
],
|
|
332
|
+
remarkDirective,
|
|
333
|
+
[
|
|
334
|
+
remarkDirectiveContainer,
|
|
335
|
+
REMARK_DIRECTIVE_CONTAINER_OPTIONS
|
|
336
|
+
],
|
|
318
337
|
[
|
|
319
338
|
remarkRehypePlugin,
|
|
320
339
|
{
|
|
@@ -398,7 +417,7 @@ var createMarkdownProcessor = function createMarkdownProcessor(plugins, config)
|
|
|
398
417
|
* @throws {Error} 当转换过程中发生错误时返回空字符串
|
|
399
418
|
*/ export var markdownToHtml = function markdownToHtml(markdown, plugins, config) {
|
|
400
419
|
return _async_to_generator(function() {
|
|
401
|
-
var htmlContent, error;
|
|
420
|
+
var _file_value, file, htmlContent, error;
|
|
402
421
|
return _ts_generator(this, function(_state) {
|
|
403
422
|
switch(_state.label){
|
|
404
423
|
case 0:
|
|
@@ -413,10 +432,11 @@ var createMarkdownProcessor = function createMarkdownProcessor(plugins, config)
|
|
|
413
432
|
createMarkdownProcessor(plugins, config).process(markdown)
|
|
414
433
|
];
|
|
415
434
|
case 1:
|
|
416
|
-
|
|
435
|
+
file = _state.sent();
|
|
436
|
+
htmlContent = file && (typeof file === "undefined" ? "undefined" : _type_of(file)) === 'object' && 'value' in file ? String((_file_value = file.value) !== null && _file_value !== void 0 ? _file_value : '') : String(file);
|
|
417
437
|
return [
|
|
418
438
|
2,
|
|
419
|
-
|
|
439
|
+
htmlContent.split(JINJA_DOLLAR_PLACEHOLDER).join('$')
|
|
420
440
|
];
|
|
421
441
|
case 2:
|
|
422
442
|
error = _state.sent();
|
|
@@ -464,8 +484,10 @@ var createMarkdownProcessor = function createMarkdownProcessor(plugins, config)
|
|
|
464
484
|
* - 同步版本可能影响用户界面响应性
|
|
465
485
|
*/ export var markdownToHtmlSync = function markdownToHtmlSync(markdown, plugins, config) {
|
|
466
486
|
try {
|
|
487
|
+
var _file_value;
|
|
467
488
|
var file = createMarkdownProcessor(plugins, config).processSync(markdown);
|
|
468
|
-
|
|
489
|
+
var htmlContent = file && (typeof file === "undefined" ? "undefined" : _type_of(file)) === 'object' && 'value' in file ? String((_file_value = file.value) !== null && _file_value !== void 0 ? _file_value : '') : String(file);
|
|
490
|
+
return htmlContent.split(JINJA_DOLLAR_PLACEHOLDER).join('$');
|
|
469
491
|
} catch (error) {
|
|
470
492
|
console.error('Error converting markdown to HTML:', error);
|
|
471
493
|
return '';
|
|
@@ -7,7 +7,7 @@
|
|
|
7
7
|
* @returns A complete HTML document as a string
|
|
8
8
|
*/ export var generateHtmlDocument = function generateHtmlDocument(content) {
|
|
9
9
|
var title = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : 'Markdown Export', styles = arguments.length > 2 && arguments[2] !== void 0 ? arguments[2] : '';
|
|
10
|
-
return '<!DOCTYPE html>\n<html>\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 <style>\n body {\n font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;\n line-height: 1.6;\n padding: 12px;\n max-width: 900px;\n margin: 0 auto;\n color: #333;\n }\n pre {\n background-color: #f6f8fa;\n border-radius: 3px;\n padding: 16px;\n overflow: auto;\n }\n code {\n background-color: rgba(27, 31, 35, 0.05);\n border-radius: 3px;\n padding: 0.2em 0.4em;\n font-family: SFMono-Regular, Consolas, 'Liberation Mono', Menlo, monospace;\n }\n blockquote {\n border-left: 4px solid #ddd;\n padding-left: 16px;\n margin-left: 0;\n color: #666;\n }\n img {\n max-width: 100%;\n }\n table {\n border-collapse: collapse;\n width: 100%;\n margin-bottom: 16px;\n }\n table, th, td {\n border: 1px solid #ddd;\n }\n th, td {\n padding: 8px;\n text-align: left;\n vertical-align: middle;\n }\n th {\n background-color: #f6f8fa;\n }\n @media screen and (max-width: 768px) {\n th, td {\n padding: 2px;\n }\n }\n ").concat(styles, "\n </style>\n</head>\n<body>\n ").concat(content, "\n</body>\n</html>");
|
|
10
|
+
return '<!DOCTYPE html>\n<html>\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 <style>\n body {\n font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;\n line-height: 1.6;\n padding: 12px;\n max-width: 900px;\n margin: 0 auto;\n color: #333;\n }\n pre {\n background-color: #f6f8fa;\n border-radius: 3px;\n padding: 16px;\n overflow: auto;\n }\n code {\n background-color: rgba(27, 31, 35, 0.05);\n border-radius: 3px;\n padding: 0.2em 0.4em;\n font-family: SFMono-Regular, Consolas, 'Liberation Mono', Menlo, monospace;\n }\n blockquote {\n border-left: 4px solid #ddd;\n padding-left: 16px;\n margin-left: 0;\n color: #666;\n }\n .markdown-container {\n padding: 12px 16px;\n margin: 1em 0;\n border-radius: 6px;\n border-left: 4px solid;\n line-height: 1.6;\n }\n .markdown-container__title {\n font-weight: 600;\n margin-bottom: 8px;\n }\n .markdown-container.info {\n border-left-color: #1677ff;\n background-color: rgba(22, 119, 255, 0.08);\n }\n .markdown-container.warning {\n border-left-color: #faad14;\n background-color: rgba(250, 173, 20, 0.08);\n }\n .markdown-container.success {\n border-left-color: #52c41a;\n background-color: rgba(82, 196, 26, 0.08);\n }\n .markdown-container.error {\n border-left-color: #ff4d4f;\n background-color: rgba(255, 77, 79, 0.08);\n }\n img {\n max-width: 100%;\n }\n table {\n border-collapse: collapse;\n width: 100%;\n margin-bottom: 16px;\n }\n table, th, td {\n border: 1px solid #ddd;\n }\n th, td {\n padding: 8px;\n text-align: left;\n vertical-align: middle;\n }\n th {\n background-color: #f6f8fa;\n }\n @media screen and (max-width: 768px) {\n th, td {\n padding: 2px;\n }\n }\n ").concat(styles, "\n </style>\n</head>\n<body>\n ").concat(content, "\n</body>\n</html>");
|
|
11
11
|
};
|
|
12
12
|
/**
|
|
13
13
|
* Export HTML content to a file
|
|
@@ -7,5 +7,7 @@ export type AttachmentFileListProps = {
|
|
|
7
7
|
onDownload?: (file: AttachmentFile) => void;
|
|
8
8
|
onRetry?: (file: AttachmentFile) => void;
|
|
9
9
|
onClearFileMap?: () => void;
|
|
10
|
+
/** E2E 测试 ID */
|
|
11
|
+
dataTestId?: string;
|
|
10
12
|
};
|
|
11
13
|
export declare const AttachmentFileList: React.FC<AttachmentFileListProps>;
|
|
@@ -110,7 +110,7 @@ var ClearButton = function ClearButton(param) {
|
|
|
110
110
|
}, /*#__PURE__*/ React.createElement(X, null));
|
|
111
111
|
};
|
|
112
112
|
export var AttachmentFileList = function AttachmentFileList(param) {
|
|
113
|
-
var fileMap = param.fileMap, onDelete = param.onDelete, onPreview = param.onPreview, onDownload = param.onDownload, onRetry = param.onRetry, onClearFileMap = param.onClearFileMap;
|
|
113
|
+
var fileMap = param.fileMap, onDelete = param.onDelete, onPreview = param.onPreview, onDownload = param.onDownload, onRetry = param.onRetry, onClearFileMap = param.onClearFileMap, dataTestId = param.dataTestId;
|
|
114
114
|
var context = useContext(ConfigProvider.ConfigContext);
|
|
115
115
|
var prefix = context === null || context === void 0 ? void 0 : context.getPrefixCls('agentic-md-editor-attachment-list');
|
|
116
116
|
var _useStyle = useStyle(prefix), wrapSSR = _useStyle.wrapSSR, hashId = _useStyle.hashId;
|
|
@@ -139,7 +139,8 @@ export var AttachmentFileList = function AttachmentFileList(param) {
|
|
|
139
139
|
if (!visible) setImgSrc(undefined);
|
|
140
140
|
};
|
|
141
141
|
return wrapSSR(/*#__PURE__*/ React.createElement("div", {
|
|
142
|
-
className: classNames("".concat(prefix, "-container"), hashId, _define_property({}, "".concat(prefix, "-container-empty"), !hasFiles))
|
|
142
|
+
className: classNames("".concat(prefix, "-container"), hashId, _define_property({}, "".concat(prefix, "-container-empty"), !hasFiles)),
|
|
143
|
+
"data-testid": dataTestId
|
|
143
144
|
}, /*#__PURE__*/ React.createElement(motion.div, {
|
|
144
145
|
variants: ANIMATION_VARIANTS,
|
|
145
146
|
whileInView: "visible",
|
|
@@ -148,6 +148,7 @@ import { QuickActions } from "./QuickActions";
|
|
|
148
148
|
import { SkillModeBar } from "./SkillModeBar";
|
|
149
149
|
import { useStyle } from "./style";
|
|
150
150
|
import { Suggestion } from "./Suggestion";
|
|
151
|
+
import { MARKDOWN_INPUT_FIELD_TEST_IDS } from "./testIds";
|
|
151
152
|
import TopOperatingArea from "./TopOperatingArea";
|
|
152
153
|
import { useAttachmentList, useBeforeTools, useSendActionsNode } from "./utils/renderHelpers";
|
|
153
154
|
import { useVoiceInputManager } from "./VoiceInputManager";
|
|
@@ -196,16 +197,17 @@ import { useVoiceInputManager } from "./VoiceInputManager";
|
|
|
196
197
|
enable: false
|
|
197
198
|
};
|
|
198
199
|
var MarkdownInputFieldComponent = function MarkdownInputFieldComponent(_0) {
|
|
199
|
-
var tagInputProps = _0.tagInputProps, markdownProps = _0.markdownProps, _0_borderRadius = _0.borderRadius, borderRadius = _0_borderRadius === void 0 ? 16 : _0_borderRadius, onBlur = _0.onBlur, onFocus = _0.onFocus, _0_isShowTopOperatingArea = _0.isShowTopOperatingArea, isShowTopOperatingArea = _0_isShowTopOperatingArea === void 0 ? false : _0_isShowTopOperatingArea, props = _object_without_properties(_0, [
|
|
200
|
+
var tagInputProps = _0.tagInputProps, markdownProps = _0.markdownProps, _0_borderRadius = _0.borderRadius, borderRadius = _0_borderRadius === void 0 ? 16 : _0_borderRadius, onBlur = _0.onBlur, onFocus = _0.onFocus, _0_isShowTopOperatingArea = _0.isShowTopOperatingArea, isShowTopOperatingArea = _0_isShowTopOperatingArea === void 0 ? false : _0_isShowTopOperatingArea, testId = _0.testId, props = _object_without_properties(_0, [
|
|
200
201
|
"tagInputProps",
|
|
201
202
|
"markdownProps",
|
|
202
203
|
"borderRadius",
|
|
203
204
|
"onBlur",
|
|
204
205
|
"onFocus",
|
|
205
|
-
"isShowTopOperatingArea"
|
|
206
|
+
"isShowTopOperatingArea",
|
|
207
|
+
"testId"
|
|
206
208
|
]);
|
|
207
209
|
var _ref;
|
|
208
|
-
var _props_skillMode, _props_enlargeable, _props_refinePrompt, _props_enlargeable1, _props_enlargeable2;
|
|
210
|
+
var _props_skillMode, _props_enlargeable, _props_refinePrompt, _props_enlargeable1, _props_enlargeable2, _props_toolsRender;
|
|
209
211
|
// 默认关闭文件上传,需显式传入 attachment.enable: true 开启
|
|
210
212
|
var attachment = _object_spread({}, DEFAULT_ATTACHMENT, props.attachment);
|
|
211
213
|
var getPrefixCls = useContext(ConfigProvider.ConfigContext).getPrefixCls;
|
|
@@ -232,7 +234,7 @@ var MarkdownInputFieldComponent = function MarkdownInputFieldComponent(_0) {
|
|
|
232
234
|
}), hasEnlargeAction = _useMarkdownInputFieldActions.hasEnlargeAction, hasRefineAction = _useMarkdownInputFieldActions.hasRefineAction, isMultiRowLayout = _useMarkdownInputFieldActions.isMultiRowLayout, totalActionCount = _useMarkdownInputFieldActions.totalActionCount;
|
|
233
235
|
// 样式计算
|
|
234
236
|
var _useMarkdownInputFieldStyles = useMarkdownInputFieldStyles({
|
|
235
|
-
|
|
237
|
+
hasTools: !!props.toolsRender || !!props.actionsRender,
|
|
236
238
|
maxHeight: props.maxHeight,
|
|
237
239
|
style: props.style,
|
|
238
240
|
attachment: attachment,
|
|
@@ -334,13 +336,15 @@ var MarkdownInputFieldComponent = function MarkdownInputFieldComponent(_0) {
|
|
|
334
336
|
});
|
|
335
337
|
var _obj, _obj1;
|
|
336
338
|
return wrapSSR(/*#__PURE__*/ React.createElement(React.Fragment, null, isShowTopOperatingArea && /*#__PURE__*/ React.createElement("div", {
|
|
337
|
-
className: classNames("".concat(baseCls, "-top-area"), hashId)
|
|
339
|
+
className: classNames("".concat(baseCls, "-top-area"), hashId),
|
|
340
|
+
"data-testid": MARKDOWN_INPUT_FIELD_TEST_IDS.TOP_AREA
|
|
338
341
|
}, /*#__PURE__*/ React.createElement(TopOperatingArea, {
|
|
339
342
|
targetRef: props.targetRef,
|
|
340
343
|
operationBtnRender: props.operationBtnRender,
|
|
341
344
|
isShowBackTo: props.isShowBackTo
|
|
342
345
|
})), beforeTools ? /*#__PURE__*/ React.createElement("div", {
|
|
343
|
-
className: classNames("".concat(baseCls, "-before-tools"), hashId)
|
|
346
|
+
className: classNames("".concat(baseCls, "-before-tools"), hashId),
|
|
347
|
+
"data-testid": MARKDOWN_INPUT_FIELD_TEST_IDS.BEFORE_TOOLS
|
|
344
348
|
}, beforeTools) : null, /*#__PURE__*/ React.createElement(Suggestion, {
|
|
345
349
|
tagInputProps: _object_spread({
|
|
346
350
|
enable: true,
|
|
@@ -348,7 +352,7 @@ var MarkdownInputFieldComponent = function MarkdownInputFieldComponent(_0) {
|
|
|
348
352
|
}, tagInputProps)
|
|
349
353
|
}, /*#__PURE__*/ React.createElement("div", {
|
|
350
354
|
ref: inputRef,
|
|
351
|
-
"data-testid":
|
|
355
|
+
"data-testid": testId !== null && testId !== void 0 ? testId : MARKDOWN_INPUT_FIELD_TEST_IDS.ROOT,
|
|
352
356
|
className: classNames(baseCls, hashId, props.className, (_obj = {}, _define_property(_obj, "".concat(baseCls, "-disabled"), props.disabled), _define_property(_obj, "".concat(baseCls, "-skill-mode"), (_props_skillMode = props.skillMode) === null || _props_skillMode === void 0 ? void 0 : _props_skillMode.open), _define_property(_obj, "".concat(baseCls, "-typing"), false), _define_property(_obj, "".concat(baseCls, "-loading"), isLoading), _define_property(_obj, "".concat(baseCls, "-is-multi-row"), isMultiRowLayout), _define_property(_obj, "".concat(baseCls, "-enlarged"), isEnlarged), _define_property(_obj, "".concat(baseCls, "-focused"), isFocused), _define_property(_obj, "".concat(baseCls, "-has-tools-wrapper"), !!props.toolsRender), _obj)),
|
|
353
357
|
style: _object_spread_props(_object_spread({}, props.style, enlargedStyle), {
|
|
354
358
|
height: isEnlarged ? "".concat((_ref = (_props_enlargeable = props.enlargeable) === null || _props_enlargeable === void 0 ? void 0 : _props_enlargeable.height) !== null && _ref !== void 0 ? _ref : 980, "px") : "min(".concat(collapsedHeightPx, "px,100%)"),
|
|
@@ -381,12 +385,14 @@ var MarkdownInputFieldComponent = function MarkdownInputFieldComponent(_0) {
|
|
|
381
385
|
flex: 1,
|
|
382
386
|
minHeight: 0
|
|
383
387
|
},
|
|
384
|
-
className: classNames("".concat(baseCls, "-editor"), hashId, (_obj1 = {}, _define_property(_obj1, "".concat(baseCls, "-editor-hover"), isHover), _define_property(_obj1, "".concat(baseCls, "-editor-disabled"), props.disabled), _obj1))
|
|
388
|
+
className: classNames("".concat(baseCls, "-editor"), hashId, (_obj1 = {}, _define_property(_obj1, "".concat(baseCls, "-editor-hover"), isHover), _define_property(_obj1, "".concat(baseCls, "-editor-disabled"), props.disabled), _obj1)),
|
|
389
|
+
"data-testid": MARKDOWN_INPUT_FIELD_TEST_IDS.EDITOR
|
|
385
390
|
}, /*#__PURE__*/ React.createElement(SkillModeBar, {
|
|
386
391
|
skillMode: props.skillMode,
|
|
387
392
|
onSkillModeOpenChange: props.onSkillModeOpenChange
|
|
388
393
|
}), /*#__PURE__*/ React.createElement("div", {
|
|
389
|
-
className: classNames("".concat(baseCls, "-editor-content"), hashId)
|
|
394
|
+
className: classNames("".concat(baseCls, "-editor-content"), hashId),
|
|
395
|
+
"data-testid": MARKDOWN_INPUT_FIELD_TEST_IDS.EDITOR_CONTENT
|
|
390
396
|
}, attachmentList, /*#__PURE__*/ React.createElement(BaseMarkdownEditor, _object_spread({
|
|
391
397
|
editorRef: markdownEditorRef,
|
|
392
398
|
leafRender: props.leafRender,
|
|
@@ -484,13 +490,15 @@ var MarkdownInputFieldComponent = function MarkdownInputFieldComponent(_0) {
|
|
|
484
490
|
setTopRightPadding(width);
|
|
485
491
|
setQuickRightOffset(rightOffset);
|
|
486
492
|
}
|
|
487
|
-
}) : null))), props.toolsRender ? /*#__PURE__*/ React.createElement("div", {
|
|
488
|
-
className: classNames("".concat(baseCls, "-tools-wrapper"), hashId)
|
|
493
|
+
}) : null))), props.toolsRender || props.actionsRender ? /*#__PURE__*/ React.createElement("div", {
|
|
494
|
+
className: classNames("".concat(baseCls, "-tools-wrapper"), hashId),
|
|
495
|
+
"data-testid": MARKDOWN_INPUT_FIELD_TEST_IDS.TOOLS_WRAPPER
|
|
489
496
|
}, /*#__PURE__*/ React.createElement("div", {
|
|
490
497
|
ref: actionsRef,
|
|
491
498
|
contentEditable: false,
|
|
492
|
-
className: classNames("".concat(baseCls, "-send-tools"), hashId)
|
|
493
|
-
|
|
499
|
+
className: classNames("".concat(baseCls, "-send-tools"), hashId),
|
|
500
|
+
"data-testid": MARKDOWN_INPUT_FIELD_TEST_IDS.SEND_TOOLS
|
|
501
|
+
}, props === null || props === void 0 ? void 0 : (_props_toolsRender = props.toolsRender) === null || _props_toolsRender === void 0 ? void 0 : _props_toolsRender.call(props, _object_spread_props(_object_spread({
|
|
494
502
|
value: value,
|
|
495
503
|
fileMap: fileMap,
|
|
496
504
|
onFileMapChange: setFileMap,
|
|
@@ -203,6 +203,7 @@ import React, { useState } from "react";
|
|
|
203
203
|
import { useRefFunction } from "../../Hooks/useRefFunction";
|
|
204
204
|
import Enlargement from "../Enlargement";
|
|
205
205
|
import { RefinePromptButton } from "../RefinePromptButton";
|
|
206
|
+
import { MARKDOWN_INPUT_FIELD_TEST_IDS } from "../testIds";
|
|
206
207
|
/**
|
|
207
208
|
* QuickActions 组件 - 快速操作区域
|
|
208
209
|
*
|
|
@@ -306,7 +307,8 @@ import { RefinePromptButton } from "../RefinePromptButton";
|
|
|
306
307
|
e.stopPropagation();
|
|
307
308
|
e.preventDefault();
|
|
308
309
|
},
|
|
309
|
-
className: classNames("".concat(prefixCls, "-quick-actions"), hashId, _define_property({}, "".concat(prefixCls, "-quick-actions-vertical"), enlargeable))
|
|
310
|
+
className: classNames("".concat(prefixCls, "-quick-actions"), hashId, _define_property({}, "".concat(prefixCls, "-quick-actions-vertical"), enlargeable)),
|
|
311
|
+
"data-testid": MARKDOWN_INPUT_FIELD_TEST_IDS.QUICK_ACTIONS
|
|
310
312
|
}, [
|
|
311
313
|
// Enlargement组件 - 显示在最上方
|
|
312
314
|
enlargeable && /*#__PURE__*/ React.createElement(Enlargement, {
|
|
@@ -60,6 +60,7 @@ import { I18nContext } from "../../I18n";
|
|
|
60
60
|
import { AttachmentButton } from "../AttachmentButton";
|
|
61
61
|
import { SendButton } from "../SendButton";
|
|
62
62
|
import { VoiceInputButton } from "../VoiceInput";
|
|
63
|
+
import { MARKDOWN_INPUT_FIELD_TEST_IDS } from "../testIds";
|
|
63
64
|
/**
|
|
64
65
|
* SendActions 组件 - 发送操作按钮区域
|
|
65
66
|
*
|
|
@@ -170,7 +171,8 @@ import { VoiceInputButton } from "../VoiceInput";
|
|
|
170
171
|
e.stopPropagation();
|
|
171
172
|
e.preventDefault();
|
|
172
173
|
},
|
|
173
|
-
className: classNames("".concat(prefixCls, "-send-actions"), _define_property({}, "".concat(prefixCls, "-send-has-tools"), hasTools), hashId)
|
|
174
|
+
className: classNames("".concat(prefixCls, "-send-actions"), _define_property({}, "".concat(prefixCls, "-send-has-tools"), hasTools), hashId),
|
|
175
|
+
"data-testid": MARKDOWN_INPUT_FIELD_TEST_IDS.SEND_ACTIONS
|
|
174
176
|
}, collapseSendActions && actionsList.length > 2 ? /*#__PURE__*/ React.createElement(React.Fragment, null, /*#__PURE__*/ React.createElement(Popover, {
|
|
175
177
|
trigger: "click",
|
|
176
178
|
styles: {
|
|
@@ -196,7 +198,8 @@ import { VoiceInputButton } from "../VoiceInput";
|
|
|
196
198
|
style: {
|
|
197
199
|
fontSize: 16,
|
|
198
200
|
color: 'var(--color-gray-text-secondary)'
|
|
199
|
-
}
|
|
201
|
+
},
|
|
202
|
+
"data-testid": MARKDOWN_INPUT_FIELD_TEST_IDS.MORE_ACTIONS
|
|
200
203
|
}, /*#__PURE__*/ React.createElement(EllipsisVertical, null))), actionsList.find(function(item) {
|
|
201
204
|
if (/*#__PURE__*/ React.isValidElement(item) && (item === null || item === void 0 ? void 0 : item.key) === 'send-button') {
|
|
202
205
|
return true;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
import type { MarkdownInputFieldProps } from '../types/MarkdownInputFieldProps';
|
|
3
3
|
interface UseMarkdownInputFieldStylesParams {
|
|
4
|
-
|
|
4
|
+
hasTools?: boolean;
|
|
5
5
|
maxHeight?: MarkdownInputFieldProps['maxHeight'];
|
|
6
6
|
style?: React.CSSProperties;
|
|
7
7
|
attachment?: {
|
|
@@ -27,5 +27,5 @@ interface UseMarkdownInputFieldStylesReturn {
|
|
|
27
27
|
* 样式计算 Hook
|
|
28
28
|
* 计算组件所需的样式值
|
|
29
29
|
*/
|
|
30
|
-
export declare const useMarkdownInputFieldStyles: ({
|
|
30
|
+
export declare const useMarkdownInputFieldStyles: ({ hasTools, maxHeight, style, attachment, isEnlarged, rightPadding, topRightPadding, quickRightOffset, hasEnlargeAction, hasRefineAction, totalActionCount, isMultiRowLayout, }: UseMarkdownInputFieldStylesParams) => UseMarkdownInputFieldStylesReturn;
|
|
31
31
|
export {};
|
|
@@ -3,13 +3,13 @@ import { useMemo } from "react";
|
|
|
3
3
|
* 样式计算 Hook
|
|
4
4
|
* 计算组件所需的样式值
|
|
5
5
|
*/ export var useMarkdownInputFieldStyles = function useMarkdownInputFieldStyles(param) {
|
|
6
|
-
var
|
|
6
|
+
var hasTools = param.hasTools, maxHeight = param.maxHeight, style = param.style, attachment = param.attachment, isEnlarged = param.isEnlarged, rightPadding = param.rightPadding, topRightPadding = param.topRightPadding, quickRightOffset = param.quickRightOffset, hasEnlargeAction = param.hasEnlargeAction, hasRefineAction = param.hasRefineAction, totalActionCount = param.totalActionCount, isMultiRowLayout = param.isMultiRowLayout;
|
|
7
7
|
var computedRightPadding = useMemo(function() {
|
|
8
|
-
var bottomOverlayPadding =
|
|
8
|
+
var bottomOverlayPadding = hasTools ? 0 : rightPadding || 52;
|
|
9
9
|
var topOverlayPadding = (topRightPadding || 0) + (quickRightOffset || 0);
|
|
10
10
|
return Math.max(bottomOverlayPadding, topOverlayPadding);
|
|
11
11
|
}, [
|
|
12
|
-
|
|
12
|
+
hasTools,
|
|
13
13
|
rightPadding,
|
|
14
14
|
topRightPadding,
|
|
15
15
|
quickRightOffset
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* MarkdownInputField 内置 testId 常量
|
|
3
|
+
* 用于 E2E 测试与自动化测试中的 data-testid 定位
|
|
4
|
+
*/
|
|
5
|
+
export declare const MARKDOWN_INPUT_FIELD_TEST_IDS: {
|
|
6
|
+
/** 根容器 */
|
|
7
|
+
readonly ROOT: "markdown-input-field";
|
|
8
|
+
/** 顶部操作区域 */
|
|
9
|
+
readonly TOP_AREA: "markdown-input-field-top-area";
|
|
10
|
+
/** 前置工具栏区域 */
|
|
11
|
+
readonly BEFORE_TOOLS: "markdown-input-field-before-tools";
|
|
12
|
+
/** 编辑器容器 */
|
|
13
|
+
readonly EDITOR: "markdown-input-field-editor";
|
|
14
|
+
/** 编辑器内容区 */
|
|
15
|
+
readonly EDITOR_CONTENT: "markdown-input-field-editor-content";
|
|
16
|
+
/** 快速操作区(放大、提示词优化等) */
|
|
17
|
+
readonly QUICK_ACTIONS: "markdown-input-field-quick-actions";
|
|
18
|
+
/** 工具栏包装器 */
|
|
19
|
+
readonly TOOLS_WRAPPER: "markdown-input-field-tools-wrapper";
|
|
20
|
+
/** 发送工具区域 */
|
|
21
|
+
readonly SEND_TOOLS: "markdown-input-field-send-tools";
|
|
22
|
+
/** 发送操作区(附件、语音、发送按钮等) */
|
|
23
|
+
readonly SEND_ACTIONS: "markdown-input-field-send-actions";
|
|
24
|
+
/** 更多操作按钮(折叠时的省略号) */
|
|
25
|
+
readonly MORE_ACTIONS: "markdown-input-field-more-actions";
|
|
26
|
+
/** 附件列表 */
|
|
27
|
+
readonly ATTACHMENT_LIST: "markdown-input-field-attachment-list";
|
|
28
|
+
};
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* MarkdownInputField 内置 testId 常量
|
|
3
|
+
* 用于 E2E 测试与自动化测试中的 data-testid 定位
|
|
4
|
+
*/ export var MARKDOWN_INPUT_FIELD_TEST_IDS = {
|
|
5
|
+
/** 根容器 */ ROOT: 'markdown-input-field',
|
|
6
|
+
/** 顶部操作区域 */ TOP_AREA: 'markdown-input-field-top-area',
|
|
7
|
+
/** 前置工具栏区域 */ BEFORE_TOOLS: 'markdown-input-field-before-tools',
|
|
8
|
+
/** 编辑器容器 */ EDITOR: 'markdown-input-field-editor',
|
|
9
|
+
/** 编辑器内容区 */ EDITOR_CONTENT: 'markdown-input-field-editor-content',
|
|
10
|
+
/** 快速操作区(放大、提示词优化等) */ QUICK_ACTIONS: 'markdown-input-field-quick-actions',
|
|
11
|
+
/** 工具栏包装器 */ TOOLS_WRAPPER: 'markdown-input-field-tools-wrapper',
|
|
12
|
+
/** 发送工具区域 */ SEND_TOOLS: 'markdown-input-field-send-tools',
|
|
13
|
+
/** 发送操作区(附件、语音、发送按钮等) */ SEND_ACTIONS: 'markdown-input-field-send-actions',
|
|
14
|
+
/** 更多操作按钮(折叠时的省略号) */ MORE_ACTIONS: 'markdown-input-field-more-actions',
|
|
15
|
+
/** 附件列表 */ ATTACHMENT_LIST: 'markdown-input-field-attachment-list'
|
|
16
|
+
};
|
|
@@ -363,6 +363,11 @@ export type MarkdownInputFieldProps = {
|
|
|
363
363
|
* ```
|
|
364
364
|
*/
|
|
365
365
|
targetRef?: React.RefObject<HTMLDivElement>;
|
|
366
|
+
/**
|
|
367
|
+
* 测试 ID
|
|
368
|
+
* @description 用于 E2E 或自动化测试中的 `data-testid` 属性,覆盖根元素的默认 `markdown-input-field`
|
|
369
|
+
*/
|
|
370
|
+
testId?: string;
|
|
366
371
|
/**
|
|
367
372
|
* 顶部操作区域自定义操作按钮渲染函数
|
|
368
373
|
* @description 用于在顶部操作区域中央渲染自定义操作按钮
|
|
@@ -53,6 +53,7 @@ function _object_spread_props(target, source) {
|
|
|
53
53
|
import React, { useMemo } from "react";
|
|
54
54
|
import { AttachmentFileList } from "../AttachmentButton/AttachmentFileList";
|
|
55
55
|
import { SendActions } from "../SendActions";
|
|
56
|
+
import { MARKDOWN_INPUT_FIELD_TEST_IDS } from "../testIds";
|
|
56
57
|
/**
|
|
57
58
|
* 附件列表渲染 Hook
|
|
58
59
|
*/ export var useAttachmentList = function useAttachmentList(param) {
|
|
@@ -65,7 +66,8 @@ import { SendActions } from "../SendActions";
|
|
|
65
66
|
onRetry: handleFileRetry,
|
|
66
67
|
onClearFileMap: function onClearFileMap() {
|
|
67
68
|
updateAttachmentFiles(undefined);
|
|
68
|
-
}
|
|
69
|
+
},
|
|
70
|
+
dataTestId: MARKDOWN_INPUT_FIELD_TEST_IDS.ATTACHMENT_LIST
|
|
69
71
|
});
|
|
70
72
|
}, [
|
|
71
73
|
attachment === null || attachment === void 0 ? void 0 : attachment.enable,
|
package/dist/index.d.ts
CHANGED
|
@@ -56,6 +56,7 @@ export * from './MarkdownInputField/AttachmentButton/utils';
|
|
|
56
56
|
export { ActionItemContainer } from './MarkdownInputField/BeforeToolContainer/BeforeToolContainer';
|
|
57
57
|
export * from './MarkdownInputField/FileMapView';
|
|
58
58
|
export * from './MarkdownInputField/MarkdownInputField';
|
|
59
|
+
export { MARKDOWN_INPUT_FIELD_TEST_IDS } from './MarkdownInputField/testIds';
|
|
59
60
|
export * from './MarkdownInputField/VoiceInput';
|
|
60
61
|
export * from './Schema';
|
|
61
62
|
export * from './Schema/SchemaRenderer/templateEngine';
|
package/dist/index.js
CHANGED
|
@@ -65,6 +65,7 @@ export * from "./MarkdownInputField/AttachmentButton/utils";
|
|
|
65
65
|
export { ActionItemContainer } from "./MarkdownInputField/BeforeToolContainer/BeforeToolContainer";
|
|
66
66
|
export * from "./MarkdownInputField/FileMapView";
|
|
67
67
|
export * from "./MarkdownInputField/MarkdownInputField";
|
|
68
|
+
export { MARKDOWN_INPUT_FIELD_TEST_IDS } from "./MarkdownInputField/testIds";
|
|
68
69
|
export * from "./MarkdownInputField/VoiceInput";
|
|
69
70
|
// ─── Schema ──────────────────────────────────────────────────────────────────
|
|
70
71
|
export * from "./Schema";
|
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.55",
|
|
4
4
|
"description": "面向智能体的 UI 组件库,提供多步推理可视化、工具调用展示、任务执行协同等 Agentic UI 能力",
|
|
5
5
|
"repository": "git@github.com:ant-design/agentic-ui.git",
|
|
6
6
|
"license": "MIT",
|
|
@@ -24,6 +24,7 @@
|
|
|
24
24
|
"lint:css": "stylelint \"{src,test}/**/*.{css,less}\"",
|
|
25
25
|
"lint:es": "eslint \"{src,test}/**/*.{js,jsx,ts,tsx}\"",
|
|
26
26
|
"prepare": "husky install && dumi setup",
|
|
27
|
+
"prepublishOnly": "npm run build && npm run test",
|
|
27
28
|
"prettier": "prettier --write \"{src,docs,test}/**/*.{js,jsx,ts,tsx,css,less,json,md}\"",
|
|
28
29
|
"preview": "pnpm dumi preview",
|
|
29
30
|
"report:demo": "node scripts/generateDemoReport.js",
|
|
@@ -87,6 +88,8 @@
|
|
|
87
88
|
"lodash": "^4.17.23",
|
|
88
89
|
"lodash-es": "^4.17.23",
|
|
89
90
|
"lottie-react": "^2.4.1",
|
|
91
|
+
"markdown-it": "^14.1.1",
|
|
92
|
+
"markdown-it-container": "^4.0.0",
|
|
90
93
|
"mermaid": "^11.12.2",
|
|
91
94
|
"mustache": "^4.2.0",
|
|
92
95
|
"nanoid": "^5.1.6",
|
|
@@ -104,6 +107,7 @@
|
|
|
104
107
|
"rehype-raw": "^7.0.0",
|
|
105
108
|
"rehype-stringify": "^10.0.1",
|
|
106
109
|
"remark": "^15.0.1",
|
|
110
|
+
"remark-directive": "^4.0.0",
|
|
107
111
|
"remark-frontmatter": "^5.0.0",
|
|
108
112
|
"remark-gfm": "^4.0.1",
|
|
109
113
|
"remark-html": "^16.0.1",
|