@ant-design/agentic-ui 2.20.2 → 2.21.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.
- package/dist/MarkdownEditor/BaseMarkdownEditor.js +1 -1
- package/dist/MarkdownEditor/editor/elements/Code.js +1 -1
- package/dist/MarkdownEditor/editor/elements/Image/index.js +37 -9
- package/dist/MarkdownEditor/editor/elements/LinkCard/index.js +87 -2
- package/dist/MarkdownEditor/editor/elements/List/List.js +10 -2
- package/dist/MarkdownEditor/editor/elements/Media.js +75 -23
- package/dist/MarkdownEditor/editor/elements/Table/ReadonlyTableComponent.js +2 -13
- package/dist/MarkdownEditor/editor/elements/Table/SimpleTable.js +89 -15
- package/dist/MarkdownEditor/editor/elements/Table/Table.js +3 -75
- package/dist/MarkdownEditor/editor/elements/index.js +1 -32
- package/dist/MarkdownEditor/editor/parser/parse/parseCode.d.ts +32 -0
- package/dist/MarkdownEditor/editor/parser/parse/parseCode.js +186 -0
- package/dist/MarkdownEditor/editor/parser/parse/parseTable.d.ts +39 -0
- package/dist/MarkdownEditor/editor/parser/parse/parseTable.js +315 -0
- package/dist/MarkdownEditor/editor/parser/parserMarkdownToSlateNode.d.ts +0 -4
- package/dist/MarkdownEditor/editor/parser/parserMarkdownToSlateNode.js +629 -1043
- package/dist/MarkdownEditor/editor/parser/parserSlateNodeToMarkdown.js +15 -3
- package/dist/MarkdownEditor/editor/parser/remarkParse.d.ts +11 -1
- package/dist/MarkdownEditor/editor/parser/remarkParse.js +218 -39
- package/dist/MarkdownEditor/editor/types/Table.d.ts +2 -1
- package/dist/MarkdownEditor/editor/utils/markdownToHtml.js +2 -1
- package/dist/MarkdownEditor/el.d.ts +3 -0
- package/dist/MarkdownEditor/style.js +2 -0
- package/dist/Plugins/chart/index.js +7 -7
- package/dist/Plugins/code/components/CodeRenderer.js +27 -10
- package/dist/Plugins/code/components/CodeToolbar.js +2 -2
- package/dist/Workspace/Task/index.d.ts +13 -8
- package/dist/Workspace/Task/index.js +19 -2
- package/dist/Workspace/index.js +3 -2
- package/dist/Workspace/types.d.ts +3 -1
- package/package.json +1 -1
|
@@ -131,33 +131,19 @@ function _unsupported_iterable_to_array(o, minLen) {
|
|
|
131
131
|
if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _array_like_to_array(o, minLen);
|
|
132
132
|
}
|
|
133
133
|
import json5 from "json5";
|
|
134
|
-
//@ts-ignore
|
|
135
|
-
import rehypeKatex from "rehype-katex";
|
|
136
|
-
import rehypeRaw from "rehype-raw";
|
|
137
|
-
import { remark } from "remark";
|
|
138
|
-
import remarkFrontmatter from "remark-frontmatter";
|
|
139
|
-
import remarkGfm from "remark-gfm";
|
|
140
|
-
import remarkMath from "remark-math";
|
|
141
|
-
import remarkParse from "remark-parse";
|
|
142
|
-
import remarkRehype from "remark-rehype";
|
|
143
|
-
import { fixStrongWithSpecialChars } from "./remarkParse";
|
|
144
134
|
import { htmlToFragmentList } from "../plugins/insertParsedHtmlNodes";
|
|
145
135
|
import { EditorUtils } from "../utils";
|
|
146
|
-
import { isCodeBlockLikelyComplete } from "../utils/findMatchingClose";
|
|
147
136
|
import partialJsonParse from "./json-parse";
|
|
137
|
+
import { handleCode, handleYaml } from "./parse/parseCode";
|
|
138
|
+
import { parseTableOrChart, preprocessMarkdownTableNewlines } from "./parse/parseTable";
|
|
148
139
|
import mdastParser from "./remarkParse";
|
|
149
140
|
// 常量定义
|
|
150
141
|
var EMPTY_LINE_DISTANCE_THRESHOLD = 4; // 两个元素之间的行距阈值
|
|
151
142
|
var EMPTY_LINE_CALCULATION_OFFSET = 2; // 计算空行数量时的偏移量
|
|
152
143
|
var EMPTY_LINE_DIVISOR = 2; // 计算空行数量的除数
|
|
153
|
-
var MIN_TABLE_CELL_LENGTH = 5; // 表格单元格最小长度
|
|
154
144
|
var INLINE_MATH_SUFFIX_PATTERN = '(?:%|[kKmMbB]|千|万|亿|兆|万亿|百万|亿万)?';
|
|
155
145
|
var INLINE_MATH_CURRENCY_PATTERN = new RegExp("^[+-]?\\d{1,3}(?:,\\d{3})*(?:\\.\\d+)?".concat(INLINE_MATH_SUFFIX_PATTERN, "$"));
|
|
156
146
|
var INLINE_MATH_SIMPLE_NUMBER_PATTERN = new RegExp("^[+-]?\\d+(?:\\.\\d+)?".concat(INLINE_MATH_SUFFIX_PATTERN, "$"));
|
|
157
|
-
// HTML 转义和代码块检测相关的常量
|
|
158
|
-
var NOT_SPACE_START = /^\S*/;
|
|
159
|
-
var ENDING_NEWLINE = /\n$/;
|
|
160
|
-
var FENCED_CODE_REGEX = /^(`{3,}|~{3,})/;
|
|
161
147
|
var shouldTreatInlineMathAsText = function(rawValue) {
|
|
162
148
|
var trimmedValue = rawValue.trim();
|
|
163
149
|
if (!trimmedValue) {
|
|
@@ -168,110 +154,6 @@ var shouldTreatInlineMathAsText = function(rawValue) {
|
|
|
168
154
|
}
|
|
169
155
|
return INLINE_MATH_CURRENCY_PATTERN.test(trimmedValue) || INLINE_MATH_SIMPLE_NUMBER_PATTERN.test(trimmedValue);
|
|
170
156
|
};
|
|
171
|
-
// 处理schema类型语言的辅助函数
|
|
172
|
-
var processSchemaLanguage = function(element, value) {
|
|
173
|
-
var json = [];
|
|
174
|
-
try {
|
|
175
|
-
json = json5.parse(value || '[]');
|
|
176
|
-
} catch (error) {
|
|
177
|
-
try {
|
|
178
|
-
json = partialJsonParse(value || '[]');
|
|
179
|
-
} catch (error) {
|
|
180
|
-
json = value;
|
|
181
|
-
console.error('parse schema error', error);
|
|
182
|
-
}
|
|
183
|
-
}
|
|
184
|
-
return _object_spread_props(_object_spread({}, element), {
|
|
185
|
-
type: 'apaasify',
|
|
186
|
-
value: json,
|
|
187
|
-
children: [
|
|
188
|
-
{
|
|
189
|
-
text: value
|
|
190
|
-
}
|
|
191
|
-
]
|
|
192
|
-
});
|
|
193
|
-
};
|
|
194
|
-
// 语言类型处理策略配置
|
|
195
|
-
var LANGUAGE_HANDLERS = {
|
|
196
|
-
mermaid: function(element) {
|
|
197
|
-
return _object_spread_props(_object_spread({}, element), {
|
|
198
|
-
type: 'mermaid'
|
|
199
|
-
});
|
|
200
|
-
},
|
|
201
|
-
schema: processSchemaLanguage,
|
|
202
|
-
apaasify: processSchemaLanguage,
|
|
203
|
-
apassify: processSchemaLanguage,
|
|
204
|
-
katex: function(element) {
|
|
205
|
-
return _object_spread_props(_object_spread({}, element), {
|
|
206
|
-
type: 'katex'
|
|
207
|
-
});
|
|
208
|
-
},
|
|
209
|
-
'agentar-card': processSchemaLanguage
|
|
210
|
-
};
|
|
211
|
-
var advancedNumericCheck = function(value) {
|
|
212
|
-
var numericPattern = /^[-+]?[0-9,]*\.?[0-9]+([eE][-+]?[0-9]+)?$/;
|
|
213
|
-
return typeof value === 'number' || typeof value === 'string' && numericPattern.test(value);
|
|
214
|
-
};
|
|
215
|
-
var isNumericValue = function(value) {
|
|
216
|
-
return typeof value === 'number' || !isNaN(parseFloat(value)) && isFinite(value) || advancedNumericCheck(value);
|
|
217
|
-
};
|
|
218
|
-
/**
|
|
219
|
-
* 判断是否包含不完整输入
|
|
220
|
-
* 如果一行中包含可能尚未完成的数字输入,返回 true
|
|
221
|
-
*/ var hasIncompleteNumericInput = function(values) {
|
|
222
|
-
// 检查是否有可能是正在输入的不完整数字
|
|
223
|
-
// 例如: '12.' 或 '0.' 或 '-' 或 仅有一个数字字符的情况
|
|
224
|
-
return values.some(function(val) {
|
|
225
|
-
if (typeof val !== 'string') return false;
|
|
226
|
-
return val.endsWith('.') && /\d/.test(val) || // 以小数点结尾
|
|
227
|
-
val === '-' || // 只有负号
|
|
228
|
-
val === '+' || // 只有正号
|
|
229
|
-
val.length === 1 && /\d/.test(val) // 只有一个数字
|
|
230
|
-
;
|
|
231
|
-
});
|
|
232
|
-
};
|
|
233
|
-
/**
|
|
234
|
-
* 规范化字段名,统一处理转义字符
|
|
235
|
-
* 将 `index\_value` 转换为 `index_value`,确保字段名一致
|
|
236
|
-
* @param fieldName - 原始字段名
|
|
237
|
-
* @returns 规范化后的字段名
|
|
238
|
-
*/ var normalizeFieldName = function(fieldName) {
|
|
239
|
-
if (!fieldName) return fieldName;
|
|
240
|
-
// 移除转义字符:将 `\_` 转换为 `_`,`\\` 转换为 `\`
|
|
241
|
-
return fieldName.replace(/\\_/g, '_').replace(/\\\\/g, '\\').replace(/\\(?=")/g, '') // 移除转义的双引号
|
|
242
|
-
.trim();
|
|
243
|
-
};
|
|
244
|
-
var getColumnAlignment = function(data, columns) {
|
|
245
|
-
if (!data.length) return [];
|
|
246
|
-
// 缓存上一次的对齐结果,避免频繁切换
|
|
247
|
-
var prevAlignments = [];
|
|
248
|
-
return columns.map(function(col, index) {
|
|
249
|
-
var values = data.map(function(row) {
|
|
250
|
-
return row[col.dataIndex];
|
|
251
|
-
}).filter(Boolean);
|
|
252
|
-
values === null || values === void 0 ? void 0 : values.pop();
|
|
253
|
-
// 如果检测到可能正在输入的数字,保持当前对齐状态
|
|
254
|
-
if (hasIncompleteNumericInput(values)) {
|
|
255
|
-
return prevAlignments[index] || null;
|
|
256
|
-
}
|
|
257
|
-
var alignment = values.every(isNumericValue) ? 'right' : null;
|
|
258
|
-
prevAlignments[index] = alignment;
|
|
259
|
-
return alignment;
|
|
260
|
-
});
|
|
261
|
-
};
|
|
262
|
-
var stringifyObj = remark().use(remarkParse).use(fixStrongWithSpecialChars).use(remarkMath, {
|
|
263
|
-
singleDollarTextMath: false
|
|
264
|
-
}).use(remarkRehype, {
|
|
265
|
-
allowDangerousHtml: true
|
|
266
|
-
}).use(rehypeRaw).use(rehypeKatex).use(remarkGfm).use(remarkFrontmatter, [
|
|
267
|
-
'yaml'
|
|
268
|
-
]);
|
|
269
|
-
var myRemark = {
|
|
270
|
-
stringify: function(obj) {
|
|
271
|
-
var mdStr = stringifyObj.stringify(obj);
|
|
272
|
-
return mdStr;
|
|
273
|
-
}
|
|
274
|
-
};
|
|
275
157
|
/**
|
|
276
158
|
* 检测和解析 think 标签
|
|
277
159
|
* @param str - 要检测的字符串
|
|
@@ -446,6 +328,24 @@ var findAttachment = function(str) {
|
|
|
446
328
|
return null;
|
|
447
329
|
}
|
|
448
330
|
};
|
|
331
|
+
/**
|
|
332
|
+
* 设置节点的 finished 属性
|
|
333
|
+
*/ var setFinishedProp = function(leaf, finished) {
|
|
334
|
+
if (finished !== false) {
|
|
335
|
+
return leaf;
|
|
336
|
+
}
|
|
337
|
+
return _object_spread_props(_object_spread({}, leaf), {
|
|
338
|
+
otherProps: _object_spread_props(_object_spread({}, leaf.otherProps), {
|
|
339
|
+
finished: finished
|
|
340
|
+
})
|
|
341
|
+
});
|
|
342
|
+
};
|
|
343
|
+
/**
|
|
344
|
+
* 检查 leaf 是否有格式属性需要保留
|
|
345
|
+
*/ var hasFormattingProps = function(leaf) {
|
|
346
|
+
var _leaf_otherProps;
|
|
347
|
+
return !!(leaf.bold || leaf.italic || leaf.strikethrough || leaf.url || leaf.code || ((_leaf_otherProps = leaf.otherProps) === null || _leaf_otherProps === void 0 ? void 0 : _leaf_otherProps.finished) === false);
|
|
348
|
+
};
|
|
449
349
|
var parseText = function(els) {
|
|
450
350
|
var leaf = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : {
|
|
451
351
|
data: {}
|
|
@@ -455,42 +355,86 @@ var parseText = function(els) {
|
|
|
455
355
|
try {
|
|
456
356
|
for(var _iterator = els[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true){
|
|
457
357
|
var n = _step.value;
|
|
458
|
-
if (n.type === 'strong')
|
|
459
|
-
|
|
460
|
-
|
|
461
|
-
|
|
462
|
-
|
|
463
|
-
|
|
464
|
-
|
|
465
|
-
|
|
466
|
-
|
|
358
|
+
if (n.type === 'strong') {
|
|
359
|
+
var strongLeaf = setFinishedProp(_object_spread_props(_object_spread({}, leaf), {
|
|
360
|
+
bold: true
|
|
361
|
+
}), n.finished);
|
|
362
|
+
var strongResult = parseText(n.children, strongLeaf);
|
|
363
|
+
leafs = leafs.concat(strongResult);
|
|
364
|
+
// 如果处理完嵌套节点后没有生成任何节点,且 leaf 有格式属性,生成空文本节点以保留格式
|
|
365
|
+
if (strongResult.length === 0 && hasFormattingProps(strongLeaf)) {
|
|
366
|
+
leafs.push(_object_spread_props(_object_spread({}, strongLeaf), {
|
|
367
|
+
text: ''
|
|
368
|
+
}));
|
|
369
|
+
}
|
|
370
|
+
continue;
|
|
371
|
+
}
|
|
372
|
+
if (n.type === 'emphasis') {
|
|
373
|
+
var emphasisLeaf = setFinishedProp(_object_spread_props(_object_spread({}, leaf), {
|
|
374
|
+
italic: true
|
|
375
|
+
}), n.finished);
|
|
376
|
+
var emphasisResult = parseText(n.children, emphasisLeaf);
|
|
377
|
+
leafs = leafs.concat(emphasisResult);
|
|
378
|
+
// 如果处理完嵌套节点后没有生成任何节点,且 leaf 有格式属性,生成空文本节点以保留格式
|
|
379
|
+
if (emphasisResult.length === 0 && hasFormattingProps(emphasisLeaf)) {
|
|
380
|
+
leafs.push(_object_spread_props(_object_spread({}, emphasisLeaf), {
|
|
381
|
+
text: ''
|
|
382
|
+
}));
|
|
383
|
+
}
|
|
384
|
+
continue;
|
|
385
|
+
}
|
|
386
|
+
if (n.type === 'delete') {
|
|
387
|
+
var deleteLeaf = _object_spread_props(_object_spread({}, leaf), {
|
|
388
|
+
strikethrough: true
|
|
389
|
+
});
|
|
390
|
+
var deleteResult = parseText(n.children, deleteLeaf);
|
|
391
|
+
leafs = leafs.concat(deleteResult);
|
|
392
|
+
// 如果处理完嵌套节点后没有生成任何节点,且 leaf 有格式属性,生成空文本节点以保留格式
|
|
393
|
+
if (deleteResult.length === 0 && hasFormattingProps(deleteLeaf)) {
|
|
394
|
+
leafs.push(_object_spread_props(_object_spread({}, deleteLeaf), {
|
|
395
|
+
text: ''
|
|
396
|
+
}));
|
|
397
|
+
}
|
|
398
|
+
continue;
|
|
399
|
+
}
|
|
467
400
|
if (n.type === 'link') {
|
|
468
|
-
|
|
401
|
+
var linkLeaf = _object_spread_props(_object_spread({}, leaf), {
|
|
469
402
|
url: n === null || n === void 0 ? void 0 : n.url
|
|
470
|
-
})
|
|
403
|
+
});
|
|
404
|
+
var linkResult = parseText(n.children, linkLeaf);
|
|
405
|
+
leafs = leafs.concat(linkResult);
|
|
406
|
+
// 如果处理完嵌套节点后没有生成任何节点,且 leaf 有格式属性,生成空文本节点以保留格式
|
|
407
|
+
if (linkResult.length === 0 && hasFormattingProps(linkLeaf)) {
|
|
408
|
+
leafs.push(_object_spread_props(_object_spread({}, linkLeaf), {
|
|
409
|
+
text: ''
|
|
410
|
+
}));
|
|
411
|
+
}
|
|
412
|
+
continue;
|
|
413
|
+
}
|
|
414
|
+
if (n.type === 'inlineCode') {
|
|
415
|
+
leafs.push(_object_spread_props(_object_spread({}, leaf), {
|
|
416
|
+
text: n.value,
|
|
417
|
+
code: true
|
|
418
|
+
}));
|
|
419
|
+
continue;
|
|
471
420
|
}
|
|
472
|
-
if (n.type === 'inlineCode') leafs.push(_object_spread_props(_object_spread({}, leaf), {
|
|
473
|
-
text: n.value,
|
|
474
|
-
code: true
|
|
475
|
-
}));
|
|
476
421
|
if (n.type === 'inlineMath') {
|
|
477
422
|
var inlineMathValue = typeof n.value === 'string' ? n.value : '';
|
|
478
423
|
if (shouldTreatInlineMathAsText(inlineMathValue)) {
|
|
479
424
|
leafs.push(_object_spread_props(_object_spread({}, leaf), {
|
|
480
425
|
text: "$".concat(inlineMathValue, "$")
|
|
481
426
|
}));
|
|
482
|
-
|
|
427
|
+
} else {
|
|
428
|
+
leafs.push(_object_spread_props(_object_spread({}, leaf), {
|
|
429
|
+
type: 'inline-katex',
|
|
430
|
+
children: [
|
|
431
|
+
{
|
|
432
|
+
text: inlineMathValue
|
|
433
|
+
}
|
|
434
|
+
]
|
|
435
|
+
}));
|
|
483
436
|
}
|
|
484
|
-
|
|
485
|
-
leafs.push(_object_spread_props(_object_spread({}, leaf), {
|
|
486
|
-
type: 'inline-katex',
|
|
487
|
-
children: [
|
|
488
|
-
{
|
|
489
|
-
text: inlineMathValue
|
|
490
|
-
}
|
|
491
|
-
]
|
|
492
|
-
}));
|
|
493
|
-
continue; // 跳过后面的默认处理
|
|
437
|
+
continue;
|
|
494
438
|
}
|
|
495
439
|
// @ts-ignore
|
|
496
440
|
leafs.push(_object_spread_props(_object_spread({}, leaf), {
|
|
@@ -513,155 +457,6 @@ var parseText = function(els) {
|
|
|
513
457
|
}
|
|
514
458
|
return leafs;
|
|
515
459
|
};
|
|
516
|
-
var parseTableOrChart = function(table, preNode, plugins, parserConfig) {
|
|
517
|
-
var _table_children, _tableHeader_children, _table_children_slice, _table_children1, _table_align, _config_at, _config_at1, _table_otherProps;
|
|
518
|
-
var keyMap = new Map();
|
|
519
|
-
// @ts-ignore
|
|
520
|
-
var config = // @ts-ignore
|
|
521
|
-
(preNode === null || preNode === void 0 ? void 0 : preNode.type) === 'code' && // @ts-ignore
|
|
522
|
-
(preNode === null || preNode === void 0 ? void 0 : preNode.language) === 'html' && (// @ts-ignore
|
|
523
|
-
preNode === null || preNode === void 0 ? void 0 : preNode.otherProps) ? preNode === null || preNode === void 0 ? void 0 : preNode.otherProps : {};
|
|
524
|
-
var tableHeader = table === null || table === void 0 ? void 0 : (_table_children = table.children) === null || _table_children === void 0 ? void 0 : _table_children.at(0);
|
|
525
|
-
var columns = (tableHeader === null || tableHeader === void 0 ? void 0 : (_tableHeader_children = tableHeader.children) === null || _tableHeader_children === void 0 ? void 0 : _tableHeader_children.map(function(node) {
|
|
526
|
-
var _myRemark_stringify;
|
|
527
|
-
return (_myRemark_stringify = myRemark.stringify({
|
|
528
|
-
type: 'root',
|
|
529
|
-
children: [
|
|
530
|
-
node
|
|
531
|
-
]
|
|
532
|
-
})) === null || _myRemark_stringify === void 0 ? void 0 : _myRemark_stringify.replace(/\n/g, '').trim();
|
|
533
|
-
}).map(function(title) {
|
|
534
|
-
// 先规范化字段名,统一处理转义字符
|
|
535
|
-
var normalizedTitle = normalizeFieldName(title || ' ');
|
|
536
|
-
return normalizedTitle;
|
|
537
|
-
}).map(function(title, index) {
|
|
538
|
-
if (keyMap.has(title)) {
|
|
539
|
-
keyMap.set(title, keyMap.get(title) + '_' + index);
|
|
540
|
-
return {
|
|
541
|
-
title: title,
|
|
542
|
-
dataIndex: title + '_' + index,
|
|
543
|
-
key: title + '_' + index
|
|
544
|
-
};
|
|
545
|
-
}
|
|
546
|
-
keyMap.set(title, title);
|
|
547
|
-
return {
|
|
548
|
-
title: title,
|
|
549
|
-
dataIndex: title,
|
|
550
|
-
key: title
|
|
551
|
-
};
|
|
552
|
-
})) || [];
|
|
553
|
-
var dataSource = (table === null || table === void 0 ? void 0 : (_table_children1 = table.children) === null || _table_children1 === void 0 ? void 0 : (_table_children_slice = _table_children1.slice(1)) === null || _table_children_slice === void 0 ? void 0 : _table_children_slice.map(function(row) {
|
|
554
|
-
var _row_children;
|
|
555
|
-
return (_row_children = row.children) === null || _row_children === void 0 ? void 0 : _row_children.reduce(function(acc, cell, index) {
|
|
556
|
-
var _myRemark_stringify_replace_replace_replace, _myRemark_stringify_replace_replace, _myRemark_stringify_replace, _myRemark_stringify;
|
|
557
|
-
// 如果数据列数超出表头列数,舍弃多余的数据
|
|
558
|
-
if (index >= columns.length) {
|
|
559
|
-
return acc;
|
|
560
|
-
}
|
|
561
|
-
acc[columns[index].dataIndex] = (_myRemark_stringify = myRemark.stringify({
|
|
562
|
-
type: 'root',
|
|
563
|
-
children: [
|
|
564
|
-
cell
|
|
565
|
-
]
|
|
566
|
-
})) === null || _myRemark_stringify === void 0 ? void 0 : (_myRemark_stringify_replace = _myRemark_stringify.replace(/\n/g, '')) === null || _myRemark_stringify_replace === void 0 ? void 0 : (_myRemark_stringify_replace_replace = _myRemark_stringify_replace.replace(/\\(?=")/g, '')) === null || _myRemark_stringify_replace_replace === void 0 ? void 0 : (_myRemark_stringify_replace_replace_replace = _myRemark_stringify_replace_replace.replace(/\\_/g, '')) === null || _myRemark_stringify_replace_replace_replace === void 0 ? void 0 : _myRemark_stringify_replace_replace_replace.trim();
|
|
567
|
-
return acc;
|
|
568
|
-
}, {});
|
|
569
|
-
})) || [];
|
|
570
|
-
if ((_table_align = table.align) === null || _table_align === void 0 ? void 0 : _table_align.every(function(item) {
|
|
571
|
-
return !item;
|
|
572
|
-
})) {
|
|
573
|
-
var aligns = getColumnAlignment(dataSource, columns);
|
|
574
|
-
table.align = aligns;
|
|
575
|
-
}
|
|
576
|
-
var aligns1 = table.align;
|
|
577
|
-
var isChart = (config === null || config === void 0 ? void 0 : config.chartType) || (config === null || config === void 0 ? void 0 : (_config_at1 = config.at) === null || _config_at1 === void 0 ? void 0 : (_config_at = _config_at1.call(config, 0)) === null || _config_at === void 0 ? void 0 : _config_at.chartType);
|
|
578
|
-
/**
|
|
579
|
-
* 如果是分栏,将表格转换为分栏节点
|
|
580
|
-
*/ // 计算合并单元格信息
|
|
581
|
-
var mergeCells = config.mergeCells || [];
|
|
582
|
-
// 创建合并单元格映射,用于快速查找
|
|
583
|
-
var mergeMap = new Map();
|
|
584
|
-
mergeCells === null || mergeCells === void 0 ? void 0 : mergeCells.forEach(function(param) {
|
|
585
|
-
var row = param.row, col = param.col, rowSpan = param.rowSpan, rowspan = param.rowspan, colSpan = param.colSpan, colspan = param.colspan;
|
|
586
|
-
var rawRowSpan = rowSpan || rowspan;
|
|
587
|
-
var rawColSpan = colSpan || colspan;
|
|
588
|
-
// 主单元格
|
|
589
|
-
mergeMap.set("".concat(row, "-").concat(col), {
|
|
590
|
-
rowSpan: rawRowSpan,
|
|
591
|
-
colSpan: rawColSpan
|
|
592
|
-
});
|
|
593
|
-
// 被合并的单元格标记为隐藏
|
|
594
|
-
for(var r = row; r < row + rawRowSpan; r++){
|
|
595
|
-
for(var c = col; c < col + rawColSpan; c++){
|
|
596
|
-
if (r !== row || c !== col) {
|
|
597
|
-
mergeMap.set("".concat(r, "-").concat(c), {
|
|
598
|
-
rowSpan: 1,
|
|
599
|
-
colSpan: 1,
|
|
600
|
-
hidden: true
|
|
601
|
-
});
|
|
602
|
-
}
|
|
603
|
-
}
|
|
604
|
-
}
|
|
605
|
-
});
|
|
606
|
-
var children = table.children.map(function(r, l) {
|
|
607
|
-
return {
|
|
608
|
-
type: 'table-row',
|
|
609
|
-
align: (aligns1 === null || aligns1 === void 0 ? void 0 : aligns1[l]) || undefined,
|
|
610
|
-
children: r.children.map(function(c, i) {
|
|
611
|
-
var _c_children;
|
|
612
|
-
var mergeInfo = mergeMap.get("".concat(l, "-").concat(i));
|
|
613
|
-
return _object_spread_props(_object_spread({
|
|
614
|
-
type: 'table-cell',
|
|
615
|
-
align: (aligns1 === null || aligns1 === void 0 ? void 0 : aligns1[i]) || undefined,
|
|
616
|
-
title: l === 0,
|
|
617
|
-
rows: l,
|
|
618
|
-
cols: i
|
|
619
|
-
}, (mergeInfo === null || mergeInfo === void 0 ? void 0 : mergeInfo.rowSpan) && mergeInfo.rowSpan > 1 ? {
|
|
620
|
-
rowSpan: mergeInfo.rowSpan
|
|
621
|
-
} : {}, (mergeInfo === null || mergeInfo === void 0 ? void 0 : mergeInfo.colSpan) && mergeInfo.colSpan > 1 ? {
|
|
622
|
-
colSpan: mergeInfo.colSpan
|
|
623
|
-
} : {}, (mergeInfo === null || mergeInfo === void 0 ? void 0 : mergeInfo.hidden) ? {
|
|
624
|
-
hidden: true
|
|
625
|
-
} : {}), {
|
|
626
|
-
children: ((_c_children = c.children) === null || _c_children === void 0 ? void 0 : _c_children.length) ? [
|
|
627
|
-
{
|
|
628
|
-
type: 'paragraph',
|
|
629
|
-
children: parseNodes(c.children, plugins, false, c, parserConfig)
|
|
630
|
-
}
|
|
631
|
-
] : [
|
|
632
|
-
{
|
|
633
|
-
type: 'paragraph',
|
|
634
|
-
children: [
|
|
635
|
-
{
|
|
636
|
-
text: ''
|
|
637
|
-
}
|
|
638
|
-
]
|
|
639
|
-
}
|
|
640
|
-
]
|
|
641
|
-
});
|
|
642
|
-
})
|
|
643
|
-
};
|
|
644
|
-
});
|
|
645
|
-
// 检查表格是否完成(未闭合)
|
|
646
|
-
// 如果 table 节点有 otherProps.finish,使用它;否则默认为 false(未完成)
|
|
647
|
-
var isFinished = (table === null || table === void 0 ? void 0 : (_table_otherProps = table.otherProps) === null || _table_otherProps === void 0 ? void 0 : _table_otherProps.finish) !== undefined ? table.otherProps.finish : false;
|
|
648
|
-
var otherProps = _object_spread_props(_object_spread({}, isChart ? {
|
|
649
|
-
config: config
|
|
650
|
-
} : config), {
|
|
651
|
-
columns: columns,
|
|
652
|
-
dataSource: dataSource.map(function(item) {
|
|
653
|
-
item === null || item === void 0 ? true : delete item.chartType;
|
|
654
|
-
return _object_spread({}, item);
|
|
655
|
-
}),
|
|
656
|
-
finish: isFinished
|
|
657
|
-
});
|
|
658
|
-
var node = {
|
|
659
|
-
type: isChart ? 'chart' : 'table',
|
|
660
|
-
children: children,
|
|
661
|
-
otherProps: otherProps
|
|
662
|
-
};
|
|
663
|
-
return EditorUtils.wrapperCardNode(node);
|
|
664
|
-
};
|
|
665
460
|
/**
|
|
666
461
|
* 处理标题节点
|
|
667
462
|
* @param currentElement - 当前处理的标题元素,包含depth和children属性
|
|
@@ -687,258 +482,284 @@ export var decodeURIComponentUrl = function(url) {
|
|
|
687
482
|
}
|
|
688
483
|
};
|
|
689
484
|
/**
|
|
690
|
-
*
|
|
691
|
-
|
|
692
|
-
|
|
693
|
-
|
|
694
|
-
|
|
695
|
-
|
|
696
|
-
var _currentElement_value, _currentElement_value_trim, _currentElement_value1, _currentElement_value_trim1;
|
|
697
|
-
var value = (currentElement === null || currentElement === void 0 ? void 0 : (_currentElement_value = currentElement.value) === null || _currentElement_value === void 0 ? void 0 : _currentElement_value.replace('<!--', '').replace('-->', '').trim()) || '{}';
|
|
698
|
-
var contextProps = {};
|
|
699
|
-
if (value && (currentElement === null || currentElement === void 0 ? void 0 : (_currentElement_value1 = currentElement.value) === null || _currentElement_value1 === void 0 ? void 0 : (_currentElement_value_trim = _currentElement_value1.trim()) === null || _currentElement_value_trim === void 0 ? void 0 : _currentElement_value_trim.endsWith('-->')) && (currentElement === null || currentElement === void 0 ? void 0 : (_currentElement_value_trim1 = currentElement.value.trim()) === null || _currentElement_value_trim1 === void 0 ? void 0 : _currentElement_value_trim1.startsWith('<!--'))) {
|
|
700
|
-
try {
|
|
701
|
-
contextProps = json5.parse(value);
|
|
702
|
-
} catch (e) {
|
|
703
|
-
try {
|
|
704
|
-
contextProps = partialJsonParse(value);
|
|
705
|
-
} catch (parseError) {
|
|
706
|
-
console.warn('Failed to parse HTML comment as JSON or partial JSON:', {
|
|
707
|
-
value: value,
|
|
708
|
-
error: parseError
|
|
709
|
-
});
|
|
710
|
-
}
|
|
711
|
-
console.warn('HTML comment parse fallback attempted:', e);
|
|
712
|
-
}
|
|
485
|
+
* 解析 HTML 注释中的上下文属性
|
|
486
|
+
*/ var parseCommentContextProps = function(value, processedValue) {
|
|
487
|
+
var _processedValue_trim, _processedValue_trim1;
|
|
488
|
+
var isComment = value && (processedValue === null || processedValue === void 0 ? void 0 : (_processedValue_trim = processedValue.trim()) === null || _processedValue_trim === void 0 ? void 0 : _processedValue_trim.endsWith('-->')) && ((_processedValue_trim1 = processedValue.trim()) === null || _processedValue_trim1 === void 0 ? void 0 : _processedValue_trim1.startsWith('<!--'));
|
|
489
|
+
if (!isComment) {
|
|
490
|
+
return {};
|
|
713
491
|
}
|
|
714
|
-
|
|
715
|
-
|
|
716
|
-
|
|
717
|
-
|
|
718
|
-
|
|
719
|
-
|
|
720
|
-
|
|
721
|
-
|
|
722
|
-
|
|
723
|
-
// 直接创建带有 loading 状态的图片节点(不通过 createMediaNode,因为 URL 为空)
|
|
724
|
-
el = EditorUtils.wrapperCardNode({
|
|
725
|
-
type: 'image',
|
|
726
|
-
url: '',
|
|
727
|
-
mediaType: 'image',
|
|
728
|
-
alt: rawMarkdown,
|
|
729
|
-
loading: true,
|
|
730
|
-
rawMarkdown: rawMarkdown,
|
|
731
|
-
children: [
|
|
732
|
-
{
|
|
733
|
-
text: ''
|
|
734
|
-
}
|
|
735
|
-
]
|
|
492
|
+
try {
|
|
493
|
+
return json5.parse(value);
|
|
494
|
+
} catch (e) {
|
|
495
|
+
try {
|
|
496
|
+
return partialJsonParse(value);
|
|
497
|
+
} catch (parseError) {
|
|
498
|
+
console.warn('Failed to parse HTML comment as JSON or partial JSON:', {
|
|
499
|
+
value: value,
|
|
500
|
+
error: parseError
|
|
736
501
|
});
|
|
737
|
-
} else {
|
|
738
|
-
// 检查是否为 <think> 标签
|
|
739
|
-
var thinkElement = findThinkElement(currentElement.value);
|
|
740
|
-
if (thinkElement) {
|
|
741
|
-
// 将 <think> 标签转换为 think 类型的代码块
|
|
742
|
-
el = {
|
|
743
|
-
type: 'code',
|
|
744
|
-
language: 'think',
|
|
745
|
-
value: thinkElement.content,
|
|
746
|
-
children: [
|
|
747
|
-
{
|
|
748
|
-
text: thinkElement.content
|
|
749
|
-
}
|
|
750
|
-
]
|
|
751
|
-
};
|
|
752
|
-
} else {
|
|
753
|
-
// 检查是否为 <answer> 标签
|
|
754
|
-
var answerElement = findAnswerElement(currentElement.value);
|
|
755
|
-
if (answerElement) {
|
|
756
|
-
// 将 <answer> 标签的内容作为普通文本
|
|
757
|
-
el = {
|
|
758
|
-
text: answerElement.content
|
|
759
|
-
};
|
|
760
|
-
} else {
|
|
761
|
-
var mediaElement = findImageElement(currentElement.value);
|
|
762
|
-
if (mediaElement) {
|
|
763
|
-
el = createMediaNodeFromElement(mediaElement);
|
|
764
|
-
} else if (currentElement.value === '<br/>') {
|
|
765
|
-
el = {
|
|
766
|
-
type: 'paragraph',
|
|
767
|
-
children: [
|
|
768
|
-
{
|
|
769
|
-
text: ''
|
|
770
|
-
}
|
|
771
|
-
]
|
|
772
|
-
};
|
|
773
|
-
} else if (currentElement.value.match(/^<\/(img|video|iframe)>/)) {
|
|
774
|
-
// 如果是媒体标签的结束标签,跳过处理
|
|
775
|
-
el = null;
|
|
776
|
-
} else {
|
|
777
|
-
// 检查是否为注释(注释需要特殊处理以提取配置)
|
|
778
|
-
var isComment = currentElement.value.trim().startsWith('<!--') && currentElement.value.trim().endsWith('-->');
|
|
779
|
-
// 检查是否为标准 HTML 元素或注释
|
|
780
|
-
if (isComment || isStandardHtmlElement(currentElement.value)) {
|
|
781
|
-
// 标准 HTML 元素或注释:按原逻辑处理
|
|
782
|
-
el = currentElement.value.match(/<\/?(table|div|ul|li|ol|p|strong)[^\n>]*?>/) ? htmlToFragmentList(currentElement.value, '') : {
|
|
783
|
-
type: 'code',
|
|
784
|
-
language: 'html',
|
|
785
|
-
render: true,
|
|
786
|
-
value: currentElement.value,
|
|
787
|
-
children: [
|
|
788
|
-
{
|
|
789
|
-
text: currentElement.value
|
|
790
|
-
}
|
|
791
|
-
]
|
|
792
|
-
};
|
|
793
|
-
} else {
|
|
794
|
-
// 非标准元素(如自定义标签):当作普通文本处理
|
|
795
|
-
el = {
|
|
796
|
-
text: currentElement.value
|
|
797
|
-
};
|
|
798
|
-
}
|
|
799
|
-
}
|
|
800
|
-
}
|
|
801
|
-
}
|
|
802
|
-
}
|
|
803
|
-
} else {
|
|
804
|
-
el = processInlineHtml(currentElement, htmlTag);
|
|
805
|
-
}
|
|
806
|
-
if (el && !Array.isArray(el)) {
|
|
807
|
-
// 只有非文本节点才设置 isConfig 和 otherProps
|
|
808
|
-
if (!('text' in el && Object.keys(el).length === 1)) {
|
|
809
|
-
var _currentElement_value_trim2, _currentElement_value2;
|
|
810
|
-
el.isConfig = currentElement === null || currentElement === void 0 ? void 0 : (_currentElement_value2 = currentElement.value) === null || _currentElement_value2 === void 0 ? void 0 : (_currentElement_value_trim2 = _currentElement_value2.trim()) === null || _currentElement_value_trim2 === void 0 ? void 0 : _currentElement_value_trim2.startsWith('<!--');
|
|
811
|
-
el.otherProps = contextProps;
|
|
812
502
|
}
|
|
503
|
+
console.warn('HTML comment parse fallback attempted:', e);
|
|
813
504
|
}
|
|
814
|
-
return {
|
|
815
|
-
el: el,
|
|
816
|
-
contextProps: contextProps
|
|
817
|
-
};
|
|
505
|
+
return {};
|
|
818
506
|
};
|
|
819
507
|
/**
|
|
820
|
-
*
|
|
821
|
-
|
|
822
|
-
|
|
823
|
-
|
|
824
|
-
*/ var processInlineHtml = function(currentElement, htmlTag) {
|
|
825
|
-
var breakMatch = currentElement.value.match(/<br\/?>/);
|
|
826
|
-
if (breakMatch) {
|
|
508
|
+
* 处理块级 HTML 元素
|
|
509
|
+
*/ var handleBlockHtml = function(currentElement, processedValue, isUnclosedComment) {
|
|
510
|
+
var thinkElement = findThinkElement(currentElement.value);
|
|
511
|
+
if (thinkElement) {
|
|
827
512
|
return {
|
|
828
|
-
type: '
|
|
513
|
+
type: 'code',
|
|
514
|
+
language: 'think',
|
|
515
|
+
value: thinkElement.content,
|
|
829
516
|
children: [
|
|
830
517
|
{
|
|
831
|
-
text:
|
|
518
|
+
text: thinkElement.content
|
|
832
519
|
}
|
|
833
520
|
]
|
|
834
521
|
};
|
|
835
522
|
}
|
|
836
|
-
// 检查是否为 <answer> 标签(内联场景)
|
|
837
523
|
var answerElement = findAnswerElement(currentElement.value);
|
|
838
524
|
if (answerElement) {
|
|
839
|
-
// 将 <answer> 标签的内容作为普通文本
|
|
840
525
|
return {
|
|
841
526
|
text: answerElement.content
|
|
842
527
|
};
|
|
843
528
|
}
|
|
844
|
-
|
|
845
|
-
|
|
846
|
-
|
|
847
|
-
|
|
848
|
-
|
|
849
|
-
return
|
|
850
|
-
type: '
|
|
851
|
-
url: '',
|
|
852
|
-
mediaType: 'image',
|
|
853
|
-
alt: rawMarkdown,
|
|
854
|
-
loading: true,
|
|
855
|
-
rawMarkdown: rawMarkdown,
|
|
529
|
+
var mediaElement = findImageElement(currentElement.value);
|
|
530
|
+
if (mediaElement) {
|
|
531
|
+
return createMediaNodeFromElement(mediaElement);
|
|
532
|
+
}
|
|
533
|
+
if (currentElement.value === '<br/>') {
|
|
534
|
+
return {
|
|
535
|
+
type: 'paragraph',
|
|
856
536
|
children: [
|
|
857
537
|
{
|
|
858
538
|
text: ''
|
|
859
539
|
}
|
|
860
540
|
]
|
|
861
|
-
}
|
|
541
|
+
};
|
|
542
|
+
}
|
|
543
|
+
if (currentElement.value.match(/^<\/(img|video|iframe)>/)) {
|
|
544
|
+
return null;
|
|
545
|
+
}
|
|
546
|
+
var commentValue = isUnclosedComment ? processedValue : currentElement.value;
|
|
547
|
+
var isComment = commentValue.trim().startsWith('<!--') && commentValue.trim().endsWith('-->');
|
|
548
|
+
if (isComment || isStandardHtmlElement(commentValue)) {
|
|
549
|
+
return commentValue.match(/<\/?(table|div|ul|li|ol|p|strong)[^\n>]*?>/) ? htmlToFragmentList(commentValue, '') : {
|
|
550
|
+
type: 'code',
|
|
551
|
+
language: 'html',
|
|
552
|
+
render: true,
|
|
553
|
+
value: commentValue,
|
|
554
|
+
children: [
|
|
555
|
+
{
|
|
556
|
+
text: commentValue
|
|
557
|
+
}
|
|
558
|
+
]
|
|
559
|
+
};
|
|
560
|
+
}
|
|
561
|
+
return {
|
|
562
|
+
text: currentElement.value
|
|
563
|
+
};
|
|
564
|
+
};
|
|
565
|
+
/**
|
|
566
|
+
* 应用元素配置属性(纯函数版本)
|
|
567
|
+
*/ var applyElementConfig = function(el, contextProps, processedValue, isUnclosedComment, currentElement) {
|
|
568
|
+
var _valueToCheck_trim;
|
|
569
|
+
if (!el || Array.isArray(el)) {
|
|
570
|
+
return el;
|
|
862
571
|
}
|
|
863
|
-
|
|
864
|
-
if (
|
|
572
|
+
var isPlainText = 'text' in el && Object.keys(el).length === 1;
|
|
573
|
+
if (isPlainText) {
|
|
574
|
+
return el;
|
|
575
|
+
}
|
|
576
|
+
var valueToCheck = isUnclosedComment ? processedValue : currentElement === null || currentElement === void 0 ? void 0 : currentElement.value;
|
|
577
|
+
var otherProps = _object_spread({}, contextProps);
|
|
578
|
+
// 只有当 finished === false 时才设置 finished 属性,否则删除
|
|
579
|
+
if (isUnclosedComment) {
|
|
580
|
+
otherProps.finished = false;
|
|
581
|
+
}
|
|
582
|
+
return _object_spread_props(_object_spread({}, el), {
|
|
583
|
+
isConfig: valueToCheck === null || valueToCheck === void 0 ? void 0 : (_valueToCheck_trim = valueToCheck.trim()) === null || _valueToCheck_trim === void 0 ? void 0 : _valueToCheck_trim.startsWith('<!--'),
|
|
584
|
+
otherProps: Object.keys(otherProps).length > 0 ? otherProps : undefined
|
|
585
|
+
});
|
|
586
|
+
};
|
|
587
|
+
/**
|
|
588
|
+
* 处理HTML节点
|
|
589
|
+
* @param currentElement - 当前处理的HTML元素
|
|
590
|
+
* @param parent - 父级元素,用于判断上下文
|
|
591
|
+
* @param htmlTag - HTML标签栈,用于跟踪嵌套的HTML标签
|
|
592
|
+
* @returns 返回包含解析后元素和上下文属性的对象
|
|
593
|
+
*/ var handleHtml = function(currentElement, parent, htmlTag) {
|
|
594
|
+
var _currentElement_value;
|
|
595
|
+
var trimmedValue = (currentElement === null || currentElement === void 0 ? void 0 : (_currentElement_value = currentElement.value) === null || _currentElement_value === void 0 ? void 0 : _currentElement_value.trim()) || '';
|
|
596
|
+
var isUnclosedComment = trimmedValue.startsWith('<!--') && !trimmedValue.endsWith('-->');
|
|
597
|
+
var processedValue = isUnclosedComment ? trimmedValue + '-->' : (currentElement === null || currentElement === void 0 ? void 0 : currentElement.value) || '';
|
|
598
|
+
var value = (processedValue === null || processedValue === void 0 ? void 0 : processedValue.replace('<!--', '').replace('-->', '').trim()) || '{}';
|
|
599
|
+
var contextProps = parseCommentContextProps(value, processedValue);
|
|
600
|
+
var isBlockLevel = !parent || [
|
|
601
|
+
'listItem',
|
|
602
|
+
'blockquote'
|
|
603
|
+
].includes(parent.type);
|
|
604
|
+
var el;
|
|
605
|
+
var updatedHtmlTag = htmlTag;
|
|
606
|
+
if (isBlockLevel) {
|
|
607
|
+
el = handleBlockHtml(currentElement, processedValue, isUnclosedComment);
|
|
608
|
+
} else {
|
|
609
|
+
var inlineResult = processInlineHtml(currentElement, htmlTag);
|
|
610
|
+
el = inlineResult.el;
|
|
611
|
+
updatedHtmlTag = inlineResult.htmlTag;
|
|
612
|
+
}
|
|
613
|
+
var configuredEl = applyElementConfig(el, contextProps, processedValue, isUnclosedComment, currentElement);
|
|
614
|
+
return {
|
|
615
|
+
el: configuredEl,
|
|
616
|
+
contextProps: contextProps,
|
|
617
|
+
htmlTag: updatedHtmlTag
|
|
618
|
+
};
|
|
619
|
+
};
|
|
620
|
+
/**
|
|
621
|
+
* 处理内联HTML元素(纯函数版本)
|
|
622
|
+
* @param currentElement - 当前处理的HTML元素
|
|
623
|
+
* @param htmlTag - HTML标签栈
|
|
624
|
+
* @returns 返回处理后的元素对象和新的标签栈,如果是标签则返回null
|
|
625
|
+
*/ var processInlineHtml = function(currentElement, htmlTag) {
|
|
626
|
+
var value = currentElement.value;
|
|
627
|
+
if (value.match(/<br\/?>/)) {
|
|
865
628
|
return {
|
|
866
|
-
|
|
629
|
+
el: {
|
|
630
|
+
type: 'break',
|
|
631
|
+
children: [
|
|
632
|
+
{
|
|
633
|
+
text: '\n'
|
|
634
|
+
}
|
|
635
|
+
]
|
|
636
|
+
},
|
|
637
|
+
htmlTag: htmlTag
|
|
638
|
+
};
|
|
639
|
+
}
|
|
640
|
+
var answerElement = findAnswerElement(value);
|
|
641
|
+
if (answerElement) {
|
|
642
|
+
return {
|
|
643
|
+
el: {
|
|
644
|
+
text: answerElement.content
|
|
645
|
+
},
|
|
646
|
+
htmlTag: htmlTag
|
|
867
647
|
};
|
|
868
648
|
}
|
|
869
|
-
|
|
649
|
+
if (!isStandardHtmlElement(value)) {
|
|
650
|
+
return {
|
|
651
|
+
el: {
|
|
652
|
+
text: value
|
|
653
|
+
},
|
|
654
|
+
htmlTag: htmlTag
|
|
655
|
+
};
|
|
656
|
+
}
|
|
657
|
+
var htmlMatch = value.match(/<\/?(b|i|del|font|code|span|sup|sub|strong|a)[^\n>]*?>/);
|
|
870
658
|
if (htmlMatch) {
|
|
871
659
|
var _htmlMatch = _sliced_to_array(htmlMatch, 2), str = _htmlMatch[0], tag = _htmlMatch[1];
|
|
872
|
-
|
|
873
|
-
|
|
874
|
-
|
|
875
|
-
if (
|
|
876
|
-
|
|
660
|
+
var isClosingTag = str.startsWith('</');
|
|
661
|
+
var isMatchingTag = isClosingTag && htmlTag.length && htmlTag[htmlTag.length - 1].tag === tag;
|
|
662
|
+
var newHtmlTag = htmlTag;
|
|
663
|
+
if (isMatchingTag) {
|
|
664
|
+
newHtmlTag = htmlTag.slice(0, -1);
|
|
877
665
|
}
|
|
878
|
-
|
|
879
|
-
|
|
880
|
-
var mediaElement = findImageElement(currentElement.value);
|
|
881
|
-
if (mediaElement) {
|
|
882
|
-
return createMediaNodeFromElement(mediaElement);
|
|
883
|
-
} else {
|
|
884
|
-
return {
|
|
885
|
-
text: currentElement.value
|
|
886
|
-
};
|
|
666
|
+
if (!isClosingTag) {
|
|
667
|
+
newHtmlTag = processHtmlTag(str, tag, newHtmlTag);
|
|
887
668
|
}
|
|
669
|
+
return {
|
|
670
|
+
el: null,
|
|
671
|
+
htmlTag: newHtmlTag
|
|
672
|
+
};
|
|
888
673
|
}
|
|
674
|
+
var mediaElement = findImageElement(value);
|
|
675
|
+
return {
|
|
676
|
+
el: mediaElement ? createMediaNodeFromElement(mediaElement) : {
|
|
677
|
+
text: value
|
|
678
|
+
},
|
|
679
|
+
htmlTag: htmlTag
|
|
680
|
+
};
|
|
889
681
|
};
|
|
890
682
|
/**
|
|
891
|
-
* 处理
|
|
892
|
-
|
|
893
|
-
|
|
894
|
-
|
|
895
|
-
|
|
896
|
-
|
|
897
|
-
try {
|
|
898
|
-
var styles = str.match(/style="([^"\n]+)"/);
|
|
899
|
-
if (styles) {
|
|
900
|
-
var stylesMap = new Map(styles[1].split(';').map(function(item) {
|
|
901
|
-
return item.split(':').map(function(item) {
|
|
902
|
-
return item.trim();
|
|
903
|
-
});
|
|
904
|
-
}));
|
|
905
|
-
if (stylesMap.get('color')) {
|
|
906
|
-
htmlTag.push({
|
|
907
|
-
tag: tag,
|
|
908
|
-
color: stylesMap.get('color')
|
|
909
|
-
});
|
|
910
|
-
}
|
|
911
|
-
}
|
|
912
|
-
} catch (e) {
|
|
913
|
-
console.warn('Failed to parse span style attribute:', {
|
|
914
|
-
str: str,
|
|
915
|
-
error: e
|
|
916
|
-
});
|
|
683
|
+
* 处理 span 标签的样式属性(纯函数版本)
|
|
684
|
+
*/ var processSpanTag = function(str, tag, htmlTag) {
|
|
685
|
+
try {
|
|
686
|
+
var styles = str.match(/style="([^"\n]+)"/);
|
|
687
|
+
if (!styles) {
|
|
688
|
+
return htmlTag;
|
|
917
689
|
}
|
|
918
|
-
|
|
919
|
-
|
|
920
|
-
|
|
921
|
-
htmlTag.push({
|
|
922
|
-
tag: tag,
|
|
923
|
-
url: url[1]
|
|
690
|
+
var stylesMap = new Map(styles[1].split(';').map(function(item) {
|
|
691
|
+
return item.split(':').map(function(item) {
|
|
692
|
+
return item.trim();
|
|
924
693
|
});
|
|
925
|
-
}
|
|
926
|
-
|
|
927
|
-
var color = str.match(/color="([^"\n]+)"/);
|
|
928
|
-
if (!color) {
|
|
929
|
-
color = str.match(/color=([^"\n]+)/);
|
|
930
|
-
}
|
|
694
|
+
}));
|
|
695
|
+
var color = stylesMap.get('color');
|
|
931
696
|
if (color) {
|
|
932
|
-
htmlTag.
|
|
933
|
-
|
|
934
|
-
|
|
935
|
-
|
|
697
|
+
return _to_consumable_array(htmlTag).concat([
|
|
698
|
+
{
|
|
699
|
+
tag: tag,
|
|
700
|
+
color: color
|
|
701
|
+
}
|
|
702
|
+
]);
|
|
936
703
|
}
|
|
937
|
-
}
|
|
938
|
-
|
|
939
|
-
|
|
704
|
+
} catch (e) {
|
|
705
|
+
console.warn('Failed to parse span style attribute:', {
|
|
706
|
+
str: str,
|
|
707
|
+
error: e
|
|
940
708
|
});
|
|
941
709
|
}
|
|
710
|
+
return htmlTag;
|
|
711
|
+
};
|
|
712
|
+
/**
|
|
713
|
+
* 处理 a 标签的链接属性(纯函数版本)
|
|
714
|
+
*/ var processATag = function(str, tag, htmlTag) {
|
|
715
|
+
var url = str.match(/href="([\w:./_\-#\\]+)"/);
|
|
716
|
+
if (url) {
|
|
717
|
+
return _to_consumable_array(htmlTag).concat([
|
|
718
|
+
{
|
|
719
|
+
tag: tag,
|
|
720
|
+
url: url[1]
|
|
721
|
+
}
|
|
722
|
+
]);
|
|
723
|
+
}
|
|
724
|
+
return htmlTag;
|
|
725
|
+
};
|
|
726
|
+
/**
|
|
727
|
+
* 处理 font 标签的颜色属性(纯函数版本)
|
|
728
|
+
*/ var processFontTag = function(str, tag, htmlTag) {
|
|
729
|
+
var colorMatch = str.match(/color="([^"\n]+)"/) || str.match(/color=([^"\n]+)/);
|
|
730
|
+
if (colorMatch) {
|
|
731
|
+
return _to_consumable_array(htmlTag).concat([
|
|
732
|
+
{
|
|
733
|
+
tag: tag,
|
|
734
|
+
color: colorMatch[1].replaceAll('>', '')
|
|
735
|
+
}
|
|
736
|
+
]);
|
|
737
|
+
}
|
|
738
|
+
return htmlTag;
|
|
739
|
+
};
|
|
740
|
+
/**
|
|
741
|
+
* HTML 标签处理器映射表
|
|
742
|
+
*/ var htmlTagProcessors = {
|
|
743
|
+
span: processSpanTag,
|
|
744
|
+
a: processATag,
|
|
745
|
+
font: processFontTag
|
|
746
|
+
};
|
|
747
|
+
/**
|
|
748
|
+
* 处理HTML标签并添加到标签栈中(纯函数版本)
|
|
749
|
+
* @param str - HTML标签字符串
|
|
750
|
+
* @param tag - 标签名称
|
|
751
|
+
* @param htmlTag - HTML标签栈
|
|
752
|
+
* @returns 返回新的标签栈数组
|
|
753
|
+
*/ var processHtmlTag = function(str, tag, htmlTag) {
|
|
754
|
+
var processor = htmlTagProcessors[tag];
|
|
755
|
+
if (processor) {
|
|
756
|
+
return processor(str, tag, htmlTag);
|
|
757
|
+
}
|
|
758
|
+
return _to_consumable_array(htmlTag).concat([
|
|
759
|
+
{
|
|
760
|
+
tag: tag
|
|
761
|
+
}
|
|
762
|
+
]);
|
|
942
763
|
};
|
|
943
764
|
/**
|
|
944
765
|
* 处理图片节点
|
|
@@ -946,7 +767,8 @@ export var decodeURIComponentUrl = function(url) {
|
|
|
946
767
|
* @returns 返回格式化的图片节点对象
|
|
947
768
|
*/ var handleImage = function(currentElement) {
|
|
948
769
|
return EditorUtils.createMediaNode(decodeURIComponent(currentElement === null || currentElement === void 0 ? void 0 : currentElement.url), 'image', {
|
|
949
|
-
alt: currentElement.alt
|
|
770
|
+
alt: currentElement.alt,
|
|
771
|
+
finished: currentElement.finished
|
|
950
772
|
});
|
|
951
773
|
};
|
|
952
774
|
/**
|
|
@@ -1001,6 +823,7 @@ export var decodeURIComponentUrl = function(url) {
|
|
|
1001
823
|
type: 'list',
|
|
1002
824
|
order: currentElement.ordered,
|
|
1003
825
|
start: currentElement.start,
|
|
826
|
+
finished: currentElement.finished,
|
|
1004
827
|
children: parseNodes(currentElement.children, plugins, false, currentElement, parserConfig)
|
|
1005
828
|
};
|
|
1006
829
|
el.task = (_el_children = el.children) === null || _el_children === void 0 ? void 0 : _el_children.some(function(s) {
|
|
@@ -1039,11 +862,11 @@ export var decodeURIComponentUrl = function(url) {
|
|
|
1039
862
|
};
|
|
1040
863
|
};
|
|
1041
864
|
/**
|
|
1042
|
-
*
|
|
865
|
+
* 处理列表项节点(纯函数版本)
|
|
1043
866
|
* @param currentElement - 当前处理的列表项元素
|
|
1044
867
|
* @returns 返回格式化的列表项节点对象,包含复选框状态和提及信息
|
|
1045
868
|
*/ var handleListItem = function(currentElement, plugins, parserConfig) {
|
|
1046
|
-
var _currentElement_children, _currentElement_children__children_, _currentElement_children__children, _currentElement_children_, _currentElement_children1, _currentElement_children__children1, _currentElement_children_1, _currentElement_children2,
|
|
869
|
+
var _currentElement_children, _currentElement_children__children_, _currentElement_children__children, _currentElement_children_, _currentElement_children1, _currentElement_children__children1, _currentElement_children_1, _currentElement_children2, _processedChildren_, _processedChildren__children_, _processedChildren__children, _processedChildren_1;
|
|
1047
870
|
var children = ((_currentElement_children = currentElement.children) === null || _currentElement_children === void 0 ? void 0 : _currentElement_children.length) ? parseNodes(currentElement.children, plugins, false, currentElement, parserConfig) : [
|
|
1048
871
|
{
|
|
1049
872
|
type: 'paragraph',
|
|
@@ -1055,12 +878,13 @@ export var decodeURIComponentUrl = function(url) {
|
|
|
1055
878
|
}
|
|
1056
879
|
];
|
|
1057
880
|
var mentions = undefined;
|
|
881
|
+
var processedChildren = _to_consumable_array(children);
|
|
1058
882
|
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) {
|
|
1059
|
-
var
|
|
1060
|
-
var item =
|
|
883
|
+
var _processedChildren__children1, _processedChildren_2;
|
|
884
|
+
var item = processedChildren === null || processedChildren === void 0 ? void 0 : (_processedChildren_2 = processedChildren[0]) === null || _processedChildren_2 === void 0 ? void 0 : (_processedChildren__children1 = _processedChildren_2.children) === null || _processedChildren__children1 === void 0 ? void 0 : _processedChildren__children1[0];
|
|
1061
885
|
var label = item === null || item === void 0 ? void 0 : item.text;
|
|
1062
886
|
if (label) {
|
|
1063
|
-
var _item_url
|
|
887
|
+
var _item_url;
|
|
1064
888
|
mentions = [
|
|
1065
889
|
{
|
|
1066
890
|
avatar: item === null || item === void 0 ? void 0 : item.url,
|
|
@@ -1068,23 +892,35 @@ export var decodeURIComponentUrl = function(url) {
|
|
|
1068
892
|
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
|
|
1069
893
|
}
|
|
1070
894
|
];
|
|
1071
|
-
|
|
1072
|
-
if (
|
|
1073
|
-
|
|
1074
|
-
|
|
895
|
+
var firstChild = processedChildren[0];
|
|
896
|
+
if (firstChild && firstChild.children) {
|
|
897
|
+
processedChildren = [
|
|
898
|
+
_object_spread_props(_object_spread({}, firstChild), {
|
|
899
|
+
children: firstChild.children.filter(function(_, idx) {
|
|
900
|
+
return idx !== 0;
|
|
901
|
+
})
|
|
902
|
+
})
|
|
903
|
+
].concat(_to_consumable_array(processedChildren.slice(1)));
|
|
1075
904
|
}
|
|
1076
905
|
}
|
|
1077
906
|
}
|
|
1078
|
-
if (
|
|
1079
|
-
var
|
|
1080
|
-
var text = (_children__children_1 = children[0].children[0]) === null || _children__children_1 === void 0 ? void 0 : _children__children_1.text;
|
|
907
|
+
if (((_processedChildren_ = processedChildren[0]) === null || _processedChildren_ === void 0 ? void 0 : _processedChildren_.type) === 'paragraph' && ((_processedChildren_1 = processedChildren[0]) === null || _processedChildren_1 === void 0 ? void 0 : (_processedChildren__children = _processedChildren_1.children) === null || _processedChildren__children === void 0 ? void 0 : (_processedChildren__children_ = _processedChildren__children[0]) === null || _processedChildren__children_ === void 0 ? void 0 : _processedChildren__children_.text)) {
|
|
908
|
+
var text = processedChildren[0].children[0].text;
|
|
1081
909
|
var m = text.match(/^\[([x\s])]/);
|
|
1082
910
|
if (m) {
|
|
1083
|
-
|
|
911
|
+
var updatedFirstChild = _object_spread_props(_object_spread({}, processedChildren[0]), {
|
|
912
|
+
children: [
|
|
913
|
+
_object_spread_props(_object_spread({}, processedChildren[0].children[0]), {
|
|
914
|
+
text: text.replace(/^\[([x\s])]/, '')
|
|
915
|
+
})
|
|
916
|
+
].concat(_to_consumable_array(processedChildren[0].children.slice(1)))
|
|
917
|
+
});
|
|
1084
918
|
return {
|
|
1085
919
|
type: 'list-item',
|
|
1086
920
|
checked: m ? m[1] === 'x' : undefined,
|
|
1087
|
-
children:
|
|
921
|
+
children: [
|
|
922
|
+
updatedFirstChild
|
|
923
|
+
].concat(_to_consumable_array(processedChildren.slice(1))),
|
|
1088
924
|
mentions: mentions
|
|
1089
925
|
};
|
|
1090
926
|
}
|
|
@@ -1092,7 +928,7 @@ export var decodeURIComponentUrl = function(url) {
|
|
|
1092
928
|
return {
|
|
1093
929
|
type: 'list-item',
|
|
1094
930
|
checked: currentElement.checked,
|
|
1095
|
-
children:
|
|
931
|
+
children: processedChildren,
|
|
1096
932
|
mentions: mentions
|
|
1097
933
|
};
|
|
1098
934
|
};
|
|
@@ -1159,6 +995,58 @@ export var decodeURIComponentUrl = function(url) {
|
|
|
1159
995
|
name: link.title
|
|
1160
996
|
});
|
|
1161
997
|
};
|
|
998
|
+
/**
|
|
999
|
+
* 处理段落中的图片子元素(纯函数版本)
|
|
1000
|
+
*/ var processImageChild = function(currentChild, textNodes, elements, currentElement, plugins, parserConfig) {
|
|
1001
|
+
var newElements = _to_consumable_array(elements);
|
|
1002
|
+
var newTextNodes = _to_consumable_array(textNodes);
|
|
1003
|
+
if (textNodes.length) {
|
|
1004
|
+
newElements.push({
|
|
1005
|
+
type: 'paragraph',
|
|
1006
|
+
children: parseNodes(textNodes, plugins, false, currentElement, parserConfig)
|
|
1007
|
+
});
|
|
1008
|
+
newTextNodes = [];
|
|
1009
|
+
}
|
|
1010
|
+
newElements.push(EditorUtils.createMediaNode(decodeURIComponentUrl(currentChild === null || currentChild === void 0 ? void 0 : currentChild.url), 'image', {
|
|
1011
|
+
alt: currentChild.alt,
|
|
1012
|
+
finished: currentChild.finished
|
|
1013
|
+
}));
|
|
1014
|
+
return {
|
|
1015
|
+
elements: newElements,
|
|
1016
|
+
textNodes: newTextNodes
|
|
1017
|
+
};
|
|
1018
|
+
};
|
|
1019
|
+
/**
|
|
1020
|
+
* 处理段落中的 HTML 子元素(纯函数版本)
|
|
1021
|
+
*/ var processHtmlChild = function(currentChild, textNodes, elements) {
|
|
1022
|
+
if (currentChild.value.match(/^<\/(img|video|iframe)>/)) {
|
|
1023
|
+
return {
|
|
1024
|
+
elements: elements,
|
|
1025
|
+
textNodes: textNodes
|
|
1026
|
+
};
|
|
1027
|
+
}
|
|
1028
|
+
var mediaElement = findImageElement(currentChild.value);
|
|
1029
|
+
if (mediaElement) {
|
|
1030
|
+
var node = createMediaNodeFromElement(mediaElement);
|
|
1031
|
+
if (node) {
|
|
1032
|
+
return {
|
|
1033
|
+
elements: _to_consumable_array(elements).concat([
|
|
1034
|
+
node
|
|
1035
|
+
]),
|
|
1036
|
+
textNodes: textNodes
|
|
1037
|
+
};
|
|
1038
|
+
}
|
|
1039
|
+
}
|
|
1040
|
+
return {
|
|
1041
|
+
elements: elements,
|
|
1042
|
+
textNodes: _to_consumable_array(textNodes).concat([
|
|
1043
|
+
{
|
|
1044
|
+
type: 'html',
|
|
1045
|
+
value: currentChild.value
|
|
1046
|
+
}
|
|
1047
|
+
])
|
|
1048
|
+
};
|
|
1049
|
+
};
|
|
1162
1050
|
/**
|
|
1163
1051
|
* 处理段落中的子元素
|
|
1164
1052
|
*/ var processParagraphChildren = function(currentElement, plugins, parserConfig) {
|
|
@@ -1169,37 +1057,17 @@ export var decodeURIComponentUrl = function(url) {
|
|
|
1169
1057
|
for(var _iterator = (currentElement.children || [])[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true){
|
|
1170
1058
|
var currentChild = _step.value;
|
|
1171
1059
|
if (currentChild.type === 'image') {
|
|
1172
|
-
|
|
1173
|
-
|
|
1174
|
-
|
|
1175
|
-
type: 'paragraph',
|
|
1176
|
-
children: parseNodes(textNodes, plugins, false, currentElement, parserConfig)
|
|
1177
|
-
});
|
|
1178
|
-
textNodes = [];
|
|
1179
|
-
}
|
|
1180
|
-
// 添加图片节点
|
|
1181
|
-
elements.push(EditorUtils.createMediaNode(decodeURIComponentUrl(currentChild === null || currentChild === void 0 ? void 0 : currentChild.url), 'image', {
|
|
1182
|
-
alt: currentChild.alt
|
|
1183
|
-
}));
|
|
1060
|
+
var result = processImageChild(currentChild, textNodes, elements, currentElement, plugins, parserConfig);
|
|
1061
|
+
elements = result.elements;
|
|
1062
|
+
textNodes = result.textNodes;
|
|
1184
1063
|
} else if (currentChild.type === 'html') {
|
|
1185
|
-
|
|
1186
|
-
|
|
1187
|
-
|
|
1188
|
-
}
|
|
1189
|
-
var mediaElement = findImageElement(currentChild.value);
|
|
1190
|
-
if (mediaElement) {
|
|
1191
|
-
var node = createMediaNodeFromElement(mediaElement);
|
|
1192
|
-
if (node) {
|
|
1193
|
-
elements.push(node);
|
|
1194
|
-
}
|
|
1195
|
-
} else {
|
|
1196
|
-
textNodes.push({
|
|
1197
|
-
type: 'html',
|
|
1198
|
-
value: currentChild.value
|
|
1199
|
-
});
|
|
1200
|
-
}
|
|
1064
|
+
var result1 = processHtmlChild(currentChild, textNodes, elements);
|
|
1065
|
+
elements = result1.elements;
|
|
1066
|
+
textNodes = result1.textNodes;
|
|
1201
1067
|
} else {
|
|
1202
|
-
textNodes.
|
|
1068
|
+
textNodes = _to_consumable_array(textNodes).concat([
|
|
1069
|
+
currentChild
|
|
1070
|
+
]);
|
|
1203
1071
|
}
|
|
1204
1072
|
}
|
|
1205
1073
|
} catch (err) {
|
|
@@ -1216,7 +1084,6 @@ export var decodeURIComponentUrl = function(url) {
|
|
|
1216
1084
|
}
|
|
1217
1085
|
}
|
|
1218
1086
|
}
|
|
1219
|
-
// 处理剩余的文本节点
|
|
1220
1087
|
if (textNodes.length) {
|
|
1221
1088
|
elements.push({
|
|
1222
1089
|
type: 'paragraph',
|
|
@@ -1279,88 +1146,6 @@ export var decodeURIComponentUrl = function(url) {
|
|
|
1279
1146
|
]
|
|
1280
1147
|
};
|
|
1281
1148
|
};
|
|
1282
|
-
/**
|
|
1283
|
-
* 处理代码块节点
|
|
1284
|
-
* @param currentElement - 当前处理的代码块元素,包含语言和内容
|
|
1285
|
-
* @returns 返回格式化的代码块节点对象,根据语言类型进行特殊处理
|
|
1286
|
-
*/ var handleCode = function(currentElement) {
|
|
1287
|
-
var _match, _currentElement_otherProps, _currentElement_value_trim;
|
|
1288
|
-
var rawValue = currentElement.value || '';
|
|
1289
|
-
var langString = ((_match = (currentElement.lang || '').match(NOT_SPACE_START)) === null || _match === void 0 ? void 0 : _match[0]) || '';
|
|
1290
|
-
var code = "".concat(rawValue.replace(ENDING_NEWLINE, ''), "\n");
|
|
1291
|
-
// 检查代码块是否完整
|
|
1292
|
-
// 如果是缩进代码块,认为是完整的(因为没有结束标记)
|
|
1293
|
-
var isIndentedCode = currentElement.meta === 'indented';
|
|
1294
|
-
// 使用更智能的方法判断代码块是否完整
|
|
1295
|
-
var streamStatus = 'loading';
|
|
1296
|
-
if (isIndentedCode) {
|
|
1297
|
-
// 缩进代码块没有结束标记,认为是完整的
|
|
1298
|
-
streamStatus = 'done';
|
|
1299
|
-
} else {
|
|
1300
|
-
// 对于围栏代码块,使用多种方法判断
|
|
1301
|
-
var endsWithNewline = code.match(ENDING_NEWLINE);
|
|
1302
|
-
// 如果代码以换行结尾,可能是完整的
|
|
1303
|
-
if (endsWithNewline) {
|
|
1304
|
-
// 进一步检查代码内容是否完整(特别是对于 Mermaid 等需要完整语法的情况)
|
|
1305
|
-
var isLikelyComplete = isCodeBlockLikelyComplete(rawValue, currentElement.lang);
|
|
1306
|
-
streamStatus = isLikelyComplete ? 'done' : 'loading';
|
|
1307
|
-
} else {
|
|
1308
|
-
// 没有换行结尾,肯定不完整
|
|
1309
|
-
streamStatus = 'loading';
|
|
1310
|
-
}
|
|
1311
|
-
}
|
|
1312
|
-
// 如果已经在 parseNodes 中设置了 finish(基于是否是最后一个节点),优先使用它
|
|
1313
|
-
// 否则使用 streamStatus 判断
|
|
1314
|
-
var finishValue = ((_currentElement_otherProps = currentElement.otherProps) === null || _currentElement_otherProps === void 0 ? void 0 : _currentElement_otherProps.finish) !== undefined ? currentElement.otherProps.finish : streamStatus === 'done';
|
|
1315
|
-
var baseCodeElement = {
|
|
1316
|
-
type: 'code',
|
|
1317
|
-
language: currentElement.lang === 'apaasify' ? 'apaasify' : currentElement.lang,
|
|
1318
|
-
render: currentElement.meta === 'render',
|
|
1319
|
-
value: currentElement.value,
|
|
1320
|
-
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('<!--'),
|
|
1321
|
-
children: [
|
|
1322
|
-
{
|
|
1323
|
-
text: currentElement.value
|
|
1324
|
-
}
|
|
1325
|
-
],
|
|
1326
|
-
// 添加流式状态支持
|
|
1327
|
-
otherProps: _object_spread(_object_spread_props(_object_spread({}, currentElement.otherProps || {}), {
|
|
1328
|
-
'data-block': 'true',
|
|
1329
|
-
'data-state': streamStatus,
|
|
1330
|
-
// 优先使用 parseNodes 中设置的 finish,否则使用 streamStatus 判断
|
|
1331
|
-
finish: finishValue
|
|
1332
|
-
}), langString ? {
|
|
1333
|
-
'data-language': langString
|
|
1334
|
-
} : {})
|
|
1335
|
-
};
|
|
1336
|
-
var handler = LANGUAGE_HANDLERS[currentElement.lang];
|
|
1337
|
-
var result = handler ? handler(baseCodeElement, currentElement.value) : baseCodeElement;
|
|
1338
|
-
// 确保 otherProps 被保留
|
|
1339
|
-
var resultWithProps = result;
|
|
1340
|
-
if (baseCodeElement.otherProps && !resultWithProps.otherProps) {
|
|
1341
|
-
resultWithProps.otherProps = baseCodeElement.otherProps;
|
|
1342
|
-
} else if (baseCodeElement.otherProps && resultWithProps.otherProps) {
|
|
1343
|
-
resultWithProps.otherProps = _object_spread({}, resultWithProps.otherProps, baseCodeElement.otherProps);
|
|
1344
|
-
}
|
|
1345
|
-
return resultWithProps;
|
|
1346
|
-
};
|
|
1347
|
-
/**
|
|
1348
|
-
* 处理YAML节点
|
|
1349
|
-
* @param currentElement - 当前处理的YAML元素
|
|
1350
|
-
* @returns 返回格式化的YAML代码块节点对象
|
|
1351
|
-
*/ var handleYaml = function(currentElement) {
|
|
1352
|
-
return {
|
|
1353
|
-
type: 'code',
|
|
1354
|
-
language: 'yaml',
|
|
1355
|
-
value: currentElement.value,
|
|
1356
|
-
frontmatter: true,
|
|
1357
|
-
children: [
|
|
1358
|
-
{
|
|
1359
|
-
text: currentElement.value
|
|
1360
|
-
}
|
|
1361
|
-
]
|
|
1362
|
-
};
|
|
1363
|
-
};
|
|
1364
1149
|
/**
|
|
1365
1150
|
* 处理引用块节点
|
|
1366
1151
|
* @param currentElement - 当前处理的引用块元素
|
|
@@ -1396,26 +1181,33 @@ export var decodeURIComponentUrl = function(url) {
|
|
|
1396
1181
|
};
|
|
1397
1182
|
};
|
|
1398
1183
|
/**
|
|
1399
|
-
* 应用HTML
|
|
1184
|
+
* 应用HTML标签样式到元素(纯函数版本)
|
|
1400
1185
|
* @param el - 目标元素对象
|
|
1401
1186
|
* @param htmlTag - HTML标签数组,包含样式信息
|
|
1187
|
+
* @returns 返回应用了样式的新元素对象
|
|
1402
1188
|
*/ var applyHtmlTagsToElement = function(el, htmlTag) {
|
|
1189
|
+
if (!htmlTag.length) {
|
|
1190
|
+
return el;
|
|
1191
|
+
}
|
|
1192
|
+
var result = _object_spread({}, el);
|
|
1403
1193
|
var _iteratorNormalCompletion = true, _didIteratorError = false, _iteratorError = undefined;
|
|
1404
1194
|
try {
|
|
1405
1195
|
for(var _iterator = htmlTag[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true){
|
|
1406
1196
|
var t = _step.value;
|
|
1407
1197
|
if (t.tag === 'font') {
|
|
1408
|
-
|
|
1198
|
+
result.color = t.color;
|
|
1199
|
+
}
|
|
1200
|
+
if (t.tag === 'sup') result.identifier = el.text;
|
|
1201
|
+
if (t.tag === 'sub') result.identifier = el.text;
|
|
1202
|
+
if (t.tag === 'code') result.code = true;
|
|
1203
|
+
if (t.tag === 'i') result.italic = true;
|
|
1204
|
+
if (t.tag === 'b' || t.tag === 'strong') result.bold = true;
|
|
1205
|
+
if (t.tag === 'del') result.strikethrough = true;
|
|
1206
|
+
if ((t.tag === 'span' || t.tag === 'font') && t.color) {
|
|
1207
|
+
result.highColor = t.color;
|
|
1409
1208
|
}
|
|
1410
|
-
if (t.tag === 'sup') el.identifier = el.text;
|
|
1411
|
-
if (t.tag === 'sub') el.identifier = el.text;
|
|
1412
|
-
if (t.tag === 'code') el.code = true;
|
|
1413
|
-
if (t.tag === 'i') el.italic = true;
|
|
1414
|
-
if (t.tag === 'b' || t.tag === 'strong') el.bold = true;
|
|
1415
|
-
if (t.tag === 'del') el.strikethrough = true;
|
|
1416
|
-
if ((t.tag === 'span' || t.tag === 'font') && t.color) el.highColor = t.color;
|
|
1417
1209
|
if (t.tag === 'a' && (t === null || t === void 0 ? void 0 : t.url)) {
|
|
1418
|
-
|
|
1210
|
+
result.url = t === null || t === void 0 ? void 0 : t.url;
|
|
1419
1211
|
}
|
|
1420
1212
|
}
|
|
1421
1213
|
} catch (err) {
|
|
@@ -1432,58 +1224,124 @@ export var decodeURIComponentUrl = function(url) {
|
|
|
1432
1224
|
}
|
|
1433
1225
|
}
|
|
1434
1226
|
}
|
|
1227
|
+
return result;
|
|
1435
1228
|
};
|
|
1436
1229
|
/**
|
|
1437
|
-
*
|
|
1230
|
+
* 处理文本和内联元素节点(纯函数版本)
|
|
1231
|
+
* @param currentElement - 当前处理的元素
|
|
1232
|
+
* @param htmlTag - HTML标签数组
|
|
1233
|
+
* @param applyInlineFormattingFn - 应用内联格式的函数
|
|
1234
|
+
* @param parseNodesFn - 解析节点的函数
|
|
1235
|
+
* @returns 处理后的元素对象
|
|
1236
|
+
*/ var handleTextAndInlineElementsPure = function(currentElement, htmlTag, applyInlineFormattingFn, parseNodesFn) {
|
|
1237
|
+
var elementType = currentElement.type;
|
|
1238
|
+
// 处理文本节点
|
|
1239
|
+
if (elementType === 'text') {
|
|
1240
|
+
var el = {
|
|
1241
|
+
text: currentElement.value
|
|
1242
|
+
};
|
|
1243
|
+
return htmlTag.length > 0 && currentElement.value ? applyHtmlTagsToElement(el, htmlTag) : el;
|
|
1244
|
+
}
|
|
1245
|
+
// 处理换行
|
|
1246
|
+
if (elementType === 'break') {
|
|
1247
|
+
return {
|
|
1248
|
+
text: '\n'
|
|
1249
|
+
};
|
|
1250
|
+
}
|
|
1251
|
+
// 处理内联元素(strong, link, emphasis, delete, inlineCode)
|
|
1252
|
+
var inlineElementTypes = [
|
|
1253
|
+
'strong',
|
|
1254
|
+
'link',
|
|
1255
|
+
'emphasis',
|
|
1256
|
+
'delete',
|
|
1257
|
+
'inlineCode'
|
|
1258
|
+
];
|
|
1259
|
+
if (inlineElementTypes.includes(elementType)) {
|
|
1260
|
+
var _currentElement_children, _parseNodesFn, _currentElement_children1;
|
|
1261
|
+
var finished = currentElement.finished;
|
|
1262
|
+
var leaf = _object_spread({}, finished === false && {
|
|
1263
|
+
otherProps: {
|
|
1264
|
+
finished: finished
|
|
1265
|
+
}
|
|
1266
|
+
});
|
|
1267
|
+
var formattedLeaf = applyInlineFormattingFn(leaf, currentElement);
|
|
1268
|
+
var leafWithHtmlTags = applyHtmlTagsToElement(formattedLeaf, htmlTag);
|
|
1269
|
+
var hasHtmlChildren = currentElement === null || currentElement === void 0 ? void 0 : (_currentElement_children = currentElement.children) === null || _currentElement_children === void 0 ? void 0 : _currentElement_children.some(function(n) {
|
|
1270
|
+
return n.type === 'html';
|
|
1271
|
+
});
|
|
1272
|
+
return hasHtmlChildren ? _object_spread_props(_object_spread({}, (_parseNodesFn = parseNodesFn(currentElement === null || currentElement === void 0 ? void 0 : currentElement.children, false, currentElement)) === null || _parseNodesFn === void 0 ? void 0 : _parseNodesFn.at(0)), {
|
|
1273
|
+
url: leafWithHtmlTags.url
|
|
1274
|
+
}) : parseText(((_currentElement_children1 = currentElement.children) === null || _currentElement_children1 === void 0 ? void 0 : _currentElement_children1.length) ? currentElement.children : [
|
|
1275
|
+
{
|
|
1276
|
+
value: (leafWithHtmlTags === null || leafWithHtmlTags === void 0 ? void 0 : leafWithHtmlTags.url) || ''
|
|
1277
|
+
}
|
|
1278
|
+
], leafWithHtmlTags);
|
|
1279
|
+
}
|
|
1280
|
+
// 默认返回空文本
|
|
1281
|
+
return {
|
|
1282
|
+
text: ''
|
|
1283
|
+
};
|
|
1284
|
+
};
|
|
1285
|
+
/**
|
|
1286
|
+
* 应用上下文属性和配置到元素(纯函数版本)
|
|
1438
1287
|
* @param el - 目标元素或元素数组
|
|
1439
1288
|
* @param contextProps - 上下文属性对象
|
|
1440
1289
|
* @param config - 配置对象
|
|
1441
|
-
* @returns
|
|
1290
|
+
* @returns 返回应用了属性和配置的新元素
|
|
1442
1291
|
*/ var applyContextPropsAndConfig = function(el, contextProps, config) {
|
|
1292
|
+
var hasContextProps = Object.keys(contextProps || {}).length > 0;
|
|
1293
|
+
var hasConfig = Object.keys(config || {}).length > 0;
|
|
1443
1294
|
if (Array.isArray(el)) {
|
|
1444
1295
|
return el.map(function(item) {
|
|
1445
|
-
|
|
1446
|
-
|
|
1296
|
+
var result = _object_spread({}, item);
|
|
1297
|
+
if (hasContextProps) {
|
|
1298
|
+
result.contextProps = contextProps;
|
|
1447
1299
|
}
|
|
1448
|
-
if (
|
|
1449
|
-
|
|
1300
|
+
if (hasConfig && !item.otherProps) {
|
|
1301
|
+
result.otherProps = config;
|
|
1450
1302
|
}
|
|
1451
|
-
return
|
|
1303
|
+
return result;
|
|
1452
1304
|
});
|
|
1453
|
-
} else {
|
|
1454
|
-
if (Object.keys(contextProps || {}).length) {
|
|
1455
|
-
el.contextProps = contextProps;
|
|
1456
|
-
}
|
|
1457
|
-
if (Object.keys(config || {}).length && !el.otherProps) {
|
|
1458
|
-
el.otherProps = config;
|
|
1459
|
-
}
|
|
1460
|
-
return el;
|
|
1461
1305
|
}
|
|
1306
|
+
var result = _object_spread({}, el);
|
|
1307
|
+
if (hasContextProps) {
|
|
1308
|
+
result.contextProps = contextProps;
|
|
1309
|
+
}
|
|
1310
|
+
if (hasConfig && !el.otherProps) {
|
|
1311
|
+
result.otherProps = config;
|
|
1312
|
+
}
|
|
1313
|
+
return result;
|
|
1462
1314
|
};
|
|
1463
1315
|
/**
|
|
1464
|
-
*
|
|
1316
|
+
* 根据行间距添加空行元素(纯函数版本)
|
|
1465
1317
|
* @param els - 目标元素数组
|
|
1466
1318
|
* @param preNode - 前一个节点
|
|
1467
1319
|
* @param currentElement - 当前处理的元素
|
|
1468
1320
|
* @param top - 是否为顶级解析
|
|
1321
|
+
* @returns 返回添加了空行元素的新数组
|
|
1469
1322
|
*/ var addEmptyLinesIfNeeded = function(els, preNode, currentElement, top) {
|
|
1470
|
-
|
|
1471
|
-
|
|
1472
|
-
|
|
1473
|
-
if (distance >= EMPTY_LINE_DISTANCE_THRESHOLD) {
|
|
1474
|
-
var lines = Math.floor((distance - EMPTY_LINE_CALCULATION_OFFSET) / EMPTY_LINE_DIVISOR);
|
|
1475
|
-
Array.from(new Array(lines)).forEach(function() {
|
|
1476
|
-
els.push({
|
|
1477
|
-
type: 'paragraph',
|
|
1478
|
-
children: [
|
|
1479
|
-
{
|
|
1480
|
-
text: ''
|
|
1481
|
-
}
|
|
1482
|
-
]
|
|
1483
|
-
});
|
|
1484
|
-
});
|
|
1485
|
-
}
|
|
1323
|
+
var _currentElement_position, _preNode_position;
|
|
1324
|
+
if (!preNode || !top) {
|
|
1325
|
+
return els;
|
|
1486
1326
|
}
|
|
1327
|
+
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);
|
|
1328
|
+
if (distance < EMPTY_LINE_DISTANCE_THRESHOLD) {
|
|
1329
|
+
return els;
|
|
1330
|
+
}
|
|
1331
|
+
var lines = Math.floor((distance - EMPTY_LINE_CALCULATION_OFFSET) / EMPTY_LINE_DIVISOR);
|
|
1332
|
+
var emptyLines = Array.from({
|
|
1333
|
+
length: lines
|
|
1334
|
+
}, function() {
|
|
1335
|
+
return {
|
|
1336
|
+
type: 'paragraph',
|
|
1337
|
+
children: [
|
|
1338
|
+
{
|
|
1339
|
+
text: ''
|
|
1340
|
+
}
|
|
1341
|
+
]
|
|
1342
|
+
};
|
|
1343
|
+
});
|
|
1344
|
+
return _to_consumable_array(els).concat(_to_consumable_array(emptyLines));
|
|
1487
1345
|
};
|
|
1488
1346
|
/**
|
|
1489
1347
|
* 元素处理器映射表
|
|
@@ -1567,7 +1425,7 @@ export var decodeURIComponentUrl = function(url) {
|
|
|
1567
1425
|
},
|
|
1568
1426
|
table: {
|
|
1569
1427
|
handler: function(el, plugins, config, parent, htmlTag, preElement) {
|
|
1570
|
-
return parseTableOrChart(el, preElement, plugins);
|
|
1428
|
+
return parseTableOrChart(el, preElement, plugins, parseNodes, undefined);
|
|
1571
1429
|
}
|
|
1572
1430
|
},
|
|
1573
1431
|
definition: {
|
|
@@ -1589,7 +1447,6 @@ export var decodeURIComponentUrl = function(url) {
|
|
|
1589
1447
|
var parser = new MarkdownToSlateParser(parserConfig || {}, plugins || []);
|
|
1590
1448
|
return parser.parseNodes(nodes, top, parent);
|
|
1591
1449
|
};
|
|
1592
|
-
var tableRegex = /^\|.*\|\s*\n\|[-:| ]+\|/m;
|
|
1593
1450
|
/**
|
|
1594
1451
|
* 标准 HTML 元素列表
|
|
1595
1452
|
* 这些标签会被正常解析为 HTML,其他标签会被当作普通文本处理
|
|
@@ -1693,9 +1550,7 @@ var tableRegex = /^\|.*\|\s*\n\|[-:| ]+\|/m;
|
|
|
1693
1550
|
'menu',
|
|
1694
1551
|
'menuitem',
|
|
1695
1552
|
// 字体
|
|
1696
|
-
'font'
|
|
1697
|
-
// 自定义标签(用于流式渲染)
|
|
1698
|
-
'incomplete-image'
|
|
1553
|
+
'font'
|
|
1699
1554
|
]);
|
|
1700
1555
|
/**
|
|
1701
1556
|
* 检查 HTML 标签是否为标准元素
|
|
@@ -1736,78 +1591,6 @@ var tableRegex = /^\|.*\|\s*\n\|[-:| ]+\|/m;
|
|
|
1736
1591
|
*/ function preprocessThinkTags(markdown) {
|
|
1737
1592
|
return preprocessSpecialTags(markdown, 'think');
|
|
1738
1593
|
}
|
|
1739
|
-
/**
|
|
1740
|
-
* 检测不完整的图片标记
|
|
1741
|
-
* 参考 useStreaming 中的逻辑,检测类似  {
|
|
1745
|
-
// 匹配不完整的图片语法:
|
|
1746
|
-
// 1. ![ 开始但还没有 ]
|
|
1747
|
-
// 2. ![text] 开始但还没有 (
|
|
1748
|
-
// 3. 
|
|
1749
|
-
var incompleteImagePatterns = [
|
|
1750
|
-
/^!\[[^\]\r\n]{0,1000}$/,
|
|
1751
|
-
/^!\[[^\r\n]{0,1000}\]\(*[^)\r\n]{0,1000}$/
|
|
1752
|
-
];
|
|
1753
|
-
return incompleteImagePatterns.some(function(pattern) {
|
|
1754
|
-
return pattern.test(markdown);
|
|
1755
|
-
});
|
|
1756
|
-
}
|
|
1757
|
-
/**
|
|
1758
|
-
* 预处理不完整的图片标记,将其转换为特殊的 HTML 标签
|
|
1759
|
-
* @param markdown - 原始 Markdown 字符串
|
|
1760
|
-
* @returns 处理后的 Markdown 字符串
|
|
1761
|
-
*/ function preprocessIncompleteImages(markdown) {
|
|
1762
|
-
if (!markdown) return markdown;
|
|
1763
|
-
// 按行处理,避免在代码块中处理
|
|
1764
|
-
var lines = markdown.split('\n');
|
|
1765
|
-
var inCodeBlock = false;
|
|
1766
|
-
var codeBlockFence = '';
|
|
1767
|
-
var codeBlockFenceLen = 0;
|
|
1768
|
-
var processedLines = lines.map(function(line) {
|
|
1769
|
-
// 检测代码块开始/结束
|
|
1770
|
-
var fenceMatch = line.match(FENCED_CODE_REGEX);
|
|
1771
|
-
if (fenceMatch) {
|
|
1772
|
-
var currentFence = fenceMatch[1];
|
|
1773
|
-
var char = currentFence[0];
|
|
1774
|
-
var len = currentFence.length;
|
|
1775
|
-
if (!inCodeBlock) {
|
|
1776
|
-
inCodeBlock = true;
|
|
1777
|
-
codeBlockFence = char;
|
|
1778
|
-
codeBlockFenceLen = len;
|
|
1779
|
-
} else if (char === codeBlockFence && len >= codeBlockFenceLen) {
|
|
1780
|
-
inCodeBlock = false;
|
|
1781
|
-
codeBlockFence = '';
|
|
1782
|
-
codeBlockFenceLen = 0;
|
|
1783
|
-
}
|
|
1784
|
-
return line;
|
|
1785
|
-
}
|
|
1786
|
-
// 如果在代码块中,不处理
|
|
1787
|
-
if (inCodeBlock) {
|
|
1788
|
-
return line;
|
|
1789
|
-
}
|
|
1790
|
-
// 检测不完整的图片标记
|
|
1791
|
-
// 匹配行尾的不完整图片语法(避免匹配完整的图片)
|
|
1792
|
-
var trimmedLine = line.trim();
|
|
1793
|
-
// 如果整行就是一个不完整的图片标记
|
|
1794
|
-
if (isIncompleteImage(trimmedLine)) {
|
|
1795
|
-
var encodedRaw = encodeURIComponent(trimmedLine);
|
|
1796
|
-
return '<incomplete-image data-raw="'.concat(encodedRaw, '" />');
|
|
1797
|
-
}
|
|
1798
|
-
// 检测行内不完整的图片标记(在行尾)
|
|
1799
|
-
// 使用负向前瞻确保不是完整图片的一部分
|
|
1800
|
-
return line.replace(/(!\[[^\]]*\]?\(?[^)]*)$/, function(match) {
|
|
1801
|
-
// 检查是否是不完整的图片
|
|
1802
|
-
if (isIncompleteImage(match.trim())) {
|
|
1803
|
-
var encodedRaw = encodeURIComponent(match.trim());
|
|
1804
|
-
return '<incomplete-image data-raw="'.concat(encodedRaw, '" />');
|
|
1805
|
-
}
|
|
1806
|
-
return match;
|
|
1807
|
-
});
|
|
1808
|
-
});
|
|
1809
|
-
return processedLines.join('\n');
|
|
1810
|
-
}
|
|
1811
1594
|
/**
|
|
1812
1595
|
* 预处理所有非标准 HTML 标签,提取其内容(删除标签本身)
|
|
1813
1596
|
* @param markdown - 原始 Markdown 字符串
|
|
@@ -1819,12 +1602,7 @@ var tableRegex = /^\|.*\|\s*\n\|[-:| ]+\|/m;
|
|
|
1819
1602
|
while(hasNonStandardTags){
|
|
1820
1603
|
var before = result;
|
|
1821
1604
|
// 匹配所有 HTML 标签对:<tagname>content</tagname>
|
|
1822
|
-
// 注意:跳过 incomplete-image 标签(它是自闭合标签,需要特殊处理)
|
|
1823
1605
|
result = result.replace(/<(\w+)>([\s\S]*?)<\/\1>/g, function(match, tagName, content) {
|
|
1824
|
-
// 保护 incomplete-image 标签(虽然它是自闭合的,但为了安全起见)
|
|
1825
|
-
if (tagName.toLowerCase() === 'incomplete-image') {
|
|
1826
|
-
return match;
|
|
1827
|
-
}
|
|
1828
1606
|
// 检查是否为标准 HTML 元素
|
|
1829
1607
|
if (STANDARD_HTML_ELEMENTS.has(tagName.toLowerCase())) {
|
|
1830
1608
|
// 标准元素保持不变
|
|
@@ -1838,28 +1616,6 @@ var tableRegex = /^\|.*\|\s*\n\|[-:| ]+\|/m;
|
|
|
1838
1616
|
}
|
|
1839
1617
|
return result;
|
|
1840
1618
|
}
|
|
1841
|
-
function preprocessMarkdownTableNewlines(markdown) {
|
|
1842
|
-
// 检查是否包含表格
|
|
1843
|
-
if (!tableRegex.test(markdown)) return markdown; // 如果没有表格,直接返回原始字符串
|
|
1844
|
-
// 处理表格结尾的换行符:
|
|
1845
|
-
// 1. 如果只有一个换行符,改成两个
|
|
1846
|
-
// 2. 如果有两个以上换行符,改成两个
|
|
1847
|
-
// 3. 如果已经是两个换行符,保持不变
|
|
1848
|
-
var processedMarkdown = markdown.replace(/(\|[^|\n]*\|)\n(?!\n|\|)/g, '$1\n\n').replace(/(\|[^|\n]*\|)\n{3,}(?!\|)/g, '$1\n\n');
|
|
1849
|
-
// 如果包含表格,处理换行符
|
|
1850
|
-
return processedMarkdown === null || processedMarkdown === void 0 ? void 0 : processedMarkdown.split('\n\n').map(function(line) {
|
|
1851
|
-
if (line.includes('```')) return line; // 如果包含代码块,直接返回原始字符串
|
|
1852
|
-
// 检查是否包含表格
|
|
1853
|
-
if (!tableRegex.test(line)) return line; // 如果没有表格,直接返回原始字符串
|
|
1854
|
-
// 匹配所有表格的行(确保我们在表格行内匹配换行符)
|
|
1855
|
-
return line.replace(/\|([^|]+)\|/g, function(match) {
|
|
1856
|
-
var _match_replaceAll;
|
|
1857
|
-
if (((_match_replaceAll = match.replaceAll('\n', '')) === null || _match_replaceAll === void 0 ? void 0 : _match_replaceAll.length) < MIN_TABLE_CELL_LENGTH) return match;
|
|
1858
|
-
// 只替换每个表格单元格内的换行符
|
|
1859
|
-
return match.split('\n').join('<br>');
|
|
1860
|
-
});
|
|
1861
|
-
}).join('\n\n');
|
|
1862
|
-
}
|
|
1863
1619
|
/**
|
|
1864
1620
|
* Markdown 到 Slate 节点解析器类
|
|
1865
1621
|
*
|
|
@@ -1884,11 +1640,12 @@ function preprocessMarkdownTableNewlines(markdown) {
|
|
|
1884
1640
|
* @returns 一个包含解析后的元素数组和链接信息的对象
|
|
1885
1641
|
*/ key: "parse",
|
|
1886
1642
|
value: function parse(md) {
|
|
1887
|
-
// 先预处理 <think>
|
|
1643
|
+
// 先预处理 <think> 标签,然后预处理其他非标准 HTML 标签,最后处理表格换行
|
|
1888
1644
|
var thinkProcessed = preprocessThinkTags(md || '');
|
|
1889
|
-
var
|
|
1890
|
-
|
|
1891
|
-
var
|
|
1645
|
+
var nonStandardProcessed = preprocessNonStandardHtmlTags(thinkProcessed);
|
|
1646
|
+
// parse() 只执行 parser,需要 runSync() 来执行 transformer 插件
|
|
1647
|
+
var ast = mdastParser.parse(preprocessMarkdownTableNewlines(nonStandardProcessed));
|
|
1648
|
+
var processedMarkdown = mdastParser.runSync(ast);
|
|
1892
1649
|
var markdownRoot = processedMarkdown.children;
|
|
1893
1650
|
// 使用类的配置和插件,通过 this 访问
|
|
1894
1651
|
var schema = this.parseNodes(markdownRoot, true, undefined);
|
|
@@ -1959,33 +1716,14 @@ function preprocessMarkdownTableNewlines(markdown) {
|
|
|
1959
1716
|
// 如果插件没有处理,使用默认处理逻辑
|
|
1960
1717
|
if (!pluginHandled) {
|
|
1961
1718
|
var isLastNode = i === nodes.length - 1;
|
|
1962
|
-
// 如果是
|
|
1963
|
-
if (currentElement.type === 'table') {
|
|
1964
|
-
// 如果 table 不是最后一个节点,finish 设置为 true
|
|
1965
|
-
if (!isLastNode) {
|
|
1966
|
-
if (!currentElement.otherProps) {
|
|
1967
|
-
currentElement.otherProps = {};
|
|
1968
|
-
}
|
|
1969
|
-
currentElement.otherProps.finish = true;
|
|
1970
|
-
} else {
|
|
1971
|
-
// 如果是最后一个节点,且 typing=false,finish 设置为 true
|
|
1972
|
-
if (_this.config.typing === false) {
|
|
1973
|
-
if (!currentElement.otherProps) {
|
|
1974
|
-
currentElement.otherProps = {};
|
|
1975
|
-
}
|
|
1976
|
-
currentElement.otherProps.finish = true;
|
|
1977
|
-
}
|
|
1978
|
-
// 否则保持原逻辑(在 parseTableOrChart 中处理,默认为 false)
|
|
1979
|
-
}
|
|
1980
|
-
}
|
|
1981
|
-
// 如果是 code 节点,检查是否是最后一个节点,设置 finish 属性
|
|
1719
|
+
// 如果是 code 节点,检查是否是最后一个节点,设置 finished 属性
|
|
1982
1720
|
if (currentElement.type === 'code') {
|
|
1983
1721
|
// 如果 code 不是最后一个节点,finish 设置为 true
|
|
1984
1722
|
if (!isLastNode) {
|
|
1985
1723
|
if (!currentElement.otherProps) {
|
|
1986
1724
|
currentElement.otherProps = {};
|
|
1987
1725
|
}
|
|
1988
|
-
currentElement.otherProps.
|
|
1726
|
+
delete currentElement.otherProps.finished;
|
|
1989
1727
|
}
|
|
1990
1728
|
// 如果是最后一个节点,保持原逻辑(在 handleCode 中处理)
|
|
1991
1729
|
}
|
|
@@ -1995,12 +1733,17 @@ function preprocessMarkdownTableNewlines(markdown) {
|
|
|
1995
1733
|
if (result.contextProps) {
|
|
1996
1734
|
contextProps = _object_spread({}, contextProps, result.contextProps);
|
|
1997
1735
|
}
|
|
1736
|
+
// 更新 htmlTag 数组,以便后续节点可以使用
|
|
1737
|
+
if (result.htmlTag) {
|
|
1738
|
+
htmlTag = result.htmlTag;
|
|
1739
|
+
}
|
|
1998
1740
|
}
|
|
1999
|
-
addEmptyLinesIfNeeded(els, preNode, currentElement, top);
|
|
1741
|
+
els = addEmptyLinesIfNeeded(els, preNode, currentElement, top);
|
|
2000
1742
|
if (el) {
|
|
2001
|
-
var _els;
|
|
2002
1743
|
el = applyContextPropsAndConfig(el, contextProps, config);
|
|
2003
|
-
Array.isArray(el) ? (
|
|
1744
|
+
els = Array.isArray(el) ? _to_consumable_array(els).concat(_to_consumable_array(el)) : _to_consumable_array(els).concat([
|
|
1745
|
+
el
|
|
1746
|
+
]);
|
|
2004
1747
|
}
|
|
2005
1748
|
preNode = currentElement;
|
|
2006
1749
|
preElement = el;
|
|
@@ -2030,46 +1773,56 @@ function preprocessMarkdownTableNewlines(markdown) {
|
|
|
2030
1773
|
value: /**
|
|
2031
1774
|
* 处理单个元素(类方法版本)
|
|
2032
1775
|
*/ function handleSingleElement(currentElement, config, parent, htmlTag, preElement) {
|
|
1776
|
+
var _this = this;
|
|
2033
1777
|
var elementType = currentElement.type;
|
|
2034
1778
|
var handlerInfo = elementHandlers[elementType];
|
|
2035
|
-
// 特殊处理 html 类型
|
|
2036
1779
|
if (handlerInfo === null || handlerInfo === void 0 ? void 0 : handlerInfo.needsHtmlResult) {
|
|
2037
1780
|
var htmlResult = handleHtml(currentElement, parent, htmlTag);
|
|
2038
1781
|
return {
|
|
2039
1782
|
el: htmlResult.el,
|
|
2040
|
-
contextProps: htmlResult.contextProps
|
|
1783
|
+
contextProps: htmlResult.contextProps,
|
|
1784
|
+
htmlTag: htmlResult.htmlTag
|
|
2041
1785
|
};
|
|
2042
1786
|
}
|
|
2043
|
-
|
|
2044
|
-
|
|
2045
|
-
|
|
2046
|
-
|
|
2047
|
-
|
|
2048
|
-
|
|
2049
|
-
|
|
2050
|
-
|
|
2051
|
-
|
|
2052
|
-
|
|
2053
|
-
|
|
2054
|
-
}
|
|
2055
|
-
|
|
2056
|
-
|
|
2057
|
-
|
|
2058
|
-
|
|
2059
|
-
|
|
2060
|
-
}
|
|
2061
|
-
|
|
2062
|
-
|
|
2063
|
-
|
|
2064
|
-
|
|
1787
|
+
if (!handlerInfo) {
|
|
1788
|
+
return {
|
|
1789
|
+
el: this.handleTextAndInlineElements(currentElement, htmlTag)
|
|
1790
|
+
};
|
|
1791
|
+
}
|
|
1792
|
+
var classMethodHandlers = {
|
|
1793
|
+
heading: function(el) {
|
|
1794
|
+
return _this.handleHeading(el);
|
|
1795
|
+
},
|
|
1796
|
+
list: function(el) {
|
|
1797
|
+
return _this.handleList(el);
|
|
1798
|
+
},
|
|
1799
|
+
listItem: function(el) {
|
|
1800
|
+
return _this.handleListItem(el);
|
|
1801
|
+
},
|
|
1802
|
+
blockquote: function(el) {
|
|
1803
|
+
return _this.handleBlockquote(el);
|
|
1804
|
+
},
|
|
1805
|
+
footnoteDefinition: function(el) {
|
|
1806
|
+
return _this.handleFootnoteDefinition(el);
|
|
1807
|
+
},
|
|
1808
|
+
paragraph: function(el) {
|
|
1809
|
+
return _this.handleParagraph(el, config);
|
|
1810
|
+
},
|
|
1811
|
+
table: function(el) {
|
|
1812
|
+
return parseTableOrChart(el, preElement || parent, _this.plugins, function(nodes, plugins, top, parentNode) {
|
|
1813
|
+
return _this.parseNodes(nodes, top, parentNode);
|
|
1814
|
+
}, _this.config);
|
|
2065
1815
|
}
|
|
1816
|
+
};
|
|
1817
|
+
var classMethodHandler = classMethodHandlers[elementType];
|
|
1818
|
+
if (classMethodHandler) {
|
|
2066
1819
|
return {
|
|
2067
|
-
el:
|
|
1820
|
+
el: classMethodHandler(currentElement)
|
|
2068
1821
|
};
|
|
2069
1822
|
}
|
|
2070
|
-
|
|
1823
|
+
var handlerResult = handlerInfo.handler(currentElement, this.plugins, config, parent, htmlTag, preElement);
|
|
2071
1824
|
return {
|
|
2072
|
-
el:
|
|
1825
|
+
el: handlerResult
|
|
2073
1826
|
};
|
|
2074
1827
|
}
|
|
2075
1828
|
},
|
|
@@ -2100,6 +1853,7 @@ function preprocessMarkdownTableNewlines(markdown) {
|
|
|
2100
1853
|
type: 'list',
|
|
2101
1854
|
order: currentElement.ordered,
|
|
2102
1855
|
start: currentElement.start,
|
|
1856
|
+
finished: currentElement.finished,
|
|
2103
1857
|
children: this.parseNodes(currentElement.children, false, currentElement)
|
|
2104
1858
|
};
|
|
2105
1859
|
el.task = (_el_children = el.children) === null || _el_children === void 0 ? void 0 : _el_children.some(function(s) {
|
|
@@ -2190,7 +1944,8 @@ function preprocessMarkdownTableNewlines(markdown) {
|
|
|
2190
1944
|
}
|
|
2191
1945
|
// 添加图片节点
|
|
2192
1946
|
elements.push(EditorUtils.createMediaNode(decodeURIComponentUrl(currentChild === null || currentChild === void 0 ? void 0 : currentChild.url), 'image', {
|
|
2193
|
-
alt: currentChild.alt
|
|
1947
|
+
alt: currentChild.alt,
|
|
1948
|
+
finished: currentChild.finished
|
|
2194
1949
|
}));
|
|
2195
1950
|
} else if (currentChild.type === 'html') {
|
|
2196
1951
|
// 跳过媒体标签的结束标签
|
|
@@ -2282,56 +2037,12 @@ function preprocessMarkdownTableNewlines(markdown) {
|
|
|
2282
2037
|
value: /**
|
|
2283
2038
|
* 处理文本和内联元素节点(类方法版本)
|
|
2284
2039
|
*/ function handleTextAndInlineElements(currentElement, htmlTag) {
|
|
2285
|
-
|
|
2286
|
-
|
|
2287
|
-
|
|
2288
|
-
|
|
2289
|
-
|
|
2290
|
-
|
|
2291
|
-
}
|
|
2292
|
-
return el;
|
|
2293
|
-
}
|
|
2294
|
-
if ([
|
|
2295
|
-
'strong',
|
|
2296
|
-
'link',
|
|
2297
|
-
'text',
|
|
2298
|
-
'emphasis',
|
|
2299
|
-
'delete',
|
|
2300
|
-
'inlineCode'
|
|
2301
|
-
].includes(currentElement.type)) {
|
|
2302
|
-
var _currentElement_children;
|
|
2303
|
-
if (currentElement.type === 'text') {
|
|
2304
|
-
return {
|
|
2305
|
-
text: currentElement.value
|
|
2306
|
-
};
|
|
2307
|
-
}
|
|
2308
|
-
var leaf = {};
|
|
2309
|
-
this.applyInlineFormatting(leaf, currentElement);
|
|
2310
|
-
applyHtmlTagsToElement(leaf, htmlTag);
|
|
2311
|
-
if (currentElement === null || currentElement === void 0 ? void 0 : (_currentElement_children = currentElement.children) === null || _currentElement_children === void 0 ? void 0 : _currentElement_children.some(function(n) {
|
|
2312
|
-
return n.type === 'html';
|
|
2313
|
-
})) {
|
|
2314
|
-
var _this_parseNodes;
|
|
2315
|
-
return _object_spread_props(_object_spread({}, (_this_parseNodes = this.parseNodes(currentElement === null || currentElement === void 0 ? void 0 : currentElement.children, false, currentElement)) === null || _this_parseNodes === void 0 ? void 0 : _this_parseNodes.at(0)), {
|
|
2316
|
-
url: leaf.url
|
|
2317
|
-
});
|
|
2318
|
-
} else {
|
|
2319
|
-
var _currentElement_children1;
|
|
2320
|
-
return parseText(((_currentElement_children1 = currentElement.children) === null || _currentElement_children1 === void 0 ? void 0 : _currentElement_children1.length) ? currentElement.children : [
|
|
2321
|
-
{
|
|
2322
|
-
value: (leaf === null || leaf === void 0 ? void 0 : leaf.url) || ''
|
|
2323
|
-
}
|
|
2324
|
-
], leaf);
|
|
2325
|
-
}
|
|
2326
|
-
}
|
|
2327
|
-
if (currentElement.type === 'break') {
|
|
2328
|
-
return {
|
|
2329
|
-
text: '\n'
|
|
2330
|
-
};
|
|
2331
|
-
}
|
|
2332
|
-
return {
|
|
2333
|
-
text: ''
|
|
2334
|
-
};
|
|
2040
|
+
var _this = this;
|
|
2041
|
+
return handleTextAndInlineElementsPure(currentElement, htmlTag, function(leaf, element) {
|
|
2042
|
+
return _this.applyInlineFormatting(leaf, element);
|
|
2043
|
+
}, function(children, top, parent) {
|
|
2044
|
+
return _this.parseNodes(children, top, parent);
|
|
2045
|
+
});
|
|
2335
2046
|
}
|
|
2336
2047
|
},
|
|
2337
2048
|
{
|
|
@@ -2339,169 +2050,44 @@ function preprocessMarkdownTableNewlines(markdown) {
|
|
|
2339
2050
|
value: /**
|
|
2340
2051
|
* 应用内联格式到叶子节点(类方法版本)
|
|
2341
2052
|
*/ function applyInlineFormatting(leaf, currentElement) {
|
|
2342
|
-
|
|
2343
|
-
|
|
2344
|
-
|
|
2345
|
-
if (
|
|
2053
|
+
var result = _object_spread({}, leaf);
|
|
2054
|
+
var elementType = currentElement.type;
|
|
2055
|
+
var finished = currentElement.finished;
|
|
2056
|
+
if (elementType === 'strong') {
|
|
2057
|
+
return setFinishedProp(_object_spread_props(_object_spread({}, result), {
|
|
2058
|
+
bold: true
|
|
2059
|
+
}), finished);
|
|
2060
|
+
}
|
|
2061
|
+
if (elementType === 'emphasis') {
|
|
2062
|
+
return setFinishedProp(_object_spread_props(_object_spread({}, result), {
|
|
2063
|
+
italic: true
|
|
2064
|
+
}), finished);
|
|
2065
|
+
}
|
|
2066
|
+
if (elementType === 'delete') {
|
|
2067
|
+
result.strikethrough = true;
|
|
2068
|
+
return result;
|
|
2069
|
+
}
|
|
2070
|
+
if (elementType === 'link') {
|
|
2346
2071
|
try {
|
|
2347
2072
|
var _this_config;
|
|
2348
|
-
|
|
2349
|
-
|
|
2350
|
-
if (
|
|
2351
|
-
|
|
2352
|
-
|
|
2353
|
-
leaf.otherProps = {};
|
|
2073
|
+
result.url = currentElement === null || currentElement === void 0 ? void 0 : currentElement.url;
|
|
2074
|
+
var shouldOpenInNewTab = ((_this_config = this.config) === null || _this_config === void 0 ? void 0 : _this_config.openLinksInNewTab) || finished === false;
|
|
2075
|
+
if (shouldOpenInNewTab) {
|
|
2076
|
+
if (!result.otherProps) {
|
|
2077
|
+
result.otherProps = {};
|
|
2354
2078
|
}
|
|
2355
|
-
|
|
2356
|
-
|
|
2357
|
-
|
|
2358
|
-
|
|
2359
|
-
leaf.url = currentElement === null || currentElement === void 0 ? void 0 : currentElement.url;
|
|
2360
|
-
}
|
|
2361
|
-
}
|
|
2362
|
-
}
|
|
2363
|
-
},
|
|
2364
|
-
{
|
|
2365
|
-
key: "parseTableOrChart",
|
|
2366
|
-
value: /**
|
|
2367
|
-
* 解析表格或图表(类方法版本)
|
|
2368
|
-
*/ function parseTableOrChart(table, preNode) {
|
|
2369
|
-
var _this = this;
|
|
2370
|
-
var _table_children, _tableHeader_children, _table_children_slice, _table_children1, _table_align, _config_at, _config_at1, _table_otherProps;
|
|
2371
|
-
var keyMap = new Map();
|
|
2372
|
-
// @ts-ignore
|
|
2373
|
-
var config = // @ts-ignore
|
|
2374
|
-
(preNode === null || preNode === void 0 ? void 0 : preNode.type) === 'code' && // @ts-ignore
|
|
2375
|
-
(preNode === null || preNode === void 0 ? void 0 : preNode.language) === 'html' && (// @ts-ignore
|
|
2376
|
-
preNode === null || preNode === void 0 ? void 0 : preNode.otherProps) ? preNode === null || preNode === void 0 ? void 0 : preNode.otherProps : {};
|
|
2377
|
-
var tableHeader = table === null || table === void 0 ? void 0 : (_table_children = table.children) === null || _table_children === void 0 ? void 0 : _table_children.at(0);
|
|
2378
|
-
var columns = (tableHeader === null || tableHeader === void 0 ? void 0 : (_tableHeader_children = tableHeader.children) === null || _tableHeader_children === void 0 ? void 0 : _tableHeader_children.map(function(node) {
|
|
2379
|
-
return myRemark.stringify({
|
|
2380
|
-
type: 'root',
|
|
2381
|
-
children: [
|
|
2382
|
-
node
|
|
2383
|
-
]
|
|
2384
|
-
}).trim();
|
|
2385
|
-
}).map(function(key) {
|
|
2386
|
-
// 规范化字段名,统一处理转义字符
|
|
2387
|
-
var normalizedKey = normalizeFieldName(key);
|
|
2388
|
-
var value = keyMap.get(normalizedKey) || normalizedKey;
|
|
2389
|
-
return value;
|
|
2390
|
-
}).map(function(key) {
|
|
2391
|
-
return {
|
|
2392
|
-
dataIndex: key
|
|
2393
|
-
};
|
|
2394
|
-
})) || [];
|
|
2395
|
-
var dataSource = (table === null || table === void 0 ? void 0 : (_table_children1 = table.children) === null || _table_children1 === void 0 ? void 0 : (_table_children_slice = _table_children1.slice(1)) === null || _table_children_slice === void 0 ? void 0 : _table_children_slice.map(function(row) {
|
|
2396
|
-
var _row_children;
|
|
2397
|
-
return (_row_children = row.children) === null || _row_children === void 0 ? void 0 : _row_children.reduce(function(acc, cell, index) {
|
|
2398
|
-
var column = columns[index];
|
|
2399
|
-
var key = (column === null || column === void 0 ? void 0 : column.dataIndex) || (typeof column === 'string' ? column : undefined);
|
|
2400
|
-
if (key) {
|
|
2401
|
-
acc[key] = myRemark.stringify({
|
|
2402
|
-
type: 'root',
|
|
2403
|
-
children: [
|
|
2404
|
-
cell
|
|
2405
|
-
]
|
|
2406
|
-
}).trim();
|
|
2407
|
-
}
|
|
2408
|
-
return acc;
|
|
2409
|
-
}, {});
|
|
2410
|
-
})) || [];
|
|
2411
|
-
if ((_table_align = table.align) === null || _table_align === void 0 ? void 0 : _table_align.every(function(item) {
|
|
2412
|
-
return !item;
|
|
2413
|
-
})) {
|
|
2414
|
-
var aligns = getColumnAlignment(dataSource, columns);
|
|
2415
|
-
table.align = aligns;
|
|
2416
|
-
}
|
|
2417
|
-
var aligns1 = table.align;
|
|
2418
|
-
var isChart = (config === null || config === void 0 ? void 0 : config.chartType) || (config === null || config === void 0 ? void 0 : (_config_at1 = config.at) === null || _config_at1 === void 0 ? void 0 : (_config_at = _config_at1.call(config, 0)) === null || _config_at === void 0 ? void 0 : _config_at.chartType);
|
|
2419
|
-
// 计算合并单元格信息
|
|
2420
|
-
var mergeCells = config.mergeCells || [];
|
|
2421
|
-
// 创建合并单元格映射,用于快速查找
|
|
2422
|
-
var mergeMap = new Map();
|
|
2423
|
-
mergeCells === null || mergeCells === void 0 ? void 0 : mergeCells.forEach(function(param) {
|
|
2424
|
-
var row = param.row, col = param.col, rowSpan = param.rowSpan, rowspan = param.rowspan, colSpan = param.colSpan, colspan = param.colspan;
|
|
2425
|
-
var rawRowSpan = rowSpan || rowspan;
|
|
2426
|
-
var rawColSpan = colSpan || colspan;
|
|
2427
|
-
// 主单元格
|
|
2428
|
-
mergeMap.set("".concat(row, "-").concat(col), {
|
|
2429
|
-
rowSpan: rawRowSpan,
|
|
2430
|
-
colSpan: rawColSpan
|
|
2431
|
-
});
|
|
2432
|
-
// 被合并的单元格标记为隐藏
|
|
2433
|
-
for(var r = row; r < row + rawRowSpan; r++){
|
|
2434
|
-
for(var c = col; c < col + rawColSpan; c++){
|
|
2435
|
-
if (r !== row || c !== col) {
|
|
2436
|
-
mergeMap.set("".concat(r, "-").concat(c), {
|
|
2437
|
-
rowSpan: 1,
|
|
2438
|
-
colSpan: 1,
|
|
2439
|
-
hidden: true
|
|
2440
|
-
});
|
|
2079
|
+
result.otherProps.target = '_blank';
|
|
2080
|
+
result.otherProps.rel = 'noopener noreferrer';
|
|
2081
|
+
if (finished === false) {
|
|
2082
|
+
result.otherProps.finished = finished;
|
|
2441
2083
|
}
|
|
2442
2084
|
}
|
|
2085
|
+
} catch (e) {
|
|
2086
|
+
result.url = currentElement === null || currentElement === void 0 ? void 0 : currentElement.url;
|
|
2443
2087
|
}
|
|
2444
|
-
|
|
2445
|
-
|
|
2446
|
-
|
|
2447
|
-
type: 'table-row',
|
|
2448
|
-
align: (aligns1 === null || aligns1 === void 0 ? void 0 : aligns1[l]) || undefined,
|
|
2449
|
-
children: r.children.map(function(c, i) {
|
|
2450
|
-
var _c_children;
|
|
2451
|
-
var mergeInfo = mergeMap.get("".concat(l, "-").concat(i));
|
|
2452
|
-
return _object_spread_props(_object_spread({
|
|
2453
|
-
type: 'table-cell',
|
|
2454
|
-
align: (aligns1 === null || aligns1 === void 0 ? void 0 : aligns1[i]) || undefined,
|
|
2455
|
-
title: l === 0,
|
|
2456
|
-
rows: l,
|
|
2457
|
-
cols: i
|
|
2458
|
-
}, (mergeInfo === null || mergeInfo === void 0 ? void 0 : mergeInfo.rowSpan) && mergeInfo.rowSpan > 1 ? {
|
|
2459
|
-
rowSpan: mergeInfo.rowSpan
|
|
2460
|
-
} : {}, (mergeInfo === null || mergeInfo === void 0 ? void 0 : mergeInfo.colSpan) && mergeInfo.colSpan > 1 ? {
|
|
2461
|
-
colSpan: mergeInfo.colSpan
|
|
2462
|
-
} : {}, (mergeInfo === null || mergeInfo === void 0 ? void 0 : mergeInfo.hidden) ? {
|
|
2463
|
-
hidden: true
|
|
2464
|
-
} : {}), {
|
|
2465
|
-
children: ((_c_children = c.children) === null || _c_children === void 0 ? void 0 : _c_children.length) ? [
|
|
2466
|
-
{
|
|
2467
|
-
type: 'paragraph',
|
|
2468
|
-
children: _this.parseNodes(c.children, false, c)
|
|
2469
|
-
}
|
|
2470
|
-
] : [
|
|
2471
|
-
{
|
|
2472
|
-
type: 'paragraph',
|
|
2473
|
-
children: [
|
|
2474
|
-
{
|
|
2475
|
-
text: ''
|
|
2476
|
-
}
|
|
2477
|
-
]
|
|
2478
|
-
}
|
|
2479
|
-
]
|
|
2480
|
-
});
|
|
2481
|
-
})
|
|
2482
|
-
};
|
|
2483
|
-
});
|
|
2484
|
-
// 检查表格是否完成(未闭合)
|
|
2485
|
-
// 如果 table 节点有 otherProps.finish,使用它;否则默认为 false(未完成)
|
|
2486
|
-
var isFinished = (table === null || table === void 0 ? void 0 : (_table_otherProps = table.otherProps) === null || _table_otherProps === void 0 ? void 0 : _table_otherProps.finish) !== undefined ? table.otherProps.finish : false;
|
|
2487
|
-
var otherProps = _object_spread_props(_object_spread({}, isChart ? {
|
|
2488
|
-
config: config
|
|
2489
|
-
} : config), {
|
|
2490
|
-
columns: columns.map(function(col) {
|
|
2491
|
-
return col.dataIndex;
|
|
2492
|
-
}),
|
|
2493
|
-
dataSource: dataSource.map(function(item) {
|
|
2494
|
-
item === null || item === void 0 ? true : delete item.chartType;
|
|
2495
|
-
return _object_spread({}, item);
|
|
2496
|
-
}),
|
|
2497
|
-
finish: isFinished
|
|
2498
|
-
});
|
|
2499
|
-
var node = {
|
|
2500
|
-
type: isChart ? 'chart' : 'table',
|
|
2501
|
-
children: children,
|
|
2502
|
-
otherProps: otherProps
|
|
2503
|
-
};
|
|
2504
|
-
return EditorUtils.wrapperCardNode(node);
|
|
2088
|
+
return result;
|
|
2089
|
+
}
|
|
2090
|
+
return result;
|
|
2505
2091
|
}
|
|
2506
2092
|
}
|
|
2507
2093
|
]);
|