@ant-design/agentic-ui 2.30.20 → 2.30.21
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.
|
@@ -58,6 +58,19 @@ import { MatchKey } from "./hotKeyCommands/match";
|
|
|
58
58
|
import { TabKey } from "./hotKeyCommands/tab";
|
|
59
59
|
import { NativeTableKeyboard } from "../../utils/native-table";
|
|
60
60
|
import { useEditorStore } from "../store";
|
|
61
|
+
// Block types where plain Enter must be handled by EnterKey (not Slate's default insertBreak
|
|
62
|
+
// and not the outer MarkdownInputField send handler). These are blocks where entering would
|
|
63
|
+
// incorrectly split the node into two nodes with Slate's default behavior.
|
|
64
|
+
var SPECIAL_ENTER_BLOCK_TYPES = new Set([
|
|
65
|
+
'list-item',
|
|
66
|
+
'code',
|
|
67
|
+
'table-cell',
|
|
68
|
+
'head',
|
|
69
|
+
'blockquote',
|
|
70
|
+
'card-before',
|
|
71
|
+
'card-after',
|
|
72
|
+
'break'
|
|
73
|
+
]);
|
|
61
74
|
/**
|
|
62
75
|
* 键盘事件处理 Hook - 管理 Markdown 编辑器的所有键盘交互
|
|
63
76
|
*
|
|
@@ -215,27 +228,26 @@ import { useEditorStore } from "../store";
|
|
|
215
228
|
enter.run(e);
|
|
216
229
|
return;
|
|
217
230
|
}
|
|
218
|
-
// Enter 键(无 Shift
|
|
231
|
+
// Enter 键(无 Shift)处理:如果在特殊块类型中(列表项、代码块等),让 EnterKey 处理;否则由 MarkdownInputField 处理发送
|
|
219
232
|
if (e.key === 'Enter' && !(e.ctrlKey || e.metaKey) && !e.shiftKey) {
|
|
220
|
-
// 检查当前是否在列表项中
|
|
221
233
|
var selection1 = markdownEditorRef.current.selection;
|
|
222
234
|
if (selection1 && Range.isCollapsed(selection1)) {
|
|
223
235
|
var _Editor_nodes1 = _sliced_to_array(Editor.nodes(markdownEditorRef.current, {
|
|
224
236
|
at: selection1.focus.path,
|
|
225
237
|
match: function match(n) {
|
|
226
|
-
return Element.isElement(n) && n.type
|
|
238
|
+
return Element.isElement(n) && SPECIAL_ENTER_BLOCK_TYPES.has(n.type);
|
|
227
239
|
},
|
|
228
240
|
mode: 'lowest'
|
|
229
241
|
}), 1), node1 = _Editor_nodes1[0];
|
|
230
242
|
if (node1) {
|
|
231
|
-
//
|
|
243
|
+
// 在特殊块中,让 EnterKey 处理(如代码块插入换行、列表项创建新列表等)
|
|
232
244
|
e.stopPropagation();
|
|
233
245
|
e.preventDefault();
|
|
234
246
|
enter.run(e);
|
|
235
247
|
return;
|
|
236
248
|
}
|
|
237
249
|
}
|
|
238
|
-
//
|
|
250
|
+
// 不在特殊块中,让 MarkdownInputField 处理发送
|
|
239
251
|
return;
|
|
240
252
|
}
|
|
241
253
|
var _Editor_nodes2 = _sliced_to_array(Editor.nodes(markdownEditorRef.current, {
|