@ant-design/agentic-ui 2.21.0 → 2.22.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 (28) hide show
  1. package/dist/MarkdownEditor/editor/elements/TagPopup/index.js +4 -4
  2. package/dist/MarkdownEditor/editor/elements/TagPopup/style.js +14 -12
  3. package/dist/MarkdownEditor/editor/parser/parse/applyContextPropsAndConfig.d.ts +8 -0
  4. package/dist/MarkdownEditor/editor/parser/parse/applyContextPropsAndConfig.js +58 -0
  5. package/dist/MarkdownEditor/editor/parser/parse/parseBlockElements.d.ts +67 -0
  6. package/dist/MarkdownEditor/editor/parser/parse/parseBlockElements.js +289 -0
  7. package/dist/MarkdownEditor/editor/parser/parse/parseElements.d.ts +27 -0
  8. package/dist/MarkdownEditor/editor/parser/parse/parseElements.js +83 -0
  9. package/dist/MarkdownEditor/editor/parser/parse/parseEmptyLines.d.ts +9 -0
  10. package/dist/MarkdownEditor/editor/parser/parse/parseEmptyLines.js +60 -0
  11. package/dist/MarkdownEditor/editor/parser/parse/parseFootnote.d.ts +10 -0
  12. package/dist/MarkdownEditor/editor/parser/parse/parseFootnote.js +12 -0
  13. package/dist/MarkdownEditor/editor/parser/parse/parseHtml.d.ts +63 -0
  14. package/dist/MarkdownEditor/editor/parser/parse/parseHtml.js +759 -0
  15. package/dist/MarkdownEditor/editor/parser/parse/parseMath.d.ts +24 -0
  16. package/dist/MarkdownEditor/editor/parser/parse/parseMath.js +58 -0
  17. package/dist/MarkdownEditor/editor/parser/parse/parseMedia.d.ts +27 -0
  18. package/dist/MarkdownEditor/editor/parser/parse/parseMedia.js +127 -0
  19. package/dist/MarkdownEditor/editor/parser/parse/parseTable.js +36 -3
  20. package/dist/MarkdownEditor/editor/parser/parse/parseText.d.ts +26 -0
  21. package/dist/MarkdownEditor/editor/parser/parse/parseText.js +304 -0
  22. package/dist/MarkdownEditor/editor/parser/parserMarkdownToSlateNode.d.ts +3 -40
  23. package/dist/MarkdownEditor/editor/parser/parserMarkdownToSlateNode.js +128 -1855
  24. package/dist/MarkdownEditor/editor/parser/parserSlateNodeToMarkdown.js +131 -18
  25. package/dist/MarkdownEditor/editor/parser/remarkParse.js +24 -17
  26. package/dist/MarkdownEditor/editor/plugins/elements.js +1 -1
  27. package/dist/Plugins/code/components/CodeToolbar.js +3 -16
  28. package/package.json +1 -1
