@ant-design/agentic-ui 2.20.2 → 2.22.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (52) hide show
  1. package/dist/MarkdownEditor/BaseMarkdownEditor.js +1 -1
  2. package/dist/MarkdownEditor/editor/elements/Code.js +1 -1
  3. package/dist/MarkdownEditor/editor/elements/Image/index.js +37 -9
  4. package/dist/MarkdownEditor/editor/elements/LinkCard/index.js +87 -2
  5. package/dist/MarkdownEditor/editor/elements/List/List.js +10 -2
  6. package/dist/MarkdownEditor/editor/elements/Media.js +75 -23
  7. package/dist/MarkdownEditor/editor/elements/Table/ReadonlyTableComponent.js +2 -13
  8. package/dist/MarkdownEditor/editor/elements/Table/SimpleTable.js +89 -15
  9. package/dist/MarkdownEditor/editor/elements/Table/Table.js +3 -75
  10. package/dist/MarkdownEditor/editor/elements/TagPopup/index.js +4 -4
  11. package/dist/MarkdownEditor/editor/elements/TagPopup/style.js +14 -12
  12. package/dist/MarkdownEditor/editor/elements/index.js +1 -32
  13. package/dist/MarkdownEditor/editor/parser/parse/applyContextPropsAndConfig.d.ts +8 -0
  14. package/dist/MarkdownEditor/editor/parser/parse/applyContextPropsAndConfig.js +58 -0
  15. package/dist/MarkdownEditor/editor/parser/parse/parseBlockElements.d.ts +67 -0
  16. package/dist/MarkdownEditor/editor/parser/parse/parseBlockElements.js +289 -0
  17. package/dist/MarkdownEditor/editor/parser/parse/parseCode.d.ts +32 -0
  18. package/dist/MarkdownEditor/editor/parser/parse/parseCode.js +186 -0
  19. package/dist/MarkdownEditor/editor/parser/parse/parseElements.d.ts +27 -0
  20. package/dist/MarkdownEditor/editor/parser/parse/parseElements.js +83 -0
  21. package/dist/MarkdownEditor/editor/parser/parse/parseEmptyLines.d.ts +9 -0
  22. package/dist/MarkdownEditor/editor/parser/parse/parseEmptyLines.js +60 -0
  23. package/dist/MarkdownEditor/editor/parser/parse/parseFootnote.d.ts +10 -0
  24. package/dist/MarkdownEditor/editor/parser/parse/parseFootnote.js +12 -0
  25. package/dist/MarkdownEditor/editor/parser/parse/parseHtml.d.ts +63 -0
  26. package/dist/MarkdownEditor/editor/parser/parse/parseHtml.js +759 -0
  27. package/dist/MarkdownEditor/editor/parser/parse/parseMath.d.ts +24 -0
  28. package/dist/MarkdownEditor/editor/parser/parse/parseMath.js +58 -0
  29. package/dist/MarkdownEditor/editor/parser/parse/parseMedia.d.ts +27 -0
  30. package/dist/MarkdownEditor/editor/parser/parse/parseMedia.js +127 -0
  31. package/dist/MarkdownEditor/editor/parser/parse/parseTable.d.ts +39 -0
  32. package/dist/MarkdownEditor/editor/parser/parse/parseTable.js +348 -0
  33. package/dist/MarkdownEditor/editor/parser/parse/parseText.d.ts +26 -0
  34. package/dist/MarkdownEditor/editor/parser/parse/parseText.js +304 -0
  35. package/dist/MarkdownEditor/editor/parser/parserMarkdownToSlateNode.d.ts +3 -44
  36. package/dist/MarkdownEditor/editor/parser/parserMarkdownToSlateNode.js +141 -2282
  37. package/dist/MarkdownEditor/editor/parser/parserSlateNodeToMarkdown.js +137 -12
  38. package/dist/MarkdownEditor/editor/parser/remarkParse.d.ts +11 -1
  39. package/dist/MarkdownEditor/editor/parser/remarkParse.js +225 -39
  40. package/dist/MarkdownEditor/editor/plugins/elements.js +1 -1
  41. package/dist/MarkdownEditor/editor/types/Table.d.ts +2 -1
  42. package/dist/MarkdownEditor/editor/utils/markdownToHtml.js +2 -1
  43. package/dist/MarkdownEditor/el.d.ts +3 -0
  44. package/dist/MarkdownEditor/style.js +2 -0
  45. package/dist/Plugins/chart/index.js +7 -7
  46. package/dist/Plugins/code/components/CodeRenderer.js +27 -10
  47. package/dist/Plugins/code/components/CodeToolbar.js +3 -16
  48. package/dist/Workspace/Task/index.d.ts +13 -8
  49. package/dist/Workspace/Task/index.js +19 -2
  50. package/dist/Workspace/index.js +3 -2
  51. package/dist/Workspace/types.d.ts +3 -1
  52. package/package.json +1 -1
