@ant-design/agentic-ui 2.30.6 → 2.30.8

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (27) hide show
  1. package/dist/MarkdownEditor/editor/parser/parserMarkdownToSlateNode.js +1 -3
  2. package/dist/MarkdownEditor/editor/parser/remarkDirectiveContainersOnly.d.ts +14 -0
  3. package/dist/MarkdownEditor/editor/parser/remarkDirectiveContainersOnly.js +26 -0
  4. package/dist/MarkdownEditor/editor/parser/remarkParse.d.ts +1 -1
  5. package/dist/MarkdownEditor/editor/parser/remarkParse.js +2 -2
  6. package/dist/MarkdownEditor/editor/style.js +7 -5
  7. package/dist/MarkdownEditor/editor/utils/markdownToHtml.js +2 -2
  8. package/dist/MarkdownInputField/FileMapView/FileMapViewItem.js +54 -16
  9. package/dist/MarkdownInputField/FileMapView/index.js +8 -2
  10. package/dist/MarkdownInputField/FileMapView/style.js +5 -1
  11. package/dist/MarkdownRenderer/MarkdownRenderer.js +2 -1
  12. package/dist/MarkdownRenderer/index.d.ts +2 -0
  13. package/dist/MarkdownRenderer/index.js +1 -0
  14. package/dist/MarkdownRenderer/markdownReactShared.d.ts +93 -0
  15. package/dist/MarkdownRenderer/markdownReactShared.js +1159 -0
  16. package/dist/MarkdownRenderer/streaming/MarkdownBlockPiece.d.ts +15 -0
  17. package/dist/MarkdownRenderer/streaming/MarkdownBlockPiece.js +61 -0
  18. package/dist/MarkdownRenderer/streaming/lastBlockThrottle.d.ts +4 -0
  19. package/dist/MarkdownRenderer/streaming/lastBlockThrottle.js +14 -0
  20. package/dist/MarkdownRenderer/streaming/revisionPolicy.d.ts +5 -0
  21. package/dist/MarkdownRenderer/streaming/revisionPolicy.js +10 -0
  22. package/dist/MarkdownRenderer/streaming/useStreamingMarkdownReact.d.ts +6 -0
  23. package/dist/MarkdownRenderer/streaming/useStreamingMarkdownReact.js +70 -0
  24. package/dist/MarkdownRenderer/useMarkdownToReact.d.ts +3 -22
  25. package/dist/MarkdownRenderer/useMarkdownToReact.js +3 -1286
  26. package/dist/Types/micromark-extension-directive-subpath.d.ts +8 -0
  27. package/package.json +4 -2
