@ant-design/agentic-ui 2.21.0 → 2.23.0

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.
Files changed (32) hide show
  1. package/dist/Bubble/BubbleBeforeNode.js +9 -9
  2. package/dist/MarkdownEditor/editor/Editor.js +14 -3
  3. package/dist/MarkdownEditor/editor/elements/TagPopup/index.js +4 -4
  4. package/dist/MarkdownEditor/editor/elements/TagPopup/style.js +14 -12
  5. package/dist/MarkdownEditor/editor/parser/parse/applyContextPropsAndConfig.d.ts +8 -0
  6. package/dist/MarkdownEditor/editor/parser/parse/applyContextPropsAndConfig.js +58 -0
  7. package/dist/MarkdownEditor/editor/parser/parse/parseBlockElements.d.ts +67 -0
  8. package/dist/MarkdownEditor/editor/parser/parse/parseBlockElements.js +289 -0
  9. package/dist/MarkdownEditor/editor/parser/parse/parseCode.d.ts +2 -1
  10. package/dist/MarkdownEditor/editor/parser/parse/parseCode.js +15 -8
  11. package/dist/MarkdownEditor/editor/parser/parse/parseElements.d.ts +27 -0
  12. package/dist/MarkdownEditor/editor/parser/parse/parseElements.js +83 -0
  13. package/dist/MarkdownEditor/editor/parser/parse/parseEmptyLines.d.ts +9 -0
  14. package/dist/MarkdownEditor/editor/parser/parse/parseEmptyLines.js +60 -0
  15. package/dist/MarkdownEditor/editor/parser/parse/parseFootnote.d.ts +10 -0
  16. package/dist/MarkdownEditor/editor/parser/parse/parseFootnote.js +12 -0
  17. package/dist/MarkdownEditor/editor/parser/parse/parseHtml.d.ts +63 -0
  18. package/dist/MarkdownEditor/editor/parser/parse/parseHtml.js +781 -0
  19. package/dist/MarkdownEditor/editor/parser/parse/parseMath.d.ts +24 -0
  20. package/dist/MarkdownEditor/editor/parser/parse/parseMath.js +58 -0
  21. package/dist/MarkdownEditor/editor/parser/parse/parseMedia.d.ts +27 -0
  22. package/dist/MarkdownEditor/editor/parser/parse/parseMedia.js +127 -0
  23. package/dist/MarkdownEditor/editor/parser/parse/parseTable.js +36 -3
  24. package/dist/MarkdownEditor/editor/parser/parse/parseText.d.ts +26 -0
  25. package/dist/MarkdownEditor/editor/parser/parse/parseText.js +304 -0
  26. package/dist/MarkdownEditor/editor/parser/parserMarkdownToSlateNode.d.ts +3 -40
  27. package/dist/MarkdownEditor/editor/parser/parserMarkdownToSlateNode.js +189 -1856
  28. package/dist/MarkdownEditor/editor/parser/parserSlateNodeToMarkdown.js +131 -18
  29. package/dist/MarkdownEditor/editor/parser/remarkParse.js +24 -17
  30. package/dist/MarkdownEditor/editor/plugins/elements.js +1 -1
  31. package/dist/Plugins/code/components/CodeToolbar.js +3 -16
  32. package/package.json +1 -1
@@ -71,15 +71,15 @@ var canRenderThoughtChain = function(placement, role, thoughtChainEnabled) {
71
71
  if (thoughtChainEnabled === false) return false;
72
72
  return true;
73
73
  };