@@ -336,6 +336,7 @@ var inlineNode = new Set([
336
336
  var configProps = _object_spread({}, node.otherProps);
337
337
  delete configProps['columns'];
338
338
  delete configProps['dataSource'];
339
+ delete configProps['finished'];
339
340
  if (node.type === 'link-card') {
340
341
  configProps.type = 'card';
341
342
  configProps.url = encodeURI(node === null || node === void 0 ? void 0 : node.url);
@@ -356,9 +357,107 @@ var inlineNode = new Set([
356
357
  }
357
358
  });
358
359
  // 只有当 configProps 不为空对象时才生成注释
359
- if (Object.keys(configProps).length > 0) {
360
- var propsToSerialize = node.type === 'chart' && configProps.config ? configProps.config : configProps;
361
- str += "<!--".concat(JSON.stringify(propsToSerialize), "-->\n");
360
+ // 检查 configProps 是否为空对象(删除 finished 后可能变成空对象)
361
+ var hasValidProps = Object.keys(configProps).length > 0;
362
+ if (hasValidProps) {
363
+ /**
364
+ * 将对象转换为数组(处理 {0: {...}, 1: {...}} 这种错误格式)
365
+ * @param obj - 要转换的对象
366
+ * @returns 转换后的数组,如果不是数字键对象则返回原对象
367
+ */ var convertObjectToArray = function(obj) {
368
+ if (!obj || (typeof obj === "undefined" ? "undefined" : _type_of(obj)) !== 'object' || Array.isArray(obj)) {
369
+ return obj;
370
+ }
371
+ var keys = Object.keys(obj);
372
+ // 检查是否所有键都是数字字符串(如 "0", "1", "2")
373
+ var allNumericKeys = keys.length > 0 && keys.every(function(key) {
374
+ return /^\d+$/.test(key);
375
+ });
376
+ if (allNumericKeys) {
377
+ // 按数字顺序排序并转换为数组
378
+ var sortedKeys = keys.sort(function(a, b) {
379
+ return parseInt(a, 10) - parseInt(b, 10);
380
+ });
381
+ return sortedKeys.map(function(key) {
382
+ return obj[key];
383
+ });
384
+ }
385
+ return obj;
386
+ };
387
+ // 对于图表类型,配置应该总是以数组形式存储在 config 中
388
+ if (node.type === 'chart') {
389
+ var chartConfig = configProps.config;
390
+ // 如果 config 不存在,但 configProps 看起来像图表配置(有 chartType),使用 configProps
391
+ if (!chartConfig && configProps.chartType) {
392
+ chartConfig = configProps;
393
+ }
394
+ // 如果 chartConfig 是对象且键都是数字(如 {0: {...}}),转换为数组
395
+ chartConfig = convertObjectToArray(chartConfig);
396
+ // 如果 chartConfig 还不是数组,将其包装为数组
397
+ // 这样可以确保即使只有一个配置项,也会被放入数组中
398
+ if (!Array.isArray(chartConfig)) {
399
+ // 如果 chartConfig 是对象,检查是否是 {0: {...}} 格式但转换失败的情况
400
+ if (chartConfig && (typeof chartConfig === "undefined" ? "undefined" : _type_of(chartConfig)) === 'object') {
401
+ var keys = Object.keys(chartConfig);
402
+ // 如果只有一个键且是数字,提取该值
403
+ if (keys.length === 1 && /^\d+$/.test(keys[0])) {
404
+ chartConfig = [
405
+ chartConfig[keys[0]]
406
+ ];
407
+ } else if (chartConfig.chartType) {
408
+ // 如果 chartConfig 有 chartType,说明是单个配置对象
409
+ chartConfig = [
410
+ chartConfig
411
+ ];
412
+ } else {
413
+ // 其他情况,也包装为数组
414
+ chartConfig = [
415
+ chartConfig
416
+ ];
417
+ }
418
+ } else if (chartConfig) {
419
+ chartConfig = [
420
+ chartConfig
421
+ ];
422
+ } else {
423
+ chartConfig = [];
424
+ }
425
+ }
426
+ // 序列化为 { config: [...] } 格式
427
+ if (chartConfig.length > 0) {
428
+ str += "<!--".concat(JSON.stringify({
429
+ config: chartConfig
430
+ }), "-->\n");
431
+ }
432
+ } else {
433
+ // 非图表类型,使用原有逻辑
434
+ var nodeConfig = configProps;
435
+ // 如果 nodeConfig 是对象且键都是数字(如 {0: {...}}),转换为数组
436
+ nodeConfig = convertObjectToArray(nodeConfig);
437
+ var propsToSerialize = void 0;
438
+ // 如果 nodeConfig 是数组,直接使用数组
439
+ if (Array.isArray(nodeConfig)) {
440
+ propsToSerialize = nodeConfig;
441
+ } else {
442
+ // 如果是对象,过滤掉 undefined 值,但保留 false 值
443
+ propsToSerialize = Object.keys(nodeConfig).reduce(function(acc, key) {
444
+ if (nodeConfig[key] !== undefined) {
445
+ acc[key] = nodeConfig[key];
446
+ }
447
+ return acc;
448
+ }, {});
449
+ }
450
+ // 对于数组,直接序列化;对于对象,检查是否为空
451
+ if (Array.isArray(propsToSerialize)) {
452
+ if (propsToSerialize.length > 0) {
453
+ str += "<!--".concat(JSON.stringify({
454
+ config: propsToSerialize
455
+ }), "-->\n");
456
+ }
457
+ } else if (propsToSerialize && (typeof propsToSerialize === "undefined" ? "undefined" : _type_of(propsToSerialize)) === 'object' && Object.keys(propsToSerialize).length > 0) {
458
+ str += "<!--".concat(JSON.stringify(propsToSerialize), "-->\n");
459
+ }
460
+ }
362
461
  }
363
462
  }
364
463
  var p = parent.at(-1) || {};
@@ -549,25 +648,51 @@ export var isMix = function(t) {
549
648
  if (!t.text && !t.tag) return '';
550
649
  var str = (t === null || t === void 0 ? void 0 : (_t_text = t.text) === null || _t_text === void 0 ? void 0 : _t_text.replace(RegExp("(?<!\\\\)\\\\", "g"), '\\').replace(/\n/g, ' \n')) || '';
551
650
  var preStr = '', afterStr = '';
552
- // Extract whitespace
553
- if (t.code || t.bold || t.strikethrough || t.italic) {
554
- var _str_match, _str_match1;
555
- preStr = ((_str_match = str.match(/^\s+/)) === null || _str_match === void 0 ? void 0 : _str_match[0]) || '';
556
- afterStr = ((_str_match1 = str.match(/\s+$/)) === null || _str_match1 === void 0 ? void 0 : _str_match1[0]) || '';
557
- str = str.trim();
558
- }
559
651
  // Apply formats in a consistent order:
560
652
  // 1. Code (most specific)
561
653
  // 2. Bold (strong emphasis)
562
654
  // 3. Italic (emphasis)
563
655
  // 4. Strikethrough (modification)
564
656
  if (t.code && !t.tag) {
657
+ // Extract whitespace for non-tag code
658
+ if (t.code || t.bold || t.strikethrough || t.italic) {
659
+ var _str_match, _str_match1;
660
+ preStr = ((_str_match = str.match(/^\s+/)) === null || _str_match === void 0 ? void 0 : _str_match[0]) || '';
661
+ afterStr = ((_str_match1 = str.match(/\s+$/)) === null || _str_match1 === void 0 ? void 0 : _str_match1[0]) || '';
662
+ str = str.trim();
663
+ }
565
664
  str = "`".concat(str, "`");
566
665
  } else if (t.tag) {
666
+ // 如果是 tag,优先检查是否有 value,如果有 value 则使用 value 和 placeholder
667
+ // 如果没有 value 但有 text(且不为空),则使用 text
668
+ // 如果没有 text 也没有 value,则使用 placeholder
669
+ // 对于 tag,如果 text 只是空白字符,不保留空白字符
670
+ var trimmedStr = str.trim();
567
671
  if (t.value) {
568
- str = "`".concat("${placeholder:".concat((t === null || t === void 0 ? void 0 : t.placeholder) || '-', ",value:").concat(t.value, "}") || '', "`");
672
+ // value,优先使用 value placeholder(即使有 text 也使用 value
673
+ str = "`${placeholder:".concat((t === null || t === void 0 ? void 0 : t.placeholder) || '-', ",value:").concat(t.value, "}`");
674
+ } else if (trimmedStr) {
675
+ // 没有 value 但有 text 且不为空,提取空白字符并使用 text
676
+ if (t.code || t.bold || t.strikethrough || t.italic) {
677
+ var _str_match2, _str_match3;
678
+ preStr = ((_str_match2 = str.match(/^\s+/)) === null || _str_match2 === void 0 ? void 0 : _str_match2[0]) || '';
679
+ afterStr = ((_str_match3 = str.match(/\s+$/)) === null || _str_match3 === void 0 ? void 0 : _str_match3[0]) || '';
680
+ }
681
+ str = "`".concat(trimmedStr, "`");
682
+ } else if (t.placeholder) {
683
+ // 没有 text 也没有 value,使用 placeholder(不保留空白字符)
684
+ str = "`${placeholder:".concat(t.placeholder, "}`");
569
685
  } else {
570
- str = "`".concat(str || "${placeholder:".concat((t === null || t === void 0 ? void 0 : t.placeholder) || '-', "}") || '', "`");
686
+ // 都没有,使用默认值(不保留空白字符)
687
+ str = "`${placeholder:-}`";
688
+ }
689
+ } else {
690
+ // Extract whitespace for other formats
691
+ if (t.bold || t.strikethrough || t.italic) {
692
+ var _str_match4, _str_match5;
693
+ preStr = ((_str_match4 = str.match(/^\s+/)) === null || _str_match4 === void 0 ? void 0 : _str_match4[0]) || '';
694
+ afterStr = ((_str_match5 = str.match(/\s+$/)) === null || _str_match5 === void 0 ? void 0 : _str_match5[0]) || '';
695
+ str = str.trim();
571
696
  }
572
697
  }
573
698
  // For mixed formats, we want to ensure proper nesting
@@ -1,3 +1,13 @@
1
+ /**
2
+ * 将段落节点转换为相应的节点类型(根据内容开头字符)
3
+ * - ! 开头 → image
4
+ * - | 开头 → table
5
+ * - [ 开头 → link
6
+ *
7
+ * @returns {(tree: any) => void}
8
+ * Transformer function.
9
+ */
10
+ export declare function convertParagraphToImage(): (tree: any) => void;
1
11
  /**
2
12
  * Plugin to fix bold text containing special characters like **$9.698M**, **57%**, etc.
3
13
  *
@@ -5,5 +15,5 @@
5
15
  * Transformer function.
6
16
  */
7
17
  export declare function fixStrongWithSpecialChars(): (tree: any) => void;
8
- declare const markdownParser: import("unified").Processor<import("mdast").Root, import("hast").Root, import("hast").Root, import("mdast").Root, string>;
18
+ declare const markdownParser: import("unified").Processor<import("mdast").Root, undefined, undefined, import("mdast").Root, string>;
9
19
  export default markdownParser;
@@ -23,16 +23,129 @@ function _unsupported_iterable_to_array(o, minLen) {
23
23
  if (n === "Map" || n === "Set") return Array.from(n);
24
24
  if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _array_like_to_array(o, minLen);
25
25
  }
26
- import rehypeKatex from "rehype-katex";
27
- import rehypeRaw from "rehype-raw";
28
26
  import remarkFrontmatter from "remark-frontmatter";
29
27
  import remarkGfm from "remark-gfm";
30
28
  import remarkHtml from "remark-html";
31
29
  import remarkMath from "remark-math";
32
30
  import remarkParse from "remark-parse";
33
- import remarkRehype from "remark-rehype";
34
31
  import { unified } from "unified";
35
32
  import { visit } from "unist-util-visit";
33
+ /**
34
+ * 提取段落节点的文本内容
35
+ * @param paragraphNode - 段落节点
36
+ * @returns 文本内容字符串
37
+ */ function extractParagraphText(paragraphNode) {
38
+ if (!paragraphNode.children || !Array.isArray(paragraphNode.children)) {
39
+ return '';
40
+ }
41
+ return paragraphNode.children.map(function(child) {
42
+ if (child.type === 'text') {
43
+ return child.value || '';
44
+ }
45
+ // 处理嵌套节点(如 strong, emphasis 等)
46
+ if (child.children && Array.isArray(child.children)) {
47
+ return child.children.map(function(grandChild) {
48
+ return grandChild.type === 'text' ? grandChild.value || '' : '';
49
+ }).join('');
50
+ }
51
+ return '';
52
+ }).join('').trim();
53
+ }
54
+ /**
55
+ * 将段落节点转换为相应的节点类型(根据内容开头字符)
56
+ * - ! 开头 → image
57
+ * - | 开头 → table
58
+ * - [ 开头 → link
59
+ *
60
+ * @returns {(tree: any) => void}
61
+ * Transformer function.
62
+ */ export function convertParagraphToImage() {
63
+ return function(tree) {
64
+ // 使用 visit 访问 paragraph 节点,并通过 index 和 parent 来替换
65
+ visit(tree, 'paragraph', function(paragraphNode, index, parent) {
66
+ var _parent_children;
67
+ var textContent = extractParagraphText(paragraphNode);
68
+ if (!textContent || !index || !parent) {
69
+ return;
70
+ }
71
+ var nextNode = parent === null || parent === void 0 ? void 0 : (_parent_children = parent.children) === null || _parent_children === void 0 ? void 0 : _parent_children[index + 1];
72
+ // 检查是否以 ! 开头(图片)
73
+ if (textContent.startsWith('!') && !nextNode) {
74
+ // 提取 URL(去掉开头的 !)
75
+ var imageUrl = textContent.slice(1).trim();
76
+ // 如果 URL 不为空,则创建 image 节点并替换
77
+ if (imageUrl) {
78
+ var imageNode = {
79
+ type: 'image',
80
+ url: imageUrl,
81
+ finished: false,
82
+ alt: ''
83
+ };
84
+ // 替换父节点中的 paragraph 节点为 image 节点
85
+ if (parent && Array.isArray(parent.children) && typeof index === 'number') {
86
+ parent.children[index] = imageNode;
87
+ }
88
+ }
89
+ return;
90
+ }
91
+ // 检查是否以 | 开头(表格)
92
+ // 注意:如果 remark-gfm 已经正确解析了表格,表格节点应该是 'table' 类型,不会进入这里
93
+ // 这里只处理未被解析的表格行(通常是不完整的表格输入)
94
+ if (textContent.startsWith('|') && !nextNode) {
95
+ // 只有不完整的表格输入(比如只有 | 开头,没有结束)才转换为表格节点
96
+ // 创建不完整的表格节点(用于不完整的表格输入)
97
+ var tableNode = {
98
+ type: 'table',
99
+ finished: false,
100
+ align: [],
101
+ children: [
102
+ {
103
+ type: 'tableRow',
104
+ children: [
105
+ {
106
+ type: 'tableCell',
107
+ children: [
108
+ {
109
+ type: 'paragraph',
110
+ children: [
111
+ {
112
+ type: 'text',
113
+ value: textContent
114
+ }
115
+ ]
116
+ }
117
+ ]
118
+ }
119
+ ]
120
+ }
121
+ ]
122
+ };
123
+ // 替换父节点中的 paragraph 节点为 table 节点
124
+ if (parent && Array.isArray(parent.children) && typeof index === 'number') {
125
+ parent.children[index] = tableNode;
126
+ }
127
+ return;
128
+ }
129
+ if (textContent.startsWith('[') && !nextNode) {
130
+ // 检查是否匹配 [内容](url) 格式
131
+ var linkPattern = /^\[([^\]]+)\]\(([^)]+)\)$/;
132
+ var match = textContent.match(linkPattern);
133
+ if (match) {
134
+ var linkNode = {
135
+ type: 'link',
136
+ url: match[2],
137
+ finished: false,
138
+ children: paragraphNode.children
139
+ };
140
+ if (parent && Array.isArray(parent.children) && typeof index === 'number') {
141
+ parent.children[index] = linkNode;
142
+ }
143
+ }
144
+ }
145
+ return;
146
+ });
147
+ };
148
+ }
36
149
  /**
37
150
  * Plugin to fix bold text containing special characters like **$9.698M**, **57%**, etc.
38
151
  *
@@ -47,13 +160,18 @@ import { visit } from "unist-util-visit";
47
160
  for(var i = 0; i < paragraphNode.children.length; i++){
48
161
  var child = paragraphNode.children[i];
49
162
  if (child.type === 'text' && child.value && typeof child.value === 'string') {
50
- // 匹配包含特殊字符的加粗文本(美元符号、百分号、引号、书名号、其他数字相关符号)
163
+ // 匹配完整的加粗文本(**text**)
51
164
  var strongPattern = /\*\*([^*\n]*[$%#@&+\-=\w\d.,。、;:!?""''()【】《》]+[^*\n]*?)\*\*/g;
165
+ // 匹配不完整的加粗文本(**text 但没有结束的 **)
166
+ var incompleteStrongPattern = /^\*\*([^*\n]+)$/;
167
+ var newNodes = [];
168
+ var lastIndex = 0;
169
+ var hasMatch = false;
170
+ // 先检查是否有完整的加粗文本
52
171
  if (strongPattern.test(child.value)) {
53
172
  // 重置正则表达式
54
173
  strongPattern.lastIndex = 0;
55
- var newNodes = [];
56
- var lastIndex = 0;
174
+ hasMatch = true;
57
175
  var match = void 0;
58
176
  // 分割文本并创建新的节点结构
59
177
  while((match = strongPattern.exec(child.value)) !== null){
@@ -83,22 +201,52 @@ import { visit } from "unist-util-visit";
83
201
  if (lastIndex < child.value.length) {
84
202
  var afterText = child.value.slice(lastIndex);
85
203
  if (afterText) {
86
- newNodes.push({
87
- type: 'text',
88
- value: afterText
89
- });
204
+ // 检查剩余文本是否是不完整的加粗
205
+ var incompleteMatch = incompleteStrongPattern.exec(afterText);
206
+ if (incompleteMatch) {
207
+ newNodes.push({
208
+ type: 'strong',
209
+ finished: false,
210
+ children: [
211
+ {
212
+ type: 'text',
213
+ value: incompleteMatch[1]
214
+ }
215
+ ]
216
+ });
217
+ } else {
218
+ newNodes.push({
219
+ type: 'text',
220
+ value: afterText
221
+ });
222
+ }
90
223
  }
91
224
  }
92
- // 替换当前文本节点
93
- if (newNodes.length > 0) {
94
- var _paragraphNode_children;
95
- (_paragraphNode_children = paragraphNode.children).splice.apply(_paragraphNode_children, [
96
- i,
97
- 1
98
- ].concat(_to_consumable_array(newNodes)));
99
- i += newNodes.length - 1; // 调整索引以跳过新插入的节点
225
+ } else if (incompleteStrongPattern.test(child.value)) {
226
+ var incompleteMatch1 = incompleteStrongPattern.exec(child.value);
227
+ if (incompleteMatch1) {
228
+ hasMatch = true;
229
+ newNodes.push({
230
+ type: 'strong',
231
+ finished: false,
232
+ children: [
233
+ {
234
+ type: 'text',
235
+ value: incompleteMatch1[1]
236
+ }
237
+ ]
238
+ });
100
239
  }
101
240
  }
241
+ // 替换当前文本节点
242
+ if (hasMatch && newNodes.length > 0) {
243
+ var _paragraphNode_children;
244
+ (_paragraphNode_children = paragraphNode.children).splice.apply(_paragraphNode_children, [
245
+ i,
246
+ 1
247
+ ].concat(_to_consumable_array(newNodes)));
248
+ i += newNodes.length - 1; // 调整索引以跳过新插入的节点
249
+ }
102
250
  }
103
251
  }
104
252
  }
