@ant-design/agentic-ui 2.27.10 → 2.28.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/editor/elements/Blockquote/index.js +11 -1
- package/dist/MarkdownEditor/editor/elements/Break/index.js +2 -0
- package/dist/MarkdownEditor/editor/elements/Card/index.js +11 -0
- package/dist/MarkdownEditor/editor/elements/Code/index.js +22 -7
- package/dist/MarkdownEditor/editor/elements/FootnoteDefinition/index.js +15 -1
- package/dist/MarkdownEditor/editor/elements/FootnoteReference/index.js +11 -1
- package/dist/MarkdownEditor/editor/elements/Head/index.d.ts +1 -1
- package/dist/MarkdownEditor/editor/elements/Head/index.js +17 -1
- package/dist/MarkdownEditor/editor/elements/Hr/index.js +2 -0
- package/dist/MarkdownEditor/editor/elements/Image/index.js +75 -34
- package/dist/MarkdownEditor/editor/elements/InlineKatex/index.js +5 -0
- package/dist/MarkdownEditor/editor/elements/Katex/index.js +5 -0
- package/dist/MarkdownEditor/editor/elements/LinkCard/index.js +13 -1
- package/dist/MarkdownEditor/editor/elements/List/List.js +16 -1
- package/dist/MarkdownEditor/editor/elements/List/ListItem.js +16 -4
- package/dist/MarkdownEditor/editor/elements/Mermaid/index.js +7 -2
- package/dist/MarkdownEditor/editor/elements/Paragraph/index.js +14 -2
- package/dist/MarkdownEditor/editor/elements/Schema/index.js +13 -0
- package/dist/MarkdownEditor/editor/elements/index.js +131 -16
- package/dist/MarkdownEditor/editor/parser/parse/parseBlockElements.js +84 -17
- package/dist/MarkdownEditor/editor/parser/parse/parseCode.js +39 -2
- package/dist/MarkdownEditor/editor/parser/parse/parseElements.js +27 -2
- package/dist/MarkdownEditor/editor/parser/parse/parseFootnote.js +11 -1
- package/dist/MarkdownEditor/editor/parser/parse/parseMath.js +31 -4
- package/dist/MarkdownEditor/editor/parser/parse/parseMedia.js +41 -6
- package/dist/MarkdownEditor/editor/parser/parserMarkdownToSlateNode.js +141 -24
- package/dist/MarkdownEditor/editor/parser/parserSlateNodeToMarkdown.js +127 -6
- package/dist/MarkdownEditor/editor/plugins/insertParsedHtmlNodes.js +109 -2
- package/package.json +1 -1
|
@@ -53,14 +53,19 @@ function _object_spread_props(target, source) {
|
|
|
53
53
|
import { ConfigProvider } from "antd";
|
|
54
54
|
import classNames from "classnames";
|
|
55
55
|
import React, { useContext } from "react";
|
|
56
|
+
import { debugInfo } from "../../../../Utils/debugUtils";
|
|
56
57
|
import { useStyle } from "./style";
|
|
57
58
|
export var Mermaid = function(param) {
|
|
58
59
|
var attributes = param.attributes, children = param.children, element = param.element;
|
|
59
|
-
var _element_otherProps;
|
|
60
|
+
var _element_otherProps, _element_value, _element_otherProps1;
|
|
61
|
+
debugInfo('Mermaid - 渲染 Mermaid 图表', {
|
|
62
|
+
hasError: (element === null || element === void 0 ? void 0 : (_element_otherProps = element.otherProps) === null || _element_otherProps === void 0 ? void 0 : _element_otherProps.error) === true,
|
|
63
|
+
valueLength: element === null || element === void 0 ? void 0 : (_element_value = element.value) === null || _element_value === void 0 ? void 0 : _element_value.length
|
|
64
|
+
});
|
|
60
65
|
var context = useContext(ConfigProvider.ConfigContext);
|
|
61
66
|
var baseCls = context === null || context === void 0 ? void 0 : context.getPrefixCls('agentic-md-editor-mermaid');
|
|
62
67
|
var _useStyle = useStyle(baseCls), wrapSSR = _useStyle.wrapSSR, hashId = _useStyle.hashId;
|
|
63
|
-
var hasError = (element === null || element === void 0 ? void 0 : (
|
|
68
|
+
var hasError = (element === null || element === void 0 ? void 0 : (_element_otherProps1 = element.otherProps) === null || _element_otherProps1 === void 0 ? void 0 : _element_otherProps1.error) === true;
|
|
64
69
|
return wrapSSR(/*#__PURE__*/ React.createElement("pre", _object_spread_props(_object_spread({}, attributes), {
|
|
65
70
|
className: classNames(baseCls, hashId, _define_property({}, "".concat(baseCls, "-error"), hasError))
|
|
66
71
|
}), /*#__PURE__*/ React.createElement("code", null, children)));
|
|
@@ -100,17 +100,28 @@ import classNames from "classnames";
|
|
|
100
100
|
import React, { useContext } from "react";
|
|
101
101
|
import { Node } from "slate";
|
|
102
102
|
import { I18nContext } from "../../../../I18n";
|
|
103
|
+
import { debugInfo } from "../../../../Utils/debugUtils";
|
|
103
104
|
import { useSelStatus } from "../../../hooks/editor";
|
|
104
105
|
import { useEditorStore } from "../../store";
|
|
105
106
|
import { DragHandle } from "../../tools/DragHandle";
|
|
106
107
|
export var Paragraph = function(props) {
|
|
107
|
-
var _markdownEditorRef_current;
|
|
108
|
+
var _props_element_children, _markdownEditorRef_current;
|
|
109
|
+
debugInfo('Paragraph - 渲染段落', {
|
|
110
|
+
align: props.element.align,
|
|
111
|
+
childrenCount: (_props_element_children = props.element.children) === null || _props_element_children === void 0 ? void 0 : _props_element_children.length
|
|
112
|
+
});
|
|
108
113
|
var _useEditorStore = useEditorStore(), store = _useEditorStore.store, markdownEditorRef = _useEditorStore.markdownEditorRef, markdownContainerRef = _useEditorStore.markdownContainerRef, readonly = _useEditorStore.readonly, editorProps = _useEditorStore.editorProps;
|
|
109
114
|
var locale = useContext(I18nContext).locale;
|
|
110
115
|
var _useSelStatus = _sliced_to_array(useSelStatus(props.element), 1), selected = _useSelStatus[0];
|
|
111
116
|
return React.useMemo(function() {
|
|
112
117
|
var _markdownEditorRef_current, _props_element_children_every, _props_element_children, _props_element, _props_children;
|
|
113
118
|
var str = Node.string(props.element).trim();
|
|
119
|
+
debugInfo('Paragraph - useMemo 渲染', {
|
|
120
|
+
strLength: str.length,
|
|
121
|
+
selected: selected,
|
|
122
|
+
readonly: readonly,
|
|
123
|
+
align: props.element.align
|
|
124
|
+
});
|
|
114
125
|
var isEmpty = !str && ((_markdownEditorRef_current = markdownEditorRef.current) === null || _markdownEditorRef_current === void 0 ? void 0 : _markdownEditorRef_current.children.length) === 1 && ((_props_element = props.element) === null || _props_element === void 0 ? void 0 : (_props_element_children = _props_element.children) === null || _props_element_children === void 0 ? void 0 : (_props_element_children_every = _props_element_children.every) === null || _props_element_children_every === void 0 ? void 0 : _props_element_children_every.call(_props_element_children, function(child) {
|
|
115
126
|
return !child.type && !child.code && !child.tag;
|
|
116
127
|
})) ? true : undefined;
|
|
@@ -123,7 +134,8 @@ export var Paragraph = function(props) {
|
|
|
123
134
|
"data-align": props.element.align,
|
|
124
135
|
"data-slate-placeholder": isEmpty ? editorProps.titlePlaceholderContent || (locale === null || locale === void 0 ? void 0 : locale.inputPlaceholder) || '请输入内容...' : undefined,
|
|
125
136
|
onDragStart: function(e) {
|
|
126
|
-
|
|
137
|
+
debugInfo('Paragraph - 拖拽开始');
|
|
138
|
+
store.dragStart(e, markdownContainerRef.current);
|
|
127
139
|
},
|
|
128
140
|
"data-empty": isEmpty,
|
|
129
141
|
style: {
|
|
@@ -50,9 +50,14 @@ function _object_spread_props(target, source) {
|
|
|
50
50
|
}
|
|
51
51
|
return target;
|
|
52
52
|
}
|
|
53
|
+
function _type_of(obj) {
|
|
54
|
+
"@swc/helpers - typeof";
|
|
55
|
+
return obj && typeof Symbol !== "undefined" && obj.constructor === Symbol ? "symbol" : typeof obj;
|
|
56
|
+
}
|
|
53
57
|
import React, { useContext, useMemo } from "react";
|
|
54
58
|
import { BubbleConfigContext } from "../../../../Bubble/BubbleConfigProvide";
|
|
55
59
|
import { SchemaRenderer } from "../../../../Schema";
|
|
60
|
+
import { debugInfo } from "../../../../Utils/debugUtils";
|
|
56
61
|
import { useEditorStore } from "../../store";
|
|
57
62
|
/**
|
|
58
63
|
* Schema 组件 - 模式渲染组件
|
|
@@ -91,12 +96,18 @@ import { useEditorStore } from "../../store";
|
|
|
91
96
|
* 2. AgentAR 卡片渲染
|
|
92
97
|
* 3. 默认 JSON 字符串渲染
|
|
93
98
|
*/ export var Schema = function(props) {
|
|
99
|
+
debugInfo('Schema - 渲染 Schema', {
|
|
100
|
+
language: props.element.language,
|
|
101
|
+
valueType: _type_of(props.element.value),
|
|
102
|
+
hasApaasify: !!props.element.apaasify
|
|
103
|
+
});
|
|
94
104
|
var node = props.element;
|
|
95
105
|
var editorProps = useEditorStore().editorProps;
|
|
96
106
|
var apaasify = (editorProps === null || editorProps === void 0 ? void 0 : editorProps.apaasify) || (editorProps === null || editorProps === void 0 ? void 0 : editorProps.apassify);
|
|
97
107
|
var bubble = (useContext(BubbleConfigContext) || {}).bubble;
|
|
98
108
|
return useMemo(function() {
|
|
99
109
|
if ((apaasify === null || apaasify === void 0 ? void 0 : apaasify.enable) && apaasify.render) {
|
|
110
|
+
debugInfo('Schema - 使用自定义 apaasify 渲染');
|
|
100
111
|
var renderedContent = apaasify.render(props, bubble === null || bubble === void 0 ? void 0 : bubble.originData);
|
|
101
112
|
return /*#__PURE__*/ React.createElement("div", _object_spread_props(_object_spread({}, node.attributes), {
|
|
102
113
|
"data-testid": "schema-container",
|
|
@@ -120,6 +131,7 @@ import { useEditorStore } from "../../store";
|
|
|
120
131
|
}
|
|
121
132
|
if (node.language === 'agentar-card') {
|
|
122
133
|
var _props_element_value;
|
|
134
|
+
debugInfo('Schema - 使用 AgentAR 卡片渲染');
|
|
123
135
|
return /*#__PURE__*/ React.createElement("div", {
|
|
124
136
|
"data-testid": "agentar-card-container",
|
|
125
137
|
style: {
|
|
@@ -134,6 +146,7 @@ import { useEditorStore } from "../../store";
|
|
|
134
146
|
useDefaultValues: false
|
|
135
147
|
}));
|
|
136
148
|
}
|
|
149
|
+
debugInfo('Schema - 使用默认 JSON 渲染');
|
|
137
150
|
return /*#__PURE__*/ React.createElement("div", _object_spread_props(_object_spread({}, node.attributes), {
|
|
138
151
|
"data-testid": "schema-container",
|
|
139
152
|
style: {
|
|
@@ -57,6 +57,7 @@ import { Editor, Path, Transforms } from "slate";
|
|
|
57
57
|
import { ReactEditor } from "slate-react";
|
|
58
58
|
import { I18nContext } from "../../../I18n";
|
|
59
59
|
import { isMobileDevice } from "../../../MarkdownInputField/AttachmentButton/utils";
|
|
60
|
+
import { debugInfo } from "../../../Utils/debugUtils";
|
|
60
61
|
import { useEditorStore } from "../store";
|
|
61
62
|
import { EditorUtils } from "../utils/editorUtils";
|
|
62
63
|
import { Blockquote } from "./Blockquote";
|
|
@@ -159,12 +160,23 @@ import { TagPopup } from "./TagPopup";
|
|
|
159
160
|
return true;
|
|
160
161
|
};
|
|
161
162
|
var MElementComponent = function(props) {
|
|
163
|
+
debugInfo('MElementComponent - 渲染元素', {
|
|
164
|
+
elementType: props.element.type,
|
|
165
|
+
readonly: props.readonly,
|
|
166
|
+
hasChildren: !!props.children
|
|
167
|
+
});
|
|
162
168
|
var dom = tableRenderElement(props, {
|
|
163
169
|
readonly: props.readonly
|
|
164
170
|
});
|
|
165
171
|
if (dom) {
|
|
172
|
+
debugInfo('MElementComponent - 使用表格渲染', {
|
|
173
|
+
elementType: props.element.type
|
|
174
|
+
});
|
|
166
175
|
return dom;
|
|
167
176
|
}
|
|
177
|
+
debugInfo('MElementComponent - 选择元素渲染器', {
|
|
178
|
+
elementType: props.element.type
|
|
179
|
+
});
|
|
168
180
|
switch(props.element.type){
|
|
169
181
|
case 'link-card':
|
|
170
182
|
return /*#__PURE__*/ React.createElement(LinkCard, props);
|
|
@@ -233,6 +245,9 @@ var MElementComponent = function(props) {
|
|
|
233
245
|
"data-be": 'card-after'
|
|
234
246
|
}, props.attributes), props.children);
|
|
235
247
|
default:
|
|
248
|
+
debugInfo('MElementComponent - 使用默认段落渲染', {
|
|
249
|
+
elementType: props.element.type
|
|
250
|
+
});
|
|
236
251
|
return /*#__PURE__*/ React.createElement(Paragraph, props);
|
|
237
252
|
}
|
|
238
253
|
};
|
|
@@ -304,29 +319,61 @@ export var MElement = /*#__PURE__*/ React.memo(MElementComponent, areElementProp
|
|
|
304
319
|
return true;
|
|
305
320
|
};
|
|
306
321
|
var MLeafComponent = function(props) {
|
|
307
|
-
var _leaf_text, _leaf_text1, _leaf_text_replaceAll_replaceAll, _leaf_text_replaceAll,
|
|
322
|
+
var _leaf_text, _leaf_text1, _leaf_text2, _leaf_text_replaceAll_replaceAll, _leaf_text_replaceAll, _leaf_text3, _props_fncProps, _props_leaf, _props_leaf1;
|
|
308
323
|
var _useEditorStore = useEditorStore(), markdownEditorRef = _useEditorStore.markdownEditorRef, markdownContainerRef = _useEditorStore.markdownContainerRef, setShowComment = _useEditorStore.setShowComment;
|
|
309
324
|
var context = useContext(ConfigProvider.ConfigContext);
|
|
310
325
|
var locale = useContext(I18nContext).locale;
|
|
311
326
|
var mdEditorBaseClass = context === null || context === void 0 ? void 0 : context.getPrefixCls('agentic-md-editor-content');
|
|
312
327
|
var leaf = props.leaf;
|
|
328
|
+
debugInfo('MLeafComponent - 渲染叶节点', {
|
|
329
|
+
hasCode: !!leaf.code,
|
|
330
|
+
hasTag: !!leaf.tag,
|
|
331
|
+
hasBold: !!leaf.bold,
|
|
332
|
+
hasItalic: !!leaf.italic,
|
|
333
|
+
hasStrikethrough: !!leaf.strikethrough,
|
|
334
|
+
hasUrl: !!leaf.url,
|
|
335
|
+
hasFnc: !!leaf.fnc,
|
|
336
|
+
hasComment: !!leaf.comment,
|
|
337
|
+
text: (_leaf_text = leaf.text) === null || _leaf_text === void 0 ? void 0 : _leaf_text.substring(0, 50)
|
|
338
|
+
});
|
|
313
339
|
var style = {};
|
|
314
340
|
var prefixClassName = classNames(props.hashId);
|
|
315
341
|
var children = /*#__PURE__*/ React.createElement(React.Fragment, null, props.children);
|
|
316
342
|
if (leaf.code || leaf.tag) {
|
|
317
343
|
var _ref = (props === null || props === void 0 ? void 0 : props.leaf) || {}, text = _ref.text, tag = _ref.tag, placeholder = _ref.placeholder, autoOpen = _ref.autoOpen, triggerText = _ref.triggerText;
|
|
318
344
|
var _ref1 = props.tagInputProps || {}, enable = _ref1.enable, tagTextRender = _ref1.tagTextRender;
|
|
345
|
+
debugInfo('MLeafComponent - 处理代码/标签', {
|
|
346
|
+
code: leaf.code,
|
|
347
|
+
tag: tag,
|
|
348
|
+
enable: enable,
|
|
349
|
+
hasTagTextRender: !!tagTextRender
|
|
350
|
+
});
|
|
319
351
|
if (enable && tag) {
|
|
352
|
+
debugInfo('MLeafComponent - 使用 TagPopup', {
|
|
353
|
+
text: text,
|
|
354
|
+
placeholder: placeholder,
|
|
355
|
+
autoOpen: autoOpen,
|
|
356
|
+
triggerText: triggerText
|
|
357
|
+
});
|
|
320
358
|
children = /*#__PURE__*/ React.createElement(React.Fragment, null, /*#__PURE__*/ React.createElement(TagPopup, _object_spread_props(_object_spread(_object_spread_props(_object_spread({}, props), {
|
|
321
359
|
autoOpen: autoOpen
|
|
322
360
|
}), props.tagInputProps), {
|
|
323
361
|
text: text,
|
|
324
362
|
onSelect: function(v, path, tagNode) {
|
|
325
363
|
var _markdownContainerRef_current;
|
|
364
|
+
debugInfo('MLeafComponent - TagPopup onSelect', {
|
|
365
|
+
value: v,
|
|
366
|
+
path: path,
|
|
367
|
+
hasTagNode: !!tagNode
|
|
368
|
+
});
|
|
326
369
|
if (!v) return;
|
|
327
370
|
if (!(path === null || path === void 0 ? void 0 : path.length)) return;
|
|
328
371
|
if (!markdownEditorRef.current) return;
|
|
329
372
|
Editor.withoutNormalizing(markdownEditorRef.current, function() {
|
|
373
|
+
debugInfo('MLeafComponent - 更新标签节点', {
|
|
374
|
+
value: v,
|
|
375
|
+
path: path
|
|
376
|
+
});
|
|
330
377
|
var newText = (tagTextRender === null || tagTextRender === void 0 ? void 0 : tagTextRender(_object_spread_props(_object_spread({}, props, props.tagInputProps), {
|
|
331
378
|
text: v
|
|
332
379
|
}), "".concat(triggerText !== null && triggerText !== void 0 ? triggerText : '$').concat(v))) || "".concat(triggerText !== null && triggerText !== void 0 ? triggerText : '$').concat(v);
|
|
@@ -376,41 +423,80 @@ var MLeafComponent = function(props) {
|
|
|
376
423
|
placeholder: placeholder || (locale === null || locale === void 0 ? void 0 : locale['input.placeholder']) || '请输入'
|
|
377
424
|
}), children));
|
|
378
425
|
} else {
|
|
426
|
+
debugInfo('MLeafComponent - 使用内联代码样式', {
|
|
427
|
+
code: leaf.code,
|
|
428
|
+
tag: leaf.tag
|
|
429
|
+
});
|
|
379
430
|
children = /*#__PURE__*/ React.createElement("code", {
|
|
380
431
|
className: classNames(mdEditorBaseClass + '-inline-code', props.hashId)
|
|
381
432
|
}, children);
|
|
382
433
|
}
|
|
383
434
|
}
|
|
384
|
-
if (leaf.highColor)
|
|
385
|
-
|
|
435
|
+
if (leaf.highColor) {
|
|
436
|
+
style.color = leaf.highColor;
|
|
437
|
+
debugInfo('MLeafComponent - 应用高亮颜色', {
|
|
438
|
+
color: leaf.highColor
|
|
439
|
+
});
|
|
440
|
+
}
|
|
441
|
+
if (leaf.color) {
|
|
442
|
+
style.color = leaf.color;
|
|
443
|
+
debugInfo('MLeafComponent - 应用颜色', {
|
|
444
|
+
color: leaf.color
|
|
445
|
+
});
|
|
446
|
+
}
|
|
386
447
|
if (leaf.bold) {
|
|
387
448
|
style.fontWeight = 'bold';
|
|
388
449
|
children = /*#__PURE__*/ React.createElement("span", {
|
|
389
450
|
"data-testid": "markdown-bold"
|
|
390
451
|
}, children);
|
|
452
|
+
debugInfo('MLeafComponent - 应用粗体');
|
|
453
|
+
}
|
|
454
|
+
if (leaf.strikethrough) {
|
|
455
|
+
children = /*#__PURE__*/ React.createElement("s", null, children);
|
|
456
|
+
debugInfo('MLeafComponent - 应用删除线');
|
|
457
|
+
}
|
|
458
|
+
if (leaf.italic) {
|
|
459
|
+
style.fontStyle = 'italic';
|
|
460
|
+
debugInfo('MLeafComponent - 应用斜体');
|
|
461
|
+
}
|
|
462
|
+
if (leaf.html) {
|
|
463
|
+
prefixClassName = classNames(prefixClassName, mdEditorBaseClass + '-m-html');
|
|
464
|
+
debugInfo('MLeafComponent - 应用 HTML 样式');
|
|
391
465
|
}
|
|
392
|
-
if (leaf.strikethrough) children = /*#__PURE__*/ React.createElement("s", null, children);
|
|
393
|
-
if (leaf.italic) style.fontStyle = 'italic';
|
|
394
|
-
if (leaf.html) prefixClassName = classNames(prefixClassName, mdEditorBaseClass + '-m-html');
|
|
395
466
|
if (leaf.current) {
|
|
396
467
|
style.background = '#f59e0b';
|
|
468
|
+
debugInfo('MLeafComponent - 应用当前高亮');
|
|
397
469
|
}
|
|
398
470
|
var selectFormat = function() {
|
|
399
471
|
try {
|
|
472
|
+
debugInfo('MLeafComponent - selectFormat 调用');
|
|
400
473
|
if (EditorUtils.isDirtLeaf(props.leaf)) {
|
|
401
474
|
var path = ReactEditor.findPath(markdownEditorRef.current, props.text);
|
|
475
|
+
debugInfo('MLeafComponent - 选择格式路径', {
|
|
476
|
+
path: path
|
|
477
|
+
});
|
|
402
478
|
if (path) {
|
|
403
479
|
Transforms.select(markdownEditorRef.current, {
|
|
404
480
|
anchor: Editor.start(markdownEditorRef.current, path),
|
|
405
481
|
focus: Editor.end(markdownEditorRef.current, path)
|
|
406
482
|
});
|
|
483
|
+
debugInfo('MLeafComponent - 格式选择完成');
|
|
407
484
|
}
|
|
408
485
|
}
|
|
409
|
-
} catch (e) {
|
|
486
|
+
} catch (e) {
|
|
487
|
+
debugInfo('MLeafComponent - selectFormat 错误', {
|
|
488
|
+
error: e
|
|
489
|
+
});
|
|
490
|
+
}
|
|
410
491
|
};
|
|
411
492
|
var handleFncOpen = function() {
|
|
412
|
-
var _props_fncProps;
|
|
413
|
-
|
|
493
|
+
var _props_fncProps, _props_fncProps1;
|
|
494
|
+
debugInfo('MLeafComponent - handleFncOpen', {
|
|
495
|
+
identifier: leaf === null || leaf === void 0 ? void 0 : leaf.identifier,
|
|
496
|
+
hasFncProps: !!props.fncProps,
|
|
497
|
+
hasOnOriginUrlClick: !!((_props_fncProps = props.fncProps) === null || _props_fncProps === void 0 ? void 0 : _props_fncProps.onOriginUrlClick)
|
|
498
|
+
});
|
|
499
|
+
if ((_props_fncProps1 = props.fncProps) === null || _props_fncProps1 === void 0 ? void 0 : _props_fncProps1.onOriginUrlClick) {
|
|
414
500
|
props.fncProps.onOriginUrlClick(leaf === null || leaf === void 0 ? void 0 : leaf.identifier);
|
|
415
501
|
}
|
|
416
502
|
};
|
|
@@ -456,28 +542,46 @@ var MLeafComponent = function(props) {
|
|
|
456
542
|
onDragStart: dragStart,
|
|
457
543
|
onClick: function(e) {
|
|
458
544
|
var _props_fncProps, _props_linkConfig, _props_linkConfig1, _props_linkConfig2;
|
|
545
|
+
debugInfo('MLeafComponent - onClick 事件', {
|
|
546
|
+
isMobile: isMobile,
|
|
547
|
+
hasFnc: hasFnc,
|
|
548
|
+
detail: e.detail,
|
|
549
|
+
hasUrl: !!leaf.url
|
|
550
|
+
});
|
|
459
551
|
// 在手机上,如果是 fnc,阻止点击事件(使用长按代替)
|
|
460
552
|
if (isMobile && hasFnc) {
|
|
553
|
+
debugInfo('MLeafComponent - 移动端阻止 fnc 点击');
|
|
461
554
|
e.preventDefault();
|
|
462
555
|
return;
|
|
463
556
|
}
|
|
464
557
|
if (e.detail === 2) {
|
|
558
|
+
debugInfo('MLeafComponent - 双击选择格式');
|
|
465
559
|
selectFormat();
|
|
466
560
|
}
|
|
467
561
|
if ((_props_fncProps = props.fncProps) === null || _props_fncProps === void 0 ? void 0 : _props_fncProps.onOriginUrlClick) {
|
|
562
|
+
debugInfo('MLeafComponent - 触发 fnc 点击');
|
|
468
563
|
props.fncProps.onOriginUrlClick(leaf === null || leaf === void 0 ? void 0 : leaf.identifier);
|
|
469
564
|
}
|
|
470
565
|
if ((_props_linkConfig = props.linkConfig) === null || _props_linkConfig === void 0 ? void 0 : _props_linkConfig.onClick) {
|
|
471
566
|
var _props_linkConfig3;
|
|
472
567
|
var res = (_props_linkConfig3 = props.linkConfig) === null || _props_linkConfig3 === void 0 ? void 0 : _props_linkConfig3.onClick(leaf.url);
|
|
568
|
+
debugInfo('MLeafComponent - 链接点击处理', {
|
|
569
|
+
result: res
|
|
570
|
+
});
|
|
473
571
|
if (res === false) {
|
|
474
572
|
return;
|
|
475
573
|
}
|
|
476
574
|
}
|
|
477
575
|
if (leaf.url && ((_props_linkConfig1 = props.linkConfig) === null || _props_linkConfig1 === void 0 ? void 0 : _props_linkConfig1.openInNewTab) !== false) {
|
|
576
|
+
debugInfo('MLeafComponent - 新标签页打开链接', {
|
|
577
|
+
url: leaf.url
|
|
578
|
+
});
|
|
478
579
|
window.open(leaf.url, '_blank');
|
|
479
580
|
}
|
|
480
581
|
if (leaf.url && ((_props_linkConfig2 = props.linkConfig) === null || _props_linkConfig2 === void 0 ? void 0 : _props_linkConfig2.openInNewTab) === false) {
|
|
582
|
+
debugInfo('MLeafComponent - 当前窗口打开链接', {
|
|
583
|
+
url: leaf.url
|
|
584
|
+
});
|
|
481
585
|
window.location.href = leaf.url;
|
|
482
586
|
}
|
|
483
587
|
},
|
|
@@ -488,23 +592,34 @@ var MLeafComponent = function(props) {
|
|
|
488
592
|
"data-fnc": leaf.fnc || leaf.identifier ? 'fnc' : undefined,
|
|
489
593
|
"data-fnd": leaf.fnd ? 'fnd' : undefined,
|
|
490
594
|
"data-comment": leaf.comment ? 'comment' : undefined,
|
|
491
|
-
"data-fnc-name": leaf.fnc ? (
|
|
595
|
+
"data-fnc-name": leaf.fnc ? (_leaf_text1 = leaf.text) === null || _leaf_text1 === void 0 ? void 0 : _leaf_text1.replace(/\[\^(.+)]:?/g, '$1') : undefined,
|
|
492
596
|
"data-url": leaf.url ? 'url' : undefined,
|
|
493
|
-
"data-fnd-name": leaf.fnd ? (
|
|
597
|
+
"data-fnd-name": leaf.fnd ? (_leaf_text2 = leaf.text) === null || _leaf_text2 === void 0 ? void 0 : _leaf_text2.replace(/\[\^(.+)]:?/g, '$1') : undefined,
|
|
494
598
|
className: fncClassName ? fncClassName : undefined,
|
|
495
599
|
style: _object_spread({
|
|
496
600
|
fontSize: leaf.fnc ? 10 : undefined
|
|
497
601
|
}, style)
|
|
498
|
-
}), leaf.fnc || leaf.identifier ? (
|
|
602
|
+
}), leaf.fnc || leaf.identifier ? (_leaf_text3 = leaf.text) === null || _leaf_text3 === void 0 ? void 0 : (_leaf_text_replaceAll = _leaf_text3.replaceAll(']', '')) === null || _leaf_text_replaceAll === void 0 ? void 0 : (_leaf_text_replaceAll_replaceAll = _leaf_text_replaceAll.replaceAll('[^DOC_', '')) === null || _leaf_text_replaceAll_replaceAll === void 0 ? void 0 : _leaf_text_replaceAll_replaceAll.replaceAll('[^', '') : children);
|
|
499
603
|
if (((_props_fncProps = props.fncProps) === null || _props_fncProps === void 0 ? void 0 : _props_fncProps.render) && (leaf.fnc || leaf.identifier)) {
|
|
500
|
-
var _leaf_text_toLocaleUpperCase,
|
|
604
|
+
var _leaf_text_toLocaleUpperCase, _leaf_text4, _props_fncProps_render, _props_fncProps1;
|
|
605
|
+
debugInfo('MLeafComponent - 使用 fnc 自定义渲染', {
|
|
606
|
+
hasFnc: !!leaf.fnc,
|
|
607
|
+
hasIdentifier: !!leaf.identifier
|
|
608
|
+
});
|
|
501
609
|
dom = /*#__PURE__*/ React.createElement(React.Fragment, null, (_props_fncProps_render = (_props_fncProps1 = props.fncProps).render) === null || _props_fncProps_render === void 0 ? void 0 : _props_fncProps_render.call(_props_fncProps1, _object_spread_props(_object_spread({}, leaf), {
|
|
502
|
-
children: ((
|
|
610
|
+
children: ((_leaf_text4 = leaf.text) === null || _leaf_text4 === void 0 ? void 0 : (_leaf_text_toLocaleUpperCase = _leaf_text4.toLocaleUpperCase()) === null || _leaf_text_toLocaleUpperCase === void 0 ? void 0 : _leaf_text_toLocaleUpperCase.replaceAll('[^', '').replaceAll(']', '')) || ''
|
|
503
611
|
}), dom));
|
|
504
612
|
}
|
|
505
|
-
if (!props.leaf.comment)
|
|
613
|
+
if (!props.leaf.comment) {
|
|
614
|
+
debugInfo('MLeafComponent - 返回 DOM(无评论)');
|
|
615
|
+
return dom;
|
|
616
|
+
}
|
|
617
|
+
debugInfo('MLeafComponent - 返回带评论的 DOM', {
|
|
618
|
+
commentId: (_props_leaf = props.leaf) === null || _props_leaf === void 0 ? void 0 : _props_leaf.id,
|
|
619
|
+
hasCommentItem: !!(leaf === null || leaf === void 0 ? void 0 : leaf.comment)
|
|
620
|
+
});
|
|
506
621
|
return /*#__PURE__*/ React.createElement(CommentView, {
|
|
507
|
-
id: "comment-".concat((
|
|
622
|
+
id: "comment-".concat((_props_leaf1 = props.leaf) === null || _props_leaf1 === void 0 ? void 0 : _props_leaf1.id),
|
|
508
623
|
comment: props.comment,
|
|
509
624
|
hashId: props.hashId,
|
|
510
625
|
selection: leaf === null || leaf === void 0 ? void 0 : leaf.selection,
|
|
@@ -50,6 +50,7 @@ function _object_spread_props(target, source) {
|
|
|
50
50
|
}
|
|
51
51
|
return target;
|
|
52
52
|
}
|
|
53
|
+
import { debugInfo } from "../../../../Utils/debugUtils";
|
|
53
54
|
import { EditorUtils } from "../../utils";
|
|
54
55
|
import { createMediaNodeFromElement, decodeURIComponentUrl, findImageElement } from "./parseHtml";
|
|
55
56
|
import { handleAttachmentLink, handleLinkCard } from "./parseMedia";
|
|
@@ -57,21 +58,36 @@ import { handleTextAndInlineElementsPure, setFinishedProp } from "./parseText";
|
|
|
57
58
|
/**
|
|
58
59
|
* 处理标题节点
|
|
59
60
|
*/ export var handleHeading = function(currentElement, parseNodes) {
|
|
60
|
-
var _currentElement_children;
|
|
61
|
-
|
|
61
|
+
var _currentElement_children, _currentElement_children1, _result_children;
|
|
62
|
+
debugInfo('handleHeading - 处理标题', {
|
|
63
|
+
depth: currentElement.depth,
|
|
64
|
+
childrenCount: (_currentElement_children = currentElement.children) === null || _currentElement_children === void 0 ? void 0 : _currentElement_children.length
|
|
65
|
+
});
|
|
66
|
+
var result = {
|
|
62
67
|
type: 'head',
|
|
63
68
|
level: currentElement.depth,
|
|
64
|
-
children: ((
|
|
69
|
+
children: ((_currentElement_children1 = currentElement.children) === null || _currentElement_children1 === void 0 ? void 0 : _currentElement_children1.length) ? parseNodes(currentElement.children, false, currentElement) : [
|
|
65
70
|
{
|
|
66
71
|
text: ''
|
|
67
72
|
}
|
|
68
73
|
]
|
|
69
74
|
};
|
|
75
|
+
debugInfo('handleHeading - 标题处理完成', {
|
|
76
|
+
level: result.level,
|
|
77
|
+
childrenCount: (_result_children = result.children) === null || _result_children === void 0 ? void 0 : _result_children.length
|
|
78
|
+
});
|
|
79
|
+
return result;
|
|
70
80
|
};
|
|
71
81
|
/**
|
|
72
82
|
* 处理列表节点
|
|
73
83
|
*/ export var handleList = function(currentElement, parseNodes) {
|
|
74
|
-
var _el_children;
|
|
84
|
+
var _currentElement_children, _el_children, _el_children1;
|
|
85
|
+
debugInfo('handleList - 处理列表', {
|
|
86
|
+
ordered: currentElement.ordered,
|
|
87
|
+
start: currentElement.start,
|
|
88
|
+
finished: currentElement.finished,
|
|
89
|
+
childrenCount: (_currentElement_children = currentElement.children) === null || _currentElement_children === void 0 ? void 0 : _currentElement_children.length
|
|
90
|
+
});
|
|
75
91
|
var el = {
|
|
76
92
|
type: 'list',
|
|
77
93
|
order: currentElement.ordered,
|
|
@@ -82,6 +98,13 @@ import { handleTextAndInlineElementsPure, setFinishedProp } from "./parseText";
|
|
|
82
98
|
el.task = (_el_children = el.children) === null || _el_children === void 0 ? void 0 : _el_children.some(function(s) {
|
|
83
99
|
return typeof s.checked === 'boolean';
|
|
84
100
|
});
|
|
101
|
+
debugInfo('handleList - 列表处理完成', {
|
|
102
|
+
type: el.type,
|
|
103
|
+
order: el.order,
|
|
104
|
+
start: el.start,
|
|
105
|
+
task: el.task,
|
|
106
|
+
childrenCount: (_el_children1 = el.children) === null || _el_children1 === void 0 ? void 0 : _el_children1.length
|
|
107
|
+
});
|
|
85
108
|
return el;
|
|
86
109
|
};
|
|
87
110
|
/**
|
|
@@ -103,8 +126,12 @@ import { handleTextAndInlineElementsPure, setFinishedProp } from "./parseText";
|
|
|
103
126
|
/**
|
|
104
127
|
* 处理列表项节点
|
|
105
128
|
*/ export var handleListItem = function(currentElement, parseNodes) {
|
|
106
|
-
var _currentElement_children, _currentElement_children__children_, _currentElement_children__children, _currentElement_children_,
|
|
107
|
-
|
|
129
|
+
var _currentElement_children, _currentElement_children1, _currentElement_children__children_, _currentElement_children__children, _currentElement_children_, _currentElement_children2, _currentElement_children__children1, _currentElement_children_1, _currentElement_children3, _result_children;
|
|
130
|
+
debugInfo('handleListItem - 处理列表项', {
|
|
131
|
+
checked: currentElement.checked,
|
|
132
|
+
childrenCount: (_currentElement_children = currentElement.children) === null || _currentElement_children === void 0 ? void 0 : _currentElement_children.length
|
|
133
|
+
});
|
|
134
|
+
var children = ((_currentElement_children1 = currentElement.children) === null || _currentElement_children1 === void 0 ? void 0 : _currentElement_children1.length) ? parseNodes(currentElement.children, false, currentElement) : [
|
|
108
135
|
{
|
|
109
136
|
type: 'paragraph',
|
|
110
137
|
children: [
|
|
@@ -115,7 +142,7 @@ import { handleTextAndInlineElementsPure, setFinishedProp } from "./parseText";
|
|
|
115
142
|
}
|
|
116
143
|
];
|
|
117
144
|
var mentions = undefined;
|
|
118
|
-
if (((
|
|
145
|
+
if (((_currentElement_children2 = currentElement.children) === null || _currentElement_children2 === void 0 ? void 0 : (_currentElement_children_ = _currentElement_children2[0]) === null || _currentElement_children_ === void 0 ? void 0 : (_currentElement_children__children = _currentElement_children_.children) === null || _currentElement_children__children === void 0 ? void 0 : (_currentElement_children__children_ = _currentElement_children__children[0]) === null || _currentElement_children__children_ === void 0 ? void 0 : _currentElement_children__children_.type) === 'link' && ((_currentElement_children3 = currentElement.children) === null || _currentElement_children3 === void 0 ? void 0 : (_currentElement_children_1 = _currentElement_children3[0]) === null || _currentElement_children_1 === void 0 ? void 0 : (_currentElement_children__children1 = _currentElement_children_1.children) === null || _currentElement_children__children1 === void 0 ? void 0 : _currentElement_children__children1.length) > 1) {
|
|
119
146
|
var _children__children, _children_;
|
|
120
147
|
var item = children === null || children === void 0 ? void 0 : (_children_ = children[0]) === null || _children_ === void 0 ? void 0 : (_children__children = _children_.children) === null || _children__children === void 0 ? void 0 : _children__children[0];
|
|
121
148
|
var label = item === null || item === void 0 ? void 0 : item.text;
|
|
@@ -129,14 +156,24 @@ import { handleTextAndInlineElementsPure, setFinishedProp } from "./parseText";
|
|
|
129
156
|
}
|
|
130
157
|
];
|
|
131
158
|
children === null || children === void 0 ? true : (_children_1 = children[0]) === null || _children_1 === void 0 ? true : (_children__children1 = _children_1.children) === null || _children__children1 === void 0 ? true : delete _children__children1[0];
|
|
159
|
+
debugInfo('handleListItem - 提取 mentions', {
|
|
160
|
+
mentions: mentions
|
|
161
|
+
});
|
|
132
162
|
}
|
|
133
163
|
}
|
|
134
|
-
|
|
164
|
+
var result = {
|
|
135
165
|
type: 'list-item',
|
|
136
166
|
checked: currentElement.checked,
|
|
137
167
|
children: children,
|
|
138
168
|
mentions: mentions
|
|
139
169
|
};
|
|
170
|
+
debugInfo('handleListItem - 列表项处理完成', {
|
|
171
|
+
type: result.type,
|
|
172
|
+
checked: result.checked,
|
|
173
|
+
childrenCount: (_result_children = result.children) === null || _result_children === void 0 ? void 0 : _result_children.length,
|
|
174
|
+
hasMentions: !!result.mentions
|
|
175
|
+
});
|
|
176
|
+
return result;
|
|
140
177
|
};
|
|
141
178
|
/**
|
|
142
179
|
* 处理段落子节点
|
|
@@ -208,26 +245,51 @@ import { handleTextAndInlineElementsPure, setFinishedProp } from "./parseText";
|
|
|
208
245
|
/**
|
|
209
246
|
* 处理段落节点
|
|
210
247
|
*/ export var handleParagraph = function(currentElement, config, parseNodes) {
|
|
211
|
-
var _currentElement_children, _currentElement_children_at,
|
|
248
|
+
var _currentElement_children, _currentElement_children_, _currentElement_children1, _currentElement_children2, _currentElement_children_at, _currentElement_children3;
|
|
249
|
+
debugInfo('handleParagraph - 处理段落', {
|
|
250
|
+
childrenCount: (_currentElement_children = currentElement.children) === null || _currentElement_children === void 0 ? void 0 : _currentElement_children.length,
|
|
251
|
+
firstChildType: (_currentElement_children1 = currentElement.children) === null || _currentElement_children1 === void 0 ? void 0 : (_currentElement_children_ = _currentElement_children1[0]) === null || _currentElement_children_ === void 0 ? void 0 : _currentElement_children_.type,
|
|
252
|
+
configType: config === null || config === void 0 ? void 0 : config.type
|
|
253
|
+
});
|
|
212
254
|
// 检查是否是附件链接
|
|
213
|
-
if (((
|
|
255
|
+
if (((_currentElement_children2 = currentElement.children) === null || _currentElement_children2 === void 0 ? void 0 : _currentElement_children2[0].type) === 'html' && currentElement.children[0].value.startsWith('<a')) {
|
|
256
|
+
debugInfo('handleParagraph - 检测到附件链接');
|
|
214
257
|
var attachNode = handleAttachmentLink(currentElement);
|
|
215
|
-
if (attachNode)
|
|
258
|
+
if (attachNode) {
|
|
259
|
+
debugInfo('handleParagraph - 返回附件节点', {
|
|
260
|
+
type: attachNode === null || attachNode === void 0 ? void 0 : attachNode.type
|
|
261
|
+
});
|
|
262
|
+
return attachNode;
|
|
263
|
+
}
|
|
216
264
|
}
|
|
217
265
|
// 检查是否是链接卡片
|
|
218
|
-
if ((currentElement === null || currentElement === void 0 ? void 0 : (
|
|
219
|
-
|
|
266
|
+
if ((currentElement === null || currentElement === void 0 ? void 0 : (_currentElement_children3 = currentElement.children) === null || _currentElement_children3 === void 0 ? void 0 : (_currentElement_children_at = _currentElement_children3.at(0)) === null || _currentElement_children_at === void 0 ? void 0 : _currentElement_children_at.type) === 'link' && config.type === 'card') {
|
|
267
|
+
debugInfo('handleParagraph - 检测到链接卡片');
|
|
268
|
+
var linkCard = handleLinkCard(currentElement, config);
|
|
269
|
+
debugInfo('handleParagraph - 返回链接卡片', {
|
|
270
|
+
type: linkCard === null || linkCard === void 0 ? void 0 : linkCard.type
|
|
271
|
+
});
|
|
272
|
+
return linkCard;
|
|
220
273
|
}
|
|
221
274
|
// 处理混合内容段落
|
|
222
|
-
|
|
275
|
+
debugInfo('handleParagraph - 处理混合内容段落');
|
|
276
|
+
var result = processParagraphChildren(currentElement, parseNodes);
|
|
277
|
+
debugInfo('handleParagraph - 段落处理完成', {
|
|
278
|
+
resultType: Array.isArray(result) ? 'array' : result === null || result === void 0 ? void 0 : result.type,
|
|
279
|
+
resultLength: Array.isArray(result) ? result.length : 1
|
|
280
|
+
});
|
|
281
|
+
return result;
|
|
223
282
|
};
|
|
224
283
|
/**
|
|
225
284
|
* 处理引用块节点
|
|
226
285
|
*/ export var handleBlockquote = function(currentElement, parseNodes) {
|
|
227
|
-
var _currentElement_children;
|
|
228
|
-
|
|
286
|
+
var _currentElement_children, _currentElement_children1, _result_children;
|
|
287
|
+
debugInfo('handleBlockquote - 处理引用块', {
|
|
288
|
+
childrenCount: (_currentElement_children = currentElement.children) === null || _currentElement_children === void 0 ? void 0 : _currentElement_children.length
|
|
289
|
+
});
|
|
290
|
+
var result = {
|
|
229
291
|
type: 'blockquote',
|
|
230
|
-
children: ((
|
|
292
|
+
children: ((_currentElement_children1 = currentElement.children) === null || _currentElement_children1 === void 0 ? void 0 : _currentElement_children1.length) ? parseNodes(currentElement.children, false, currentElement) : [
|
|
231
293
|
{
|
|
232
294
|
type: 'paragraph',
|
|
233
295
|
children: [
|
|
@@ -238,6 +300,11 @@ import { handleTextAndInlineElementsPure, setFinishedProp } from "./parseText";
|
|
|
238
300
|
}
|
|
239
301
|
]
|
|
240
302
|
};
|
|
303
|
+
debugInfo('handleBlockquote - 引用块处理完成', {
|
|
304
|
+
type: result.type,
|
|
305
|
+
childrenCount: (_result_children = result.children) === null || _result_children === void 0 ? void 0 : _result_children.length
|
|
306
|
+
});
|
|
307
|
+
return result;
|
|
241
308
|
};
|
|
242
309
|
/**
|
|
243
310
|
* 应用内联格式到叶子节点
|