74
- /**
75
- * BubbleBeforeNode 组件
76
- *
77
- * 在聊天气泡之前渲染思维链或任务列表,显示AI的思考过程
78
- *
79
- * @example
80
- * ```tsx
81
- * <BubbleBeforeNode bubble={bubbleData} />
82
- * ```
74
+ /**
75
+ * BubbleBeforeNode 组件
76
+ *
77
+ * 在聊天气泡之前渲染思维链或任务列表,显示AI的思考过程
78
+ *
79
+ * @example
80
+ * ```tsx
81
+ * <BubbleBeforeNode bubble={bubbleData} />
82
+ * ```
83
83
  */ export var BubbleBeforeNode = function(param) {
84
84
  var bubble = param.bubble, className = param.className, style = param.style;
85
85
  var _context_thoughtChain, _originData_extra, _context_thoughtChain1, _context_thoughtChain2;
@@ -1165,12 +1165,23 @@ var defaultAllowedTypes = [
1165
1165
  return decorateList;
1166
1166
  }
1167
1167
  };
1168
+ // 在 SSR 环境下,如果有 initSchemaValue,直接使用它作为初始值
1169
+ // 因为 useEffect 在 SSR 环境下不会执行,initialNote 不会被调用
1170
+ var initialValue = useMemo(function() {
1171
+ var _props_initSchemaValue;
1172
+ if ((_props_initSchemaValue = props.initSchemaValue) === null || _props_initSchemaValue === void 0 ? void 0 : _props_initSchemaValue.length) {
1173
+ return props.initSchemaValue;
1174
+ }
1175
+ return [
1176
+ EditorUtils.p
1177
+ ];
1178
+ }, [
1179
+ props.initSchemaValue
1180
+ ]);
1168
1181
  var _obj;