@@ -106,13 +254,18 @@ import { visit } from "unist-util-visit";
106
254
  // 处理所有文本节点(作为备用方案)
107
255
  visit(tree, 'text', function(node, index, parent) {
108
256
  if (node.value && typeof node.value === 'string') {
109
- // 匹配包含特殊字符的加粗文本(美元符号、百分号、引号、书名号、其他数字相关符号)
257
+ // 匹配完整的加粗文本(**text**)
110
258
  var strongPattern = /\*\*([^*\n]*[$%#@&+\-=\w\d.,。、;:!?""''()【】《》]+[^*\n]*?)\*\*/g;
259
+ // 匹配不完整的加粗文本(**text 但没有结束的 **)
260
+ var incompleteStrongPattern = /^\*\*([^*\n]+)$/;
261
+ var newNodes = [];
262
+ var lastIndex = 0;
263
+ var hasMatch = false;
264
+ // 先检查是否有完整的加粗文本
111
265
  if (strongPattern.test(node.value)) {
112
266
  // 重置正则表达式
113
267
  strongPattern.lastIndex = 0;
114
- var newNodes = [];
115
- var lastIndex = 0;
268
+ hasMatch = true;
116
269
  var match;
117
270
  // 分割文本并创建新的节点结构
118
271
  while((match = strongPattern.exec(node.value)) !== null){
@@ -142,33 +295,66 @@ import { visit } from "unist-util-visit";
142
295
  if (lastIndex < node.value.length) {
143
296
  var afterText = node.value.slice(lastIndex);
144
297
  if (afterText) {
145
- newNodes.push({
146
- type: 'text',
147
- value: afterText
148
- });
298
+ // 检查剩余文本是否是不完整的加粗
299
+ var incompleteMatch = incompleteStrongPattern.exec(afterText);
300
+ if (incompleteMatch) {
301
+ newNodes.push({
302
+ type: 'strong',
303
+ finished: false,
304
+ children: [
305
+ {
306
+ type: 'text',
307
+ value: incompleteMatch[1]
308
+ }
309
+ ]
310
+ });
311
+ } else {
312
+ newNodes.push({
313
+ type: 'text',
314
+ value: afterText
315
+ });
316
+ }
149
317
  }
150
318
  }
151
- // 替换原节点
152
- if (parent && Array.isArray(parent.children) && typeof index === 'number') {
153
- var _parent_children;
154
- (_parent_children = parent.children).splice.apply(_parent_children, [
155
- index,
156
- 1
157
- ].concat(_to_consumable_array(newNodes)));
319
+ } else if (incompleteStrongPattern.test(node.value)) {
320
+ var incompleteMatch1 = incompleteStrongPattern.exec(node.value);
321
+ if (incompleteMatch1) {
322
+ hasMatch = true;
323
+ newNodes.push({
324
+ type: 'strong',
325
+ finished: false,
326
+ children: [
327
+ {
328
+ type: 'text',
329
+ value: incompleteMatch1[1]
330
+ }
331
+ ]
332
+ });
158
333
  }
159
334
  }
335
+ // 替换原节点
336
+ if (hasMatch && newNodes.length > 0 && parent && Array.isArray(parent.children) && typeof index === 'number') {
337
+ var _parent_children;
338
+ (_parent_children = parent.children).splice.apply(_parent_children, [
339
+ index,
340
+ 1
341
+ ].concat(_to_consumable_array(newNodes)));
342
+ }
160
343
  }
161
344
  });
162
345
  };
163
346
  }
164
- // 完整的 HTML 渲染解析器
165
- var markdownParser = unified().use(remarkParse).use(remarkHtml).use(remarkGfm) // GFM 插件
347
+ // Markdown 解析器(用于解析 Markdown 为 mdast AST)
348
+ // 注意:这个解析器只用于解析,不包含 HTML 渲染相关的插件
349
+ var markdownParser = unified().use(remarkParse) // 解析 Markdown
350
+ .use(remarkHtml).use(remarkFrontmatter, [
351
+ 'yaml'
352
+ ]) // 处理前置元数据
353
+ .use(remarkGfm) // GFM 插件
166
354
  .use(fixStrongWithSpecialChars) // 修复包含特殊字符的加粗文本
355
+ .use(convertParagraphToImage) // 将以 ! 开头的段落转换为图片,将 | 开头的段落转换为表格
167
356
  .use(remarkMath, {
168
357
  singleDollarTextMath: true
169
- }).use(remarkRehype, {
170
- allowDangerousHtml: true
171
- }).use(rehypeRaw).use(rehypeKatex).use(remarkFrontmatter, [
172
- 'yaml'
173
- ]);
358
+ });
359
+ // 默认导出解析器(用于解析 Markdown 为 mdast AST)
174
360
  export default markdownParser;
