@ant-design/agentic-ui 2.29.54 → 2.29.56

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.
@@ -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
- return /*#__PURE__*/ React.createElement("blockquote", _object_spread_props(_object_spread({
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
- }), props.children);
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
- htmlContent = _state.sent();
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
- String(htmlContent).split(JINJA_DOLLAR_PLACEHOLDER).join('$')
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
- return String(file).split(JINJA_DOLLAR_PLACEHOLDER).join('$');
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
@@ -250,8 +250,9 @@ var MarkdownInputFieldComponent = function MarkdownInputFieldComponent(_0) {
250
250
  // Refs 管理
251
251
  var _useMarkdownInputFieldRefs = useMarkdownInputFieldRefs({
252
252
  inputRef: props.inputRef,
253
- value: props.value
254
- }, value), markdownEditorRef = _useMarkdownInputFieldRefs.markdownEditorRef, quickActionsRef = _useMarkdownInputFieldRefs.quickActionsRef, actionsRef = _useMarkdownInputFieldRefs.actionsRef, isSendingRef = _useMarkdownInputFieldRefs.isSendingRef;
253
+ value: props.value,
254
+ setValue: setValue
255
+ }), markdownEditorRef = _useMarkdownInputFieldRefs.markdownEditorRef, quickActionsRef = _useMarkdownInputFieldRefs.quickActionsRef, actionsRef = _useMarkdownInputFieldRefs.actionsRef, isSendingRef = _useMarkdownInputFieldRefs.isSendingRef;
255
256
  // 文件上传管理
256
257
  var _useFileUploadManager = useFileUploadManager({
257
258
  attachment: attachment,
@@ -1,13 +1,17 @@
1
1
  /// <reference types="react" />
2
2
  import type { MarkdownEditorInstance } from '../../MarkdownEditor';
3
3
  import type { MarkdownInputFieldProps } from '../types/MarkdownInputFieldProps';
4
+ interface UseMarkdownInputFieldRefsParams extends Pick<MarkdownInputFieldProps, 'inputRef' | 'value'> {
5
+ setValue: (value: string) => void;
6
+ }
4
7
  /**
5
8
  * Refs 管理 Hook
6
9
  * 管理组件中所有的 refs 和相关逻辑
7
10
  */
8
- export declare const useMarkdownInputFieldRefs: (props: Pick<MarkdownInputFieldProps, 'inputRef' | 'value'>, value: string) => {
11
+ export declare const useMarkdownInputFieldRefs: (props: UseMarkdownInputFieldRefsParams) => {
9
12
  markdownEditorRef: import("react").MutableRefObject<MarkdownEditorInstance | undefined>;
10
13
  quickActionsRef: import("react").RefObject<HTMLDivElement>;
11
14
  actionsRef: import("react").RefObject<HTMLDivElement>;
12
15
  isSendingRef: import("react").MutableRefObject<boolean>;
13
16
  };
17
+ export {};
@@ -1,24 +1,98 @@
1
+ function _define_property(obj, key, value) {
2
+ if (key in obj) {
3
+ Object.defineProperty(obj, key, {
4
+ value: value,
5
+ enumerable: true,
6
+ configurable: true,
7
+ writable: true
8
+ });
9
+ } else {
10
+ obj[key] = value;
11
+ }
12
+ return obj;
13
+ }
14
+ function _object_spread(target) {
15
+ for(var i = 1; i < arguments.length; i++){
16
+ var source = arguments[i] != null ? arguments[i] : {};
17
+ var ownKeys = Object.keys(source);
18
+ if (typeof Object.getOwnPropertySymbols === "function") {
19
+ ownKeys = ownKeys.concat(Object.getOwnPropertySymbols(source).filter(function(sym) {
20
+ return Object.getOwnPropertyDescriptor(source, sym).enumerable;
21
+ }));
22
+ }
23
+ ownKeys.forEach(function(key) {
24
+ _define_property(target, key, source[key]);
25
+ });
26
+ }
27
+ return target;
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
+ }
1
53
  import { useEffect, useImperativeHandle, useRef } from "react";
2
54
  /**
3
55
  * Refs 管理 Hook
4
56
  * 管理组件中所有的 refs 和相关逻辑
5
- */ export var useMarkdownInputFieldRefs = function useMarkdownInputFieldRefs(props, value) {
57
+ */ export var useMarkdownInputFieldRefs = function useMarkdownInputFieldRefs(props) {
6
58
  var markdownEditorRef = useRef();
7
59
  var quickActionsRef = useRef(null);
8
60
  var actionsRef = useRef(null);
9
61
  var isSendingRef = useRef(false);
10
62
  // 同步外部 value 到编辑器
11
63
  useEffect(function() {
64
+ var _props_value;
12
65
  var _markdownEditorRef_current_store, _markdownEditorRef_current;
13
66
  if (!markdownEditorRef.current) return;
14
- (_markdownEditorRef_current = markdownEditorRef.current) === null || _markdownEditorRef_current === void 0 ? void 0 : (_markdownEditorRef_current_store = _markdownEditorRef_current.store) === null || _markdownEditorRef_current_store === void 0 ? void 0 : _markdownEditorRef_current_store.setMDContent(value);
67
+ (_markdownEditorRef_current = markdownEditorRef.current) === null || _markdownEditorRef_current === void 0 ? void 0 : (_markdownEditorRef_current_store = _markdownEditorRef_current.store) === null || _markdownEditorRef_current_store === void 0 ? void 0 : _markdownEditorRef_current_store.setMDContent((_props_value = props.value) !== null && _props_value !== void 0 ? _props_value : '');
15
68
  }, [
16
69
  props.value
17
70
  ]);
18
- // 通过 ref 暴露编辑器实例
71
+ // 通过 ref 暴露编辑器实例,包装 store.setMDContent 以同步 value 状态,确保发送按钮正确响应
19
72
  useImperativeHandle(props.inputRef, function() {
20
- return markdownEditorRef.current;
21
- });
73
+ var editor = markdownEditorRef.current;
74
+ var syncValueAndSetMDContent = function syncValueAndSetMDContent(md, plugins, options) {
75
+ var _editor_store;
76
+ if (md !== undefined) {
77
+ props.setValue(md);
78
+ }
79
+ return editor === null || editor === void 0 ? void 0 : (_editor_store = editor.store) === null || _editor_store === void 0 ? void 0 : _editor_store.setMDContent(md, plugins, options);
80
+ };
81
+ if (!editor) {
82
+ return {
83
+ store: {
84
+ setMDContent: syncValueAndSetMDContent
85
+ }
86
+ };
87
+ }
88
+ return _object_spread_props(_object_spread({}, editor), {
89
+ store: _object_spread_props(_object_spread({}, editor.store), {
90
+ setMDContent: syncValueAndSetMDContent
91
+ })
92
+ });
93
+ }, [
94
+ props.setValue
95
+ ]);
22
96
  return {
23
97
  markdownEditorRef: markdownEditorRef,
24
98
  quickActionsRef: quickActionsRef,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ant-design/agentic-ui",
3
- "version": "2.29.54",
3
+ "version": "2.29.56",
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",