@@ -0,0 +1,1159 @@
1
+ function _array_like_to_array(arr, len) {
2
+ if (len == null || len > arr.length) len = arr.length;
3
+ for(var i = 0, arr2 = new Array(len); i < len; i++)arr2[i] = arr[i];
4
+ return arr2;
5
+ }
6
+ function _array_with_holes(arr) {
7
+ if (Array.isArray(arr)) return arr;
8
+ }
9
+ function _array_without_holes(arr) {
10
+ if (Array.isArray(arr)) return _array_like_to_array(arr);
11
+ }
12
+ function _define_property(obj, key, value) {
13
+ if (key in obj) {
14
+ Object.defineProperty(obj, key, {
15
+ value: value,
16
+ enumerable: true,
17
+ configurable: true,
18
+ writable: true
19
+ });
20
+ } else {
21
+ obj[key] = value;
22
+ }
23
+ return obj;
24
+ }
25
+ function _iterable_to_array(iter) {
26
+ if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter);
27
+ }
28
+ function _non_iterable_rest() {
29
+ throw new TypeError("Invalid attempt to destructure non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
30
+ }
31
+ function _non_iterable_spread() {
32
+ throw new TypeError("Invalid attempt to spread non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
33
+ }
34
+ function _object_spread(target) {
35
+ for(var i = 1; i < arguments.length; i++){
36
+ var source = arguments[i] != null ? arguments[i] : {};
37
+ var ownKeys = Object.keys(source);
38
+ if (typeof Object.getOwnPropertySymbols === "function") {
39
+ ownKeys = ownKeys.concat(Object.getOwnPropertySymbols(source).filter(function(sym) {
40
+ return Object.getOwnPropertyDescriptor(source, sym).enumerable;
41
+ }));
42
+ }
43
+ ownKeys.forEach(function(key) {
44
+ _define_property(target, key, source[key]);
45
+ });
46
+ }
47
+ return target;
48
+ }
49
+ function ownKeys(object, enumerableOnly) {
50
+ var keys = Object.keys(object);
51
+ if (Object.getOwnPropertySymbols) {
52
+ var symbols = Object.getOwnPropertySymbols(object);
53
+ if (enumerableOnly) {
54
+ symbols = symbols.filter(function(sym) {
55
+ return Object.getOwnPropertyDescriptor(object, sym).enumerable;
56
+ });
57
+ }
58
+ keys.push.apply(keys, symbols);
59
+ }
60
+ return keys;
61
+ }
62
+ function _object_spread_props(target, source) {
63
+ source = source != null ? source : {};
64
+ if (Object.getOwnPropertyDescriptors) {
65
+ Object.defineProperties(target, Object.getOwnPropertyDescriptors(source));
66
+ } else {
67
+ ownKeys(Object(source)).forEach(function(key) {
68
+ Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key));
69
+ });
70
+ }
71
+ return target;
72
+ }
73
+ function _object_without_properties(source, excluded) {
74
+ if (source == null) return {};
75
+ var target = {}, sourceKeys, key, i;
76
+ if (typeof Reflect !== "undefined" && Reflect.ownKeys) {
77
+ sourceKeys = Reflect.ownKeys(source);
78
+ for(i = 0; i < sourceKeys.length; i++){
79
+ key = sourceKeys[i];
80
+ if (excluded.indexOf(key) >= 0) continue;
81
+ if (!Object.prototype.propertyIsEnumerable.call(source, key)) continue;
82
+ target[key] = source[key];
83
+ }
84
+ return target;
85
+ }
86
+ target = _object_without_properties_loose(source, excluded);
87
+ if (Object.getOwnPropertySymbols) {
88
+ sourceKeys = Object.getOwnPropertySymbols(source);
89
+ for(i = 0; i < sourceKeys.length; i++){
90
+ key = sourceKeys[i];
91
+ if (excluded.indexOf(key) >= 0) continue;
92
+ if (!Object.prototype.propertyIsEnumerable.call(source, key)) continue;
93
+ target[key] = source[key];
94
+ }
95
+ }
96
+ return target;
97
+ }
98
+ function _object_without_properties_loose(source, excluded) {
99
+ if (source == null) return {};
100
+ var target = {}, sourceKeys = Object.getOwnPropertyNames(source), key, i;
101
+ for(i = 0; i < sourceKeys.length; i++){
102
+ key = sourceKeys[i];
103
+ if (excluded.indexOf(key) >= 0) continue;
104
+ if (!Object.prototype.propertyIsEnumerable.call(source, key)) continue;
105
+ target[key] = source[key];
106
+ }
107
+ return target;
108
+ }
109
+ function _to_array(arr) {
110
+ return _array_with_holes(arr) || _iterable_to_array(arr) || _unsupported_iterable_to_array(arr) || _non_iterable_rest();
111
+ }
112
+ function _to_consumable_array(arr) {
113
+ return _array_without_holes(arr) || _iterable_to_array(arr) || _unsupported_iterable_to_array(arr) || _non_iterable_spread();
114
+ }
115
+ function _unsupported_iterable_to_array(o, minLen) {
116
+ if (!o) return;
117
+ if (typeof o === "string") return _array_like_to_array(o, minLen);
118
+ var n = Object.prototype.toString.call(o).slice(8, -1);
119
+ if (n === "Object" && o.constructor) n = o.constructor.name;
120
+ if (n === "Map" || n === "Set") return Array.from(n);
121
+ if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _array_like_to_array(o, minLen);
122
+ }
123
+ import { Checkbox, Image } from "antd";
124
+ import { toJsxRuntime } from "hast-util-to-jsx-runtime";
125
+ import React, { useContext } from "react";
126
+ import { Fragment, jsx, jsxs } from "react/jsx-runtime";
127
+ import rehypeKatex from "rehype-katex";
128
+ import rehypeRaw from "rehype-raw";
129
+ import remarkFrontmatter from "remark-frontmatter";
130
+ import remarkGfm from "remark-gfm";
131
+ import remarkMath from "remark-math";
132
+ import remarkParse from "remark-parse";
133
+ import remarkRehype from "remark-rehype";
134
+ import { unified } from "unified";
135
+ import { visit } from "unist-util-visit";
136
+ import { remarkDirectiveContainer } from "../MarkdownEditor/editor/parser/remarkDirectiveContainer";
137
+ import remarkDirectiveContainersOnly from "../MarkdownEditor/editor/parser/remarkDirectiveContainersOnly";
138
+ import { convertParagraphToImage, fixStrongWithSpecialChars, protectJinjaDollarInText } from "../MarkdownEditor/editor/parser/remarkParse";
139
+ import { REMARK_REHYPE_DIRECTIVE_HANDLERS } from "../MarkdownEditor/editor/utils/markdownToHtml";
140
+ import { parseChineseCurrencyToNumber } from "../Plugins/chart/utils";
141
+ import { ToolUseBarThink } from "../ToolUseBarThink";
142
+ import AnimationText from "./AnimationText";
143
+ import { StreamingAnimationContext } from "./StreamingAnimationContext";
144
+ var INLINE_MATH_WITH_SINGLE_DOLLAR = {
145
+ singleDollarTextMath: true
146
+ };
147
+ var FRONTMATTER_LANGUAGES = [
148
+ 'yaml'
149
+ ];
150
+ var REMARK_DIRECTIVE_CONTAINER_OPTIONS = {
151
+ className: 'markdown-container',
152
+ titleElement: {
153
+ className: [
154
+ 'markdown-container__title'
155
+ ]
156
+ }
157
+ };
158
+ var remarkRehypePlugin = remarkRehype;
159
+ var FOOTNOTE_REF_PATTERN = /\[\^([^\]]+)\]/g;
160
+ var CHART_COMMENT_PATTERN = /^<!--\s*(\[[\s\S]*\]|\{[\s\S]*\})\s*-->$/;
161
+ var extractCellText = function extractCellText1(cell) {
162
+ if (!(cell === null || cell === void 0 ? void 0 : cell.children)) return '';
163
+ return cell.children.map(function(child) {
164
+ if (child.type === 'text') return child.value || '';
165
+ if (child.children) return extractCellText(child);
166
+ return '';
167
+ }).join('').trim();
168
+ };
169
+ /**
170
+ * 从 mdast table 节点提取列名和数据
171
+ */ var extractTableData = function extractTableData(tableNode) {
172
+ var _loop = function(i) {
173
+ var row = tableNode.children[i];
174
+ if (!(row === null || row === void 0 ? void 0 : row.children)) return "continue";
175
+ var record = {
176
+ key: "row-".concat(i)
177
+ };
178
+ row.children.forEach(function(cell, j) {
179
+ if (j < columns.length) {
180
+ var val = extractCellText(cell);
181
+ if (val === '') {
182
+ record[columns[j].dataIndex] = val;
183
+ } else {
184
+ var num = Number(val);
185
+ if (Number.isFinite(num)) {
186
+ record[columns[j].dataIndex] = num;
187
+ } else {
188
+ var cn = parseChineseCurrencyToNumber(val);
189
+ record[columns[j].dataIndex] = cn !== null ? cn : val;
190
+ }
191
+ }
192
+ }
193
+ });
194
+ dataSource.push(record);
195
+ };
196
+ var _tableNode_children, _headerRow_children;
197
+ if (!((_tableNode_children = tableNode.children) === null || _tableNode_children === void 0 ? void 0 : _tableNode_children.length)) return null;
198
+ var headerRow = tableNode.children[0];
199
+ if (!(headerRow === null || headerRow === void 0 ? void 0 : (_headerRow_children = headerRow.children) === null || _headerRow_children === void 0 ? void 0 : _headerRow_children.length)) return null;
200
+ var columns = headerRow.children.map(function(cell) {
201
+ var text = extractCellText(cell);
202
+ return {
203
+ title: text,
204
+ dataIndex: text,
205
+ key: text
206
+ };
207
+ });
208
+ var dataSource = [];
209
+ for(var i = 1; i < tableNode.children.length; i++)_loop(i);
210
+ return {
211
+ columns: columns,
212
+ dataSource: dataSource
213
+ };
214
+ };
215
+ /**
216
+ * remark 插件:将 "HTML 注释(图表配置)+ 表格" 组合转为 chart 代码块。
217
+ *
218
+ * 在 MarkdownEditor 中,parseTableOrChart 负责此逻辑。
219
+ * 在 MarkdownRenderer 中,此插件在 mdast 层面完成等价转换。
220
+ *
221
+ * 匹配模式:
222
+ * ```
223
+ * <!-- [{"chartType":"line","x":"month","y":"value",...}] -->
224
+ * | month | value |
225
+ * |-------|-------|
226
+ * | 2024 | 100 |
227
+ * ```
228
+ */ var remarkChartFromComment = function remarkChartFromComment() {
229
+ return function(tree) {
230
+ var children = tree.children;
231
+ if (!children || !Array.isArray(children)) return;
232
+ var toRemove = [];
233
+ for(var i = 0; i < children.length - 1; i++){
234
+ var _node_value;
235
+ var node = children[i];
236
+ var next = children[i + 1];
237
+ if (node.type !== 'html' || next.type !== 'table') continue;
238
+ var match = (_node_value = node.value) === null || _node_value === void 0 ? void 0 : _node_value.match(CHART_COMMENT_PATTERN);
239
+ if (!match) continue;
240
+ var chartConfig = void 0;
241
+ try {
242
+ chartConfig = JSON.parse(match[1]);
243
+ } catch (unused) {
244
+ continue;
245
+ }
246
+ if (!Array.isArray(chartConfig)) chartConfig = [
247
+ chartConfig
248
+ ];
249
+ var hasChartType = chartConfig.some(function(c) {
250
+ return c.chartType && c.chartType !== 'table';
251
+ });
252
+ if (!hasChartType) continue;
253
+ var tableData = extractTableData(next);
254
+ if (!tableData) continue;
255
+ var chartJson = JSON.stringify({
256
+ config: chartConfig,
257
+ columns: tableData.columns,
258
+ dataSource: tableData.dataSource
259
+ });
260
+ children[i] = {
261
+ type: 'code',
262
+ lang: 'chart',
263
+ value: chartJson
264
+ };
265
+ toRemove.push(i + 1);
266
+ i++;
267
+ }
268
+ for(var j = toRemove.length - 1; j >= 0; j--){
269
+ children.splice(toRemove[j], 1);
270
+ }
271
+ };
272
+ };
273
+ /**
274
+ * rehype 插件:将文本中残留的 [^N] 模式转为 fnc 标记元素。
275
+ *
276
+ * remark-gfm 只在有对应 footnoteDefinition 时才会转换 footnoteReference,
277
+ * 但 AI 对话场景中 [^1] 常用作内联引用(无底部定义)。
278
+ * 此插件在 hast 层面补充处理这些"裸引用"。
279
+ */ var rehypeFootnoteRef = function rehypeFootnoteRef() {
280
+ return function(tree) {
281
+ visit(tree, 'text', function(node, index, parent) {
282
+ if (!parent || index === undefined) return;
283
+ var value = node.value;
284
+ if (!FOOTNOTE_REF_PATTERN.test(value)) return;
285
+ FOOTNOTE_REF_PATTERN.lastIndex = 0;
286
+ var children = [];
287
+ var lastIndex = 0;
288
+ var match;
289
+ while((match = FOOTNOTE_REF_PATTERN.exec(value)) !== null){
290
+ if (match.index > lastIndex) {
291
+ children.push({
292
+ type: 'text',
293
+ value: value.slice(lastIndex, match.index)
294
+ });
295
+ }
296
+ children.push({
297
+ type: 'element',
298
+ tagName: 'span',
299
+ properties: {
300
+ 'data-fnc': 'fnc',
301
+ 'data-fnc-name': match[1]
302
+ },
303
+ children: [
304
+ {
305
+ type: 'text',
306
+ value: match[1]
307
+ }
308
+ ]
309
+ });
310
+ lastIndex = match.index + match[0].length;
311
+ }
312
+ if (lastIndex < value.length) {
313
+ children.push({
314
+ type: 'text',
315
+ value: value.slice(lastIndex)
316
+ });
317
+ }
318
+ if (children.length > 0) {
319
+ var _parent_children;
320
+ (_parent_children = parent.children).splice.apply(_parent_children, [
321
+ index,
322
+ 1
323
+ ].concat(_to_consumable_array(children)));
324
+ return index + children.length;
325
+ }
326
+ });
327
+ };
328
+ };
329
+ var createHastProcessor = function createHastProcessor(extraRemarkPlugins, config) {
330
+ var processor = unified();
331
+ processor.use(remarkParse).use(remarkGfm, {
332
+ singleTilde: false
333
+ }).use(fixStrongWithSpecialChars).use(convertParagraphToImage).use(protectJinjaDollarInText).use(remarkMath, INLINE_MATH_WITH_SINGLE_DOLLAR).use(remarkFrontmatter, FRONTMATTER_LANGUAGES).use(remarkDirectiveContainersOnly).use(remarkDirectiveContainer, REMARK_DIRECTIVE_CONTAINER_OPTIONS).use(remarkChartFromComment).use(remarkRehypePlugin, {
334
+ allowDangerousHtml: true,
335
+ handlers: REMARK_REHYPE_DIRECTIVE_HANDLERS
336
+ }).use(rehypeRaw).use(rehypeKatex, {
337
+ strict: 'ignore'
338
+ }).use(rehypeFootnoteRef);
339
+ if (extraRemarkPlugins) {
340
+ extraRemarkPlugins.forEach(function(entry) {
341
+ if (Array.isArray(entry)) {
342
+ var _processor;
343
+ var _entry = _to_array(entry), plugin = _entry[0], pluginOptions = _entry.slice(1);
344
+ (_processor = processor).use.apply(_processor, [
345
+ plugin
346
+ ].concat(_to_consumable_array(pluginOptions)));
347
+ } else {
348
+ processor.use(entry);
349
+ }
350
+ });
351
+ }
352
+ if (config === null || config === void 0 ? void 0 : config.markedConfig) {
353
+ config.markedConfig.forEach(function(entry) {
354
+ if (Array.isArray(entry)) {
355
+ var _processor;
356
+ var _entry = _to_array(entry), plugin = _entry[0], pluginOptions = _entry.slice(1);
357
+ (_processor = processor).use.apply(_processor, [
358
+ plugin
359
+ ].concat(_to_consumable_array(pluginOptions)));
360
+ } else {
361
+ processor.use(entry);
362
+ }
363
+ });
364
+ }
365
+ return processor;
366
+ };
367
+ var extractLanguageFromClassName = function extractLanguageFromClassName(className) {
368
+ if (!className) return undefined;
369
+ var flat = typeof className === 'string' ? className : className.map(String).join(' ');
370
+ var classes = flat.split(/\s+/).filter(Boolean);
371
+ var _iteratorNormalCompletion = true, _didIteratorError = false, _iteratorError = undefined;
372
+ try {
373
+ for(var _iterator = classes[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true){
374
+ var cls = _step.value;
375
+ var match = cls.match(/^language-(.+)$/);
376
+ if (match) return match[1];
377
+ }
378
+ } catch (err) {
379
+ _didIteratorError = true;
380
+ _iteratorError = err;
381
+ } finally{
382
+ try {
383
+ if (!_iteratorNormalCompletion && _iterator.return != null) {
384
+ _iterator.return();
385
+ }
386
+ } finally{
387
+ if (_didIteratorError) {
388
+ throw _iteratorError;
389
+ }
390
+ }
391
+ }
392
+ return undefined;
393
+ };
394
+ /**
395
+ * 提取 React children 的文本内容
396
+ */ var extractChildrenText = function extractChildrenText1(children) {
397
+ var _children_props;
398
+ if (typeof children === 'string') return children;
399
+ if (typeof children === 'number') return String(children);
400
+ if (Array.isArray(children)) return children.map(extractChildrenText).join('');
401
+ if (React.isValidElement(children) && ((_children_props = children.props) === null || _children_props === void 0 ? void 0 : _children_props.children)) {
402
+ return extractChildrenText(children.props.children);
403
+ }
404
+ return '';
405
+ };
406
+ /**
407
+ * <think> 标签渲染组件——使用 ToolUseBarThink 替代原生 DOM。
408
+ * 在 MarkdownEditor 中,<think> 被预处理为 ```think 代码块,
409
+ * 然后由 ThinkBlock 组件(依赖 Slate 上下文)渲染为 ToolUseBarThink。
410
+ * 在 MarkdownRenderer 中,<think> 通过 rehypeRaw 保留为 hast 元素,
411
+ * 这里直接渲染为 ToolUseBarThink,无需 Slate 上下文。
412
+ */ var ThinkBlockRendererComponent = function ThinkBlockRendererComponent(props) {
413
+ var children = props.children;
414
+ var content = extractChildrenText(children);
415
+ var isLoading = content.endsWith('...');
416
+ return React.createElement(ToolUseBarThink, {
417
+ testId: 'think-block-renderer',
418
+ styles: {
419
+ root: {
420
+ boxSizing: 'border-box',
421
+ maxWidth: '680px',
422
+ marginTop: 8
423
+ }
424
+ },
425
+ toolName: isLoading ? '深度思考...' : '深度思考',
426
+ thinkContent: content,
427
+ status: isLoading ? 'loading' : 'success'
428
+ });
429
+ };
430
+ /**
431
+ * 构建与 MarkdownEditor Readonly 组件对齐的 hast→React 组件映射。
432
+ *
433
+ * MarkdownEditor 的 Slate 元素使用 data-be 属性和 prefixCls 类名,
434
+ * 这里为原生 HTML 标签添加相同的属性,使共用的 CSS 能正确命中。
435
+ */ var buildEditorAlignedComponents = function buildEditorAlignedComponents(prefixCls, userComponents, streaming, linkConfig, streamingParagraphAnimation) {
436
+ var listCls = "".concat(prefixCls, "-list");
437
+ var tableCls = "".concat(prefixCls, "-content-table");
438
+ var contentCls = prefixCls; // e.g. ant-agentic-md-editor-content
439
+ /** 仅当 streaming、末块动画上下文允许且显式开启段落动画时包 AnimationText */ var StreamAnimWrap = function StreamAnimWrap(param) {
440
+ var children = param.children;
441
+ var _ref;
442
+ var ctx = useContext(StreamingAnimationContext);
443
+ var animateBlock = (_ref = ctx === null || ctx === void 0 ? void 0 : ctx.animateBlock) !== null && _ref !== void 0 ? _ref : true;
444
+ var allow = !!streaming && animateBlock && !!streamingParagraphAnimation;
445
+ if (!allow) return children;
446
+ return jsx(AnimationText, {
447
+ children: children
448
+ });
449
+ };
450
+ StreamAnimWrap.displayName = 'StreamAnimWrap';
451
+ var wrapAnimation = function wrapAnimation(children) {
452
+ return jsx(StreamAnimWrap, {
453
+ children: children
454
+ });
455
+ };
456
+ return _object_spread({
457
+ // ================================================================
458
+ // Block 级别元素
459
+ // ================================================================
460
+ p: function p(props) {
461
+ var _node = props.node, children = props.children, rest = _object_without_properties(props, [
462
+ "node",
463
+ "children"
464
+ ]);
465
+ return jsx('div', _object_spread_props(_object_spread({}, rest), {
466
+ 'data-be': 'paragraph',
467
+ 'data-testid': 'markdown-paragraph',
468
+ children: wrapAnimation(children)
469
+ }));
470
+ },
471
+ h1: function h1(props) {
472
+ var _node = props.node, children = props.children, rest = _object_without_properties(props, [
473
+ "node",
474
+ "children"
475
+ ]);
476
+ return jsx('h1', _object_spread_props(_object_spread({}, rest), {
477
+ 'data-be': 'head',
478
+ 'data-testid': 'markdown-heading-1',
479
+ children: children
480
+ }));
481
+ },
482
+ h2: function h2(props) {
483
+ var _node = props.node, children = props.children, rest = _object_without_properties(props, [
484
+ "node",
485
+ "children"
486
+ ]);
487
+ return jsx('h2', _object_spread_props(_object_spread({}, rest), {
488
+ 'data-be': 'head',
489
+ 'data-testid': 'markdown-heading-2',
490
+ children: children
491
+ }));
492
+ },
493
+ h3: function h3(props) {
494
+ var _node = props.node, children = props.children, rest = _object_without_properties(props, [
495
+ "node",
496
+ "children"
497
+ ]);
498
+ return jsx('h3', _object_spread_props(_object_spread({}, rest), {
499
+ 'data-be': 'head',
500
+ 'data-testid': 'markdown-heading-3',
501
+ children: children
502
+ }));
503
+ },
504
+ h4: function h4(props) {
505
+ var _node = props.node, children = props.children, rest = _object_without_properties(props, [
506
+ "node",
507
+ "children"
508
+ ]);
509
+ return jsx('h4', _object_spread_props(_object_spread({}, rest), {
510
+ 'data-be': 'head',
511
+ 'data-testid': 'markdown-heading-4',
512
+ children: children
513
+ }));
514
+ },
515
+ h5: function h5(props) {
516
+ var _node = props.node, children = props.children, rest = _object_without_properties(props, [
517
+ "node",
518
+ "children"
519
+ ]);
520
+ return jsx('h5', _object_spread_props(_object_spread({}, rest), {
521
+ 'data-be': 'head',
522
+ 'data-testid': 'markdown-heading-5',
523
+ children: children
524
+ }));
525
+ },
526
+ h6: function h6(props) {
527
+ var _node = props.node, children = props.children, rest = _object_without_properties(props, [
528
+ "node",
529
+ "children"
530
+ ]);
531
+ return jsx('h6', _object_spread_props(_object_spread({}, rest), {
532
+ 'data-be': 'head',
533
+ 'data-testid': 'markdown-heading-6',
534
+ children: children
535
+ }));
536
+ },
537
+ blockquote: function blockquote(props) {
538
+ var _node = props.node, children = props.children, rest = _object_without_properties(props, [
539
+ "node",
540
+ "children"
541
+ ]);
542
+ return jsx('blockquote', _object_spread_props(_object_spread({}, rest), {
543
+ 'data-be': 'blockquote',
544
+ 'data-testid': 'markdown-blockquote',
545
+ children: children
546
+ }));
547
+ },
548
+ ul: function ul(props) {
549
+ var _node = props.node, children = props.children, rest = _object_without_properties(props, [
550
+ "node",
551
+ "children"
552
+ ]);
553
+ return jsx('div', {
554
+ className: "".concat(listCls, "-container"),
555
+ 'data-be': 'list',
556
+ 'data-testid': 'markdown-unordered-list',
557
+ children: jsx('ul', _object_spread_props(_object_spread({}, rest), {
558
+ className: "".concat(listCls, " ul"),
559
+ children: children
560
+ }))
561
+ });
562
+ },
563
+ ol: function ol(props) {
564
+ var _node = props.node, children = props.children, start = props.start, rest = _object_without_properties(props, [
565
+ "node",
566
+ "children",
567
+ "start"
568
+ ]);
569
+ return jsx('div', {
570
+ className: "".concat(listCls, "-container"),
571
+ 'data-be': 'list',
572
+ 'data-testid': 'markdown-ordered-list',
573
+ children: jsx('ol', _object_spread_props(_object_spread({}, rest), {
574
+ className: "".concat(listCls, " ol"),
575
+ start: start,
576
+ children: children
577
+ }))
578
+ });
579
+ },
580
+ li: function li(props) {
581
+ var _node = props.node, children = props.children, className = props.className, rest = _object_without_properties(props, [
582
+ "node",
583
+ "children",
584
+ "className"
585
+ ]);
586
+ var isTask = className === 'task-list-item' || Array.isArray(className) && className.includes('task-list-item');
587
+ if (isTask) {
588
+ var childArray = Array.isArray(children) ? children : [
589
+ children
590
+ ];
591
+ var checked = false;
592
+ var filteredChildren = childArray.filter(function(child) {
593
+ var _child_props;
594
+ if (React.isValidElement(child) && ((_child_props = child.props) === null || _child_props === void 0 ? void 0 : _child_props.type) === 'checkbox') {
595
+ var _child_props1;
596
+ checked = !!((_child_props1 = child.props) === null || _child_props1 === void 0 ? void 0 : _child_props1.checked);
597
+ return false;
598
+ }
599
+ return true;
600
+ });
601
+ return jsxs('li', _object_spread_props(_object_spread({}, rest), {
602
+ className: "".concat(listCls, "-item ").concat(listCls, "-task"),
603
+ 'data-be': 'list-item',
604
+ 'data-testid': 'markdown-task-item',
605
+ children: [
606
+ jsx('span', {
607
+ className: "".concat(listCls, "-check-item"),
608
+ contentEditable: false,
609
+ 'data-check-item': true,
610
+ children: jsx(Checkbox, {
611
+ checked: checked,
612
+ disabled: true
613
+ })
614
+ })
615
+ ].concat(_to_consumable_array(filteredChildren))
616
+ }));
617
+ }
618
+ return jsx('li', _object_spread_props(_object_spread({}, rest), {
619
+ className: "".concat(listCls, "-item"),
620
+ 'data-be': 'list-item',
621
+ 'data-testid': 'markdown-list-item',
622
+ children: children
623
+ }));
624
+ },
625
+ table: function table(props) {
626
+ var _node = props.node, children = props.children, rest = _object_without_properties(props, [
627
+ "node",
628
+ "children"
629
+ ]);
630
+ return jsx('div', {
631
+ className: tableCls,
632
+ 'data-testid': 'markdown-table',
633
+ children: jsx('div', {
634
+ className: "".concat(tableCls, "-container"),
635
+ children: jsx('table', _object_spread_props(_object_spread({}, rest), {
636
+ className: "".concat(tableCls, "-readonly-table"),
637
+ style: {
638
+ tableLayout: 'auto',
639
+ width: '100%'
640
+ },
641
+ children: children
642
+ }))
643
+ })
644
+ });
645
+ },
646
+ thead: function thead(props) {
647
+ var _node = props.node, children = props.children, rest = _object_without_properties(props, [
648
+ "node",
649
+ "children"
650
+ ]);
651
+ return jsx('thead', _object_spread_props(_object_spread({}, rest), {
652
+ 'data-testid': 'markdown-thead',
653
+ children: children
654
+ }));
655
+ },
656
+ tbody: function tbody(props) {
657
+ var _node = props.node, children = props.children, rest = _object_without_properties(props, [
658
+ "node",
659
+ "children"
660
+ ]);
661
+ return jsx('tbody', _object_spread_props(_object_spread({}, rest), {
662
+ 'data-testid': 'markdown-tbody',
663
+ children: children
664
+ }));
665
+ },
666
+ tr: function tr(props) {
667
+ var _node = props.node, children = props.children, rest = _object_without_properties(props, [
668
+ "node",
669
+ "children"
670
+ ]);
671
+ return jsx('tr', _object_spread_props(_object_spread({}, rest), {
672
+ 'data-testid': 'markdown-tr',
673
+ children: children
674
+ }));
675
+ },
676
+ th: function th(props) {
677
+ var _node = props.node, children = props.children, rest = _object_without_properties(props, [
678
+ "node",
679
+ "children"
680
+ ]);
681
+ return jsx('th', _object_spread_props(_object_spread({}, rest), {
682
+ 'data-testid': 'markdown-th',
683
+ style: {
684
+ whiteSpace: 'normal',
685
+ maxWidth: '20%'
686
+ },
687
+ children: children
688
+ }));
689
+ },
690
+ td: function td(props) {
691
+ var _node = props.node, children = props.children, rest = _object_without_properties(props, [
692
+ "node",
693
+ "children"
694
+ ]);
695
+ return jsx('td', _object_spread_props(_object_spread({}, rest), {
696
+ 'data-testid': 'markdown-td',
697
+ style: {
698
+ whiteSpace: 'normal',
699
+ maxWidth: '20%'
700
+ },
701
+ children: children
702
+ }));
703
+ },
704
+ // input[type=checkbox]:task list 的 checkbox(兜底,主逻辑在 li 中)
705
+ input: function input(props) {
706
+ var _node = props.node, type = props.type, checked = props.checked, disabled = props.disabled, rest = _object_without_properties(props, [
707
+ "node",
708
+ "type",
709
+ "checked",
710
+ "disabled"
711
+ ]);
712
+ if (type === 'checkbox') {
713
+ return jsx(Checkbox, {
714
+ checked: !!checked,
715
+ disabled: true,
716
+ 'data-testid': 'markdown-checkbox'
717
+ });
718
+ }
719
+ return jsx('input', _object_spread_props(_object_spread({}, rest), {
720
+ type: type,
721
+ checked: checked,
722
+ disabled: disabled
723
+ }));
724
+ },
725
+ // ================================================================
726
+ // Leaf 级别(行内元素)
727
+ // ================================================================
728
+ a: function a(props) {
729
+ var _node = props.node, href = props.href, _origOnClick = props.onClick, rest = _object_without_properties(props, [
730
+ "node",
731
+ "href",
732
+ "onClick"
733
+ ]);
734
+ var openInNewTab = (linkConfig === null || linkConfig === void 0 ? void 0 : linkConfig.openInNewTab) !== false;
735
+ return jsx('a', _object_spread_props(_object_spread({}, rest), {
736
+ href: href,
737
+ 'data-be': 'text',
738
+ 'data-url': 'url',
739
+ 'data-testid': 'markdown-link',
740
+ target: openInNewTab ? '_blank' : undefined,
741
+ rel: openInNewTab ? 'noopener noreferrer' : undefined,
742
+ onClick: function onClick(e) {
743
+ if (linkConfig === null || linkConfig === void 0 ? void 0 : linkConfig.onClick) {
744
+ var res = linkConfig.onClick(href);
745
+ if (res === false) {
746
+ e.preventDefault();
747
+ return;
748
+ }
749
+ }
750
+ }
751
+ }));
752
+ },
753
+ strong: function strong(props) {
754
+ var _node = props.node, children = props.children, rest = _object_without_properties(props, [
755
+ "node",
756
+ "children"
757
+ ]);
758
+ return jsx('strong', _object_spread_props(_object_spread({}, rest), {
759
+ 'data-testid': 'markdown-bold',
760
+ style: {
761
+ fontWeight: 'bold'
762
+ },
763
+ children: children
764
+ }));
765
+ },
766
+ em: function em(props) {
767
+ var _node = props.node, children = props.children, rest = _object_without_properties(props, [
768
+ "node",
769
+ "children"
770
+ ]);
771
+ return jsx('em', _object_spread_props(_object_spread({}, rest), {
772
+ 'data-testid': 'markdown-italic',
773
+ style: {
774
+ fontStyle: 'italic'
775
+ },
776
+ children: children
777
+ }));
778
+ },
779
+ del: function del(props) {
780
+ var _node = props.node, children = props.children, rest = _object_without_properties(props, [
781
+ "node",
782
+ "children"
783
+ ]);
784
+ return jsx('del', _object_spread_props(_object_spread({}, rest), {
785
+ 'data-testid': 'markdown-strikethrough',
786
+ children: children
787
+ }));
788
+ },
789
+ code: function code(props) {
790
+ var _node = props.node, children = props.children, className = props.className, rest = _object_without_properties(props, [
791
+ "node",
792
+ "children",
793
+ "className"
794
+ ]);
795
+ var fenceLang = extractLanguageFromClassName(className);
796
+ return jsx('code', _object_spread_props(_object_spread({}, rest), {
797
+ 'data-testid': fenceLang ? 'markdown-fenced-code' : 'markdown-inline-code',
798
+ className: fenceLang ? className : "".concat(contentCls, "-inline-code"),
799
+ children: children
800
+ }));
801
+ },
802
+ mark: function mark(props) {
803
+ var _node = props.node, children = props.children, rest = _object_without_properties(props, [
804
+ "node",
805
+ "children"
806
+ ]);
807
+ return jsx('mark', _object_spread_props(_object_spread({}, rest), {
808
+ 'data-testid': 'markdown-mark',
809
+ style: {
810
+ background: '#f59e0b',
811
+ padding: '0.1em 0.2em',
812
+ borderRadius: 2
813
+ },
814
+ children: children
815
+ }));
816
+ },
817
+ kbd: function kbd(props) {
818
+ var _node = props.node, children = props.children, rest = _object_without_properties(props, [
819
+ "node",
820
+ "children"
821
+ ]);
822
+ return jsx('kbd', _object_spread_props(_object_spread({}, rest), {
823
+ 'data-testid': 'markdown-kbd',
824
+ style: {
825
+ padding: '0.1em 0.4em',
826
+ fontSize: '0.85em',
827
+ border: '1px solid var(--color-gray-border-light, #d9d9d9)',
828
+ borderRadius: 3,
829
+ boxShadow: '0 1px 0 var(--color-gray-border-light, #d9d9d9)',
830
+ fontFamily: 'Consolas, Monaco, "Courier New", monospace'
831
+ },
832
+ children: children
833
+ }));
834
+ },
835
+ sub: function sub(props) {
836
+ var _node = props.node, children = props.children, rest = _object_without_properties(props, [
837
+ "node",
838
+ "children"
839
+ ]);
840
+ return jsx('sub', _object_spread_props(_object_spread({}, rest), {
841
+ 'data-testid': 'markdown-sub',
842
+ children: children
843
+ }));
844
+ },
845
+ // ================================================================
846
+ // 代码块 pre > code → 路由到自定义渲染器
847
+ pre: function pre(props) {
848
+ var _hastPreNode_children_, _hastPreNode_children, _hastPreNode_children__properties;
849
+ var hastPreNode = props.node, children = props.children, rest = _object_without_properties(props, [
850
+ "node",
851
+ "children"
852
+ ]);
853
+ var codeChild = Array.isArray(children) ? children[0] : children;
854
+ var codeProps = (codeChild === null || codeChild === void 0 ? void 0 : codeChild.props) || {};
855
+ var codeHastClass = (hastPreNode === null || hastPreNode === void 0 ? void 0 : (_hastPreNode_children = hastPreNode.children) === null || _hastPreNode_children === void 0 ? void 0 : (_hastPreNode_children_ = _hastPreNode_children[0]) === null || _hastPreNode_children_ === void 0 ? void 0 : _hastPreNode_children_.type) === 'element' && hastPreNode.children[0].tagName === 'code' ? (_hastPreNode_children__properties = hastPreNode.children[0].properties) === null || _hastPreNode_children__properties === void 0 ? void 0 : _hastPreNode_children__properties.className : undefined;
856
+ var language = extractLanguageFromClassName(codeProps.className);
857
+ if (!language) {
858
+ language = extractLanguageFromClassName(codeHastClass);
859
+ }
860
+ var CodeBlockComponent = userComponents.__codeBlock || userComponents.code;
861
+ if (CodeBlockComponent) {
862
+ return jsx(CodeBlockComponent, _object_spread_props(_object_spread({}, rest), {
863
+ language: language,
864
+ children: codeProps.children,
865
+ node: hastPreNode
866
+ }));
867
+ }
868
+ return jsxs('pre', _object_spread_props(_object_spread({}, rest), {
869
+ children: [
870
+ children
871
+ ]
872
+ }));
873
+ },
874
+ img: function img(props) {
875
+ var _node = props.node, src = props.src, alt = props.alt, width = props.width, height = props.height, _rest = _object_without_properties(props, [
876
+ "node",
877
+ "src",
878
+ "alt",
879
+ "width",
880
+ "height"
881
+ ]);
882
+ var imgWidth = width ? Number(width) || width : 400;
883
+ return jsx('div', {
884
+ 'data-be': 'image',
885
+ 'data-testid': 'markdown-image',
886
+ style: {
887
+ position: 'relative',
888
+ userSelect: 'none',
889
+ width: '100%',
890
+ maxWidth: '100%',
891
+ boxSizing: 'border-box'
892
+ },
893
+ children: jsx('div', {
894
+ style: {
895
+ padding: 4,
896
+ userSelect: 'none',
897
+ display: 'flex',
898
+ flexDirection: 'column',
899
+ width: '100%',
900
+ maxWidth: '100%',
901
+ boxSizing: 'border-box'
902
+ },
903
+ 'data-testid': 'image-container',
904
+ 'data-be': 'image-container',
905
+ children: jsx(Image, {
906
+ src: src,
907
+ alt: alt || 'image',
908
+ width: imgWidth,
909
+ height: height,
910
+ preview: {
911
+ getContainer: function getContainer() {
912
+ return document.body;
913
+ }
914
+ },
915
+ referrerPolicy: 'no-referrer',
916
+ draggable: false,
917
+ style: {
918
+ maxWidth: '100%',
919
+ height: 'auto',
920
+ display: 'block'
921
+ }
922
+ })
923
+ })
924
+ });
925
+ },
926
+ // 视频:对齐 ReadonlyMedia 的 video 处理
927
+ video: function video(props) {
928
+ var _node = props.node, children = props.children, rest = _object_without_properties(props, [
929
+ "node",
930
+ "children"
931
+ ]);
932
+ return jsx('div', {
933
+ 'data-be': 'media',
934
+ 'data-testid': 'markdown-video',
935
+ style: {
936
+ position: 'relative',
937
+ width: '100%',
938
+ maxWidth: '100%',
939
+ margin: '0.5em 0'
940
+ },
941
+ children: jsx('video', _object_spread_props(_object_spread({}, rest), {
942
+ controls: true,
943
+ style: {
944
+ maxWidth: '100%',
945
+ borderRadius: 8
946
+ },
947
+ children: children
948
+ }))
949
+ });
950
+ },
951
+ // 音频:对齐 ReadonlyMedia 的 audio 处理
952
+ audio: function audio(props) {
953
+ var _node = props.node, children = props.children, rest = _object_without_properties(props, [
954
+ "node",
955
+ "children"
956
+ ]);
957
+ return jsx('div', {
958
+ 'data-be': 'media',
959
+ 'data-testid': 'markdown-audio',
960
+ style: {
961
+ position: 'relative',
962
+ width: '100%',
963
+ margin: '0.5em 0'
964
+ },
965
+ children: jsx('audio', _object_spread_props(_object_spread({}, rest), {
966
+ controls: true,
967
+ style: {
968
+ width: '100%'
969
+ },
970
+ children: children
971
+ }))
972
+ });
973
+ },
974
+ // iframe
975
+ iframe: function iframe(props) {
976
+ var _node = props.node, rest = _object_without_properties(props, [
977
+ "node"
978
+ ]);
979
+ return jsx('div', {
980
+ 'data-testid': 'markdown-iframe',
981
+ style: {
982
+ position: 'relative',
983
+ width: '100%',
984
+ margin: '0.5em 0'
985
+ },
986
+ children: jsx('iframe', _object_spread_props(_object_spread({}, rest), {
987
+ style: {
988
+ width: '100%',
989
+ minHeight: 300,
990
+ border: '1px solid var(--color-gray-border-light, #e8e8e8)',
991
+ borderRadius: 8
992
+ }
993
+ }))
994
+ });
995
+ },
996
+ hr: function hr(props) {
997
+ var _node = props.node, rest = _object_without_properties(props, [
998
+ "node"
999
+ ]);
1000
+ return jsx('hr', _object_spread_props(_object_spread({}, rest), {
1001
+ 'data-be': 'hr',
1002
+ 'data-testid': 'markdown-hr'
1003
+ }));
1004
+ },
1005
+ // 脚注引用 sup > a(remark-gfm 有定义时生成)
1006
+ sup: function sup(props) {
1007
+ var _node = props.node, children = props.children, rest = _object_without_properties(props, [
1008
+ "node",
1009
+ "children"
1010
+ ]);
1011
+ return jsx('span', _object_spread_props(_object_spread({}, rest), {
1012
+ 'data-fnc': 'fnc',
1013
+ 'data-testid': 'markdown-footnote-ref',
1014
+ className: "".concat(contentCls, "-fnc"),
1015
+ style: {
1016
+ fontSize: 12,
1017
+ cursor: 'pointer'
1018
+ },
1019
+ children: children
1020
+ }));
1021
+ },
1022
+ span: function span(props) {
1023
+ var _node = props.node, children = props.children, rest = _object_without_properties(props, [
1024
+ "node",
1025
+ "children"
1026
+ ]);
1027
+ if (rest['data-fnc'] === 'fnc') {
1028
+ return jsx('span', _object_spread_props(_object_spread({}, rest), {
1029
+ 'data-testid': 'markdown-footnote-ref',
1030
+ className: "".concat(contentCls, "-fnc"),
1031
+ style: {
1032
+ fontSize: 12,
1033
+ cursor: 'pointer'
1034
+ },
1035
+ children: children
1036
+ }));
1037
+ }
1038
+ return jsx('span', _object_spread_props(_object_spread({}, rest), {
1039
+ children: children
1040
+ }));
1041
+ },
1042
+ section: function section(props) {
1043
+ var _node = props.node, children = props.children, className = props.className, rest = _object_without_properties(props, [
1044
+ "node",
1045
+ "children",
1046
+ "className"
1047
+ ]);
1048
+ var isFootnotes = className === 'footnotes' || typeof (rest === null || rest === void 0 ? void 0 : rest['data-footnotes']) !== 'undefined';
1049
+ if (isFootnotes) {
1050
+ return jsx('div', _object_spread_props(_object_spread({}, rest), {
1051
+ 'data-be': 'footnoteDefinition',
1052
+ 'data-testid': 'markdown-footnote-section',
1053
+ style: {
1054
+ fontSize: 12,
1055
+ borderTop: '1px solid var(--color-gray-border-light, #e8e8e8)',
1056
+ marginTop: 16,
1057
+ paddingTop: 8
1058
+ },
1059
+ children: children
1060
+ }));
1061
+ }
1062
+ return jsx('section', _object_spread_props(_object_spread({}, rest), {
1063
+ className: className,
1064
+ children: children
1065
+ }));
1066
+ },
1067
+ think: ThinkBlockRendererComponent,
1068
+ answer: function answer(props) {
1069
+ var _node = props.node, children = props.children;
1070
+ return jsx(Fragment, {
1071
+ children: children
1072
+ });
1073
+ }
1074
+ }, userComponents);
1075
+ };
1076
+ /**
1077
+ * 在 hast 上标记「最后一个 p」,用于流式时仅该段落播放入场(单块长文时避免全页 p 一起闪)
1078
+ */ var markLastParagraphStreamingTail = function markLastParagraphStreamingTail(hast) {
1079
+ var paragraphs = [];
1080
+ visit(hast, 'element', function(node) {
1081
+ if (node.tagName === 'p') {
1082
+ paragraphs.push(node);
1083
+ }
1084
+ });
1085
+ var last = paragraphs[paragraphs.length - 1];
1086
+ if (last) {
1087
+ last.properties = last.properties || {};
1088
+ last.properties.dataStreamingTail = true;
1089
+ }
1090
+ };
1091
+ /**
1092
+ * 将单个 markdown 片段转为 React 元素(内部函数)
1093
+ */ var renderMarkdownBlock = function renderMarkdownBlock(blockContent, processor, components, blockOpts) {
1094
+ if (!blockContent.trim()) return null;
1095
+ try {
1096
+ var mdast = processor.parse(blockContent);
1097
+ var hast = processor.runSync(mdast);
1098
+ if (blockOpts === null || blockOpts === void 0 ? void 0 : blockOpts.markStreamingTailParagraph) {
1099
+ markLastParagraphStreamingTail(hast);
1100
+ }
1101
+ return toJsxRuntime(hast, {
1102
+ Fragment: Fragment,
1103
+ jsx: jsx,
1104
+ jsxs: jsxs,
1105
+ components: components,
1106
+ passNode: true
1107
+ });
1108
+ } catch (unused) {
1109
+ return null;
1110
+ }
1111
+ };
1112
+ /**
1113
+ * 将 markdown 按块(双换行)拆分,尊重代码围栏边界。
1114
+ * 返回的每个块是一个独立的 markdown 片段,可单独解析。
1115
+ */ var splitMarkdownBlocks = function splitMarkdownBlocks(content) {
1116
+ var lines = content.split('\n');
1117
+ var blocks = [];
1118
+ var current = [];
1119
+ var inFence = false;
1120
+ var _iteratorNormalCompletion = true, _didIteratorError = false, _iteratorError = undefined;
1121
+ try {
1122
+ for(var _iterator = lines[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true){
1123
+ var line = _step.value;
1124
+ var trimmed = line.trimStart();
1125
+ if (trimmed.startsWith('```') || trimmed.startsWith('~~~')) {
1126
+ inFence = !inFence;
1127
+ }
1128
+ if (!inFence && line === '' && current.length > 0) {
1129
+ var prev = current[current.length - 1];
1130
+ if (prev === '') {
1131
+ // 触发分割的是「第二个连续空行」,不应并入上一块末尾,否则与单块解析结果字符串不一致、缓存失效
1132
+ var withoutTrailingBlank = current.slice(0, -1);
1133
+ blocks.push(withoutTrailingBlank.join('\n'));
1134
+ current = [];
1135
+ continue;
1136
+ }
1137
+ }
1138
+ current.push(line);
1139
+ }
1140
+ } catch (err) {
1141
+ _didIteratorError = true;
1142
+ _iteratorError = err;
1143
+ } finally{
1144
+ try {
1145
+ if (!_iteratorNormalCompletion && _iterator.return != null) {
1146
+ _iterator.return();
1147
+ }
1148
+ } finally{
1149
+ if (_didIteratorError) {
1150
+ throw _iteratorError;
1151
+ }
1152
+ }
1153
+ }
1154
+ if (current.length > 0) {
1155
+ blocks.push(current.join('\n'));
1156
+ }
1157
+ return blocks;
1158
+ };
1159
+ export { buildEditorAlignedComponents, createHastProcessor, markLastParagraphStreamingTail, renderMarkdownBlock, splitMarkdownBlocks };