@@ -24,7 +24,7 @@ function _unsupported_iterable_to_array(o, minLen) {
24
24
  if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _array_like_to_array(o, minLen);
25
25
  }
26
26
  import { Editor, Node, Path, Point, Range, Transforms } from "slate";
27
- import { decodeURIComponentUrl } from "../parser/parserMarkdownToSlateNode";
27
+ import { decodeURIComponentUrl } from "../parser/parse/parseHtml";
28
28
  import { EditorUtils } from "../utils/editorUtils";
29
29
  export var insertAfter = function(editor, path) {
30
30
  var node = arguments.length > 2 && arguments[2] !== void 0 ? arguments[2] : {
@@ -3,6 +3,7 @@ export type TableCustomElement = TableNode | TableHeadNode | TableFooterNode | T
3
3
  export interface TableNode {
4
4
  type: 'table';
5
5
  children: Array<TableHeadNode | TrNode | TableFooterNode>;
6
+ finished?: boolean;
6
7
  otherProps?: {
7
8
  mergeCells?: Array<{
8
9
  row: number;
@@ -10,7 +11,7 @@ export interface TableNode {
10
11
  rowSpan: number;
11
12
  colSpan: number;
12
13
  }>;
13
- finish?: boolean;
14
+ finished?: boolean;
14
15
  config?: any;
15
16
  columns?: Array<any>;
16
17
  };
@@ -166,7 +166,7 @@ import remarkParse from "remark-parse";
166
166
  import remarkRehype from "remark-rehype";
167
167
  import { unified } from "unified";
168
168
  import { visit } from "unist-util-visit";
169
- import { fixStrongWithSpecialChars } from "../parser/remarkParse";
169
+ import { convertParagraphToImage, fixStrongWithSpecialChars } from "../parser/remarkParse";
170
170
  // HTML 转义相关的正则表达式和工具
171
171
  var ESCAPE_TEST_NO_ENCODE = /[<>"']|&(?!(#\d{1,7}|#[Xx][a-fA-F0-9]{1,6}|\w+);)/;
172
172
  var ESCAPE_TEST = /[&<>"']/;
@@ -295,6 +295,7 @@ export var DEFAULT_MARKDOWN_REMARK_PLUGINS = [
295
295
  remarkParse,
296
296
  remarkGfm,
297
297
  fixStrongWithSpecialChars,
298
+ convertParagraphToImage,
298
299
  [
299
300
  remarkMath,
300
301
  INLINE_MATH_WITH_SINGLE_DOLLAR
@@ -74,6 +74,7 @@ export type ListNode<T = Record<string, any>> = {
74
74
  order?: boolean;
75
75
  start?: number;
76
76
  task?: boolean;
77
+ finished?: boolean;
77
78
  h?: number;
78
79
  };
79
80
  export type ChartTypeConfig<T = Record<string, any>> = {
@@ -139,6 +140,7 @@ export type MediaNode<T = Record<string, any>> = {
139
140
  url?: string;
140
141
  alt: string;
141
142
  downloadUrl?: string;
143
+ finished?: boolean;
142
144
  height?: number;
143
145
  width?: number;
144
146
  docId?: string;
@@ -164,6 +166,7 @@ export type LinkCardNode<T = Record<string, any>> = {
164
166
  title?: string;
165
167
  name?: string;
166
168
  alt: string;
169
+ finished?: boolean;
167
170
  children: BaseElement['children'];
168
171
  };
169
172
  export type AttachNode<T = Record<string, any>> = {
@@ -83,6 +83,8 @@ var genStyle = function(token) {
83
83
  '&-edit-area': {
84
84
  outline: 'none !important'
85
85
  },
86
+ '&-container': {
87
+ },
86
88
  '&-content': _define_property({
87
89
  // 默认 padding,可以通过 contentStyle 覆盖
88
90
  // 使用 CSS 变量,允许通过内联样式覆盖
@@ -316,7 +316,7 @@ export { ChartFilter, ChartToolBar, downloadChart } from "./components";
316
316
  ]);
317
317
  var columns = ((_node_otherProps2 = node.otherProps) === null || _node_otherProps2 === void 0 ? void 0 : _node_otherProps2.columns) || [];
318
318
  // 检查图表是否未闭合
319
- var isUnclosed = (node === null || node === void 0 ? void 0 : (_node_otherProps3 = node.otherProps) === null || _node_otherProps3 === void 0 ? void 0 : _node_otherProps3.finish) === false;
319
+ var isUnclosed = (node === null || node === void 0 ? void 0 : (_node_otherProps3 = node.otherProps) === null || _node_otherProps3 === void 0 ? void 0 : _node_otherProps3.finished) === false;
320
320
  // 获取编辑器更新函数
321
321
  var _useMEditor = _sliced_to_array(useMEditor(node), 2), update = _useMEditor[1];
322
322
  // 判断是否是最后一个节点
@@ -334,11 +334,11 @@ export { ChartFilter, ChartToolBar, downloadChart } from "./components";
334
334
  useEffect(function() {
335
335
  if (isUnclosed && !readonly && !isLastNode) {
336
336
  var _node_otherProps;
337
- // 检查 finish 是否仍然是 false(可能已经被其他逻辑更新)
338
- if ((node === null || node === void 0 ? void 0 : (_node_otherProps = node.otherProps) === null || _node_otherProps === void 0 ? void 0 : _node_otherProps.finish) === false) {
337
+ // 检查 finished 是否仍然是 false(可能已经被其他逻辑更新)
338
+ if ((node === null || node === void 0 ? void 0 : (_node_otherProps = node.otherProps) === null || _node_otherProps === void 0 ? void 0 : _node_otherProps.finished) === false) {
339
339
  update({
340
340
  otherProps: _object_spread_props(_object_spread({}, node === null || node === void 0 ? void 0 : node.otherProps), {
341
- finish: true
341
+ finished: true
342
342
  })
343
343
  }, node);
344
344
  }
@@ -355,11 +355,11 @@ export { ChartFilter, ChartToolBar, downloadChart } from "./components";
355
355
  if (isUnclosed && !readonly && isLastNode) {
356
356
  var timer = setTimeout(function() {
357
357
  var _node_otherProps;
358
- // 检查 finish 是否仍然是 false(可能已经被其他逻辑更新)
359
- if ((node === null || node === void 0 ? void 0 : (_node_otherProps = node.otherProps) === null || _node_otherProps === void 0 ? void 0 : _node_otherProps.finish) === false) {
358
+ // 检查 finished 是否仍然是 false(可能已经被其他逻辑更新)
359
+ if ((node === null || node === void 0 ? void 0 : (_node_otherProps = node.otherProps) === null || _node_otherProps === void 0 ? void 0 : _node_otherProps.finished) === false) {
360
360
  update({
361
361
  otherProps: _object_spread_props(_object_spread({}, node === null || node === void 0 ? void 0 : node.otherProps), {
362
- finish: true
362
+ finished: true
363
363
  })
364
364
  }, node);
365
365
  }