@ant-design/agentic-ui 2.27.10 → 2.28.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/MarkdownEditor/editor/elements/Blockquote/index.js +11 -1
- package/dist/MarkdownEditor/editor/elements/Break/index.js +2 -0
- package/dist/MarkdownEditor/editor/elements/Card/index.js +11 -0
- package/dist/MarkdownEditor/editor/elements/Code/index.js +22 -7
- package/dist/MarkdownEditor/editor/elements/FootnoteDefinition/index.js +15 -1
- package/dist/MarkdownEditor/editor/elements/FootnoteReference/index.js +11 -1
- package/dist/MarkdownEditor/editor/elements/Head/index.d.ts +1 -1
- package/dist/MarkdownEditor/editor/elements/Head/index.js +17 -1
- package/dist/MarkdownEditor/editor/elements/Hr/index.js +2 -0
- package/dist/MarkdownEditor/editor/elements/Image/index.js +75 -34
- package/dist/MarkdownEditor/editor/elements/InlineKatex/index.js +5 -0
- package/dist/MarkdownEditor/editor/elements/Katex/index.js +5 -0
- package/dist/MarkdownEditor/editor/elements/LinkCard/index.js +13 -1
- package/dist/MarkdownEditor/editor/elements/List/List.js +16 -1
- package/dist/MarkdownEditor/editor/elements/List/ListItem.js +16 -4
- package/dist/MarkdownEditor/editor/elements/Mermaid/index.js +7 -2
- package/dist/MarkdownEditor/editor/elements/Paragraph/index.js +14 -2
- package/dist/MarkdownEditor/editor/elements/Schema/index.js +13 -0
- package/dist/MarkdownEditor/editor/elements/Table/SimpleTable.js +43 -88
- package/dist/MarkdownEditor/editor/elements/index.js +131 -16
- package/dist/MarkdownEditor/editor/parser/parse/parseBlockElements.js +84 -17
- package/dist/MarkdownEditor/editor/parser/parse/parseCode.js +39 -2
- package/dist/MarkdownEditor/editor/parser/parse/parseElements.js +27 -2
- package/dist/MarkdownEditor/editor/parser/parse/parseFootnote.js +11 -1
- package/dist/MarkdownEditor/editor/parser/parse/parseMath.js +31 -4
- package/dist/MarkdownEditor/editor/parser/parse/parseMedia.js +41 -6
- package/dist/MarkdownEditor/editor/parser/parse/parseTable.js +9 -2
- package/dist/MarkdownEditor/editor/parser/parserMarkdownToSlateNode.js +141 -24
- package/dist/MarkdownEditor/editor/parser/parserSlateNodeToMarkdown.js +127 -6
- package/dist/MarkdownEditor/editor/plugins/insertParsedHtmlNodes.js +109 -2
- package/dist/Plugins/chart/AreaChart/index.js +3 -0
- package/dist/Plugins/chart/BarChart/index.js +3 -0
- package/dist/Plugins/chart/DonutChart/index.js +1 -1
- package/dist/Plugins/chart/FunnelChart/index.js +3 -0
- package/dist/Plugins/chart/LineChart/index.js +3 -0
- package/dist/Plugins/chart/RadarChart/index.js +3 -0
- package/dist/Plugins/chart/ScatterChart/index.js +3 -0
- package/dist/Plugins/code/components/ThinkBlock.js +66 -5
- package/package.json +1 -1
|
@@ -74,6 +74,7 @@ function _unsupported_iterable_to_array(o, minLen) {
|
|
|
74
74
|
if (n === "Map" || n === "Set") return Array.from(n);
|
|
75
75
|
if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _array_like_to_array(o, minLen);
|
|
76
76
|
}
|
|
77
|
+
import { debugInfo } from "../../../Utils/debugUtils";
|
|
77
78
|
import { applyContextPropsAndConfig } from "./parse/applyContextPropsAndConfig";
|
|
78
79
|
import { handleBlockquote, handleFootnoteDefinition, handleHeading, handleList, handleListItem, handleParagraph, handleTextAndInlineElements } from "./parse/parseBlockElements";
|
|
79
80
|
import { handleCode, handleYaml } from "./parse/parseCode";
|
|
@@ -113,29 +114,65 @@ var removeAnswerTags = function(text) {
|
|
|
113
114
|
* @returns 一个包含解析后的元素数组和链接信息的对象
|
|
114
115
|
*/ key: "parse",
|
|
115
116
|
value: function parse(md) {
|
|
117
|
+
var _this_plugins, _ast_children;
|
|
118
|
+
debugInfo('parserMarkdownToSlateNode.parse - 开始解析', {
|
|
119
|
+
inputLength: md === null || md === void 0 ? void 0 : md.length,
|
|
120
|
+
hasPlugins: ((_this_plugins = this.plugins) === null || _this_plugins === void 0 ? void 0 : _this_plugins.length) > 0,
|
|
121
|
+
config: this.config
|
|
122
|
+
});
|
|
116
123
|
// 先预处理 <think> 标签,然后预处理其他非标准 HTML 标签,最后处理表格换行
|
|
117
124
|
var thinkProcessed = removeAnswerTags(preprocessThinkTags(md || ''));
|
|
125
|
+
debugInfo('parserMarkdownToSlateNode.parse - thinkProcessed', {
|
|
126
|
+
length: thinkProcessed.length,
|
|
127
|
+
changed: thinkProcessed !== md
|
|
128
|
+
});
|
|
118
129
|
var nonStandardProcessed = removeAnswerTags(preprocessNonStandardHtmlTags(thinkProcessed));
|
|
130
|
+
debugInfo('parserMarkdownToSlateNode.parse - nonStandardProcessed', {
|
|
131
|
+
length: nonStandardProcessed.length,
|
|
132
|
+
changed: nonStandardProcessed !== thinkProcessed
|
|
133
|
+
});
|
|
119
134
|
// parse() 只执行 parser,需要 runSync() 来执行 transformer 插件
|
|
120
|
-
var
|
|
135
|
+
var preprocessedMarkdown = preprocessMarkdownTableNewlines(nonStandardProcessed);
|
|
136
|
+
debugInfo('parserMarkdownToSlateNode.parse - preprocessedMarkdown', {
|
|
137
|
+
length: preprocessedMarkdown.length
|
|
138
|
+
});
|
|
139
|
+
var ast = mdastParser.parse(preprocessedMarkdown);
|
|
140
|
+
debugInfo('parserMarkdownToSlateNode.parse - AST 解析完成', {
|
|
141
|
+
astType: ast === null || ast === void 0 ? void 0 : ast.type,
|
|
142
|
+
childrenCount: ast === null || ast === void 0 ? void 0 : (_ast_children = ast.children) === null || _ast_children === void 0 ? void 0 : _ast_children.length
|
|
143
|
+
});
|
|
121
144
|
var processedMarkdown = mdastParser.runSync(ast);
|
|
122
145
|
var markdownRoot = processedMarkdown.children;
|
|
146
|
+
debugInfo('parserMarkdownToSlateNode.parse - 插件处理完成', {
|
|
147
|
+
rootChildrenCount: markdownRoot === null || markdownRoot === void 0 ? void 0 : markdownRoot.length
|
|
148
|
+
});
|
|
123
149
|
// 使用类的配置和插件,通过 this 访问
|
|
124
150
|
var schema = this.parseNodes(markdownRoot, true, undefined);
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
151
|
+
debugInfo('parserMarkdownToSlateNode.parse - 节点解析完成', {
|
|
152
|
+
schemaLength: schema === null || schema === void 0 ? void 0 : schema.length,
|
|
153
|
+
schemaTypes: schema === null || schema === void 0 ? void 0 : schema.map(function(s) {
|
|
154
|
+
return s.type;
|
|
155
|
+
})
|
|
156
|
+
});
|
|
157
|
+
var filteredSchema = schema === null || schema === void 0 ? void 0 : schema.filter(function(item) {
|
|
158
|
+
var _item_children, _item_children1;
|
|
159
|
+
if (item.type === 'paragraph' && !((_item_children = item.children) === null || _item_children === void 0 ? void 0 : _item_children.length)) {
|
|
160
|
+
return false;
|
|
161
|
+
}
|
|
162
|
+
if (item.type === 'paragraph' && ((_item_children1 = item.children) === null || _item_children1 === void 0 ? void 0 : _item_children1.length) === 1) {
|
|
163
|
+
if (item.children[0].text === '\n' || item.children[0].text === undefined) {
|
|
129
164
|
return false;
|
|
130
165
|
}
|
|
131
|
-
if (item.type === 'paragraph' && ((_item_children1 = item.children) === null || _item_children1 === void 0 ? void 0 : _item_children1.length) === 1) {
|
|
132
|
-
if (item.children[0].text === '\n' || item.children[0].text === undefined) {
|
|
133
|
-
return false;
|
|
134
|
-
}
|
|
135
|
-
return true;
|
|
136
|
-
}
|
|
137
166
|
return true;
|
|
138
|
-
}
|
|
167
|
+
}
|
|
168
|
+
return true;
|
|
169
|
+
});
|
|
170
|
+
debugInfo('parserMarkdownToSlateNode.parse - 过滤完成', {
|
|
171
|
+
beforeFilter: schema === null || schema === void 0 ? void 0 : schema.length,
|
|
172
|
+
afterFilter: filteredSchema === null || filteredSchema === void 0 ? void 0 : filteredSchema.length
|
|
173
|
+
});
|
|
174
|
+
return {
|
|
175
|
+
schema: filteredSchema,
|
|
139
176
|
links: []
|
|
140
177
|
};
|
|
141
178
|
}
|
|
@@ -148,8 +185,13 @@ var removeAnswerTags = function(text) {
|
|
|
148
185
|
* - 插件未处理时,使用默认处理逻辑
|
|
149
186
|
*/ function parseNodes(nodes) {
|
|
150
187
|
var _this, _loop = function(i) {
|
|
151
|
-
var _currentElement_value_trim, _currentElement_value, _currentElement_value_trim1, _currentElement_value1;
|
|
188
|
+
var _currentElement_children, _currentElement_value_trim, _currentElement_value, _currentElement_value_trim1, _currentElement_value1;
|
|
152
189
|
var currentElement = nodes[i];
|
|
190
|
+
debugInfo("parserMarkdownToSlateNode.parseNodes - 处理节点 ".concat(i, "/").concat(nodes.length), {
|
|
191
|
+
type: currentElement === null || currentElement === void 0 ? void 0 : currentElement.type,
|
|
192
|
+
hasChildren: !!(currentElement === null || currentElement === void 0 ? void 0 : currentElement.children),
|
|
193
|
+
childrenCount: currentElement === null || currentElement === void 0 ? void 0 : (_currentElement_children = currentElement.children) === null || _currentElement_children === void 0 ? void 0 : _currentElement_children.length
|
|
194
|
+
});
|
|
153
195
|
var el = null;
|
|
154
196
|
var pluginHandled = false;
|
|
155
197
|
// 检查当前元素是否是 HTML 注释
|
|
@@ -222,6 +264,10 @@ var removeAnswerTags = function(text) {
|
|
|
222
264
|
return r.match(currentElement);
|
|
223
265
|
});
|
|
224
266
|
if (rule) {
|
|
267
|
+
debugInfo("parserMarkdownToSlateNode.parseNodes - 插件处理节点 ".concat(i), {
|
|
268
|
+
pluginName: plugin.name || 'unknown',
|
|
269
|
+
elementType: currentElement === null || currentElement === void 0 ? void 0 : currentElement.type
|
|
270
|
+
});
|
|
225
271
|
var converted = rule.convert(currentElement);
|
|
226
272
|
// 检查转换结果是否为 NodeEntry<Text> 格式
|
|
227
273
|
if (Array.isArray(converted) && converted.length === 2) {
|
|
@@ -232,6 +278,9 @@ var removeAnswerTags = function(text) {
|
|
|
232
278
|
el = converted;
|
|
233
279
|
}
|
|
234
280
|
pluginHandled = true;
|
|
281
|
+
debugInfo("parserMarkdownToSlateNode.parseNodes - 插件转换完成 ".concat(i), {
|
|
282
|
+
convertedType: el === null || el === void 0 ? void 0 : el.type
|
|
283
|
+
});
|
|
235
284
|
break;
|
|
236
285
|
}
|
|
237
286
|
}
|
|
@@ -254,9 +303,19 @@ var removeAnswerTags = function(text) {
|
|
|
254
303
|
}
|
|
255
304
|
// 如果插件没有处理,使用默认处理逻辑
|
|
256
305
|
if (!pluginHandled) {
|
|
306
|
+
debugInfo("parserMarkdownToSlateNode.parseNodes - 使用默认处理 ".concat(i), {
|
|
307
|
+
elementType: currentElement === null || currentElement === void 0 ? void 0 : currentElement.type,
|
|
308
|
+
configKeys: Object.keys(config || {})
|
|
309
|
+
});
|
|
257
310
|
// 使用统一的处理函数,通过 this 访问配置和插件
|
|
258
311
|
var result = _this.handleSingleElement(currentElement, config, parent, htmlTag, preElement);
|
|
259
312
|
el = result.el;
|
|
313
|
+
debugInfo("parserMarkdownToSlateNode.parseNodes - 默认处理完成 ".concat(i), {
|
|
314
|
+
resultType: Array.isArray(el) ? 'array' : el === null || el === void 0 ? void 0 : el.type,
|
|
315
|
+
resultLength: Array.isArray(el) ? el.length : 1,
|
|
316
|
+
hasContextProps: !!result.contextProps,
|
|
317
|
+
hasHtmlTag: !!result.htmlTag
|
|
318
|
+
});
|
|
260
319
|
if (result.contextProps) {
|
|
261
320
|
contextProps = _object_spread({}, contextProps, result.contextProps);
|
|
262
321
|
}
|
|
@@ -281,16 +340,24 @@ var removeAnswerTags = function(text) {
|
|
|
281
340
|
preElement = el;
|
|
282
341
|
};
|
|
283
342
|
var top = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : false, parent = arguments.length > 2 ? arguments[2] : void 0;
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
343
|
+
debugInfo('parserMarkdownToSlateNode.parseNodes - 开始解析节点', {
|
|
344
|
+
nodesCount: nodes === null || nodes === void 0 ? void 0 : nodes.length,
|
|
345
|
+
top: top,
|
|
346
|
+
parentType: parent === null || parent === void 0 ? void 0 : parent.type
|
|
347
|
+
});
|
|
348
|
+
if (!(nodes === null || nodes === void 0 ? void 0 : nodes.length)) {
|
|
349
|
+
debugInfo('parserMarkdownToSlateNode.parseNodes - 空节点,返回默认段落');
|
|
350
|
+
return [
|
|
351
|
+
{
|
|
352
|
+
type: 'paragraph',
|
|
353
|
+
children: [
|
|
354
|
+
{
|
|
355
|
+
text: ''
|
|
356
|
+
}
|
|
357
|
+
]
|
|
358
|
+
}
|
|
359
|
+
];
|
|
360
|
+
}
|
|
294
361
|
var els = [];
|
|
295
362
|
var preNode = null;
|
|
296
363
|
var preElement = null;
|
|
@@ -298,6 +365,12 @@ var removeAnswerTags = function(text) {
|
|
|
298
365
|
var contextProps = {};
|
|
299
366
|
var pendingHtmlCommentProps = null;
|
|
300
367
|
for(var i = 0; i < nodes.length; i++)_this = this, _loop(i);
|
|
368
|
+
debugInfo('parserMarkdownToSlateNode.parseNodes - 所有节点解析完成', {
|
|
369
|
+
totalElements: els.length,
|
|
370
|
+
elementTypes: els.map(function(e) {
|
|
371
|
+
return (e === null || e === void 0 ? void 0 : e.type) || 'text';
|
|
372
|
+
})
|
|
373
|
+
});
|
|
301
374
|
return els;
|
|
302
375
|
}
|
|
303
376
|
},
|
|
@@ -410,9 +483,21 @@ var removeAnswerTags = function(text) {
|
|
|
410
483
|
value: function handleSingleElement(currentElement, config, parent, htmlTag, preElement) {
|
|
411
484
|
var _this = this;
|
|
412
485
|
var elementType = currentElement.type;
|
|
486
|
+
debugInfo('handleSingleElement - 开始处理元素', {
|
|
487
|
+
elementType: elementType,
|
|
488
|
+
hasConfig: !!config && Object.keys(config).length > 0,
|
|
489
|
+
configKeys: config ? Object.keys(config) : [],
|
|
490
|
+
parentType: parent === null || parent === void 0 ? void 0 : parent.type,
|
|
491
|
+
htmlTagLength: htmlTag === null || htmlTag === void 0 ? void 0 : htmlTag.length,
|
|
492
|
+
preElementType: preElement === null || preElement === void 0 ? void 0 : preElement.type
|
|
493
|
+
});
|
|
413
494
|
var elementHandlers = this.getElementHandlers();
|
|
414
495
|
var handlerInfo = elementHandlers[elementType];
|
|
415
496
|
if (handlerInfo === null || handlerInfo === void 0 ? void 0 : handlerInfo.needsHtmlResult) {
|
|
497
|
+
var _result_el;
|
|
498
|
+
debugInfo('handleSingleElement - 使用 HTML 结果处理', {
|
|
499
|
+
elementType: elementType
|
|
500
|
+
});
|
|
416
501
|
var htmlResult = handleHtml(currentElement, parent, htmlTag);
|
|
417
502
|
var result = {
|
|
418
503
|
el: htmlResult.el
|
|
@@ -423,16 +508,48 @@ var removeAnswerTags = function(text) {
|
|
|
423
508
|
if (htmlResult.htmlTag) {
|
|
424
509
|
result.htmlTag = htmlResult.htmlTag;
|
|
425
510
|
}
|
|
511
|
+
debugInfo('handleSingleElement - HTML 结果处理完成', {
|
|
512
|
+
elementType: elementType,
|
|
513
|
+
resultType: Array.isArray(result.el) ? 'array' : (_result_el = result.el) === null || _result_el === void 0 ? void 0 : _result_el.type,
|
|
514
|
+
hasContextProps: !!result.contextProps,
|
|
515
|
+
hasHtmlTag: !!result.htmlTag
|
|
516
|
+
});
|
|
426
517
|
return result;
|
|
427
518
|
}
|
|
428
519
|
if (!handlerInfo) {
|
|
429
|
-
|
|
520
|
+
var _result_el1;
|
|
521
|
+
debugInfo('handleSingleElement - 使用默认文本处理', {
|
|
522
|
+
elementType: elementType
|
|
523
|
+
});
|
|
524
|
+
var result1 = {
|
|
430
525
|
el: handleTextAndInlineElements(currentElement, htmlTag, function(nodes, top, parent) {
|
|
431
526
|
return _this.parseNodes(nodes, top, parent);
|
|
432
527
|
}, this.config)
|
|
433
528
|
};
|
|
529
|
+
debugInfo('handleSingleElement - 默认文本处理完成', {
|
|
530
|
+
elementType: elementType,
|
|
531
|
+
resultType: Array.isArray(result1.el) ? 'array' : (_result_el1 = result1.el) === null || _result_el1 === void 0 ? void 0 : _result_el1.type,
|
|
532
|
+
resultLength: Array.isArray(result1.el) ? result1.el.length : 1
|
|
533
|
+
});
|
|
534
|
+
return result1;
|
|
434
535
|
}
|
|
536
|
+
debugInfo('handleSingleElement - 调用元素处理器', {
|
|
537
|
+
elementType: elementType,
|
|
538
|
+
handlerExists: !!handlerInfo.handler
|
|
539
|
+
});
|
|
435
540
|
var handlerResult = handlerInfo.handler(currentElement, this.plugins, config, parent, htmlTag, preElement, this);
|
|
541
|
+
debugInfo('handleSingleElement - 元素处理完成', {
|
|
542
|
+
elementType: elementType,
|
|
543
|
+
resultType: Array.isArray(handlerResult) ? 'array' : handlerResult === null || handlerResult === void 0 ? void 0 : handlerResult.type,
|
|
544
|
+
resultLength: Array.isArray(handlerResult) ? handlerResult.length : 1,
|
|
545
|
+
resultPreview: Array.isArray(handlerResult) ? handlerResult.map(function(r) {
|
|
546
|
+
return {
|
|
547
|
+
type: r === null || r === void 0 ? void 0 : r.type
|
|
548
|
+
};
|
|
549
|
+
}) : {
|
|
550
|
+
type: handlerResult === null || handlerResult === void 0 ? void 0 : handlerResult.type
|
|
551
|
+
}
|
|
552
|
+
});
|
|
436
553
|
return {
|
|
437
554
|
el: handlerResult
|
|
438
555
|
};
|
|
@@ -81,6 +81,7 @@ function _unsupported_iterable_to_array(o, minLen) {
|
|
|
81
81
|
}
|
|
82
82
|
import { Node } from "slate";
|
|
83
83
|
import stringWidth from "string-width";
|
|
84
|
+
import { debugInfo } from "../../../Utils/debugUtils";
|
|
84
85
|
import { getMediaType } from "../utils/dom";
|
|
85
86
|
var inlineNode = new Set([
|
|
86
87
|
'break'
|
|
@@ -248,11 +249,23 @@ var inlineNode = new Set([
|
|
|
248
249
|
* ```
|
|
249
250
|
*/ var parserNode = function(node) {
|
|
250
251
|
var preString = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : '', parent = arguments.length > 2 ? arguments[2] : void 0, plugins = arguments.length > 3 ? arguments[3] : void 0;
|
|
252
|
+
var _parent_;
|
|
251
253
|
var str = '';
|
|
252
|
-
if (!node)
|
|
254
|
+
if (!node) {
|
|
255
|
+
debugInfo('parserSlateNodeToMarkdown.parserNode - 空节点');
|
|
256
|
+
return str;
|
|
257
|
+
}
|
|
258
|
+
debugInfo('parserSlateNodeToMarkdown.parserNode - 开始解析节点', {
|
|
259
|
+
nodeType: node.type,
|
|
260
|
+
preString: preString,
|
|
261
|
+
parentType: (_parent_ = parent[parent.length - 1]) === null || _parent_ === void 0 ? void 0 : _parent_.type
|
|
262
|
+
});
|
|
253
263
|
// 首先尝试使用插件处理
|
|
254
264
|
var pluginResult = tryPluginConversion(node, preString, parent, plugins);
|
|
255
265
|
if (pluginResult !== null) {
|
|
266
|
+
debugInfo('parserSlateNodeToMarkdown.parserNode - 使用插件转换', {
|
|
267
|
+
resultLength: pluginResult.length
|
|
268
|
+
});
|
|
256
269
|
return pluginResult;
|
|
257
270
|
}
|
|
258
271
|
switch(node.type){
|
|
@@ -315,6 +328,11 @@ var inlineNode = new Set([
|
|
|
315
328
|
str += handleDefault(node, parent);
|
|
316
329
|
break;
|
|
317
330
|
}
|
|
331
|
+
debugInfo('parserSlateNodeToMarkdown.parserNode - 节点解析完成', {
|
|
332
|
+
nodeType: node.type,
|
|
333
|
+
resultLength: str.length,
|
|
334
|
+
resultPreview: str.substring(0, 50)
|
|
335
|
+
});
|
|
318
336
|
return str;
|
|
319
337
|
};
|
|
320
338
|
/**
|
|
@@ -332,7 +350,16 @@ var inlineNode = new Set([
|
|
|
332
350
|
var _loop = function(i) {
|
|
333
351
|
var _tree_, _tree_1;
|
|
334
352
|
var node = tree[i];
|
|
353
|
+
debugInfo("parserSlateNodeToMarkdown - 处理节点 ".concat(i, "/").concat(tree.length), {
|
|
354
|
+
nodeType: node === null || node === void 0 ? void 0 : node.type,
|
|
355
|
+
hasOtherProps: !!(node === null || node === void 0 ? void 0 : node.otherProps),
|
|
356
|
+
otherPropsKeys: (node === null || node === void 0 ? void 0 : node.otherProps) ? Object.keys(node.otherProps) : []
|
|
357
|
+
});
|
|
335
358
|
if (node.otherProps && Object.keys(node.otherProps).length) {
|
|
359
|
+
debugInfo("parserSlateNodeToMarkdown - 处理 otherProps ".concat(i), {
|
|
360
|
+
nodeType: node.type,
|
|
361
|
+
originalOtherProps: node.otherProps
|
|
362
|
+
});
|
|
336
363
|
var configProps = _object_spread({}, node.otherProps);
|
|
337
364
|
delete configProps['columns'];
|
|
338
365
|
delete configProps['dataSource'];
|
|
@@ -343,6 +370,9 @@ var inlineNode = new Set([
|
|
|
343
370
|
configProps.name = node.name || node.title || configProps.name;
|
|
344
371
|
configProps.description = node.description || configProps.description;
|
|
345
372
|
configProps.icon = node.icon || configProps.icon;
|
|
373
|
+
debugInfo("parserSlateNodeToMarkdown - link-card 转换 ".concat(i), {
|
|
374
|
+
configProps: configProps
|
|
375
|
+
});
|
|
346
376
|
}
|
|
347
377
|
Object.keys(configProps).forEach(function(key) {
|
|
348
378
|
if (_type_of(configProps[key]) === 'object' && configProps[key]) {
|
|
@@ -386,6 +416,10 @@ var inlineNode = new Set([
|
|
|
386
416
|
};
|
|
387
417
|
// 对于图表类型,配置应该总是以数组形式存储在 config 中
|
|
388
418
|
if (node.type === 'chart') {
|
|
419
|
+
debugInfo("parserSlateNodeToMarkdown - 处理图表节点 ".concat(i), {
|
|
420
|
+
originalConfig: configProps.config,
|
|
421
|
+
hasChartType: !!configProps.chartType
|
|
422
|
+
});
|
|
389
423
|
var chartConfig = configProps.config;
|
|
390
424
|
// 如果 config 不存在,但 configProps 看起来像图表配置(有 chartType),使用 configProps
|
|
391
425
|
if (!chartConfig && configProps.chartType) {
|
|
@@ -393,6 +427,10 @@ var inlineNode = new Set([
|
|
|
393
427
|
}
|
|
394
428
|
// 如果 chartConfig 是对象且键都是数字(如 {0: {...}}),转换为数组
|
|
395
429
|
chartConfig = convertObjectToArray(chartConfig);
|
|
430
|
+
debugInfo("parserSlateNodeToMarkdown - 图表配置转换后 ".concat(i), {
|
|
431
|
+
chartConfig: chartConfig,
|
|
432
|
+
isArray: Array.isArray(chartConfig)
|
|
433
|
+
});
|
|
396
434
|
// 如果 chartConfig 还不是数组,将其包装为数组
|
|
397
435
|
// 这样可以确保即使只有一个配置项,也会被放入数组中
|
|
398
436
|
if (!Array.isArray(chartConfig)) {
|
|
@@ -472,6 +510,13 @@ var inlineNode = new Set([
|
|
|
472
510
|
str += '\n' + preString + '> ';
|
|
473
511
|
}
|
|
474
512
|
} else if (node.type === 'blockquote') {
|
|
513
|
+
var _node_children, _node_children1;
|
|
514
|
+
debugInfo("parserSlateNodeToMarkdown - 处理引用块 ".concat(i), {
|
|
515
|
+
childrenCount: (_node_children = node.children) === null || _node_children === void 0 ? void 0 : _node_children.length,
|
|
516
|
+
hasNestedBlockquote: (_node_children1 = node.children) === null || _node_children1 === void 0 ? void 0 : _node_children1.some(function(c) {
|
|
517
|
+
return c.type === 'blockquote';
|
|
518
|
+
})
|
|
519
|
+
});
|
|
475
520
|
// Handle blockquotes
|
|
476
521
|
var blockquoteContent = node.children.map(function(child) {
|
|
477
522
|
if (child.type === 'blockquote') {
|
|
@@ -495,7 +540,16 @@ var inlineNode = new Set([
|
|
|
495
540
|
}
|
|
496
541
|
}).join('\n');
|
|
497
542
|
str += blockquoteContent;
|
|
543
|
+
debugInfo("parserSlateNodeToMarkdown - 引用块处理完成 ".concat(i), {
|
|
544
|
+
contentLength: blockquoteContent.length
|
|
545
|
+
});
|
|
498
546
|
} else if (node.type === 'list') {
|
|
547
|
+
var _node_children2;
|
|
548
|
+
debugInfo("parserSlateNodeToMarkdown - 处理列表 ".concat(i), {
|
|
549
|
+
isOrdered: node.order,
|
|
550
|
+
start: node.start,
|
|
551
|
+
childrenCount: (_node_children2 = node.children) === null || _node_children2 === void 0 ? void 0 : _node_children2.length
|
|
552
|
+
});
|
|
499
553
|
// Handle lists
|
|
500
554
|
var listItems = node.children.map(function(item, index) {
|
|
501
555
|
var prefix = node.order ? "".concat(index + (node.start || 1), ".") : '-';
|
|
@@ -510,6 +564,10 @@ var inlineNode = new Set([
|
|
|
510
564
|
str += '\n\n';
|
|
511
565
|
}
|
|
512
566
|
}
|
|
567
|
+
debugInfo("parserSlateNodeToMarkdown - 列表处理完成 ".concat(i), {
|
|
568
|
+
listItemsLength: listItems.length,
|
|
569
|
+
hasContent: !!listItems.trim()
|
|
570
|
+
});
|
|
513
571
|
} else if (node.type === 'paragraph' && ((_tree_ = tree[i - 1]) === null || _tree_ === void 0 ? void 0 : _tree_.type) === 'list' && ((_tree_1 = tree[i + 1]) === null || _tree_1 === void 0 ? void 0 : _tree_1.type) === 'list') {
|
|
514
572
|
var _Node_string;
|
|
515
573
|
if (!((_Node_string = Node.string(node)) === null || _Node_string === void 0 ? void 0 : _Node_string.replace(/\s|\t/g, ''))) {
|
|
@@ -543,20 +601,40 @@ var inlineNode = new Set([
|
|
|
543
601
|
root: true
|
|
544
602
|
}
|
|
545
603
|
], plugins = arguments.length > 3 ? arguments[3] : void 0;
|
|
604
|
+
var _parent_;
|
|
605
|
+
debugInfo('parserSlateNodeToMarkdown - 开始转换', {
|
|
606
|
+
treeLength: tree === null || tree === void 0 ? void 0 : tree.length,
|
|
607
|
+
preString: preString,
|
|
608
|
+
parentType: ((_parent_ = parent[parent.length - 1]) === null || _parent_ === void 0 ? void 0 : _parent_.type) || 'root',
|
|
609
|
+
hasPlugins: !!plugins && plugins.length > 0
|
|
610
|
+
});
|
|
546
611
|
var str = '';
|
|
547
612
|
for(var i = 0; i < tree.length; i++)_loop(i);
|
|
548
613
|
// Clean up trailing newlines and handle special cases
|
|
549
614
|
if (str) {
|
|
550
|
-
var
|
|
615
|
+
var _parent_1;
|
|
616
|
+
debugInfo('parserSlateNodeToMarkdown - 开始清理换行符', {
|
|
617
|
+
strLength: str.length,
|
|
618
|
+
trailingNewlines: (str.match(/\n+$/) || [
|
|
619
|
+
''
|
|
620
|
+
])[0].length
|
|
621
|
+
});
|
|
551
622
|
// Remove all trailing newlines first
|
|
552
623
|
str = str.replace(/\n+$/, '');
|
|
553
624
|
// Only add newlines in specific cases
|
|
554
625
|
var lastNode = tree[tree.length - 1];
|
|
555
626
|
var isRoot = parent.length === 1 && parent[0].root;
|
|
556
627
|
var isConverted = lastNode === null || lastNode === void 0 ? void 0 : lastNode.converted;
|
|
557
|
-
var parentType = (
|
|
628
|
+
var parentType = (_parent_1 = parent[parent.length - 1]) === null || _parent_1 === void 0 ? void 0 : _parent_1.type;
|
|
558
629
|
var nextNode = tree[tree.indexOf(lastNode) + 1];
|
|
559
630
|
var isLastNodeInParent = !nextNode;
|
|
631
|
+
debugInfo('parserSlateNodeToMarkdown - 换行符处理上下文', {
|
|
632
|
+
lastNodeType: lastNode === null || lastNode === void 0 ? void 0 : lastNode.type,
|
|
633
|
+
isRoot: isRoot,
|
|
634
|
+
isConverted: isConverted,
|
|
635
|
+
parentType: parentType,
|
|
636
|
+
isLastNodeInParent: isLastNodeInParent
|
|
637
|
+
});
|
|
560
638
|
if (lastNode && lastNode.type && !isConverted) {
|
|
561
639
|
if (parentType === 'blockquote') {
|
|
562
640
|
// Only add trailing blockquote marker if this is not the last node in a nested blockquote
|
|
@@ -586,11 +664,25 @@ var inlineNode = new Set([
|
|
|
586
664
|
}
|
|
587
665
|
}
|
|
588
666
|
// Clean up multiple consecutive newlines
|
|
667
|
+
var beforeCleanup = str.length;
|
|
589
668
|
str = str.replace(/\n{3,}/g, '\n\n');
|
|
669
|
+
debugInfo('parserSlateNodeToMarkdown - 清理连续换行符', {
|
|
670
|
+
beforeLength: beforeCleanup,
|
|
671
|
+
afterLength: str.length
|
|
672
|
+
});
|
|
590
673
|
// Remove leading newlines for root level content
|
|
591
674
|
if (parent.length === 1 && parent[0].root) {
|
|
675
|
+
var beforeLeading = str.length;
|
|
592
676
|
str = str.replace(/^\n+/, '');
|
|
677
|
+
debugInfo('parserSlateNodeToMarkdown - 清理前导换行符', {
|
|
678
|
+
beforeLength: beforeLeading,
|
|
679
|
+
afterLength: str.length
|
|
680
|
+
});
|
|
593
681
|
}
|
|
682
|
+
debugInfo('parserSlateNodeToMarkdown - 转换完成', {
|
|
683
|
+
finalLength: str.length,
|
|
684
|
+
finalPreview: str.substring(0, 100)
|
|
685
|
+
});
|
|
594
686
|
return str;
|
|
595
687
|
};
|
|
596
688
|
export var isMix = function(t) {
|
|
@@ -779,10 +871,26 @@ export var isMix = function(t) {
|
|
|
779
871
|
* | 左对齐 | 居中 | 右对齐 |
|
|
780
872
|
* ```
|
|
781
873
|
*/ var table = function(el, parent, plugins) {
|
|
782
|
-
var _children_;
|
|
874
|
+
var _el_children, _children_;
|
|
875
|
+
debugInfo('parserSlateNodeToMarkdown.table - 开始处理表格', {
|
|
876
|
+
elType: el.type,
|
|
877
|
+
childrenCount: (_el_children = el.children) === null || _el_children === void 0 ? void 0 : _el_children.length
|
|
878
|
+
});
|
|
783
879
|
var children = el.children;
|
|
784
880
|
var head = (_children_ = children[0]) === null || _children_ === void 0 ? void 0 : _children_.children;
|
|
785
|
-
if (!children.length || !head.length)
|
|
881
|
+
if (!children.length || !head.length) {
|
|
882
|
+
debugInfo('parserSlateNodeToMarkdown.table - 空表格,返回空字符串');
|
|
883
|
+
return '';
|
|
884
|
+
}
|
|
885
|
+
debugInfo('parserSlateNodeToMarkdown.table - 表格头部信息', {
|
|
886
|
+
headLength: head.length,
|
|
887
|
+
headCells: head.map(function(h) {
|
|
888
|
+
return {
|
|
889
|
+
type: h.type,
|
|
890
|
+
align: h.align
|
|
891
|
+
};
|
|
892
|
+
})
|
|
893
|
+
});
|
|
786
894
|
var data = new Array(children.length);
|
|
787
895
|
var maxColumns = 0;
|
|
788
896
|
// 使用策略模式处理不同类型的表格
|
|
@@ -855,6 +963,13 @@ export var isMix = function(t) {
|
|
|
855
963
|
var processor = tableProcessors[el.type] || tableProcessors.default;
|
|
856
964
|
var rowCount = processor();
|
|
857
965
|
data.length = rowCount;
|
|
966
|
+
debugInfo('parserSlateNodeToMarkdown.table - 表格数据处理完成', {
|
|
967
|
+
rowCount: rowCount,
|
|
968
|
+
maxColumns: maxColumns,
|
|
969
|
+
dataPreview: data.slice(0, 2).map(function(row) {
|
|
970
|
+
return row.slice(0, 3);
|
|
971
|
+
})
|
|
972
|
+
});
|
|
858
973
|
// 计算列宽
|
|
859
974
|
var colLength = new Array(maxColumns).fill(0);
|
|
860
975
|
var _iteratorNormalCompletion = true, _didIteratorError = false, _iteratorError = undefined;
|
|
@@ -939,7 +1054,13 @@ export var isMix = function(t) {
|
|
|
939
1054
|
output.push("| ".concat(separators.join(' | '), " |"));
|
|
940
1055
|
}
|
|
941
1056
|
}
|
|
942
|
-
|
|
1057
|
+
var result = output.join('\n');
|
|
1058
|
+
debugInfo('parserSlateNodeToMarkdown.table - 表格转换完成', {
|
|
1059
|
+
outputRows: output.length,
|
|
1060
|
+
resultLength: result.length,
|
|
1061
|
+
resultPreview: result.substring(0, 200)
|
|
1062
|
+
});
|
|
1063
|
+
return result;
|
|
943
1064
|
};
|
|
944
1065
|
/**
|
|
945
1066
|
* 处理卡片节点,递归处理其子节点
|