@ant-design/agentic-ui 2.20.1 → 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/Schema/SchemaEditor/index.js +30 -61
- 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
|
@@ -140,9 +140,7 @@ import classNames from "classnames";
|
|
|
140
140
|
import React, { useContext, useEffect, useMemo, useRef } from "react";
|
|
141
141
|
import { Node } from "slate";
|
|
142
142
|
import stringWidth from "string-width";
|
|
143
|
-
import { Loading } from "../../../../Components/Loading";
|
|
144
143
|
import { MOBILE_BREAKPOINT, MOBILE_TABLE_MIN_COLUMN_WIDTH } from "../../../../Constants/mobile";
|
|
145
|
-
import { useMEditor } from "../../../hooks/editor";
|
|
146
144
|
import { useEditorStore } from "../../store";
|
|
147
145
|
import { ReadonlyTableComponent } from "./ReadonlyTableComponent";
|
|
148
146
|
import { TablePropsContext } from "./TableContext";
|
|
@@ -178,8 +176,8 @@ import useScrollShadow from "./useScrollShadow";
|
|
|
178
176
|
"hashId",
|
|
179
177
|
"children"
|
|
180
178
|
]);
|
|
181
|
-
var _props_element_children__children, _props_element_children_, _props_element_children, _props_element, _props_element_otherProps, _props_element1, _props_element_children1, _props_element2
|
|
182
|
-
var _useEditorStore = useEditorStore(), readonly = _useEditorStore.readonly, markdownContainerRef = _useEditorStore.markdownContainerRef
|
|
179
|
+
var _props_element_children__children, _props_element_children_, _props_element_children, _props_element, _props_element_otherProps, _props_element1, _props_element_children1, _props_element2;
|
|
180
|
+
var _useEditorStore = useEditorStore(), readonly = _useEditorStore.readonly, markdownContainerRef = _useEditorStore.markdownContainerRef;
|
|
183
181
|
var getPrefixCls = useContext(ConfigProvider.ConfigContext).getPrefixCls;
|
|
184
182
|
var tablePath = useContext(TablePropsContext).tablePath;
|
|
185
183
|
var baseCls = getPrefixCls('agentic-md-editor-content-table');
|
|
@@ -342,68 +340,6 @@ import useScrollShadow from "./useScrollShadow";
|
|
|
342
340
|
scrollState,
|
|
343
341
|
readonly
|
|
344
342
|
]);
|
|
345
|
-
// 检查表格是否未闭合
|
|
346
|
-
var isUnclosed = ((_props_element3 = props.element) === null || _props_element3 === void 0 ? void 0 : (_props_element_otherProps1 = _props_element3.otherProps) === null || _props_element_otherProps1 === void 0 ? void 0 : _props_element_otherProps1.finish) === false;
|
|
347
|
-
// 获取编辑器更新函数 - 必须在早期返回之前调用 hooks
|
|
348
|
-
var _useMEditor = _sliced_to_array(useMEditor(props.element), 2), update = _useMEditor[1];
|
|
349
|
-
// 判断是否是最后一个节点 - 必须在早期返回之前调用 hooks
|
|
350
|
-
var isLastNode = useMemo(function() {
|
|
351
|
-
try {
|
|
352
|
-
return store.isLatestNode(props.element);
|
|
353
|
-
} catch (e) {
|
|
354
|
-
return false;
|
|
355
|
-
}
|
|
356
|
-
}, [
|
|
357
|
-
store,
|
|
358
|
-
props.element
|
|
359
|
-
]);
|
|
360
|
-
// 如果不是最后一个节点,且未闭合,立即设置为完成 - 必须在早期返回之前调用 hooks
|
|
361
|
-
useEffect(function() {
|
|
362
|
-
if (isUnclosed && !readonly && !isLastNode) {
|
|
363
|
-
var _props_element_otherProps, _props_element;
|
|
364
|
-
// 检查 finish 是否仍然是 false(可能已经被其他逻辑更新)
|
|
365
|
-
if (((_props_element = props.element) === null || _props_element === void 0 ? void 0 : (_props_element_otherProps = _props_element.otherProps) === null || _props_element_otherProps === void 0 ? void 0 : _props_element_otherProps.finish) === false) {
|
|
366
|
-
var _props_element1;
|
|
367
|
-
update({
|
|
368
|
-
otherProps: _object_spread_props(_object_spread({}, (_props_element1 = props.element) === null || _props_element1 === void 0 ? void 0 : _props_element1.otherProps), {
|
|
369
|
-
finish: true
|
|
370
|
-
})
|
|
371
|
-
}, props.element);
|
|
372
|
-
}
|
|
373
|
-
}
|
|
374
|
-
}, [
|
|
375
|
-
isUnclosed,
|
|
376
|
-
readonly,
|
|
377
|
-
isLastNode,
|
|
378
|
-
props.element,
|
|
379
|
-
update
|
|
380
|
-
]);
|
|
381
|
-
// 5 秒超时机制:如果是最后一个节点且未闭合,5 秒后自动设置为完成 - 必须在早期返回之前调用 hooks
|
|
382
|
-
useEffect(function() {
|
|
383
|
-
if (isUnclosed && !readonly && isLastNode) {
|
|
384
|
-
var timer = setTimeout(function() {
|
|
385
|
-
var _props_element_otherProps, _props_element;
|
|
386
|
-
// 检查 finish 是否仍然是 false(可能已经被其他逻辑更新)
|
|
387
|
-
if (((_props_element = props.element) === null || _props_element === void 0 ? void 0 : (_props_element_otherProps = _props_element.otherProps) === null || _props_element_otherProps === void 0 ? void 0 : _props_element_otherProps.finish) === false) {
|
|
388
|
-
var _props_element1;
|
|
389
|
-
update({
|
|
390
|
-
otherProps: _object_spread_props(_object_spread({}, (_props_element1 = props.element) === null || _props_element1 === void 0 ? void 0 : _props_element1.otherProps), {
|
|
391
|
-
finish: true
|
|
392
|
-
})
|
|
393
|
-
}, props.element);
|
|
394
|
-
}
|
|
395
|
-
}, 5000); // 5 秒超时
|
|
396
|
-
return function() {
|
|
397
|
-
clearTimeout(timer);
|
|
398
|
-
};
|
|
399
|
-
}
|
|
400
|
-
}, [
|
|
401
|
-
isUnclosed,
|
|
402
|
-
readonly,
|
|
403
|
-
isLastNode,
|
|
404
|
-
props.element,
|
|
405
|
-
update
|
|
406
|
-
]);
|
|
407
343
|
// readonly 模式渲染 - 使用优化的组件(早期返回)
|
|
408
344
|
if (readonly) {
|
|
409
345
|
return /*#__PURE__*/ React.createElement(ReadonlyTableComponent, {
|
|
@@ -419,7 +355,6 @@ import useScrollShadow from "./useScrollShadow";
|
|
|
419
355
|
style: _object_spread_props(_object_spread({}, boxShadowStyle), {
|
|
420
356
|
position: 'relative'
|
|
421
357
|
}),
|
|
422
|
-
"data-is-unclosed": isUnclosed,
|
|
423
358
|
onDragStart: function(e) {
|
|
424
359
|
// 阻止拖拽开始时的文字选择
|
|
425
360
|
e.preventDefault();
|
|
@@ -428,12 +363,5 @@ import useScrollShadow from "./useScrollShadow";
|
|
|
428
363
|
// 阻止双击选择文字
|
|
429
364
|
e.preventDefault();
|
|
430
365
|
}
|
|
431
|
-
},
|
|
432
|
-
style: {
|
|
433
|
-
position: 'absolute',
|
|
434
|
-
top: '8px',
|
|
435
|
-
right: '8px',
|
|
436
|
-
zIndex: 10
|
|
437
|
-
}
|
|
438
|
-
}, /*#__PURE__*/ React.createElement(Loading, null)), tableDom);
|
|
366
|
+
}, tableDom);
|
|
439
367
|
};
|
|
@@ -304,7 +304,7 @@ export var MElement = /*#__PURE__*/ React.memo(MElementComponent, areElementProp
|
|
|
304
304
|
};
|
|
305
305
|
var MLeafComponent = function(props) {
|
|
306
306
|
var _leaf_text, _leaf_text1, _leaf_text_replaceAll_replaceAll, _leaf_text_replaceAll, _leaf_text2, _props_fncProps, _props_leaf;
|
|
307
|
-
var _useEditorStore = useEditorStore(), markdownEditorRef = _useEditorStore.markdownEditorRef, markdownContainerRef = _useEditorStore.markdownContainerRef,
|
|
307
|
+
var _useEditorStore = useEditorStore(), markdownEditorRef = _useEditorStore.markdownEditorRef, markdownContainerRef = _useEditorStore.markdownContainerRef, setShowComment = _useEditorStore.setShowComment;
|
|
308
308
|
var context = useContext(ConfigProvider.ConfigContext);
|
|
309
309
|
var locale = useContext(I18nContext).locale;
|
|
310
310
|
var mdEditorBaseClass = context === null || context === void 0 ? void 0 : context.getPrefixCls('agentic-md-editor-content');
|
|
@@ -407,37 +407,6 @@ var MLeafComponent = function(props) {
|
|
|
407
407
|
}
|
|
408
408
|
} catch (e) {}
|
|
409
409
|
};
|
|
410
|
-
if ((leaf === null || leaf === void 0 ? void 0 : leaf.url) && readonly) {
|
|
411
|
-
var _props_leaf1, _props_leaf2;
|
|
412
|
-
var renderDom = /*#__PURE__*/ React.createElement("span", _object_spread({
|
|
413
|
-
"data-be": "link",
|
|
414
|
-
draggable: false,
|
|
415
|
-
onDragStart: dragStart,
|
|
416
|
-
"data-url": (leaf === null || leaf === void 0 ? void 0 : leaf.url) ? 'url' : undefined,
|
|
417
|
-
onClick: function(e) {
|
|
418
|
-
e.stopPropagation();
|
|
419
|
-
e.preventDefault();
|
|
420
|
-
if (e.metaKey || e.ctrlKey || readonly) {
|
|
421
|
-
if (!(leaf === null || leaf === void 0 ? void 0 : leaf.url)) return;
|
|
422
|
-
if (typeof window === 'undefined') return;
|
|
423
|
-
window.open(leaf === null || leaf === void 0 ? void 0 : leaf.url);
|
|
424
|
-
} else if (e.detail === 2) {
|
|
425
|
-
selectFormat();
|
|
426
|
-
}
|
|
427
|
-
},
|
|
428
|
-
id: leaf === null || leaf === void 0 ? void 0 : leaf.url,
|
|
429
|
-
"data-slate-inline": true
|
|
430
|
-
}, props.attributes), children);
|
|
431
|
-
if (!props.leaf.comment) return renderDom;
|
|
432
|
-
return /*#__PURE__*/ React.createElement(CommentView, {
|
|
433
|
-
id: "comment-".concat((_props_leaf1 = props.leaf) === null || _props_leaf1 === void 0 ? void 0 : _props_leaf1.id),
|
|
434
|
-
comment: props.comment,
|
|
435
|
-
hashId: props.hashId,
|
|
436
|
-
selection: leaf === null || leaf === void 0 ? void 0 : leaf.selection,
|
|
437
|
-
commentItem: ((_props_leaf2 = props.leaf) === null || _props_leaf2 === void 0 ? void 0 : _props_leaf2.comment) ? props.leaf.data : null,
|
|
438
|
-
setShowComment: setShowComment
|
|
439
|
-
}, renderDom);
|
|
440
|
-
}
|
|
441
410
|
var _obj;
|
|
442
411
|
var fncClassName = classNames(prefixClassName === null || prefixClassName === void 0 ? void 0 : prefixClassName.trim(), props.hashId, (_obj = {}, _define_property(_obj, "".concat(mdEditorBaseClass, "-fnc"), leaf.fnc), _define_property(_obj, "".concat(mdEditorBaseClass, "-fnd"), leaf.fnd), _define_property(_obj, "".concat(mdEditorBaseClass, "-comment"), leaf.comment), _obj));
|
|
443
412
|
var dom = /*#__PURE__*/ React.createElement("span", _object_spread_props(_object_spread({}, props.attributes), {
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
export type CodeElement = {
|
|
2
|
+
type: string;
|
|
3
|
+
language?: string | null;
|
|
4
|
+
render?: boolean;
|
|
5
|
+
value: any;
|
|
6
|
+
isConfig?: boolean;
|
|
7
|
+
children: Array<{
|
|
8
|
+
text: string;
|
|
9
|
+
}>;
|
|
10
|
+
otherProps?: Record<string, any>;
|
|
11
|
+
};
|
|
12
|
+
export type LanguageHandler = (element: CodeElement, value: string) => CodeElement;
|
|
13
|
+
/**
|
|
14
|
+
* 处理代码块节点
|
|
15
|
+
* @param currentElement - 当前处理的代码块元素,包含语言和内容
|
|
16
|
+
* @returns 返回格式化的代码块节点对象,根据语言类型进行特殊处理
|
|
17
|
+
*/
|
|
18
|
+
export declare const handleCode: (currentElement: any) => CodeElement;
|
|
19
|
+
/**
|
|
20
|
+
* 处理YAML节点
|
|
21
|
+
* @param currentElement - 当前处理的YAML元素
|
|
22
|
+
* @returns 返回格式化的YAML代码块节点对象
|
|
23
|
+
*/
|
|
24
|
+
export declare const handleYaml: (currentElement: any) => {
|
|
25
|
+
type: string;
|
|
26
|
+
language: string;
|
|
27
|
+
value: any;
|
|
28
|
+
frontmatter: boolean;
|
|
29
|
+
children: {
|
|
30
|
+
text: any;
|
|
31
|
+
}[];
|
|
32
|
+
};
|
|
@@ -0,0 +1,186 @@
|
|
|
1
|
+
function _define_property(obj, key, value) {
|
|
2
|
+
if (key in obj) {
|
|
3
|
+
Object.defineProperty(obj, key, {
|
|
4
|
+
value: value,
|
|
5
|
+
enumerable: true,
|
|
6
|
+
configurable: true,
|
|
7
|
+
writable: true
|
|
8
|
+
});
|
|
9
|
+
} else {
|
|
10
|
+
obj[key] = value;
|
|
11
|
+
}
|
|
12
|
+
return obj;
|
|
13
|
+
}
|
|
14
|
+
function _object_spread(target) {
|
|
15
|
+
for(var i = 1; i < arguments.length; i++){
|
|
16
|
+
var source = arguments[i] != null ? arguments[i] : {};
|
|
17
|
+
var ownKeys = Object.keys(source);
|
|
18
|
+
if (typeof Object.getOwnPropertySymbols === "function") {
|
|
19
|
+
ownKeys = ownKeys.concat(Object.getOwnPropertySymbols(source).filter(function(sym) {
|
|
20
|
+
return Object.getOwnPropertyDescriptor(source, sym).enumerable;
|
|
21
|
+
}));
|
|
22
|
+
}
|
|
23
|
+
ownKeys.forEach(function(key) {
|
|
24
|
+
_define_property(target, key, source[key]);
|
|
25
|
+
});
|
|
26
|
+
}
|
|
27
|
+
return target;
|
|
28
|
+
}
|
|
29
|
+
function ownKeys(object, enumerableOnly) {
|
|
30
|
+
var keys = Object.keys(object);
|
|
31
|
+
if (Object.getOwnPropertySymbols) {
|
|
32
|
+
var symbols = Object.getOwnPropertySymbols(object);
|
|
33
|
+
if (enumerableOnly) {
|
|
34
|
+
symbols = symbols.filter(function(sym) {
|
|
35
|
+
return Object.getOwnPropertyDescriptor(object, sym).enumerable;
|
|
36
|
+
});
|
|
37
|
+
}
|
|
38
|
+
keys.push.apply(keys, symbols);
|
|
39
|
+
}
|
|
40
|
+
return keys;
|
|
41
|
+
}
|
|
42
|
+
function _object_spread_props(target, source) {
|
|
43
|
+
source = source != null ? source : {};
|
|
44
|
+
if (Object.getOwnPropertyDescriptors) {
|
|
45
|
+
Object.defineProperties(target, Object.getOwnPropertyDescriptors(source));
|
|
46
|
+
} else {
|
|
47
|
+
ownKeys(Object(source)).forEach(function(key) {
|
|
48
|
+
Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key));
|
|
49
|
+
});
|
|
50
|
+
}
|
|
51
|
+
return target;
|
|
52
|
+
}
|
|
53
|
+
import json5 from "json5";
|
|
54
|
+
import { isCodeBlockLikelyComplete } from "../../utils/findMatchingClose";
|
|
55
|
+
import partialJsonParse from "../json-parse";
|
|
56
|
+
// 代码块检测相关的常量
|
|
57
|
+
var NOT_SPACE_START = /^\S*/;
|
|
58
|
+
var ENDING_NEWLINE = /\n$/;
|
|
59
|
+
/**
|
|
60
|
+
* 处理schema类型语言的辅助函数
|
|
61
|
+
*/ var processSchemaLanguage = function(element, value) {
|
|
62
|
+
var json = [];
|
|
63
|
+
try {
|
|
64
|
+
json = json5.parse(value || '[]');
|
|
65
|
+
} catch (e) {
|
|
66
|
+
try {
|
|
67
|
+
json = partialJsonParse(value || '[]');
|
|
68
|
+
} catch (error) {
|
|
69
|
+
json = value;
|
|
70
|
+
console.error('parse schema error', error);
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
return _object_spread_props(_object_spread({}, element), {
|
|
74
|
+
type: 'apaasify',
|
|
75
|
+
value: json,
|
|
76
|
+
children: [
|
|
77
|
+
{
|
|
78
|
+
text: value
|
|
79
|
+
}
|
|
80
|
+
]
|
|
81
|
+
});
|
|
82
|
+
};
|
|
83
|
+
/**
|
|
84
|
+
* 语言类型处理策略配置
|
|
85
|
+
*/ var LANGUAGE_HANDLERS = {
|
|
86
|
+
mermaid: function(element) {
|
|
87
|
+
return _object_spread_props(_object_spread({}, element), {
|
|
88
|
+
type: 'mermaid'
|
|
89
|
+
});
|
|
90
|
+
},
|
|
91
|
+
schema: processSchemaLanguage,
|
|
92
|
+
apaasify: processSchemaLanguage,
|
|
93
|
+
apassify: processSchemaLanguage,
|
|
94
|
+
katex: function(element) {
|
|
95
|
+
return _object_spread_props(_object_spread({}, element), {
|
|
96
|
+
type: 'katex'
|
|
97
|
+
});
|
|
98
|
+
},
|
|
99
|
+
'agentar-card': processSchemaLanguage
|
|
100
|
+
};
|
|
101
|
+
/**
|
|
102
|
+
* 处理代码块节点
|
|
103
|
+
* @param currentElement - 当前处理的代码块元素,包含语言和内容
|
|
104
|
+
* @returns 返回格式化的代码块节点对象,根据语言类型进行特殊处理
|
|
105
|
+
*/ export var handleCode = function(currentElement) {
|
|
106
|
+
var _match, _currentElement_otherProps, _currentElement_value_trim;
|
|
107
|
+
var rawValue = currentElement.value || '';
|
|
108
|
+
var langString = ((_match = (currentElement.lang || '').match(NOT_SPACE_START)) === null || _match === void 0 ? void 0 : _match[0]) || '';
|
|
109
|
+
var code = "".concat(rawValue.replace(ENDING_NEWLINE, ''), "\n");
|
|
110
|
+
// 检查代码块是否完整
|
|
111
|
+
// 如果是缩进代码块,认为是完整的(因为没有结束标记)
|
|
112
|
+
var isIndentedCode = currentElement.meta === 'indented';
|
|
113
|
+
// 使用更智能的方法判断代码块是否完整
|
|
114
|
+
var streamStatus = 'loading';
|
|
115
|
+
if (isIndentedCode) {
|
|
116
|
+
// 缩进代码块没有结束标记,认为是完整的
|
|
117
|
+
streamStatus = 'done';
|
|
118
|
+
} else {
|
|
119
|
+
// 对于围栏代码块,使用多种方法判断
|
|
120
|
+
var endsWithNewline = code.match(ENDING_NEWLINE);
|
|
121
|
+
// 如果代码以换行结尾,可能是完整的
|
|
122
|
+
if (endsWithNewline) {
|
|
123
|
+
// 进一步检查代码内容是否完整(特别是对于 Mermaid 等需要完整语法的情况)
|
|
124
|
+
var isLikelyComplete = isCodeBlockLikelyComplete(rawValue, currentElement.lang);
|
|
125
|
+
streamStatus = isLikelyComplete ? 'done' : 'loading';
|
|
126
|
+
} else {
|
|
127
|
+
// 没有换行结尾,肯定不完整
|
|
128
|
+
streamStatus = 'loading';
|
|
129
|
+
}
|
|
130
|
+
}
|
|
131
|
+
// 如果已经在 parseNodes 中设置了 finished(基于是否是最后一个节点),优先使用它
|
|
132
|
+
// 否则使用 streamStatus 判断
|
|
133
|
+
var finishValue = ((_currentElement_otherProps = currentElement.otherProps) === null || _currentElement_otherProps === void 0 ? void 0 : _currentElement_otherProps.finished) !== undefined ? currentElement.otherProps.finished : streamStatus === 'done';
|
|
134
|
+
var otherProps = _object_spread(_object_spread_props(_object_spread({}, currentElement.otherProps || {}), {
|
|
135
|
+
'data-block': 'true',
|
|
136
|
+
'data-state': streamStatus,
|
|
137
|
+
// 优先使用 parseNodes 中设置的 finish,否则使用 streamStatus 判断
|
|
138
|
+
finished: finishValue
|
|
139
|
+
}), langString ? {
|
|
140
|
+
'data-language': langString
|
|
141
|
+
} : {});
|
|
142
|
+
if (finishValue !== false) {
|
|
143
|
+
delete otherProps.finished;
|
|
144
|
+
}
|
|
145
|
+
var baseCodeElement = {
|
|
146
|
+
type: 'code',
|
|
147
|
+
language: currentElement.lang === 'apaasify' ? 'apaasify' : currentElement.lang,
|
|
148
|
+
render: currentElement.meta === 'render',
|
|
149
|
+
value: currentElement.value,
|
|
150
|
+
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('<!--'),
|
|
151
|
+
children: [
|
|
152
|
+
{
|
|
153
|
+
text: currentElement.value
|
|
154
|
+
}
|
|
155
|
+
],
|
|
156
|
+
// 添加流式状态支持
|
|
157
|
+
otherProps: otherProps
|
|
158
|
+
};
|
|
159
|
+
var handler = LANGUAGE_HANDLERS[currentElement.lang];
|
|
160
|
+
var result = handler ? handler(baseCodeElement, currentElement.value) : baseCodeElement;
|
|
161
|
+
// 确保 otherProps 被保留
|
|
162
|
+
var resultWithProps = result;
|
|
163
|
+
if (baseCodeElement.otherProps && !resultWithProps.otherProps) {
|
|
164
|
+
resultWithProps.otherProps = baseCodeElement.otherProps;
|
|
165
|
+
} else if (baseCodeElement.otherProps && resultWithProps.otherProps) {
|
|
166
|
+
resultWithProps.otherProps = _object_spread({}, resultWithProps.otherProps, baseCodeElement.otherProps);
|
|
167
|
+
}
|
|
168
|
+
return resultWithProps;
|
|
169
|
+
};
|
|
170
|
+
/**
|
|
171
|
+
* 处理YAML节点
|
|
172
|
+
* @param currentElement - 当前处理的YAML元素
|
|
173
|
+
* @returns 返回格式化的YAML代码块节点对象
|
|
174
|
+
*/ export var handleYaml = function(currentElement) {
|
|
175
|
+
return {
|
|
176
|
+
type: 'code',
|
|
177
|
+
language: 'yaml',
|
|
178
|
+
value: currentElement.value,
|
|
179
|
+
frontmatter: true,
|
|
180
|
+
children: [
|
|
181
|
+
{
|
|
182
|
+
text: currentElement.value
|
|
183
|
+
}
|
|
184
|
+
]
|
|
185
|
+
};
|
|
186
|
+
};
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import type { RootContent, Table } from 'mdast';
|
|
2
|
+
import { CardNode, Elements } from '../../../el';
|
|
3
|
+
import { MarkdownEditorPlugin } from '../../../plugin';
|
|
4
|
+
import type { ParserMarkdownToSlateNodeConfig } from '../parserMarkdownToSlateNode';
|
|
5
|
+
export declare const MIN_TABLE_CELL_LENGTH = 5;
|
|
6
|
+
export declare const tableRegex: RegExp;
|
|
7
|
+
type AlignType = 'left' | 'center' | 'right' | null;
|
|
8
|
+
/**
|
|
9
|
+
* 规范化字段名,统一处理转义字符
|
|
10
|
+
* 将 `index\_value` 转换为 `index_value`,确保字段名一致
|
|
11
|
+
* @param fieldName - 原始字段名
|
|
12
|
+
* @returns 规范化后的字段名
|
|
13
|
+
*/
|
|
14
|
+
export declare const normalizeFieldName: (fieldName: string) => string;
|
|
15
|
+
/**
|
|
16
|
+
* 获取列对齐方式
|
|
17
|
+
*/
|
|
18
|
+
export declare const getColumnAlignment: (data: any[], columns: {
|
|
19
|
+
dataIndex: string;
|
|
20
|
+
}[]) => AlignType[];
|
|
21
|
+
/**
|
|
22
|
+
* 解析表格或图表
|
|
23
|
+
* @param table - 表格 AST 节点
|
|
24
|
+
* @param preNode - 前一个节点(可能包含配置信息)
|
|
25
|
+
* @param plugins - 插件数组
|
|
26
|
+
* @param parseNodes - 解析节点的函数,用于解析单元格内容
|
|
27
|
+
* @param parserConfig - 解析配置
|
|
28
|
+
* @returns 返回表格或图表节点
|
|
29
|
+
*/
|
|
30
|
+
export declare const parseTableOrChart: (table: Table & {
|
|
31
|
+
finished?: boolean;
|
|
32
|
+
}, preNode: RootContent, plugins: MarkdownEditorPlugin[], parseNodes: (nodes: RootContent[], plugins: MarkdownEditorPlugin[], top?: boolean, parent?: RootContent, parserConfig?: ParserMarkdownToSlateNodeConfig) => (Elements | any)[], parserConfig?: ParserMarkdownToSlateNodeConfig) => CardNode | Elements;
|
|
33
|
+
/**
|
|
34
|
+
* 预处理 Markdown 表格换行符
|
|
35
|
+
* @param markdown - 原始 Markdown 字符串
|
|
36
|
+
* @returns 处理后的 Markdown 字符串
|
|
37
|
+
*/
|
|
38
|
+
export declare const preprocessMarkdownTableNewlines: (markdown: string) => string;
|
|
39
|
+
export {};
|