@ant-design/agentic-ui 2.30.22 → 2.30.24
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/Bubble/MessagesContent/MarkdownPreview.d.ts +0 -58
- package/dist/Bubble/MessagesContent/MarkdownPreview.js +79 -156
- package/dist/Hooks/useAutoScroll.js +6 -4
- package/dist/MarkdownEditor/BaseMarkdownEditor.d.ts +1 -50
- package/dist/MarkdownEditor/BaseMarkdownEditor.js +11 -55
- package/dist/MarkdownEditor/editor/Editor.js +11 -9
- package/dist/MarkdownEditor/editor/elements/Code/index.js +1 -0
- package/dist/MarkdownEditor/editor/plugins/elements.d.ts +2 -0
- package/dist/MarkdownEditor/editor/plugins/elements.js +4 -2
- package/dist/MarkdownEditor/editor/plugins/handlePaste.js +46 -35
- package/dist/MarkdownEditor/editor/plugins/hotKeyCommands/backspace.js +133 -133
- package/dist/MarkdownEditor/editor/plugins/hotKeyCommands/enter.js +156 -140
- package/dist/MarkdownEditor/editor/plugins/hotKeyCommands/match.d.ts +2 -1
- package/dist/MarkdownEditor/editor/plugins/hotKeyCommands/match.js +23 -4
- package/dist/MarkdownEditor/editor/plugins/hotKeyCommands/tab.js +40 -36
- package/dist/MarkdownEditor/editor/plugins/index.d.ts +1 -0
- package/dist/MarkdownEditor/editor/plugins/index.js +1 -0
- package/dist/MarkdownEditor/editor/plugins/useKeyboard.js +46 -44
- package/dist/MarkdownEditor/editor/plugins/withCodeTagPlugin.js +1 -13
- package/dist/MarkdownEditor/editor/plugins/withMarkdown.js +2 -1
- package/dist/MarkdownEditor/editor/plugins/withSanitizeInvalidChildren.d.ts +7 -0
- package/dist/MarkdownEditor/editor/plugins/withSanitizeInvalidChildren.js +217 -0
- package/dist/MarkdownEditor/editor/store.d.ts +3 -1
- package/dist/MarkdownEditor/editor/store.js +15 -29
- package/dist/MarkdownEditor/editor/utils/editorCommands.js +98 -17
- package/dist/MarkdownEditor/editor/utils/editorUtils.d.ts +11 -0
- package/dist/MarkdownEditor/editor/utils/editorUtils.js +43 -6
- package/dist/MarkdownEditor/editor/utils/keyboard.js +14 -12
- package/dist/MarkdownEditor/types.d.ts +36 -414
- package/dist/MarkdownEditor/types.js +1 -4
- package/dist/MarkdownInputField/MarkdownInputField.js +2 -0
- package/dist/MarkdownInputField/SendActions/index.js +7 -4
- package/dist/MarkdownInputField/SendButton/index.d.ts +6 -0
- package/dist/MarkdownInputField/SendButton/index.js +6 -0
- package/dist/MarkdownInputField/hooks/useMarkdownInputFieldHandlers.d.ts +2 -1
- package/dist/MarkdownInputField/hooks/useMarkdownInputFieldHandlers.js +6 -1
- package/dist/MarkdownRenderer/AnimationText.d.ts +1 -5
- package/dist/MarkdownRenderer/AnimationText.js +2 -8
- package/dist/MarkdownRenderer/CharacterQueue.d.ts +0 -2
- package/dist/MarkdownRenderer/CharacterQueue.js +2 -2
- package/dist/MarkdownRenderer/MarkdownRenderer.d.ts +1 -9
- package/dist/MarkdownRenderer/MarkdownRenderer.js +1 -9
- package/dist/MarkdownRenderer/StreamingCursor.d.ts +4 -0
- package/dist/MarkdownRenderer/StreamingCursor.js +20 -0
- package/dist/MarkdownRenderer/markdownReactShared.d.ts +8 -38
- package/dist/MarkdownRenderer/markdownReactShared.js +9 -45
- package/dist/MarkdownRenderer/renderers/ChartRenderer.js +9 -1
- package/dist/MarkdownRenderer/streaming/MarkdownBlockPiece.d.ts +1 -3
- package/dist/MarkdownRenderer/streaming/MarkdownBlockPiece.js +16 -28
- package/dist/MarkdownRenderer/style.js +18 -0
- package/dist/MarkdownRenderer/types.d.ts +14 -86
- package/dist/MarkdownRenderer/useStreaming.d.ts +1 -10
- package/dist/MarkdownRenderer/useStreaming.js +5 -13
- package/dist/ThoughtChainList/MarkdownEditor.d.ts +1 -35
- package/dist/ThoughtChainList/MarkdownEditor.js +5 -44
- package/dist/Workspace/RealtimeFollow/index.d.ts +3 -0
- package/dist/Workspace/RealtimeFollow/index.js +5 -3
- package/package.json +2 -2
|
@@ -202,15 +202,37 @@ export var EnterKey = /*#__PURE__*/ function() {
|
|
|
202
202
|
{
|
|
203
203
|
key: "empty",
|
|
204
204
|
value: function empty(e, path) {
|
|
205
|
+
var _this = this;
|
|
205
206
|
var _Editor_parent = _sliced_to_array(Editor.parent(this.editor, path), 2), parent = _Editor_parent[0], parentPath = _Editor_parent[1];
|
|
206
207
|
if (parent.type === 'blockquote') {
|
|
207
208
|
if (!Path.hasPrevious(path)) {
|
|
208
209
|
var hashNext = Editor.hasPath(this.editor, Path.next(path));
|
|
209
210
|
if (!hashNext) {
|
|
210
|
-
|
|
211
|
-
|
|
211
|
+
Editor.withoutNormalizing(this.editor, function() {
|
|
212
|
+
Transforms.delete(_this.editor, {
|
|
213
|
+
at: parentPath
|
|
214
|
+
});
|
|
215
|
+
Transforms.insertNodes(_this.editor, {
|
|
216
|
+
type: 'paragraph',
|
|
217
|
+
children: [
|
|
218
|
+
{
|
|
219
|
+
text: ''
|
|
220
|
+
}
|
|
221
|
+
]
|
|
222
|
+
}, {
|
|
223
|
+
at: parentPath,
|
|
224
|
+
select: true
|
|
225
|
+
});
|
|
212
226
|
});
|
|
213
|
-
|
|
227
|
+
e.preventDefault();
|
|
228
|
+
}
|
|
229
|
+
}
|
|
230
|
+
if (!Editor.hasPath(this.editor, Path.next(path))) {
|
|
231
|
+
Editor.withoutNormalizing(this.editor, function() {
|
|
232
|
+
Transforms.delete(_this.editor, {
|
|
233
|
+
at: path
|
|
234
|
+
});
|
|
235
|
+
Transforms.insertNodes(_this.editor, {
|
|
214
236
|
type: 'paragraph',
|
|
215
237
|
children: [
|
|
216
238
|
{
|
|
@@ -218,26 +240,9 @@ export var EnterKey = /*#__PURE__*/ function() {
|
|
|
218
240
|
}
|
|
219
241
|
]
|
|
220
242
|
}, {
|
|
221
|
-
at: parentPath,
|
|
243
|
+
at: Path.next(parentPath),
|
|
222
244
|
select: true
|
|
223
245
|
});
|
|
224
|
-
e.preventDefault();
|
|
225
|
-
}
|
|
226
|
-
}
|
|
227
|
-
if (!Editor.hasPath(this.editor, Path.next(path))) {
|
|
228
|
-
Transforms.delete(this.editor, {
|
|
229
|
-
at: path
|
|
230
|
-
});
|
|
231
|
-
Transforms.insertNodes(this.editor, {
|
|
232
|
-
type: 'paragraph',
|
|
233
|
-
children: [
|
|
234
|
-
{
|
|
235
|
-
text: ''
|
|
236
|
-
}
|
|
237
|
-
]
|
|
238
|
-
}, {
|
|
239
|
-
at: Path.next(parentPath),
|
|
240
|
-
select: true
|
|
241
246
|
});
|
|
242
247
|
e.preventDefault();
|
|
243
248
|
}
|
|
@@ -247,65 +252,69 @@ export var EnterKey = /*#__PURE__*/ function() {
|
|
|
247
252
|
var realEmpty = parent.children.length === 1;
|
|
248
253
|
if (ul.children.length === 1 && realEmpty) {
|
|
249
254
|
e.preventDefault();
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
255
|
+
Editor.withoutNormalizing(this.editor, function() {
|
|
256
|
+
Transforms.delete(_this.editor, {
|
|
257
|
+
at: ulPath
|
|
258
|
+
});
|
|
259
|
+
Transforms.insertNodes(_this.editor, EditorUtils.p, {
|
|
260
|
+
at: ulPath,
|
|
261
|
+
select: true
|
|
262
|
+
});
|
|
256
263
|
});
|
|
257
264
|
return;
|
|
258
265
|
}
|
|
259
266
|
if (realEmpty) {
|
|
260
267
|
e.preventDefault();
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
268
|
+
Editor.withoutNormalizing(this.editor, function() {
|
|
269
|
+
if (!Path.hasPrevious(parentPath)) {
|
|
270
|
+
Transforms.delete(_this.editor, {
|
|
271
|
+
at: parentPath
|
|
272
|
+
});
|
|
273
|
+
Transforms.insertNodes(_this.editor, EditorUtils.p, {
|
|
274
|
+
at: ulPath,
|
|
275
|
+
select: true
|
|
276
|
+
});
|
|
277
|
+
} else if (!Editor.hasPath(_this.editor, Path.next(parentPath))) {
|
|
278
|
+
Transforms.delete(_this.editor, {
|
|
279
|
+
at: parentPath
|
|
280
|
+
});
|
|
281
|
+
Transforms.insertNodes(_this.editor, EditorUtils.p, {
|
|
282
|
+
at: Path.next(ulPath),
|
|
283
|
+
select: true
|
|
284
|
+
});
|
|
285
|
+
} else {
|
|
286
|
+
Transforms.liftNodes(_this.editor, {
|
|
287
|
+
at: parentPath
|
|
288
|
+
});
|
|
289
|
+
Transforms.delete(_this.editor, {
|
|
290
|
+
at: Path.next(ulPath)
|
|
291
|
+
});
|
|
292
|
+
Transforms.insertNodes(_this.editor, EditorUtils.p, {
|
|
293
|
+
at: Path.next(ulPath),
|
|
294
|
+
select: true
|
|
295
|
+
});
|
|
296
|
+
}
|
|
297
|
+
});
|
|
289
298
|
} else {
|
|
290
299
|
if (!Editor.hasPath(this.editor, Path.next(path))) {
|
|
291
300
|
e.preventDefault();
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
301
|
+
Editor.withoutNormalizing(this.editor, function() {
|
|
302
|
+
Transforms.delete(_this.editor, {
|
|
303
|
+
at: path
|
|
304
|
+
});
|
|
305
|
+
Transforms.insertNodes(_this.editor, {
|
|
306
|
+
type: 'list-item',
|
|
307
|
+
checked: typeof parent.checked === 'boolean' ? false : undefined,
|
|
308
|
+
children: [
|
|
309
|
+
EditorUtils.p
|
|
310
|
+
]
|
|
311
|
+
}, {
|
|
312
|
+
at: Path.next(parentPath),
|
|
313
|
+
select: true
|
|
314
|
+
});
|
|
304
315
|
});
|
|
305
316
|
} else if (!Path.hasPrevious(path)) {
|
|
306
317
|
e.preventDefault();
|
|
307
|
-
// 在列表项开头按回车时,只创建新的空列表项,不移动任何节点
|
|
308
|
-
// 这样可以避免将嵌套列表或其他节点移动到新列表项内部,导致缩进
|
|
309
318
|
Transforms.insertNodes(this.editor, {
|
|
310
319
|
type: 'list-item',
|
|
311
320
|
checked: typeof parent.checked === 'boolean' ? false : undefined,
|
|
@@ -391,6 +400,7 @@ export var EnterKey = /*#__PURE__*/ function() {
|
|
|
391
400
|
{
|
|
392
401
|
key: "head",
|
|
393
402
|
value: function head(el, path, sel) {
|
|
403
|
+
var _this = this;
|
|
394
404
|
var start = Range.start(sel);
|
|
395
405
|
var elStart = Editor.start(this.editor, path);
|
|
396
406
|
if (Point.equals(start, elStart)) {
|
|
@@ -420,28 +430,30 @@ export var EnterKey = /*#__PURE__*/ function() {
|
|
|
420
430
|
select: true
|
|
421
431
|
});
|
|
422
432
|
} else {
|
|
423
|
-
var _fragment_;
|
|
424
433
|
var fragment = Node.fragment(this.editor, {
|
|
425
434
|
anchor: end,
|
|
426
435
|
focus: elEnd
|
|
427
436
|
});
|
|
428
|
-
|
|
429
|
-
|
|
430
|
-
|
|
431
|
-
|
|
432
|
-
|
|
433
|
-
|
|
434
|
-
Transforms.insertNodes(this.editor, {
|
|
435
|
-
type: 'paragraph',
|
|
436
|
-
children: ((_fragment_ = fragment[0]) === null || _fragment_ === void 0 ? void 0 : _fragment_.children) || [
|
|
437
|
-
{
|
|
438
|
-
text: ''
|
|
437
|
+
Editor.withoutNormalizing(this.editor, function() {
|
|
438
|
+
var _fragment_;
|
|
439
|
+
Transforms.delete(_this.editor, {
|
|
440
|
+
at: {
|
|
441
|
+
anchor: start,
|
|
442
|
+
focus: elEnd
|
|
439
443
|
}
|
|
440
|
-
|
|
441
|
-
|
|
442
|
-
|
|
444
|
+
});
|
|
445
|
+
Transforms.insertNodes(_this.editor, {
|
|
446
|
+
type: 'paragraph',
|
|
447
|
+
children: ((_fragment_ = fragment[0]) === null || _fragment_ === void 0 ? void 0 : _fragment_.children) || [
|
|
448
|
+
{
|
|
449
|
+
text: ''
|
|
450
|
+
}
|
|
451
|
+
]
|
|
452
|
+
}, {
|
|
453
|
+
at: Path.next(path)
|
|
454
|
+
});
|
|
455
|
+
Transforms.select(_this.editor, Editor.start(_this.editor, Path.next(path)));
|
|
443
456
|
});
|
|
444
|
-
Transforms.select(this.editor, Editor.start(this.editor, Path.next(path)));
|
|
445
457
|
}
|
|
446
458
|
}
|
|
447
459
|
return true;
|
|
@@ -450,6 +462,7 @@ export var EnterKey = /*#__PURE__*/ function() {
|
|
|
450
462
|
{
|
|
451
463
|
key: "paragraph",
|
|
452
464
|
value: function paragraph(e, node, sel) {
|
|
465
|
+
var _this = this;
|
|
453
466
|
var parent = Editor.parent(this.editor, node[1]);
|
|
454
467
|
var end = Editor.end(this.editor, node[1]);
|
|
455
468
|
if (Point.equals(end, sel.focus)) {
|
|
@@ -502,12 +515,14 @@ export var EnterKey = /*#__PURE__*/ function() {
|
|
|
502
515
|
var isListWithSingleEmptyItem = listNode.children.length === 1 && Node.string(node[0]) === '' && !Path.hasPrevious(listItemPath);
|
|
503
516
|
if (isListWithSingleEmptyItem) {
|
|
504
517
|
e.preventDefault();
|
|
505
|
-
|
|
506
|
-
|
|
507
|
-
|
|
508
|
-
|
|
509
|
-
|
|
510
|
-
|
|
518
|
+
Editor.withoutNormalizing(this.editor, function() {
|
|
519
|
+
Transforms.removeNodes(_this.editor, {
|
|
520
|
+
at: listPath
|
|
521
|
+
});
|
|
522
|
+
Transforms.insertNodes(_this.editor, EditorUtils.p, {
|
|
523
|
+
at: listPath,
|
|
524
|
+
select: true
|
|
525
|
+
});
|
|
511
526
|
});
|
|
512
527
|
return true;
|
|
513
528
|
}
|
|
@@ -517,25 +532,25 @@ export var EnterKey = /*#__PURE__*/ function() {
|
|
|
517
532
|
text: ''
|
|
518
533
|
}
|
|
519
534
|
] : EditorUtils.cutText(this.editor, sel.focus);
|
|
520
|
-
|
|
521
|
-
|
|
522
|
-
|
|
523
|
-
|
|
524
|
-
|
|
525
|
-
|
|
526
|
-
if (!Point.equals(end, sel.focus)) {
|
|
527
|
-
Transforms.delete(this.editor, {
|
|
528
|
-
at: {
|
|
529
|
-
anchor: sel.focus,
|
|
530
|
-
focus: end
|
|
531
|
-
}
|
|
535
|
+
Editor.withoutNormalizing(this.editor, function() {
|
|
536
|
+
Transforms.insertNodes(_this.editor, {
|
|
537
|
+
type: 'paragraph',
|
|
538
|
+
children: text || ' '
|
|
539
|
+
}, {
|
|
540
|
+
at: Path.next(node[1])
|
|
532
541
|
});
|
|
533
|
-
|
|
534
|
-
|
|
535
|
-
|
|
536
|
-
|
|
537
|
-
|
|
538
|
-
|
|
542
|
+
if (!Point.equals(end, sel.focus)) {
|
|
543
|
+
Transforms.delete(_this.editor, {
|
|
544
|
+
at: {
|
|
545
|
+
anchor: sel.focus,
|
|
546
|
+
focus: end
|
|
547
|
+
}
|
|
548
|
+
});
|
|
549
|
+
}
|
|
550
|
+
if (Editor.hasPath(_this.editor, Path.next(node[1]))) {
|
|
551
|
+
Transforms.select(_this.editor, Editor.start(_this.editor, Path.next(node[1])));
|
|
552
|
+
}
|
|
553
|
+
});
|
|
539
554
|
e.preventDefault();
|
|
540
555
|
return true;
|
|
541
556
|
} else {
|
|
@@ -564,38 +579,39 @@ export var EnterKey = /*#__PURE__*/ function() {
|
|
|
564
579
|
text: ''
|
|
565
580
|
}
|
|
566
581
|
] : EditorUtils.cutText(this.editor, sel.focus);
|
|
567
|
-
|
|
568
|
-
|
|
569
|
-
|
|
570
|
-
|
|
571
|
-
|
|
572
|
-
|
|
573
|
-
|
|
574
|
-
|
|
575
|
-
|
|
576
|
-
|
|
577
|
-
|
|
578
|
-
|
|
579
|
-
|
|
580
|
-
|
|
581
|
-
|
|
582
|
-
|
|
583
|
-
if (!Point.equals(sel.anchor, Editor.end(this.editor, node[1]))) {
|
|
584
|
-
Transforms.delete(this.editor, {
|
|
585
|
-
at: {
|
|
586
|
-
anchor: sel.anchor,
|
|
587
|
-
focus: Editor.end(this.editor, node[1])
|
|
588
|
-
}
|
|
582
|
+
Editor.withoutNormalizing(this.editor, function() {
|
|
583
|
+
Transforms.insertNodes(_this.editor, {
|
|
584
|
+
type: 'list-item',
|
|
585
|
+
children: [
|
|
586
|
+
{
|
|
587
|
+
type: 'paragraph',
|
|
588
|
+
children: text1 || [
|
|
589
|
+
{
|
|
590
|
+
text: ''
|
|
591
|
+
}
|
|
592
|
+
]
|
|
593
|
+
}
|
|
594
|
+
],
|
|
595
|
+
checked: checked
|
|
596
|
+
}, {
|
|
597
|
+
at: Path.next(parent[1])
|
|
589
598
|
});
|
|
590
|
-
|
|
591
|
-
|
|
592
|
-
|
|
593
|
-
|
|
594
|
-
|
|
595
|
-
|
|
596
|
-
|
|
597
|
-
|
|
598
|
-
|
|
599
|
+
if (!Point.equals(sel.anchor, Editor.end(_this.editor, node[1]))) {
|
|
600
|
+
Transforms.delete(_this.editor, {
|
|
601
|
+
at: {
|
|
602
|
+
anchor: sel.anchor,
|
|
603
|
+
focus: Editor.end(_this.editor, node[1])
|
|
604
|
+
}
|
|
605
|
+
});
|
|
606
|
+
}
|
|
607
|
+
if (Point.equals(sel.anchor, Editor.start(_this.editor, node[1])) && Node.string(Node.get(_this.editor, node[1])) !== '') {
|
|
608
|
+
EditorUtils.clearMarks(_this.editor);
|
|
609
|
+
}
|
|
610
|
+
var nextParentPath = Path.next(parent[1]);
|
|
611
|
+
if (Editor.hasPath(_this.editor, nextParentPath)) {
|
|
612
|
+
Transforms.select(_this.editor, Editor.start(_this.editor, nextParentPath));
|
|
613
|
+
}
|
|
614
|
+
});
|
|
599
615
|
return true;
|
|
600
616
|
}
|
|
601
617
|
}
|
|
@@ -2,7 +2,8 @@ import React from 'react';
|
|
|
2
2
|
import { Editor } from 'slate';
|
|
3
3
|
export declare class MatchKey {
|
|
4
4
|
private readonly editorRef;
|
|
5
|
-
|
|
5
|
+
private readonly isMatchInputToNodeEnabled;
|
|
6
|
+
constructor(editorRef: React.MutableRefObject<Editor | null>, isMatchInputToNodeEnabled?: () => boolean);
|
|
6
7
|
private createParams;
|
|
7
8
|
run(e: React.KeyboardEvent): boolean;
|
|
8
9
|
}
|
|
@@ -85,9 +85,14 @@ import { TextMatchNodes } from "../elements";
|
|
|
85
85
|
export var MatchKey = /*#__PURE__*/ function() {
|
|
86
86
|
"use strict";
|
|
87
87
|
function MatchKey(editorRef) {
|
|
88
|
+
var isMatchInputToNodeEnabled = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : function() {
|
|
89
|
+
return false;
|
|
90
|
+
};
|
|
88
91
|
_class_call_check(this, MatchKey);
|
|
89
92
|
_define_property(this, "editorRef", void 0);
|
|
93
|
+
_define_property(this, "isMatchInputToNodeEnabled", void 0);
|
|
90
94
|
this.editorRef = editorRef;
|
|
95
|
+
this.isMatchInputToNodeEnabled = isMatchInputToNodeEnabled;
|
|
91
96
|
}
|
|
92
97
|
_create_class(MatchKey, [
|
|
93
98
|
{
|
|
@@ -109,21 +114,35 @@ export var MatchKey = /*#__PURE__*/ function() {
|
|
|
109
114
|
var _node_;
|
|
110
115
|
var editor = this.editorRef.current;
|
|
111
116
|
if (!editor) return false;
|
|
112
|
-
var
|
|
117
|
+
var sel = editor.selection;
|
|
118
|
+
if (!sel || !Range.isCollapsed(sel)) return false;
|
|
119
|
+
var nodesResult = Editor.nodes(editor, {
|
|
120
|
+
at: sel.anchor,
|
|
113
121
|
match: function match(n) {
|
|
114
122
|
return Element.isElement(n);
|
|
115
123
|
},
|
|
116
124
|
mode: 'lowest'
|
|
117
|
-
})
|
|
125
|
+
});
|
|
126
|
+
var node;
|
|
127
|
+
if (Array.isArray(nodesResult) && nodesResult.length > 0) {
|
|
128
|
+
node = nodesResult[0];
|
|
129
|
+
} else {
|
|
130
|
+
var iter = nodesResult;
|
|
131
|
+
if (iter && typeof iter.next === 'function') {
|
|
132
|
+
var first = iter.next();
|
|
133
|
+
node = first.done ? undefined : first.value;
|
|
134
|
+
}
|
|
135
|
+
}
|
|
118
136
|
if (!node || [
|
|
119
137
|
'code'
|
|
120
138
|
].includes(node === null || node === void 0 ? void 0 : (_node_ = node[0]) === null || _node_ === void 0 ? void 0 : _node_.type)) return false;
|
|
121
|
-
var sel = editor.selection;
|
|
122
|
-
if (!sel || !Range.isCollapsed(sel)) return false;
|
|
123
139
|
var _iteratorNormalCompletion = true, _didIteratorError = false, _iteratorError = undefined;
|
|
124
140
|
try {
|
|
125
141
|
for(var _iterator = TextMatchNodes[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true){
|
|
126
142
|
var n = _step.value;
|
|
143
|
+
if (n.gatedByMatchInputToNode && !this.isMatchInputToNodeEnabled()) {
|
|
144
|
+
continue;
|
|
145
|
+
}
|
|
127
146
|
if (_type_of(n.matchKey) === 'object' ? n.matchKey.test(e.key) : n.matchKey === e.key) {
|
|
128
147
|
if (n.checkAllow && !n.checkAllow({
|
|
129
148
|
editor: editor,
|
|
@@ -103,6 +103,7 @@ import { getListType, isListType } from "../withListsPlugin";
|
|
|
103
103
|
{
|
|
104
104
|
key: "run",
|
|
105
105
|
value: function run(e) {
|
|
106
|
+
var _this = this;
|
|
106
107
|
var sel = this.editor.selection;
|
|
107
108
|
if (!sel) return;
|
|
108
109
|
e.preventDefault();
|
|
@@ -182,15 +183,19 @@ import { getListType, isListType } from "../withListsPlugin";
|
|
|
182
183
|
}), 1), node1 = _Editor_nodes3[0];
|
|
183
184
|
if (node1) {
|
|
184
185
|
var _Range_edges1 = _sliced_to_array(Range.edges(sel), 2), start1 = _Range_edges1[0], end1 = _Range_edges1[1];
|
|
185
|
-
var
|
|
186
|
-
var
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
186
|
+
var isStartInNode = Path.isDescendant(start1.path, node1[1]) || Path.equals(start1.path, node1[1]);
|
|
187
|
+
var isEndInNode = Path.isDescendant(end1.path, node1[1]) || Path.equals(end1.path, node1[1]);
|
|
188
|
+
var anchor = isStartInNode ? start1 : Editor.start(this.editor, node1[1]);
|
|
189
|
+
var focus = isEndInNode ? end1 : Editor.end(this.editor, node1[1]);
|
|
190
|
+
Editor.withoutNormalizing(this.editor, function() {
|
|
191
|
+
Transforms.liftNodes(_this.editor, {
|
|
192
|
+
at: {
|
|
193
|
+
anchor: anchor,
|
|
194
|
+
focus: focus
|
|
195
|
+
}
|
|
196
|
+
});
|
|
197
|
+
Transforms.liftNodes(_this.editor);
|
|
192
198
|
});
|
|
193
|
-
Transforms.liftNodes(this.editor);
|
|
194
199
|
} else {
|
|
195
200
|
Transforms.liftNodes(this.editor);
|
|
196
201
|
}
|
|
@@ -263,6 +268,7 @@ import { getListType, isListType } from "../withListsPlugin";
|
|
|
263
268
|
value: /**
|
|
264
269
|
* 增加缩进:将当前 list-item 移动到前一个 list-item 的子列表中
|
|
265
270
|
*/ function indentListItem(listItemPath) {
|
|
271
|
+
var _this = this;
|
|
266
272
|
// 检查是否是第一个 list-item(第一行按 Tab 应该无效)
|
|
267
273
|
if (!Path.hasPrevious(listItemPath)) {
|
|
268
274
|
return false;
|
|
@@ -292,34 +298,31 @@ import { getListType, isListType } from "../withListsPlugin";
|
|
|
292
298
|
return true;
|
|
293
299
|
}
|
|
294
300
|
} else {
|
|
295
|
-
// 如果最后一个子节点不是列表,需要创建一个新的列表
|
|
296
301
|
var listType = getListType();
|
|
297
302
|
var currentListItem = Node.get(this.editor, listItemPath);
|
|
298
|
-
// 先创建新的列表,包含当前 list-item
|
|
299
303
|
var newList = {
|
|
300
304
|
type: listType,
|
|
301
305
|
children: [
|
|
302
306
|
currentListItem
|
|
303
307
|
]
|
|
304
308
|
};
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
309
|
+
Editor.withoutNormalizing(this.editor, function() {
|
|
310
|
+
Transforms.removeNodes(_this.editor, {
|
|
311
|
+
at: listItemPath
|
|
312
|
+
});
|
|
313
|
+
Transforms.insertNodes(_this.editor, newList, {
|
|
314
|
+
at: _to_consumable_array(previousListItemPath).concat([
|
|
315
|
+
previousListItem.children.length
|
|
316
|
+
])
|
|
317
|
+
});
|
|
318
|
+
var newListPath = _to_consumable_array(previousListItemPath).concat([
|
|
311
319
|
previousListItem.children.length
|
|
312
|
-
])
|
|
320
|
+
]);
|
|
321
|
+
var newListItemPath = _to_consumable_array(newListPath).concat([
|
|
322
|
+
0
|
|
323
|
+
]);
|
|
324
|
+
Transforms.select(_this.editor, Editor.start(_this.editor, newListItemPath));
|
|
313
325
|
});
|
|
314
|
-
// 更新路径,因为节点已移动
|
|
315
|
-
var newListPath = _to_consumable_array(previousListItemPath).concat([
|
|
316
|
-
previousListItem.children.length
|
|
317
|
-
]);
|
|
318
|
-
var newListItemPath = _to_consumable_array(newListPath).concat([
|
|
319
|
-
0
|
|
320
|
-
]);
|
|
321
|
-
// 选中新位置
|
|
322
|
-
Transforms.select(this.editor, Editor.start(this.editor, newListItemPath));
|
|
323
326
|
return true;
|
|
324
327
|
}
|
|
325
328
|
return false;
|
|
@@ -330,6 +333,7 @@ import { getListType, isListType } from "../withListsPlugin";
|
|
|
330
333
|
value: /**
|
|
331
334
|
* 减少缩进:将当前 list-item 提升一级
|
|
332
335
|
*/ function outdentListItem(listItemPath, listPath) {
|
|
336
|
+
var _this = this;
|
|
333
337
|
// 检查当前 list 的父节点
|
|
334
338
|
var listParent = Editor.parent(this.editor, listPath);
|
|
335
339
|
// 如果父节点是 list-item,说明在嵌套列表中,可以提升
|
|
@@ -341,17 +345,17 @@ import { getListType, isListType } from "../withListsPlugin";
|
|
|
341
345
|
// 如果是最顶层的第一个项,不能提升
|
|
342
346
|
return false;
|
|
343
347
|
}
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
});
|
|
348
|
-
// 如果提升后,原列表为空,需要删除空列表
|
|
349
|
-
var updatedList = Node.get(this.editor, listPath);
|
|
350
|
-
if (isListType(updatedList) && Node.string(updatedList).trim() === '') {
|
|
351
|
-
Transforms.removeNodes(this.editor, {
|
|
352
|
-
at: listPath
|
|
348
|
+
Editor.withoutNormalizing(this.editor, function() {
|
|
349
|
+
Transforms.liftNodes(_this.editor, {
|
|
350
|
+
at: listItemPath
|
|
353
351
|
});
|
|
354
|
-
|
|
352
|
+
var updatedList = Node.get(_this.editor, listPath);
|
|
353
|
+
if (isListType(updatedList) && Node.string(updatedList).trim() === '') {
|
|
354
|
+
Transforms.removeNodes(_this.editor, {
|
|
355
|
+
at: listPath
|
|
356
|
+
});
|
|
357
|
+
}
|
|
358
|
+
});
|
|
355
359
|
return true;
|
|
356
360
|
} else {
|
|
357
361
|
// 已经是最顶层,不能提升
|
|
@@ -5,5 +5,6 @@ export * from './withInlineNodes';
|
|
|
5
5
|
export * from './withLinkAndMediaPlugin';
|
|
6
6
|
export * from './withListsPlugin';
|
|
7
7
|
export * from './withMarkdown';
|
|
8
|
+
export * from './withSanitizeInvalidChildren';
|
|
8
9
|
export * from './withSchemaPlugin';
|
|
9
10
|
export * from './withVoidNodes';
|
|
@@ -5,5 +5,6 @@ export * from "./withInlineNodes";
|
|
|
5
5
|
export * from "./withLinkAndMediaPlugin";
|
|
6
6
|
export * from "./withListsPlugin";
|
|
7
7
|
export * from "./withMarkdown";
|
|
8
|
+
export * from "./withSanitizeInvalidChildren";
|
|
8
9
|
export * from "./withSchemaPlugin";
|
|
9
10
|
export * from "./withVoidNodes";
|