@ant-design/agentic-ui 2.29.11 → 2.29.13
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/AILabel/style.d.ts +3 -0
- package/dist/AgentRunBar/style.d.ts +3 -0
- package/dist/AgenticLayout/style.d.ts +3 -0
- package/dist/AnswerAlert/style.d.ts +3 -0
- package/dist/BackTo/style.d.ts +3 -0
- package/dist/Bubble/List/style.d.ts +3 -0
- package/dist/Bubble/MessagesContent/VoiceButton/style.d.ts +3 -0
- package/dist/Bubble/MessagesContent/docInfoStyle.d.ts +3 -0
- package/dist/Bubble/MessagesContent/style.d.ts +3 -0
- package/dist/Bubble/style.d.ts +3 -0
- package/dist/ChatBootPage/ButtonTabGroupStyle.d.ts +3 -0
- package/dist/ChatBootPage/ButtonTabStyle.d.ts +6 -0
- package/dist/ChatBootPage/CaseReplyStyle.d.ts +3 -0
- package/dist/ChatBootPage/style.d.ts +3 -0
- package/dist/ChatLayout/style.d.ts +3 -0
- package/dist/Components/ActionIconBox/style.d.ts +3 -0
- package/dist/Components/ActionItemBox/ActionItemBox.d.ts +1 -1
- package/dist/Components/ActionItemBox/style.d.ts +3 -0
- package/dist/Components/Button/IconButton/style.d.ts +3 -0
- package/dist/Components/Button/SwitchButton/style.d.ts +3 -0
- package/dist/Components/Button/ToggleButton/style.d.ts +3 -0
- package/dist/Components/GradientText/index.d.ts +1 -1
- package/dist/Components/GradientText/style.d.ts +3 -0
- package/dist/Components/LayoutHeader/style.d.ts +3 -0
- package/dist/Components/Loading/Loading.d.ts +1 -1
- package/dist/Components/Loading/style.d.ts +3 -0
- package/dist/Components/SuggestionList/style.d.ts +3 -0
- package/dist/Components/TextAnimate/index.d.ts +1 -1
- package/dist/Components/TextAnimate/style.d.ts +3 -0
- package/dist/Components/TypingAnimation/index.d.ts +1 -1
- package/dist/Components/TypingAnimation/style.d.ts +3 -0
- package/dist/Components/VisualList/style.d.ts +3 -0
- package/dist/Components/lotties/TextLoading/style.d.ts +3 -0
- package/dist/Components/lotties/bubble-actions/Abstract/style.d.ts +3 -0
- package/dist/History/components/HistoryItem.js +3 -0
- package/dist/History/components/NewChatComponent.style.d.ts +3 -0
- package/dist/History/style.d.ts +3 -0
- package/dist/History/style.js +2 -2
- package/dist/Hooks/useLanguage.d.ts +1 -0
- package/dist/Hooks/useStyle/index.d.ts +3 -0
- package/dist/Hooks/useStyle/index.js +7 -4
- package/dist/I18n/locales.d.ts +1 -0
- package/dist/I18n/locales.js +2 -0
- package/dist/MarkdownEditor/editor/Editor.d.ts +1 -2
- package/dist/MarkdownEditor/editor/Editor.js +16 -5
- package/dist/MarkdownEditor/editor/components/CommentList/style.d.ts +3 -0
- package/dist/MarkdownEditor/editor/components/ContributorAvatar/style.d.ts +3 -0
- package/dist/MarkdownEditor/editor/components/LazyElement/style.d.ts +3 -0
- package/dist/MarkdownEditor/editor/components/fntTag/index.d.ts +1 -1
- package/dist/MarkdownEditor/editor/components/fntTag/style.d.ts +3 -0
- package/dist/MarkdownEditor/editor/elements/Blockquote/ReadonlyBlockquote.js +0 -5
- package/dist/MarkdownEditor/editor/elements/Blockquote/index.js +0 -10
- package/dist/MarkdownEditor/editor/elements/Break/ReadonlyBreak.js +0 -2
- package/dist/MarkdownEditor/editor/elements/Break/index.js +0 -2
- package/dist/MarkdownEditor/editor/elements/Card/ReadonlyCard.js +0 -6
- package/dist/MarkdownEditor/editor/elements/Card/index.js +0 -11
- package/dist/MarkdownEditor/editor/elements/Code/ReadonlyCode.js +4 -9
- package/dist/MarkdownEditor/editor/elements/Code/index.js +4 -9
- package/dist/MarkdownEditor/editor/elements/Comment/index.d.ts +0 -2
- package/dist/MarkdownEditor/editor/elements/Comment/index.js +1 -1
- package/dist/MarkdownEditor/editor/elements/CommentLeaf/index.d.ts +1 -2
- package/dist/MarkdownEditor/editor/elements/CommentLeaf/index.js +3 -9
- package/dist/MarkdownEditor/editor/elements/FncLeaf/index.d.ts +1 -2
- package/dist/MarkdownEditor/editor/elements/FncLeaf/index.js +2 -32
- package/dist/MarkdownEditor/editor/elements/FootnoteDefinition/ReadonlyFootnoteDefinition.js +0 -7
- package/dist/MarkdownEditor/editor/elements/FootnoteDefinition/index.js +0 -1
- package/dist/MarkdownEditor/editor/elements/FootnoteReference/ReadonlyFootnoteReference.js +0 -3
- package/dist/MarkdownEditor/editor/elements/FootnoteReference/index.js +0 -1
- package/dist/MarkdownEditor/editor/elements/Head/ReadonlyHead.js +0 -4
- package/dist/MarkdownEditor/editor/elements/Head/index.js +0 -9
- package/dist/MarkdownEditor/editor/elements/Hr/ReadonlyHr.js +0 -2
- package/dist/MarkdownEditor/editor/elements/Hr/index.js +0 -2
- package/dist/MarkdownEditor/editor/elements/Image/index.js +2 -31
- package/dist/MarkdownEditor/editor/elements/InlineKatex/ReadonlyInlineKatex.js +0 -5
- package/dist/MarkdownEditor/editor/elements/LinkCard/ReadonlyLinkCard.js +11 -25
- package/dist/MarkdownEditor/editor/elements/LinkCard/index.js +11 -25
- package/dist/MarkdownEditor/editor/elements/List/List.d.ts +0 -3
- package/dist/MarkdownEditor/editor/elements/List/List.js +5 -36
- package/dist/MarkdownEditor/editor/elements/List/ListItem.js +4 -18
- package/dist/MarkdownEditor/editor/elements/List/ReadonlyList.js +4 -21
- package/dist/MarkdownEditor/editor/elements/List/ReadonlyListItem.js +3 -14
- package/dist/MarkdownEditor/editor/elements/Mermaid/ReadonlyMermaid.js +5 -12
- package/dist/MarkdownEditor/editor/elements/Mermaid/index.js +5 -12
- package/dist/MarkdownEditor/editor/elements/Paragraph/ReadonlyParagraph.js +0 -9
- package/dist/MarkdownEditor/editor/elements/Paragraph/index.js +0 -1
- package/dist/MarkdownEditor/editor/elements/Schema/ReadonlySchema.js +0 -13
- package/dist/MarkdownEditor/editor/elements/Schema/index.js +0 -3
- package/dist/MarkdownEditor/editor/elements/Table/ReadonlyTableComponent.d.ts +0 -1
- package/dist/MarkdownEditor/editor/elements/Table/ReadonlyTableComponent.js +9 -7
- package/dist/MarkdownEditor/editor/elements/Table/SimpleTable.js +3 -48
- package/dist/MarkdownEditor/editor/elements/Table/Table.d.ts +1 -2
- package/dist/MarkdownEditor/editor/elements/Table/Table.js +8 -7
- package/dist/MarkdownEditor/editor/elements/Table/TableCellIndex/index.js +7 -9
- package/dist/MarkdownEditor/editor/elements/Table/TableCellIndexSpacer/index.js +7 -9
- package/dist/MarkdownEditor/editor/elements/Table/TableRowIndex/index.js +3 -5
- package/dist/MarkdownEditor/editor/elements/Table/Td/index.js +6 -8
- package/dist/MarkdownEditor/editor/elements/TagPopup/index.js +8 -10
- package/dist/MarkdownEditor/editor/elements/index.d.ts +1 -1
- package/dist/MarkdownEditor/editor/elements/index.js +83 -105
- package/dist/MarkdownEditor/editor/parser/parse/parseTable.d.ts +3 -2
- package/dist/MarkdownEditor/editor/parser/parse/parseTable.js +14 -3
- package/dist/MarkdownEditor/editor/parser/parserMarkdownToSlateNode.js +16 -6
- package/dist/MarkdownEditor/editor/plugins/useKeyboard.js +4 -1
- package/dist/MarkdownEditor/editor/plugins/useOnchange.js +9 -2
- package/dist/MarkdownEditor/editor/store.js +7 -4
- package/dist/MarkdownEditor/editor/style.d.ts +3 -0
- package/dist/MarkdownEditor/editor/tools/ToolBar/FloatBar.js +1 -2
- package/dist/MarkdownEditor/editor/tools/ToolBar/ReadonlyBaseBar.d.ts +0 -1
- package/dist/MarkdownEditor/editor/tools/ToolBar/ReadonlyBaseBar.js +3 -4
- package/dist/MarkdownEditor/editor/tools/ToolBar/floatBarStyle.d.ts +3 -0
- package/dist/MarkdownEditor/editor/tools/ToolBar/toolBarStyle.d.ts +3 -0
- package/dist/MarkdownEditor/editor/tools/insertAutocompleteStyle.d.ts +3 -0
- package/dist/MarkdownEditor/style.d.ts +3 -0
- package/dist/MarkdownEditor/style.js +575 -3
- package/dist/MarkdownInputField/AttachmentButton/AttachmentButtonPopover.d.ts +3 -0
- package/dist/MarkdownInputField/AttachmentButton/AttachmentButtonPopover.js +47 -10
- package/dist/MarkdownInputField/AttachmentButton/AttachmentFileList/style.d.ts +3 -0
- package/dist/MarkdownInputField/AttachmentButton/index.d.ts +4 -0
- package/dist/MarkdownInputField/AttachmentButton/index.js +5 -3
- package/dist/MarkdownInputField/AttachmentButton/style.d.ts +3 -0
- package/dist/MarkdownInputField/BeforeToolContainer/BeforeToolContainer.d.ts +1 -1
- package/dist/MarkdownInputField/BorderBeamAnimation.js +47 -25
- package/dist/MarkdownInputField/FileMapView/style.d.ts +3 -0
- package/dist/MarkdownInputField/RefinePromptButton/style.d.ts +3 -0
- package/dist/MarkdownInputField/SendButton/style.d.ts +3 -0
- package/dist/MarkdownInputField/SkillModeBar/style.d.ts +3 -0
- package/dist/MarkdownInputField/TopOperatingArea/style.d.ts +3 -0
- package/dist/MarkdownInputField/VoiceInput/style.d.ts +3 -0
- package/dist/MarkdownInputField/style.d.ts +3 -0
- package/dist/Plugins/chart/AreaChart/style.d.ts +3 -0
- package/dist/Plugins/chart/BarChart/style.d.ts +3 -0
- package/dist/Plugins/chart/ChartAttrToolBar/ChartAttrToolBarStyle.d.ts +3 -0
- package/dist/Plugins/chart/ChartStatistic/style.d.ts +3 -0
- package/dist/Plugins/chart/DonutChart/style.d.ts +3 -0
- package/dist/Plugins/chart/FunnelChart/style.d.ts +3 -0
- package/dist/Plugins/chart/LineChart/style.d.ts +3 -0
- package/dist/Plugins/chart/RadarChart/style.d.ts +3 -0
- package/dist/Plugins/chart/ScatterChart/style.d.ts +3 -0
- package/dist/Plugins/chart/components/ChartContainer/style.d.ts +3 -0
- package/dist/Plugins/chart/components/ChartFilter/style.d.ts +3 -0
- package/dist/Plugins/chart/components/ChartToolBar/style.d.ts +3 -0
- package/dist/Plugins/mermaid/MermaidFallback.d.ts +1 -2
- package/dist/Plugins/mermaid/MermaidRendererImpl.d.ts +1 -2
- package/dist/Plugins/mermaid/style.d.ts +3 -0
- package/dist/Plugins/mermaid/style.js +5 -2
- package/dist/Plugins/mermaid/utils.js +1 -1
- package/dist/Quote/style.d.ts +3 -0
- package/dist/Schema/SchemaEditor/style.d.ts +3 -0
- package/dist/TaskList/index.d.ts +1 -1
- package/dist/TaskList/style.d.ts +3 -0
- package/dist/ThoughtChainList/DotAni/index.d.ts +1 -2
- package/dist/ThoughtChainList/DotAni/style.d.ts +3 -0
- package/dist/ThoughtChainList/style.d.ts +3 -0
- package/dist/ToolUseBar/style.d.ts +3 -0
- package/dist/ToolUseBarThink/style.d.ts +3 -0
- package/dist/WelcomeMessage/style.d.ts +3 -0
- package/dist/Workspace/Browser/style.d.ts +3 -0
- package/dist/Workspace/File/style.d.ts +3 -0
- package/dist/Workspace/HtmlPreview/style.d.ts +3 -0
- package/dist/Workspace/RealtimeFollow/style.d.ts +3 -0
- package/dist/Workspace/Task/style.d.ts +3 -0
- package/dist/Workspace/style.d.ts +3 -0
- package/package.json +1 -1
- package/dist/MarkdownEditor/editor/elements/LinkCard/style.d.ts +0 -10
- package/dist/MarkdownEditor/editor/elements/LinkCard/style.js +0 -136
- package/dist/MarkdownEditor/editor/elements/List/style.d.ts +0 -10
- package/dist/MarkdownEditor/editor/elements/List/style.js +0 -139
- package/dist/MarkdownEditor/editor/elements/Mermaid/style.d.ts +0 -10
- package/dist/MarkdownEditor/editor/elements/Mermaid/style.js +0 -144
- package/dist/MarkdownEditor/editor/elements/Table/TableCellIndex/style.d.ts +0 -10
- package/dist/MarkdownEditor/editor/elements/Table/TableCellIndex/style.js +0 -131
- package/dist/MarkdownEditor/editor/elements/Table/TableCellIndexSpacer/style.d.ts +0 -10
- package/dist/MarkdownEditor/editor/elements/Table/TableCellIndexSpacer/style.js +0 -125
- package/dist/MarkdownEditor/editor/elements/Table/TableRowIndex/style.d.ts +0 -10
- package/dist/MarkdownEditor/editor/elements/Table/TableRowIndex/style.js +0 -74
- package/dist/MarkdownEditor/editor/elements/Table/Td/style.d.ts +0 -10
- package/dist/MarkdownEditor/editor/elements/Table/Td/style.js +0 -93
- package/dist/MarkdownEditor/editor/elements/Table/style.d.ts +0 -11
- package/dist/MarkdownEditor/editor/elements/Table/style.js +0 -255
- package/dist/MarkdownEditor/editor/elements/TagPopup/style.d.ts +0 -5
- package/dist/MarkdownEditor/editor/elements/TagPopup/style.js +0 -111
|
@@ -50,6 +50,42 @@ function _object_spread_props(target, source) {
|
|
|
50
50
|
}
|
|
51
51
|
return target;
|
|
52
52
|
}
|
|
53
|
+
function _object_without_properties(source, excluded) {
|
|
54
|
+
if (source == null) return {};
|
|
55
|
+
var target = {}, sourceKeys, key, i;
|
|
56
|
+
if (typeof Reflect !== "undefined" && Reflect.ownKeys) {
|
|
57
|
+
sourceKeys = Reflect.ownKeys(source);
|
|
58
|
+
for(i = 0; i < sourceKeys.length; i++){
|
|
59
|
+
key = sourceKeys[i];
|
|
60
|
+
if (excluded.indexOf(key) >= 0) continue;
|
|
61
|
+
if (!Object.prototype.propertyIsEnumerable.call(source, key)) continue;
|
|
62
|
+
target[key] = source[key];
|
|
63
|
+
}
|
|
64
|
+
return target;
|
|
65
|
+
}
|
|
66
|
+
target = _object_without_properties_loose(source, excluded);
|
|
67
|
+
if (Object.getOwnPropertySymbols) {
|
|
68
|
+
sourceKeys = Object.getOwnPropertySymbols(source);
|
|
69
|
+
for(i = 0; i < sourceKeys.length; i++){
|
|
70
|
+
key = sourceKeys[i];
|
|
71
|
+
if (excluded.indexOf(key) >= 0) continue;
|
|
72
|
+
if (!Object.prototype.propertyIsEnumerable.call(source, key)) continue;
|
|
73
|
+
target[key] = source[key];
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
return target;
|
|
77
|
+
}
|
|
78
|
+
function _object_without_properties_loose(source, excluded) {
|
|
79
|
+
if (source == null) return {};
|
|
80
|
+
var target = {}, sourceKeys = Object.getOwnPropertyNames(source), key, i;
|
|
81
|
+
for(i = 0; i < sourceKeys.length; i++){
|
|
82
|
+
key = sourceKeys[i];
|
|
83
|
+
if (excluded.indexOf(key) >= 0) continue;
|
|
84
|
+
if (!Object.prototype.propertyIsEnumerable.call(source, key)) continue;
|
|
85
|
+
target[key] = source[key];
|
|
86
|
+
}
|
|
87
|
+
return target;
|
|
88
|
+
}
|
|
53
89
|
import { ConfigProvider } from "antd";
|
|
54
90
|
import classNames from "classnames";
|
|
55
91
|
import React, { useContext } from "react";
|
|
@@ -151,61 +187,58 @@ var MElementComponent = function(props) {
|
|
|
151
187
|
readonly: props.readonly,
|
|
152
188
|
hasChildren: !!props.children
|
|
153
189
|
});
|
|
190
|
+
// 只读时 omit deps,减少 props 变更面,利于 Readonly* 的 memo
|
|
191
|
+
// eslint-disable-next-line @typescript-eslint/no-unused-vars -- 仅用于从 spread 中排除
|
|
192
|
+
var deps = props.deps, readonlyElementProps = _object_without_properties(props, [
|
|
193
|
+
"deps"
|
|
194
|
+
]);
|
|
154
195
|
// 表格元素特殊处理(tableRenderElement 内部已处理 readonly)
|
|
155
196
|
var tableDom = tableRenderElement(props, {
|
|
156
197
|
readonly: props.readonly
|
|
157
198
|
});
|
|
158
199
|
if (tableDom) {
|
|
159
|
-
debugInfo('MElementComponent - 使用表格渲染', {
|
|
160
|
-
elementType: props.element.type,
|
|
161
|
-
readonly: props.readonly
|
|
162
|
-
});
|
|
163
200
|
return tableDom;
|
|
164
201
|
}
|
|
165
|
-
debugInfo('MElementComponent - 选择元素渲染器', {
|
|
166
|
-
elementType: props.element.type,
|
|
167
|
-
readonly: props.readonly
|
|
168
|
-
});
|
|
169
202
|
// 统一处理预览/编辑模式切换
|
|
170
203
|
switch(props.element.type){
|
|
171
204
|
case 'link-card':
|
|
172
|
-
return props.readonly ? /*#__PURE__*/ React.createElement(ReadonlyLinkCard,
|
|
205
|
+
return props.readonly ? /*#__PURE__*/ React.createElement(ReadonlyLinkCard, readonlyElementProps) : /*#__PURE__*/ React.createElement(LinkCard, props);
|
|
173
206
|
case 'blockquote':
|
|
174
|
-
return props.readonly ? /*#__PURE__*/ React.createElement(ReadonlyBlockquote,
|
|
207
|
+
return props.readonly ? /*#__PURE__*/ React.createElement(ReadonlyBlockquote, readonlyElementProps) : /*#__PURE__*/ React.createElement(Blockquote, props);
|
|
175
208
|
case 'head':
|
|
176
|
-
return props.readonly ? /*#__PURE__*/ React.createElement(ReadonlyHead,
|
|
209
|
+
return props.readonly ? /*#__PURE__*/ React.createElement(ReadonlyHead, readonlyElementProps) : /*#__PURE__*/ React.createElement(Head, props);
|
|
177
210
|
case 'hr':
|
|
178
|
-
return props.readonly ? /*#__PURE__*/ React.createElement(ReadonlyHr,
|
|
211
|
+
return props.readonly ? /*#__PURE__*/ React.createElement(ReadonlyHr, readonlyElementProps) : /*#__PURE__*/ React.createElement(Hr, props);
|
|
179
212
|
case 'break':
|
|
180
|
-
return props.readonly ? /*#__PURE__*/ React.createElement(ReadonlyBreak,
|
|
213
|
+
return props.readonly ? /*#__PURE__*/ React.createElement(ReadonlyBreak, readonlyElementProps) : /*#__PURE__*/ React.createElement(Break, props);
|
|
181
214
|
case 'katex':
|
|
182
|
-
return props.readonly ? /*#__PURE__*/ React.createElement(ReadonlyKatex,
|
|
215
|
+
return props.readonly ? /*#__PURE__*/ React.createElement(ReadonlyKatex, readonlyElementProps) : /*#__PURE__*/ React.createElement(Katex, props);
|
|
183
216
|
case 'inline-katex':
|
|
184
|
-
return props.readonly ? /*#__PURE__*/ React.createElement(ReadonlyInlineKatex,
|
|
217
|
+
return props.readonly ? /*#__PURE__*/ React.createElement(ReadonlyInlineKatex, readonlyElementProps) : /*#__PURE__*/ React.createElement(InlineKatex, props);
|
|
185
218
|
case 'mermaid':
|
|
186
|
-
return props.readonly ? /*#__PURE__*/ React.createElement(ReadonlyMermaid,
|
|
219
|
+
return props.readonly ? /*#__PURE__*/ React.createElement(ReadonlyMermaid, readonlyElementProps) : /*#__PURE__*/ React.createElement(Mermaid, props);
|
|
187
220
|
case 'code':
|
|
188
|
-
return props.readonly ? /*#__PURE__*/ React.createElement(ReadonlyCode,
|
|
221
|
+
return props.readonly ? /*#__PURE__*/ React.createElement(ReadonlyCode, readonlyElementProps) : /*#__PURE__*/ React.createElement(Code, props);
|
|
189
222
|
case 'list-item':
|
|
190
|
-
return props.readonly ? /*#__PURE__*/ React.createElement(ReadonlyListItem,
|
|
223
|
+
return props.readonly ? /*#__PURE__*/ React.createElement(ReadonlyListItem, readonlyElementProps) : /*#__PURE__*/ React.createElement(ListItem, props);
|
|
191
224
|
case 'bulleted-list':
|
|
192
225
|
case 'numbered-list':
|
|
193
226
|
case 'list':
|
|
194
|
-
return props.readonly ? /*#__PURE__*/ React.createElement(ReadonlyList,
|
|
227
|
+
return props.readonly ? /*#__PURE__*/ React.createElement(ReadonlyList, readonlyElementProps) : /*#__PURE__*/ React.createElement(List, props);
|
|
195
228
|
case 'schema':
|
|
196
229
|
case 'apassify':
|
|
197
230
|
case 'apaasify':
|
|
198
|
-
return props.readonly ? /*#__PURE__*/ React.createElement(ReadonlySchema,
|
|
231
|
+
return props.readonly ? /*#__PURE__*/ React.createElement(ReadonlySchema, readonlyElementProps) : /*#__PURE__*/ React.createElement(Schema, props);
|
|
199
232
|
case 'image':
|
|
200
|
-
return props.readonly ? /*#__PURE__*/ React.createElement(ReadonlyEditorImage,
|
|
233
|
+
return props.readonly ? /*#__PURE__*/ React.createElement(ReadonlyEditorImage, readonlyElementProps) : /*#__PURE__*/ React.createElement(EditorImage, props);
|
|
201
234
|
case 'media':
|
|
202
|
-
return props.readonly ? /*#__PURE__*/ React.createElement(ReadonlyMedia,
|
|
235
|
+
return props.readonly ? /*#__PURE__*/ React.createElement(ReadonlyMedia, readonlyElementProps) : /*#__PURE__*/ React.createElement(Media, props);
|
|
203
236
|
case 'footnoteDefinition':
|
|
204
|
-
return props.readonly ? /*#__PURE__*/ React.createElement(ReadonlyFootnoteDefinition,
|
|
237
|
+
return props.readonly ? /*#__PURE__*/ React.createElement(ReadonlyFootnoteDefinition, readonlyElementProps) : /*#__PURE__*/ React.createElement(FootnoteDefinition, props);
|
|
205
238
|
case 'footnoteReference':
|
|
206
|
-
return props.readonly ? /*#__PURE__*/ React.createElement(ReadonlyFootnoteReference,
|
|
239
|
+
return props.readonly ? /*#__PURE__*/ React.createElement(ReadonlyFootnoteReference, readonlyElementProps) : /*#__PURE__*/ React.createElement(FootnoteReference, props);
|
|
207
240
|
case 'card':
|
|
208
|
-
return props.readonly ? /*#__PURE__*/ React.createElement(ReadonlyCard,
|
|
241
|
+
return props.readonly ? /*#__PURE__*/ React.createElement(ReadonlyCard, readonlyElementProps) : /*#__PURE__*/ React.createElement(WarpCard, props);
|
|
209
242
|
case 'card-before':
|
|
210
243
|
return /*#__PURE__*/ React.createElement("span", _object_spread({
|
|
211
244
|
style: {
|
|
@@ -235,15 +268,25 @@ var MElementComponent = function(props) {
|
|
|
235
268
|
"data-be": 'card-after'
|
|
236
269
|
}, props.attributes), props.children);
|
|
237
270
|
default:
|
|
238
|
-
|
|
239
|
-
elementType: props.element.type,
|
|
240
|
-
readonly: props.readonly
|
|
241
|
-
});
|
|
242
|
-
return props.readonly ? /*#__PURE__*/ React.createElement(ReadonlyParagraph, props) : /*#__PURE__*/ React.createElement(Paragraph, props);
|
|
271
|
+
return props.readonly ? /*#__PURE__*/ React.createElement(ReadonlyParagraph, readonlyElementProps) : /*#__PURE__*/ React.createElement(Paragraph, props);
|
|
243
272
|
}
|
|
244
273
|
};
|
|
245
274
|
// 使用 React.memo 优化 MElement 组件的性能
|
|
246
275
|
export var MElement = /*#__PURE__*/ React.memo(MElementComponent, areElementPropsEqual);
|
|
276
|
+
/**
|
|
277
|
+
* 比较函数,用于优化 MLeaf 组件的渲染性能。
|
|
278
|
+
* 只读模式下可忽略 tagInputProps。
|
|
279
|
+
*/ var areLeafPropsEqual = function(prev, next) {
|
|
280
|
+
if (prev.leaf !== next.leaf) return false;
|
|
281
|
+
if (prev.children !== next.children) return false;
|
|
282
|
+
if (prev.attributes !== next.attributes) return false;
|
|
283
|
+
if (prev.readonly !== next.readonly) return false;
|
|
284
|
+
if (!next.readonly && prev.tagInputProps !== next.tagInputProps) return false;
|
|
285
|
+
if (prev.fncProps !== next.fncProps) return false;
|
|
286
|
+
if (prev.comment !== next.comment) return false;
|
|
287
|
+
if (prev.linkConfig !== next.linkConfig) return false;
|
|
288
|
+
return true;
|
|
289
|
+
};
|
|
247
290
|
var MLeafComponent = function(props) {
|
|
248
291
|
var _leaf_text;
|
|
249
292
|
var _useEditorStore = useEditorStore(), markdownEditorRef = _useEditorStore.markdownEditorRef, markdownContainerRef = _useEditorStore.markdownContainerRef;
|
|
@@ -263,43 +306,23 @@ var MLeafComponent = function(props) {
|
|
|
263
306
|
text: (_leaf_text = leaf.text) === null || _leaf_text === void 0 ? void 0 : _leaf_text.substring(0, 50)
|
|
264
307
|
});
|
|
265
308
|
var style = {};
|
|
266
|
-
var prefixClassName = classNames(
|
|
309
|
+
var prefixClassName = classNames(mdEditorBaseClass);
|
|
267
310
|
var children = /*#__PURE__*/ React.createElement(React.Fragment, null, props.children);
|
|
268
311
|
if (leaf.code || leaf.tag) {
|
|
269
312
|
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;
|
|
270
313
|
var _ref1 = props.tagInputProps || {}, enable = _ref1.enable, tagTextRender = _ref1.tagTextRender;
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
tag: tag,
|
|
274
|
-
enable: enable,
|
|
275
|
-
hasTagTextRender: !!tagTextRender
|
|
276
|
-
});
|
|
277
|
-
if (enable && tag) {
|
|
278
|
-
debugInfo('MLeafComponent - 使用 TagPopup', {
|
|
279
|
-
text: text,
|
|
280
|
-
placeholder: placeholder,
|
|
281
|
-
autoOpen: autoOpen,
|
|
282
|
-
triggerText: triggerText
|
|
283
|
-
});
|
|
314
|
+
// 只读模式下不渲染 TagPopup 及 Transforms,仅展示 code 样式,提升性能
|
|
315
|
+
if (enable && tag && !props.readonly) {
|
|
284
316
|
children = /*#__PURE__*/ React.createElement(React.Fragment, null, /*#__PURE__*/ React.createElement(TagPopup, _object_spread_props(_object_spread(_object_spread_props(_object_spread({}, props), {
|
|
285
317
|
autoOpen: autoOpen
|
|
286
318
|
}), props.tagInputProps), {
|
|
287
319
|
text: text,
|
|
288
320
|
onSelect: function(v, path, tagNode) {
|
|
289
321
|
var _markdownContainerRef_current;
|
|
290
|
-
debugInfo('MLeafComponent - TagPopup onSelect', {
|
|
291
|
-
value: v,
|
|
292
|
-
path: path,
|
|
293
|
-
hasTagNode: !!tagNode
|
|
294
|
-
});
|
|
295
322
|
if (!v) return;
|
|
296
323
|
if (!(path === null || path === void 0 ? void 0 : path.length)) return;
|
|
297
324
|
if (!markdownEditorRef.current) return;
|
|
298
325
|
Editor.withoutNormalizing(markdownEditorRef.current, function() {
|
|
299
|
-
debugInfo('MLeafComponent - 更新标签节点', {
|
|
300
|
-
value: v,
|
|
301
|
-
path: path
|
|
302
|
-
});
|
|
303
326
|
var newText = (tagTextRender === null || tagTextRender === void 0 ? void 0 : tagTextRender(_object_spread_props(_object_spread({}, props, props.tagInputProps), {
|
|
304
327
|
text: v
|
|
305
328
|
}), "".concat(triggerText !== null && triggerText !== void 0 ? triggerText : '$').concat(v))) || "".concat(triggerText !== null && triggerText !== void 0 ? triggerText : '$').concat(v);
|
|
@@ -360,84 +383,55 @@ var MLeafComponent = function(props) {
|
|
|
360
383
|
placeholder: placeholder || (locale === null || locale === void 0 ? void 0 : locale['input.placeholder']) || '请输入'
|
|
361
384
|
}), children));
|
|
362
385
|
} else {
|
|
363
|
-
|
|
364
|
-
code: leaf.code,
|
|
365
|
-
tag: leaf.tag
|
|
366
|
-
});
|
|
386
|
+
prefixClassName = classNames(prefixClassName, mdEditorBaseClass + '-inline-code');
|
|
367
387
|
children = /*#__PURE__*/ React.createElement("code", {
|
|
368
|
-
className:
|
|
388
|
+
className: prefixClassName
|
|
369
389
|
}, children);
|
|
370
390
|
}
|
|
371
391
|
}
|
|
372
392
|
if (leaf.highColor) {
|
|
373
393
|
style.color = leaf.highColor;
|
|
374
|
-
debugInfo('MLeafComponent - 应用高亮颜色', {
|
|
375
|
-
color: leaf.highColor
|
|
376
|
-
});
|
|
377
394
|
}
|
|
378
395
|
if (leaf.color) {
|
|
379
396
|
style.color = leaf.color;
|
|
380
|
-
debugInfo('MLeafComponent - 应用颜色', {
|
|
381
|
-
color: leaf.color
|
|
382
|
-
});
|
|
383
397
|
}
|
|
384
398
|
if (leaf.bold) {
|
|
385
399
|
style.fontWeight = 'bold';
|
|
386
400
|
children = /*#__PURE__*/ React.createElement("span", {
|
|
387
401
|
"data-testid": "markdown-bold"
|
|
388
402
|
}, children);
|
|
389
|
-
debugInfo('MLeafComponent - 应用粗体');
|
|
390
403
|
}
|
|
391
404
|
if (leaf.strikethrough) {
|
|
392
405
|
children = /*#__PURE__*/ React.createElement("s", null, children);
|
|
393
|
-
debugInfo('MLeafComponent - 应用删除线');
|
|
394
406
|
}
|
|
395
407
|
if (leaf.italic) {
|
|
396
408
|
style.fontStyle = 'italic';
|
|
397
|
-
debugInfo('MLeafComponent - 应用斜体');
|
|
398
409
|
}
|
|
399
410
|
if (leaf.html) {
|
|
400
411
|
prefixClassName = classNames(prefixClassName, mdEditorBaseClass + '-m-html');
|
|
401
|
-
debugInfo('MLeafComponent - 应用 HTML 样式');
|
|
402
412
|
}
|
|
403
413
|
if (leaf.current) {
|
|
404
414
|
style.background = '#f59e0b';
|
|
405
|
-
debugInfo('MLeafComponent - 应用当前高亮');
|
|
406
415
|
}
|
|
407
416
|
var selectFormat = function() {
|
|
408
417
|
try {
|
|
409
|
-
debugInfo('MLeafComponent - selectFormat 调用');
|
|
410
418
|
if (EditorUtils.isDirtLeaf(props.leaf)) {
|
|
411
419
|
var path = ReactEditor.findPath(markdownEditorRef.current, props.text);
|
|
412
|
-
debugInfo('MLeafComponent - 选择格式路径', {
|
|
413
|
-
path: path
|
|
414
|
-
});
|
|
415
420
|
if (path) {
|
|
416
421
|
Transforms.select(markdownEditorRef.current, {
|
|
417
422
|
anchor: Editor.start(markdownEditorRef.current, path),
|
|
418
423
|
focus: Editor.end(markdownEditorRef.current, path)
|
|
419
424
|
});
|
|
420
|
-
debugInfo('MLeafComponent - 格式选择完成');
|
|
421
425
|
}
|
|
422
426
|
}
|
|
423
|
-
} catch (e) {
|
|
424
|
-
debugInfo('MLeafComponent - selectFormat 错误', {
|
|
425
|
-
error: e
|
|
426
|
-
});
|
|
427
|
-
}
|
|
427
|
+
} catch (e) {}
|
|
428
428
|
};
|
|
429
429
|
// 如果检测到 fnc、identifier 或 fnd,使用 FncLeaf 组件
|
|
430
430
|
var hasFnc = leaf.fnc || leaf.identifier || leaf.fnd;
|
|
431
431
|
var hasComment = !!leaf.comment;
|
|
432
432
|
if (hasFnc) {
|
|
433
|
-
|
|
434
|
-
hasFnc: !!leaf.fnc,
|
|
435
|
-
hasIdentifier: !!leaf.identifier,
|
|
436
|
-
hasFnd: !!leaf.fnd
|
|
437
|
-
});
|
|
438
|
-
var baseClassName = classNames(prefixClassName === null || prefixClassName === void 0 ? void 0 : prefixClassName.trim(), props.hashId);
|
|
433
|
+
var baseClassName = classNames(prefixClassName === null || prefixClassName === void 0 ? void 0 : prefixClassName.trim());
|
|
439
434
|
var fncDom = /*#__PURE__*/ React.createElement(FncLeaf, _object_spread_props(_object_spread({}, props), {
|
|
440
|
-
hashId: props.hashId,
|
|
441
435
|
fncProps: props.fncProps,
|
|
442
436
|
linkConfig: props.linkConfig,
|
|
443
437
|
style: style,
|
|
@@ -447,47 +441,32 @@ var MLeafComponent = function(props) {
|
|
|
447
441
|
if (hasComment) {
|
|
448
442
|
return /*#__PURE__*/ React.createElement(CommentLeaf, {
|
|
449
443
|
leaf: props.leaf,
|
|
450
|
-
hashId: props.hashId,
|
|
451
444
|
comment: props.comment
|
|
452
445
|
}, fncDom);
|
|
453
446
|
}
|
|
454
447
|
return fncDom;
|
|
455
448
|
}
|
|
456
|
-
var baseClassName1 = classNames(prefixClassName === null || prefixClassName === void 0 ? void 0 : prefixClassName.trim()
|
|
449
|
+
var baseClassName1 = classNames(prefixClassName === null || prefixClassName === void 0 ? void 0 : prefixClassName.trim());
|
|
457
450
|
var dom = /*#__PURE__*/ React.createElement("span", _object_spread_props(_object_spread({}, props.attributes), {
|
|
458
451
|
"data-be": "text",
|
|
459
452
|
draggable: false,
|
|
460
453
|
onDragStart: dragStart,
|
|
461
454
|
onClick: function(e) {
|
|
462
455
|
var _props_linkConfig, _props_linkConfig1, _props_linkConfig2;
|
|
463
|
-
|
|
464
|
-
detail: e.detail,
|
|
465
|
-
hasUrl: !!leaf.url
|
|
466
|
-
});
|
|
467
|
-
if (e.detail === 2) {
|
|
468
|
-
debugInfo('MLeafComponent - 双击选择格式');
|
|
456
|
+
if (e.detail === 2 && !props.readonly) {
|
|
469
457
|
selectFormat();
|
|
470
458
|
}
|
|
471
459
|
if ((_props_linkConfig = props.linkConfig) === null || _props_linkConfig === void 0 ? void 0 : _props_linkConfig.onClick) {
|
|
472
460
|
var _props_linkConfig3;
|
|
473
461
|
var res = (_props_linkConfig3 = props.linkConfig) === null || _props_linkConfig3 === void 0 ? void 0 : _props_linkConfig3.onClick(leaf.url);
|
|
474
|
-
debugInfo('MLeafComponent - 链接点击处理', {
|
|
475
|
-
result: res
|
|
476
|
-
});
|
|
477
462
|
if (res === false) {
|
|
478
463
|
return;
|
|
479
464
|
}
|
|
480
465
|
}
|
|
481
466
|
if (leaf.url && ((_props_linkConfig1 = props.linkConfig) === null || _props_linkConfig1 === void 0 ? void 0 : _props_linkConfig1.openInNewTab) !== false) {
|
|
482
|
-
debugInfo('MLeafComponent - 新标签页打开链接', {
|
|
483
|
-
url: leaf.url
|
|
484
|
-
});
|
|
485
467
|
window.open(leaf.url, '_blank');
|
|
486
468
|
}
|
|
487
469
|
if (leaf.url && ((_props_linkConfig2 = props.linkConfig) === null || _props_linkConfig2 === void 0 ? void 0 : _props_linkConfig2.openInNewTab) === false) {
|
|
488
|
-
debugInfo('MLeafComponent - 当前窗口打开链接', {
|
|
489
|
-
url: leaf.url
|
|
490
|
-
});
|
|
491
470
|
window.location.href = leaf.url;
|
|
492
471
|
}
|
|
493
472
|
},
|
|
@@ -500,13 +479,12 @@ var MLeafComponent = function(props) {
|
|
|
500
479
|
if (hasComment) {
|
|
501
480
|
return /*#__PURE__*/ React.createElement(CommentLeaf, {
|
|
502
481
|
leaf: props.leaf,
|
|
503
|
-
hashId: props.hashId,
|
|
504
482
|
comment: props.comment
|
|
505
483
|
}, dom);
|
|
506
484
|
}
|
|
507
485
|
return dom;
|
|
508
486
|
};
|
|
509
487
|
// 使用 React.memo 优化 MLeaf 组件的性能
|
|
510
|
-
export var MLeaf = /*#__PURE__*/ React.memo(MLeafComponent);
|
|
488
|
+
export var MLeaf = /*#__PURE__*/ React.memo(MLeafComponent, areLeafPropsEqual);
|
|
511
489
|
export { Blockquote, Break, Code, Head, Hr, InlineKatex, Katex, List, ListItem, Media, Mermaid, Paragraph, // 预览组件导出
|
|
512
490
|
ReadonlyBlockquote, ReadonlyBreak, ReadonlyCard, ReadonlyCode, ReadonlyEditorImage, ReadonlyFootnoteDefinition, ReadonlyFootnoteReference, ReadonlyHead, ReadonlyHr, ReadonlyInlineKatex, ReadonlyKatex, ReadonlyLinkCard, ReadonlyList, ReadonlyListItem, ReadonlyMedia, ReadonlyMermaid, ReadonlyParagraph, ReadonlySchema, ReadonlyTableComponent, Schema };
|
|
@@ -21,15 +21,16 @@ export declare const getColumnAlignment: (data: any[], columns: {
|
|
|
21
21
|
/**
|
|
22
22
|
* 解析表格或图表
|
|
23
23
|
* @param table - 表格 AST 节点
|
|
24
|
-
* @param preNode -
|
|
24
|
+
* @param preNode - 前一个节点(实际传入的是 Slate 的 preElement,即上一轮 push 到 els 的节点)
|
|
25
25
|
* @param plugins - 插件数组
|
|
26
26
|
* @param parseNodes - 解析节点的函数,用于解析单元格内容
|
|
27
27
|
* @param parserConfig - 解析配置
|
|
28
|
+
* @param contextChartConfig - 由上一条 HTML 注释(<!-- [{"chartType":...}] -->)解析得到的配置;当 preNode 无 html 配置且注释被 skip 时由此传入
|
|
28
29
|
* @returns 返回表格或图表节点
|
|
29
30
|
*/
|
|
30
31
|
export declare const parseTableOrChart: (table: Table & {
|
|
31
32
|
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
|
+
}, preNode: RootContent, plugins: MarkdownEditorPlugin[], parseNodes: (nodes: RootContent[], plugins: MarkdownEditorPlugin[], top?: boolean, parent?: RootContent, parserConfig?: ParserMarkdownToSlateNodeConfig) => (Elements | any)[], parserConfig?: ParserMarkdownToSlateNodeConfig, contextChartConfig?: Record<string, unknown>) => CardNode | Elements;
|
|
33
34
|
/**
|
|
34
35
|
* 预处理 Markdown 表格换行符
|
|
35
36
|
* @param markdown - 原始 Markdown 字符串
|
|
@@ -145,15 +145,26 @@ var myRemark = {
|
|
|
145
145
|
/**
|
|
146
146
|
* 解析表格或图表
|
|
147
147
|
* @param table - 表格 AST 节点
|
|
148
|
-
* @param preNode -
|
|
148
|
+
* @param preNode - 前一个节点(实际传入的是 Slate 的 preElement,即上一轮 push 到 els 的节点)
|
|
149
149
|
* @param plugins - 插件数组
|
|
150
150
|
* @param parseNodes - 解析节点的函数,用于解析单元格内容
|
|
151
151
|
* @param parserConfig - 解析配置
|
|
152
|
+
* @param contextChartConfig - 由上一条 HTML 注释(<!-- [{"chartType":...}] -->)解析得到的配置;当 preNode 无 html 配置且注释被 skip 时由此传入
|
|
152
153
|
* @returns 返回表格或图表节点
|
|
153
|
-
*/ export var parseTableOrChart = function(table, preNode, plugins, parseNodes, parserConfig) {
|
|
154
|
+
*/ export var parseTableOrChart = function(table, preNode, plugins, parseNodes, parserConfig, contextChartConfig) {
|
|
154
155
|
var _table_children, _tableHeader_children, _table_children_slice, _table_children1, _table_align;
|
|
155
156
|
var keyMap = new Map();
|
|
156
|
-
|
|
157
|
+
// 优先使用前一个 HTML 代码块的 otherProps;若 HTML 注释被 skip(不产出 code 节点),则使用 contextChartConfig
|
|
158
|
+
//
|
|
159
|
+
// 【为何 preNode 里常常拿不到图表配置】
|
|
160
|
+
// preNode 实际是上一轮产出的 Slate 节点(preElement)。当上一条是 <!-- [{"chartType":...}] -->
|
|
161
|
+
// 时,该注释在 parseNodes 里被 continue 掉,不生成任何 el,preElement 不会更新为 code 节点,
|
|
162
|
+
// 表格看到的「前一个」仍是再上一轮的 paragraph/heading 等,type 非 'code',无 otherProps,
|
|
163
|
+
// 故此处 config 为空。图表配置已放在 contextProps 中,由 table handler 以 contextChartConfig 传入。
|
|
164
|
+
var config = (preNode === null || preNode === void 0 ? void 0 : preNode.type) === 'code' && (preNode === null || preNode === void 0 ? void 0 : preNode.language) === 'html' && (preNode === null || preNode === void 0 ? void 0 : preNode.otherProps) ? preNode === null || preNode === void 0 ? void 0 : preNode.otherProps : {};
|
|
165
|
+
if (Object.keys(config).length === 0 && contextChartConfig && (contextChartConfig.config || (contextChartConfig === null || contextChartConfig === void 0 ? void 0 : contextChartConfig.chartType))) {
|
|
166
|
+
config = contextChartConfig;
|
|
167
|
+
}
|
|
157
168
|
var tableHeader = table === null || table === void 0 ? void 0 : (_table_children = table.children) === null || _table_children === void 0 ? void 0 : _table_children.at(0);
|
|
158
169
|
var columns = (tableHeader === null || tableHeader === void 0 ? void 0 : (_tableHeader_children = tableHeader.children) === null || _tableHeader_children === void 0 ? void 0 : _tableHeader_children.map(function(node) {
|
|
159
170
|
var _myRemark_stringify;
|
|
@@ -190,10 +190,10 @@ var parseCache = new Map();
|
|
|
190
190
|
var configStr = config ? JSON.stringify(config) : '';
|
|
191
191
|
var pluginsCount = (plugins === null || plugins === void 0 ? void 0 : plugins.length) || 0;
|
|
192
192
|
var configHash = simpleHash("".concat(configStr, "_").concat(pluginsCount));
|
|
193
|
-
return mergedBlocks.map(function(content) {
|
|
193
|
+
return mergedBlocks.map(function(content, index) {
|
|
194
194
|
return {
|
|
195
195
|
content: content,
|
|
196
|
-
hash: "".concat(simpleHash(content), "_").concat(configHash)
|
|
196
|
+
hash: "".concat(simpleHash(content), "_").concat(configHash, "_").concat(index)
|
|
197
197
|
};
|
|
198
198
|
});
|
|
199
199
|
};
|
|
@@ -293,6 +293,14 @@ var removeAnswerTags = function(text) {
|
|
|
293
293
|
// 同时将属性作为 config 传递,以便 applyContextPropsAndConfig 设置 otherProps
|
|
294
294
|
config = _object_spread({}, config, htmlCommentProps);
|
|
295
295
|
// 跳过 HTML 注释本身,避免生成独立的 HTML 代码节点
|
|
296
|
+
//
|
|
297
|
+
// 【为何 preNode 里拿不到图表配置】
|
|
298
|
+
// continue 后不会 push 任何 el,也不会执行 preNode=currentElement、preElement=el。
|
|
299
|
+
// 下一轮处理表格时,preElement 仍是「注释前」的节点(如 paragraph/heading),
|
|
300
|
+
// 不可能是 type='code' 且 language='html' 的节点,parseTableOrChart 里
|
|
301
|
+
// 从 preNode(实为 preElement)取 otherProps 会得到 {}。
|
|
302
|
+
// 因此图表配置必须通过 contextProps → config,由 table handler 以
|
|
303
|
+
// contextChartConfig 传入 parseTableOrChart。
|
|
296
304
|
return "continue";
|
|
297
305
|
}
|
|
298
306
|
// 如果当前元素应该使用 contextProps 中的属性作为 config(用于设置 otherProps)
|
|
@@ -486,8 +494,10 @@ var removeAnswerTags = function(text) {
|
|
|
486
494
|
}
|
|
487
495
|
},
|
|
488
496
|
table: {
|
|
489
|
-
|
|
490
|
-
|
|
497
|
+
// 传入 config:当上一条是图表注释且被 continue 掉时,config 来自 contextProps,
|
|
498
|
+
// 作为 contextChartConfig 供 parseTableOrChart 在 preNode 无 html 配置时使用
|
|
499
|
+
handler: function(el, _plugins, config, parent, _htmlTag, preElement) {
|
|
500
|
+
return parseTableOrChart(el, preElement || parent, _this.plugins, parseNodesForTable, _this.config, config);
|
|
491
501
|
}
|
|
492
502
|
}
|
|
493
503
|
};
|
|
@@ -593,9 +603,9 @@ var removeAnswerTags = function(text) {
|
|
|
593
603
|
var blockHash = ((_blocks_ = blocks[0]) === null || _blocks_ === void 0 ? void 0 : _blocks_.hash) || simpleHash(md || '');
|
|
594
604
|
// 为 schema 元素添加 hash
|
|
595
605
|
return {
|
|
596
|
-
schema: result.schema.map(function(s) {
|
|
606
|
+
schema: result.schema.map(function(s, index) {
|
|
597
607
|
return _object_spread_props(_object_spread({}, s), {
|
|
598
|
-
hash: blockHash
|
|
608
|
+
hash: blockHash + '-' + index
|
|
599
609
|
});
|
|
600
610
|
}),
|
|
601
611
|
links: result.links
|
|
@@ -102,6 +102,8 @@ import { useEditorStore } from "../store";
|
|
|
102
102
|
var match = new MatchKey(markdownEditorRef.current);
|
|
103
103
|
return function(e) {
|
|
104
104
|
var _props_markdown, _node_;
|
|
105
|
+
// 只读模式下跳过所有键盘处理,提升性能
|
|
106
|
+
if (props.readonly) return;
|
|
105
107
|
// 处理表格键盘事件
|
|
106
108
|
if (NativeTableKeyboard.shouldHandle(markdownEditorRef.current)) {
|
|
107
109
|
if (NativeTableKeyboard.handleKeyDown(markdownEditorRef.current, e.nativeEvent)) {
|
|
@@ -250,6 +252,7 @@ import { useEditorStore } from "../store";
|
|
|
250
252
|
}
|
|
251
253
|
};
|
|
252
254
|
}, [
|
|
253
|
-
markdownEditorRef.current
|
|
255
|
+
markdownEditorRef.current,
|
|
256
|
+
props === null || props === void 0 ? void 0 : props.readonly
|
|
254
257
|
]);
|
|
255
258
|
};
|
|
@@ -205,9 +205,15 @@ var floatBarIgnoreNode = new Set([
|
|
|
205
205
|
});
|
|
206
206
|
})();
|
|
207
207
|
}, 16);
|
|
208
|
-
var _useEditorStore = useEditorStore(), setRefreshFloatBar = _useEditorStore.setRefreshFloatBar, setDomRect = _useEditorStore.setDomRect, refreshFloatBar = _useEditorStore.refreshFloatBar;
|
|
208
|
+
var _useEditorStore = useEditorStore(), setRefreshFloatBar = _useEditorStore.setRefreshFloatBar, setDomRect = _useEditorStore.setDomRect, refreshFloatBar = _useEditorStore.refreshFloatBar, readonly = _useEditorStore.readonly;
|
|
209
209
|
return React.useMemo(function() {
|
|
210
210
|
return function(_value, _operations) {
|
|
211
|
+
// 只读且仅选区变化时,跳过 Editor.nodes、selChange$、setDomRect 等,提升性能
|
|
212
|
+
if (readonly && _operations.every(function(o) {
|
|
213
|
+
return o.type === 'set_selection';
|
|
214
|
+
})) {
|
|
215
|
+
return;
|
|
216
|
+
}
|
|
211
217
|
if (onChangeDebounce && _operations.some(function(o) {
|
|
212
218
|
return o.type !== 'set_selection';
|
|
213
219
|
})) {
|
|
@@ -263,6 +269,7 @@ var floatBarIgnoreNode = new Set([
|
|
|
263
269
|
} catch (error) {}
|
|
264
270
|
};
|
|
265
271
|
}, [
|
|
266
|
-
editor
|
|
272
|
+
editor,
|
|
273
|
+
readonly
|
|
267
274
|
]);
|
|
268
275
|
}
|
|
@@ -1522,7 +1522,7 @@ export var EditorStoreContext = createContext(null);
|
|
|
1522
1522
|
*/ function executeOperations(operations) {
|
|
1523
1523
|
var editor = this._editor.current;
|
|
1524
1524
|
if (!editor) return;
|
|
1525
|
-
//
|
|
1525
|
+
// 使用批处理模式执行所有操作,避免中间状态导致路径变化
|
|
1526
1526
|
Editor.withoutNormalizing(editor, function() {
|
|
1527
1527
|
var _iteratorNormalCompletion = true, _didIteratorError = false, _iteratorError = undefined;
|
|
1528
1528
|
try {
|
|
@@ -1532,9 +1532,12 @@ export var EditorStoreContext = createContext(null);
|
|
|
1532
1532
|
switch(op.type){
|
|
1533
1533
|
case 'insert':
|
|
1534
1534
|
if (op.node && editor.hasPath(Path.parent(op.path))) {
|
|
1535
|
-
|
|
1536
|
-
|
|
1537
|
-
|
|
1535
|
+
// 检查路径是否仍然有效,避免重复插入
|
|
1536
|
+
if (!editor.hasPath(op.path)) {
|
|
1537
|
+
Transforms.insertNodes(editor, op.node, {
|
|
1538
|
+
at: op.path
|
|
1539
|
+
});
|
|
1540
|
+
}
|
|
1538
1541
|
}
|
|
1539
1542
|
break;
|
|
1540
1543
|
case 'remove':
|
|
@@ -7,6 +7,9 @@ import './code.css';
|
|
|
7
7
|
* @returns
|
|
8
8
|
*/
|
|
9
9
|
export declare function useStyle(prefixCls: string, propsToken: Partial<ChatTokenType>): {
|
|
10
|
+
hashId: string;
|
|
10
11
|
wrapSSR: (node: import("react").ReactElement<any, string | import("react").JSXElementConstructor<any>>) => import("react").JSX.Element;
|
|
12
|
+
} | {
|
|
13
|
+
wrapSSR: (node: any) => any;
|
|
11
14
|
hashId: string;
|
|
12
15
|
};
|
|
@@ -172,8 +172,7 @@ var fileMap = new Map();
|
|
|
172
172
|
},
|
|
173
173
|
className: classNames(baseClassName, hashId)
|
|
174
174
|
}, props.readonly ? /*#__PURE__*/ React.createElement(ReadonlyBaseBar, {
|
|
175
|
-
prefix: baseClassName
|
|
176
|
-
hashId: hashId
|
|
175
|
+
prefix: baseClassName
|
|
177
176
|
}) : /*#__PURE__*/ React.createElement(BaseToolBar, {
|
|
178
177
|
prefix: baseClassName,
|
|
179
178
|
hashId: hashId
|
|
@@ -187,7 +187,6 @@ import { getPointStrOffset, getSelectionFromDomSelection } from "../../utils/edi
|
|
|
187
187
|
* @returns
|
|
188
188
|
*/ export var ReadonlyBaseBar = function(props) {
|
|
189
189
|
var baseClassName = props.prefix || "toolbar-action";
|
|
190
|
-
var hashId = props.hashId;
|
|
191
190
|
var _useEditorStore = useEditorStore(), refreshFloatBar = _useEditorStore.refreshFloatBar, markdownEditorRef = _useEditorStore.markdownEditorRef, editorProps = _useEditorStore.editorProps;
|
|
192
191
|
var _React_useState = _sliced_to_array(React.useState(false), 2), setRefresh = _React_useState[1];
|
|
193
192
|
useEffect(function() {
|
|
@@ -213,7 +212,7 @@ import { getPointStrOffset, getSelectionFromDomSelection } from "../../utils/edi
|
|
|
213
212
|
list.push(/*#__PURE__*/ React.createElement("div", {
|
|
214
213
|
role: "button",
|
|
215
214
|
key: "highlight",
|
|
216
|
-
className: classnames("".concat(baseClassName, "-item")
|
|
215
|
+
className: classnames("".concat(baseClassName, "-item")),
|
|
217
216
|
onClick: function() {
|
|
218
217
|
return _async_to_generator(function() {
|
|
219
218
|
var _editorProps_comment_onSubmit, _editorProps_comment, domSelection, editor, selection, texts, title, fragments, i, _iteratorNormalCompletion, _didIteratorError, _iteratorError, _iterator, _step, str, focus, anchor, _ref, start, end, anchorOffset, focusOffset, comment;
|
|
@@ -309,7 +308,7 @@ import { getPointStrOffset, getSelectionFromDomSelection } from "../../utils/edi
|
|
|
309
308
|
list.push(/*#__PURE__*/ React.createElement("div", {
|
|
310
309
|
role: "button",
|
|
311
310
|
key: "comment",
|
|
312
|
-
className: classnames("".concat(baseClassName, "-item")
|
|
311
|
+
className: classnames("".concat(baseClassName, "-item")),
|
|
313
312
|
onClick: function() {
|
|
314
313
|
var _i18n_locale, _editorProps_comment, _i18n_locale1;
|
|
315
314
|
if (typeof window === 'undefined') return;
|
|
@@ -444,7 +443,7 @@ import { getPointStrOffset, getSelectionFromDomSelection } from "../../utils/edi
|
|
|
444
443
|
list.push(/*#__PURE__*/ React.createElement("div", {
|
|
445
444
|
role: "button",
|
|
446
445
|
key: "insert",
|
|
447
|
-
className: classnames("".concat(baseClassName, "-item")
|
|
446
|
+
className: classnames("".concat(baseClassName, "-item")),
|
|
448
447
|
onClick: function() {
|
|
449
448
|
var domSelection = window.getSelection();
|
|
450
449
|
var editor = markdownEditorRef.current;
|
|
@@ -5,6 +5,9 @@
|
|
|
5
5
|
* @returns
|
|
6
6
|
*/
|
|
7
7
|
export declare function useStyle(prefixCls?: string): {
|
|
8
|
+
hashId: string;
|
|
8
9
|
wrapSSR: (node: import("react").ReactElement<any, string | import("react").JSXElementConstructor<any>>) => import("react").JSX.Element;
|
|
10
|
+
} | {
|
|
11
|
+
wrapSSR: (node: any) => any;
|
|
9
12
|
hashId: string;
|
|
10
13
|
};
|
|
@@ -5,6 +5,9 @@
|
|
|
5
5
|
* @returns
|
|
6
6
|
*/
|
|
7
7
|
export declare function useStyle(prefixCls?: string): {
|
|
8
|
+
hashId: string;
|
|
8
9
|
wrapSSR: (node: import("react").ReactElement<any, string | import("react").JSXElementConstructor<any>>) => import("react").JSX.Element;
|
|
10
|
+
} | {
|
|
11
|
+
wrapSSR: (node: any) => any;
|
|
9
12
|
hashId: string;
|
|
10
13
|
};
|
|
@@ -5,6 +5,9 @@
|
|
|
5
5
|
* @returns
|
|
6
6
|
*/
|
|
7
7
|
export declare function useStyle(prefixCls?: string): {
|
|
8
|
+
hashId: string;
|
|
8
9
|
wrapSSR: (node: import("react").ReactElement<any, string | import("react").JSXElementConstructor<any>>) => import("react").JSX.Element;
|
|
10
|
+
} | {
|
|
11
|
+
wrapSSR: (node: any) => any;
|
|
9
12
|
hashId: string;
|
|
10
13
|
};
|