1169
1182
  return wrapSSR(/*#__PURE__*/ React.createElement(React.Fragment, null, /*#__PURE__*/ React.createElement(Slate, {
1170
1183
  editor: markdownEditorRef.current,
1171
- initialValue: [
1172
- EditorUtils.p
1173
- ],
1184
+ initialValue: initialValue,
1174
1185
  onChange: onSlateChange
1175
1186
  }, /*#__PURE__*/ React.createElement(Editable, {
1176
1187
  decorate: decorateFn,
@@ -329,9 +329,9 @@ var createDefaultDom = function(domRef, baseCls, hashId, loading, selectedItems,
329
329
  ref: domRef,
330
330
  "data-tag-popup-input": true,
331
331
  "data-no-focus": true,
332
- className: classNames("".concat(baseCls, "-tag-popup-input"), hashId, (_obj = {
332
+ className: classNames("".concat(baseCls, "-input"), hashId, (_obj = {
333
333
  empty: isEmpty
334
- }, _define_property(_obj, "".concat(baseCls, "-tag-popup-input-loading"), loading), _define_property(_obj, "".concat(baseCls, "-tag-popup-input-has-arrow"), hasItems), _obj)),
334
+ }, _define_property(_obj, "".concat(baseCls, "-loading"), loading), _define_property(_obj, "".concat(baseCls, "-has-arrow"), hasItems), _obj)),
335
335
  onMouseEnter: function() {
336
336
  return handleMouseEnter(domRef);
337
337
  },
@@ -341,7 +341,7 @@ var createDefaultDom = function(domRef, baseCls, hashId, loading, selectedItems,
341
341
  title: placeholder,
342
342
  contentEditable: !hasItems ? undefined : false
343
343
  }, children, hasItems && /*#__PURE__*/ React.createElement(ChevronDown, {
344
- className: classNames("".concat(baseCls, "-tag-popup-input-arrow "), hashId, {
344
+ className: classNames("".concat(baseCls, "-arrow"), hashId, {
345
345
  empty: isEmpty,
346
346
  open: isOpen
347
347
  })
@@ -394,7 +394,7 @@ export var TagPopup = function(props) {
394
394
  var domRef = useRef(null);
395
395
  var suggestionConnext = useContext(SuggestionConnext);
396
396
  var antdContext = useContext(ConfigProvider.ConfigContext);
397
- var baseCls = antdContext === null || antdContext === void 0 ? void 0 : antdContext.getPrefixCls('agentic-md-editor-tag-popup-input');
397
+ var baseCls = antdContext === null || antdContext === void 0 ? void 0 : antdContext.getPrefixCls('agentic-tag-popup');
398
398
  var _useStyle = useStyle(baseCls), wrapSSR = _useStyle.wrapSSR, hashId = _useStyle.hashId;
399
399
  var currentNodePath = useRef();
400
400
  useEffect(function() {
@@ -79,21 +79,23 @@ var genStyle = function(token) {
79
79
  opacity: 0,
80
80
  overflow: 'hidden',
81
81
  userSelect: 'none'
82
- },
83
- '&-arrow': {
84
- position: 'absolute',
85
- right: '4px',
86
- top: '50%',
87
- transform: 'translateY(-50%)',
88
- color: 'var(--color-primary-text-disabled)',
89
- transition: 'transform 0.2s ease',
90
- '&.open': {
91
- transform: 'translateY(-50%) rotate(180deg)'
92
- }
93
82
  }
94
83
  },
95
- '&-tag-popup-input-has-arrow': {
84
+ '&-arrow': {
85
+ position: 'absolute',
86
+ right: '4px',
87
+ top: '50%',
88
+ transform: 'translateY(-50%)',
89
+ color: 'var(--color-primary-text-disabled)',
90
+ transition: 'transform 0.2s ease',
91
+ '&.open': {
92
+ transform: 'translateY(-50%) rotate(180deg)'
93
+ }
94
+ },
95
+ '&-has-arrow': {
96
96
  paddingRight: '12px'
97
+ },
98
+ '&-loading': {
97
99
  }
98
100
  });
99
101
  };
@@ -0,0 +1,8 @@
1
+ /**
2
+ * 应用上下文属性和配置到元素(纯函数版本)
3
+ * @param el - 目标元素或元素数组
4
+ * @param contextProps - 上下文属性对象
5
+ * @param config - 配置对象
6
+ * @returns 返回应用了属性和配置的新元素
7
+ */
8
+ export declare const applyContextPropsAndConfig: (el: any, contextProps: any, config: any) => any;
@@ -0,0 +1,58 @@
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
+ /**
30
+ * 应用上下文属性和配置到元素(纯函数版本)
31
+ * @param el - 目标元素或元素数组
32
+ * @param contextProps - 上下文属性对象
33
+ * @param config - 配置对象
34
+ * @returns 返回应用了属性和配置的新元素
35
+ */ export var applyContextPropsAndConfig = function(el, contextProps, config) {
36
+ var hasContextProps = Object.keys(contextProps || {}).length > 0;
37
+ var hasConfig = Object.keys(config || {}).length > 0;
38
+ if (Array.isArray(el)) {
39
+ return el.map(function(item) {
40
+ var result = _object_spread({}, item);
41
+ if (hasContextProps) {
42
+ result.contextProps = contextProps;
43
+ }
44
+ if (hasConfig && !item.otherProps) {
45
+ result.otherProps = config;
46
+ }
47
+ return result;
48
+ });
49
+ }
50
+ var result = _object_spread({}, el);
51
+ if (hasContextProps) {
52
+ result.contextProps = contextProps;
53
+ }
54
+ if (hasConfig && !el.otherProps) {
55
+ result.otherProps = config;
56
+ }
57
+ return result;
58
+ };
@@ -0,0 +1,67 @@
1
+ import { CustomLeaf, Elements } from '../../../el';
2
+ import type { ParserMarkdownToSlateNodeConfig } from '../parserMarkdownToSlateNode';
3
+ type ParseNodesFn = (nodes: any[], top: boolean, parent: any) => (Elements | any)[];
4
+ /**
5
+ * 处理标题节点
6
+ */
7
+ export declare const handleHeading: (currentElement: any, parseNodes: ParseNodesFn) => {
8
+ type: string;
9
+ level: any;
10
+ children: any[];
11
+ };
12
+ /**
13
+ * 处理列表节点
14
+ */
15
+ export declare const handleList: (currentElement: any, parseNodes: ParseNodesFn) => any;
16
+ /**
17
+ * 处理脚注定义节点
18
+ */
19
+ export declare const handleFootnoteDefinition: (currentElement: any, parseNodes: ParseNodesFn) => {
20
+ value: any;
21
+ url: any;
22
+ type: string;
23
+ identifier: any;
24
+ children: any[];
25
+ };
26
+ /**
27
+ * 处理列表项节点
28
+ */
29
+ export declare const handleListItem: (currentElement: any, parseNodes: ParseNodesFn) => {
30
+ type: string;
31
+ checked: any;
32
+ children: any;
33
+ mentions: {
34
+ avatar: any;
35
+ name: any;
36
+ id: string | undefined;
37
+ }[] | undefined;
38
+ };
39
+ /**
40
+ * 处理段落子节点
41
+ */
42
+ export declare const processParagraphChildren: (currentElement: any, parseNodes: ParseNodesFn) => ({
43
+ text: string;
44
+ } | {
45
+ type: string;
46
+ children: any[];
47
+ })[];
48
+ /**
49
+ * 处理段落节点
50
+ */
51
+ export declare const handleParagraph: (currentElement: any, config: any, parseNodes: ParseNodesFn) => any;
52
+ /**
53
+ * 处理引用块节点
54
+ */
55
+ export declare const handleBlockquote: (currentElement: any, parseNodes: ParseNodesFn) => {
56
+ type: string;
57
+ children: any[];
58
+ };
59
+ /**
60
+ * 应用内联格式到叶子节点
61
+ */
62
+ export declare const applyInlineFormatting: (leaf: CustomLeaf, currentElement: any, config?: ParserMarkdownToSlateNodeConfig) => CustomLeaf;
63
+ /**
64
+ * 处理文本和内联元素节点
65
+ */
66
+ export declare const handleTextAndInlineElements: (currentElement: any, htmlTag: any[], parseNodes: ParseNodesFn, config?: ParserMarkdownToSlateNodeConfig) => any;
67
+ export {};
@@ -0,0 +1,289 @@
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
+ }
53
+ import { EditorUtils } from "../../utils";
54
+ import { createMediaNodeFromElement, decodeURIComponentUrl, findImageElement } from "./parseHtml";
55
+ import { handleAttachmentLink, handleLinkCard } from "./parseMedia";
56
+ import { handleTextAndInlineElementsPure, setFinishedProp } from "./parseText";
57
+ /**
58
+ * 处理标题节点
59
+ */ export var handleHeading = function(currentElement, parseNodes) {
60
+ var _currentElement_children;
61
+ return {
62
+ type: 'head',
63
+ level: currentElement.depth,
64
+ children: ((_currentElement_children = currentElement.children) === null || _currentElement_children === void 0 ? void 0 : _currentElement_children.length) ? parseNodes(currentElement.children, false, currentElement) : [
65
+ {
66
+ text: ''
67
+ }
68
+ ]
69
+ };
70
+ };
71
+ /**
72
+ * 处理列表节点
73
+ */ export var handleList = function(currentElement, parseNodes) {
74
+ var _el_children;
75
+ var el = {
76
+ type: 'list',
77
+ order: currentElement.ordered,
78
+ start: currentElement.start,
79
+ finished: currentElement.finished,
80
+ children: parseNodes(currentElement.children, false, currentElement)
81
+ };
82
+ el.task = (_el_children = el.children) === null || _el_children === void 0 ? void 0 : _el_children.some(function(s) {
83
+ return typeof s.checked === 'boolean';
84
+ });
85
+ return el;
86
+ };
87
+ /**
88
+ * 处理脚注定义节点
89
+ */ export var handleFootnoteDefinition = function(currentElement, parseNodes) {
90
+ var _parseNodes, _linkNode_children;
91
+ var linkNode = (_parseNodes = parseNodes(currentElement.children, false, currentElement)) === null || _parseNodes === void 0 ? void 0 : _parseNodes.at(0);
92
+ var cellNode = linkNode === null || linkNode === void 0 ? void 0 : (_linkNode_children = linkNode.children) === null || _linkNode_children === void 0 ? void 0 : _linkNode_children.at(0);
93
+ return {
94
+ value: cellNode === null || cellNode === void 0 ? void 0 : cellNode.text,
95
+ url: cellNode === null || cellNode === void 0 ? void 0 : cellNode.url,
96
+ type: 'footnoteDefinition',
97
+ identifier: currentElement.identifier,
98
+ children: [
99
+ cellNode
100
+ ]
101
+ };
102
+ };
103
+ /**
104
+ * 处理列表项节点
105
+ */ export var handleListItem = function(currentElement, parseNodes) {
106
+ var _currentElement_children, _currentElement_children__children_, _currentElement_children__children, _currentElement_children_, _currentElement_children1, _currentElement_children__children1, _currentElement_children_1, _currentElement_children2;
107
+ var children = ((_currentElement_children = currentElement.children) === null || _currentElement_children === void 0 ? void 0 : _currentElement_children.length) ? parseNodes(currentElement.children, false, currentElement) : [
108
+ {
109
+ type: 'paragraph',
110
+ children: [
111
+ {
112
+ text: ''
113
+ }
114
+ ]
115
+ }
116
+ ];
117
+ var mentions = undefined;
118
+ if (((_currentElement_children1 = currentElement.children) === null || _currentElement_children1 === void 0 ? void 0 : (_currentElement_children_ = _currentElement_children1[0]) === null || _currentElement_children_ === void 0 ? void 0 : (_currentElement_children__children = _currentElement_children_.children) === null || _currentElement_children__children === void 0 ? void 0 : (_currentElement_children__children_ = _currentElement_children__children[0]) === null || _currentElement_children__children_ === void 0 ? void 0 : _currentElement_children__children_.type) === 'link' && ((_currentElement_children2 = currentElement.children) === null || _currentElement_children2 === void 0 ? void 0 : (_currentElement_children_1 = _currentElement_children2[0]) === null || _currentElement_children_1 === void 0 ? void 0 : (_currentElement_children__children1 = _currentElement_children_1.children) === null || _currentElement_children__children1 === void 0 ? void 0 : _currentElement_children__children1.length) > 1) {
119
+ var _children__children, _children_;
120
+ var item = children === null || children === void 0 ? void 0 : (_children_ = children[0]) === null || _children_ === void 0 ? void 0 : (_children__children = _children_.children) === null || _children__children === void 0 ? void 0 : _children__children[0];
121
+ var label = item === null || item === void 0 ? void 0 : item.text;
122
+ if (label) {
123
+ var _item_url, _children__children1, _children_1;
124
+ mentions = [
125
+ {
126
+ avatar: item === null || item === void 0 ? void 0 : item.url,
127
+ name: label,
128
+ id: new URLSearchParams('?' + (item === null || item === void 0 ? void 0 : (_item_url = item.url) === null || _item_url === void 0 ? void 0 : _item_url.split('?')[1])).get('id') || undefined
129
+ }
130
+ ];
131
+ children === null || children === void 0 ? true : (_children_1 = children[0]) === null || _children_1 === void 0 ? true : (_children__children1 = _children_1.children) === null || _children__children1 === void 0 ? true : delete _children__children1[0];
132
+ }
133
+ }
134
+ return {
135
+ type: 'list-item',
136
+ checked: currentElement.checked,
137
+ children: children,
138
+ mentions: mentions
139
+ };
140
+ };
141
+ /**
142
+ * 处理段落子节点
143
+ */ export var processParagraphChildren = function(currentElement, parseNodes) {
144
+ var elements = [];
145
+ var textNodes = [];
146
+ var _iteratorNormalCompletion = true, _didIteratorError = false, _iteratorError = undefined;
147
+ try {
148
+ for(var _iterator = (currentElement.children || [])[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true){
149
+ var currentChild = _step.value;
150
+ if (currentChild.type === 'image') {
151
+ // 将累积的文本节点生成段落
152
+ if (textNodes.length) {
153
+ elements.push({
154
+ type: 'paragraph',
155
+ children: parseNodes(textNodes, false, currentElement)
156
+ });
157
+ textNodes = [];
158
+ }
159
+ // 添加图片节点
160
+ elements.push(EditorUtils.createMediaNode(decodeURIComponentUrl(currentChild === null || currentChild === void 0 ? void 0 : currentChild.url), 'image', {
161
+ alt: currentChild.alt,
162
+ finished: currentChild.finished
163
+ }));
164
+ } else if (currentChild.type === 'html') {
165
+ // 跳过媒体标签的结束标签
166
+ if (currentChild.value.match(/^<\/(img|video|iframe)>/)) {
167
+ continue;
168
+ }
169
+ var mediaElement = findImageElement(currentChild.value);
170
+ if (mediaElement) {
171
+ var node = createMediaNodeFromElement(mediaElement);
172
+ if (node) {
173
+ elements.push(node);
174
+ }
175
+ } else {
176
+ textNodes.push({
177
+ type: 'html',
178
+ value: currentChild.value
179
+ });
180
+ }
181
+ } else {
182
+ textNodes.push(currentChild);
183
+ }
184
+ }
185
+ } catch (err) {
186
+ _didIteratorError = true;
187
+ _iteratorError = err;
188
+ } finally{
189
+ try {
190
+ if (!_iteratorNormalCompletion && _iterator.return != null) {
191
+ _iterator.return();
192
+ }
193
+ } finally{
194
+ if (_didIteratorError) {
195
+ throw _iteratorError;
196
+ }
197
+ }
198
+ }
199
+ // 处理剩余的文本节点
200
+ if (textNodes.length) {
201
+ elements.push({
202
+ type: 'paragraph',
203
+ children: parseNodes(textNodes, false, currentElement)
204
+ });
205
+ }
206
+ return elements;
207
+ };
208
+ /**
209
+ * 处理段落节点
210
+ */ export var handleParagraph = function(currentElement, config, parseNodes) {
211
+ var _currentElement_children, _currentElement_children_at, _currentElement_children1;
212
+ // 检查是否是附件链接
213
+ if (((_currentElement_children = currentElement.children) === null || _currentElement_children === void 0 ? void 0 : _currentElement_children[0].type) === 'html' && currentElement.children[0].value.startsWith('<a')) {
214
+ var attachNode = handleAttachmentLink(currentElement);
215
+ if (attachNode) return attachNode;
216
+ }
217
+ // 检查是否是链接卡片
218
+ if ((currentElement === null || currentElement === void 0 ? void 0 : (_currentElement_children1 = currentElement.children) === null || _currentElement_children1 === void 0 ? void 0 : (_currentElement_children_at = _currentElement_children1.at(0)) === null || _currentElement_children_at === void 0 ? void 0 : _currentElement_children_at.type) === 'link' && config.type === 'card') {
219
+ return handleLinkCard(currentElement, config);
220
+ }
221
+ // 处理混合内容段落
222
+ return processParagraphChildren(currentElement, parseNodes);
223
+ };
224
+ /**
225
+ * 处理引用块节点
226
+ */ export var handleBlockquote = function(currentElement, parseNodes) {
227
+ var _currentElement_children;
228
+ return {
229
+ type: 'blockquote',
230
+ children: ((_currentElement_children = currentElement.children) === null || _currentElement_children === void 0 ? void 0 : _currentElement_children.length) ? parseNodes(currentElement.children, false, currentElement) : [
231
+ {
232
+ type: 'paragraph',
233
+ children: [
234
+ {
235
+ text: ''
236
+ }
237
+ ]
238
+ }
239
+ ]
240
+ };
241
+ };
242
+ /**
243
+ * 应用内联格式到叶子节点
244
+ */ export var applyInlineFormatting = function(leaf, currentElement, config) {
245
+ var result = _object_spread({}, leaf);
246
+ var elementType = currentElement.type;
247
+ var finished = currentElement.finished;
248
+ if (elementType === 'strong') {
249
+ return setFinishedProp(_object_spread_props(_object_spread({}, result), {
250
+ bold: true
251
+ }), finished);
252
+ }
253
+ if (elementType === 'emphasis') {
254
+ return setFinishedProp(_object_spread_props(_object_spread({}, result), {
255
+ italic: true
256
+ }), finished);
257
+ }
258
+ if (elementType === 'delete') {
259
+ result.strikethrough = true;
260
+ return result;
261
+ }
262
+ if (elementType === 'link') {
263
+ try {
264
+ result.url = currentElement === null || currentElement === void 0 ? void 0 : currentElement.url;
265
+ var shouldOpenInNewTab = (config === null || config === void 0 ? void 0 : config.openLinksInNewTab) || finished === false;
266
+ if (shouldOpenInNewTab) {
267
+ if (!result.otherProps) {
268
+ result.otherProps = {};
269
+ }
270
+ result.otherProps.target = '_blank';
271
+ result.otherProps.rel = 'noopener noreferrer';
272
+ if (finished === false) {
273
+ result.otherProps.finished = finished;
274
+ }
275
+ }
276
+ } catch (e) {
277
+ result.url = currentElement === null || currentElement === void 0 ? void 0 : currentElement.url;
278
+ }
279
+ return result;
280
+ }
281
+ return result;
282
+ };
283
+ /**
284
+ * 处理文本和内联元素节点
285
+ */ export var handleTextAndInlineElements = function(currentElement, htmlTag, parseNodes, config) {
286
+ return handleTextAndInlineElementsPure(currentElement, htmlTag, function(leaf, element) {
287
+ return applyInlineFormatting(leaf, element, config);
288
+ }, parseNodes);
289
+ };
@@ -13,9 +13,10 @@ export type LanguageHandler = (element: CodeElement, value: string) => CodeEleme
13
13
  /**
14
14
  * 处理代码块节点
15
15
  * @param currentElement - 当前处理的代码块元素,包含语言和内容
16
+ * @param config - 可选的配置对象,可能包含从 HTML 注释中解析的属性
16
17
  * @returns 返回格式化的代码块节点对象,根据语言类型进行特殊处理
17
18
  */
18
- export declare const handleCode: (currentElement: any) => CodeElement;
19
+ export declare const handleCode: (currentElement: any, config?: any) => CodeElement;
19
20
  /**
20
21
  * 处理YAML节点
21
22
  * @param currentElement - 当前处理的YAML元素
@@ -101,11 +101,16 @@ var ENDING_NEWLINE = /\n$/;
101
101
  /**
102
102
  * 处理代码块节点
103
103
  * @param currentElement - 当前处理的代码块元素,包含语言和内容
104
+ * @param config - 可选的配置对象,可能包含从 HTML 注释中解析的属性
104
105
  * @returns 返回格式化的代码块节点对象,根据语言类型进行特殊处理
105
- */ export var handleCode = function(currentElement) {
106
- var _match, _currentElement_otherProps, _currentElement_value_trim;
106
+ */ export var handleCode = function(currentElement, config) {
107
+ var _effectiveLang_match, _currentElement_otherProps, _currentElement_value_trim;
107
108
  var rawValue = currentElement.value || '';
108
- var langString = ((_match = (currentElement.lang || '').match(NOT_SPACE_START)) === null || _match === void 0 ? void 0 : _match[0]) || '';
109
+ // 如果 config 中包含 data-language,优先使用它来恢复语言类型
110
+ var configLanguage = config === null || config === void 0 ? void 0 : config['data-language'];
111
+ // 保持原有的行为:如果没有语言,应该使用 null 而不是空字符串
112
+ var effectiveLang = configLanguage || currentElement.lang || null;
113
+ var langString = effectiveLang ? ((_effectiveLang_match = effectiveLang.match(NOT_SPACE_START)) === null || _effectiveLang_match === void 0 ? void 0 : _effectiveLang_match[0]) || '' : '';
109
114
  var code = "".concat(rawValue.replace(ENDING_NEWLINE, ''), "\n");
110
115
  // 检查代码块是否完整
111
116
  // 如果是缩进代码块,认为是完整的(因为没有结束标记)
@@ -144,7 +149,7 @@ var ENDING_NEWLINE = /\n$/;
144
149
  }
145
150
  var baseCodeElement = {
146
151
  type: 'code',
147
- language: currentElement.lang === 'apaasify' ? 'apaasify' : currentElement.lang,
152
+ language: effectiveLang === 'apaasify' ? 'apaasify' : effectiveLang || null,
148
153
  render: currentElement.meta === 'render',
149
154
  value: currentElement.value,
150
155
  isConfig: currentElement === null || currentElement === void 0 ? void 0 : (_currentElement_value_trim = currentElement.value.trim()) === null || _currentElement_value_trim === void 0 ? void 0 : _currentElement_value_trim.startsWith('<!--'),
@@ -156,14 +161,16 @@ var ENDING_NEWLINE = /\n$/;
156
161
  // 添加流式状态支持
157
162
  otherProps: otherProps
158
163
  };
159
- var handler = LANGUAGE_HANDLERS[currentElement.lang];
164
+ var handler = LANGUAGE_HANDLERS[effectiveLang];
160
165
  var result = handler ? handler(baseCodeElement, currentElement.value) : baseCodeElement;
161
- // 确保 otherProps 被保留
166
+ // 确保 otherProps 被保留,并合并 config 中的属性
162
167
  var resultWithProps = result;
163
168
  if (baseCodeElement.otherProps && !resultWithProps.otherProps) {
164
- resultWithProps.otherProps = baseCodeElement.otherProps;
169
+ resultWithProps.otherProps = _object_spread({}, baseCodeElement.otherProps, config || {});
165
170
  } else if (baseCodeElement.otherProps && resultWithProps.otherProps) {
166
- resultWithProps.otherProps = _object_spread({}, resultWithProps.otherProps, baseCodeElement.otherProps);
171
+ resultWithProps.otherProps = _object_spread({}, resultWithProps.otherProps, baseCodeElement.otherProps, config || {});
172
+ } else if (config && Object.keys(config).length > 0) {
173
+ resultWithProps.otherProps = _object_spread({}, resultWithProps.otherProps || {}, config);
167
174
  }
168
175
  return resultWithProps;
169
176
  };
@@ -0,0 +1,27 @@
1
+ /**
2
+ * 处理内联代码节点
3
+ * @param currentElement - 当前处理的内联代码元素
4
+ * @returns 返回格式化的内联代码节点对象,支持占位符和初始值
5
+ */
6
+ export declare const handleInlineCode: (currentElement: any) => any;
7
+ /**
8
+ * 处理分割线节点
9
+ * @returns 返回格式化的分割线节点对象
10
+ */
11
+ export declare const handleThematicBreak: () => {
12
+ type: string;
13
+ children: {
14
+ text: string;
15
+ }[];
16
+ };
17
+ /**
18
+ * 处理定义节点
19
+ * @param currentElement - 当前处理的定义元素,包含标签和URL
20
+ * @returns 返回格式化的定义段落节点对象
21
+ */
22
+ export declare const handleDefinition: (currentElement: any) => {
23
+ type: string;
24
+ children: {
25
+ text: string;
26
+ }[];
27
+ };