@@ -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
+ };
@@ -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
+ };
@@ -0,0 +1,83 @@
1
+ /**
2
+ * 处理内联代码节点
3
+ * @param currentElement - 当前处理的内联代码元素
4
+ * @returns 返回格式化的内联代码节点对象,支持占位符和初始值
5
+ */ export var handleInlineCode = function(currentElement) {
6
+ var _currentElement_value, _currentElement_value1;
7
+ var hasPlaceHolder = (_currentElement_value = currentElement.value) === null || _currentElement_value === void 0 ? void 0 : _currentElement_value.match(/\$\{(.*?)\}/);
8
+ var values = undefined;
9
+ if (hasPlaceHolder) {
10
+ // 使用逗号分割多个键值对,例如:placeholder:目标场景,initialValue:已选择
11
+ var content = hasPlaceHolder[1];
12
+ values = {};
13
+ // 匹配 key:value 格式,支持逗号分隔
14
+ var keyValuePattern = /(\w+):([^,]+)/g;
15
+ var match;
16
+ while((match = keyValuePattern.exec(content)) !== null){
17
+ var key = match[1];
18
+ var value = match[2];
19
+ if (key && value !== undefined && value !== null) {
20
+ values[key] = value;
21
+ }
22
+ }
23
+ }
24
+ var isTag = (_currentElement_value1 = currentElement.value) === null || _currentElement_value1 === void 0 ? void 0 : _currentElement_value1.startsWith('${');
25
+ var result = {
26
+ code: true,
27
+ tag: isTag ? true : false
28
+ };
29
+ // 优先使用 initialValue,其次使用 placeholder,最后使用原始值
30
+ if (values === null || values === void 0 ? void 0 : values.initialValue) {
31
+ result.text = values.initialValue || ' ';
32
+ }
33
+ if (!result.text && (values === null || values === void 0 ? void 0 : values.placeholder)) {
34
+ // 当有 placeholder 时,text 设置为空格,避免空字符串导致 tag 被移除
35
+ result.text = ' ';
36
+ }
37
+ if (!result.text) {
38
+ // 只有当不是 ${ 开头的占位符时,才使用原始值
39
+ if (!isTag) {
40
+ result.text = currentElement.value;
41
+ } else {
42
+ // 如果是 ${ 开头但没有匹配到值,使用空格避免空字符串
43
+ result.text = ' ';
44
+ }
45
+ }
46
+ // 设置 placeholder 和 initialValue
47
+ // 如果是 tag 且值存在,设置实际值;否则设置为 undefined(符合测试期望)
48
+ if (isTag) {
49
+ result.placeholder = values === null || values === void 0 ? void 0 : values.placeholder;
50
+ result.initialValue = values === null || values === void 0 ? void 0 : values.initialValue;
51
+ } else {
52
+ result.placeholder = undefined;
53
+ result.initialValue = undefined;
54
+ }
55
+ return result;
56
+ };
57
+ /**
58
+ * 处理分割线节点
59
+ * @returns 返回格式化的分割线节点对象
60
+ */ export var handleThematicBreak = function() {
61
+ return {
62
+ type: 'hr',
63
+ children: [
64
+ {
65
+ text: ''
66
+ }
67
+ ]
68
+ };
69
+ };
70
+ /**
71
+ * 处理定义节点
72
+ * @param currentElement - 当前处理的定义元素,包含标签和URL
73
+ * @returns 返回格式化的定义段落节点对象
74
+ */ export var handleDefinition = function(currentElement) {
75
+ return {
76
+ type: 'paragraph',
77
+ children: [
78
+ {
79
+ text: "[".concat(currentElement.label, "]: ") + (currentElement.url ? "".concat(currentElement.url) : '')
80
+ }
81
+ ]
82
+ };
83
+ };
@@ -0,0 +1,9 @@
1
+ /**
2
+ * 根据行间距添加空行元素(纯函数版本)
3
+ * @param els - 目标元素数组
4
+ * @param preNode - 前一个节点
5
+ * @param currentElement - 当前处理的元素
6
+ * @param top - 是否为顶级解析
7
+ * @returns 返回添加了空行元素的新数组
8
+ */
9
+ export declare const addEmptyLinesIfNeeded: (els: any[], preNode: any, currentElement: any, top: boolean) => any[];
@@ -0,0 +1,60 @@
1
+ // 常量定义
2
+ function _array_like_to_array(arr, len) {
3
+ if (len == null || len > arr.length) len = arr.length;
4
+ for(var i = 0, arr2 = new Array(len); i < len; i++)arr2[i] = arr[i];
5
+ return arr2;
6
+ }
7
+ function _array_without_holes(arr) {
8
+ if (Array.isArray(arr)) return _array_like_to_array(arr);
9
+ }
10
+ function _iterable_to_array(iter) {
11
+ if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter);
12
+ }
13
+ function _non_iterable_spread() {
14
+ throw new TypeError("Invalid attempt to spread non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
15
+ }
16
+ function _to_consumable_array(arr) {
17
+ return _array_without_holes(arr) || _iterable_to_array(arr) || _unsupported_iterable_to_array(arr) || _non_iterable_spread();
18
+ }
19
+ function _unsupported_iterable_to_array(o, minLen) {
20
+ if (!o) return;
21
+ if (typeof o === "string") return _array_like_to_array(o, minLen);
22
+ var n = Object.prototype.toString.call(o).slice(8, -1);
23
+ if (n === "Object" && o.constructor) n = o.constructor.name;
24
+ if (n === "Map" || n === "Set") return Array.from(n);
25
+ if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _array_like_to_array(o, minLen);
26
+ }
27
+ var EMPTY_LINE_DISTANCE_THRESHOLD = 4; // 两个元素之间的行距阈值
28
+ var EMPTY_LINE_CALCULATION_OFFSET = 2; // 计算空行数量时的偏移量
29
+ var EMPTY_LINE_DIVISOR = 2; // 计算空行数量的除数
30
+ /**
31
+ * 根据行间距添加空行元素(纯函数版本)
32
+ * @param els - 目标元素数组
33
+ * @param preNode - 前一个节点
34
+ * @param currentElement - 当前处理的元素
35
+ * @param top - 是否为顶级解析
36
+ * @returns 返回添加了空行元素的新数组
37
+ */ export var addEmptyLinesIfNeeded = function(els, preNode, currentElement, top) {
38
+ var _currentElement_position, _preNode_position;
39
+ if (!preNode || !top) {
40
+ return els;
41
+ }
42
+ var distance = (((_currentElement_position = currentElement.position) === null || _currentElement_position === void 0 ? void 0 : _currentElement_position.start.line) || 0) - (((_preNode_position = preNode.position) === null || _preNode_position === void 0 ? void 0 : _preNode_position.end.line) || 0);
43
+ if (distance < EMPTY_LINE_DISTANCE_THRESHOLD) {
44
+ return els;
45
+ }
46
+ var lines = Math.floor((distance - EMPTY_LINE_CALCULATION_OFFSET) / EMPTY_LINE_DIVISOR);
47
+ var emptyLines = Array.from({
48
+ length: lines
49
+ }, function() {
50
+ return {
51
+ type: 'paragraph',
52
+ children: [
53
+ {
54
+ text: ''
55
+ }
56
+ ]
57
+ };
58
+ });
59
+ return _to_consumable_array(els).concat(_to_consumable_array(emptyLines));
60
+ };