1
1
/* eslint-disable no-param-reassign */
2
2
3
- import type { SlateEditor } from '@udecode/plate-common' ;
4
- import { isElement , isInline } from '@udecode/plate-common' ;
5
- import type { Node } from 'slate' ;
6
- import { Text } from 'slate' ;
3
+ import { ElementApi , TextApi } from '@udecode/plate' ;
4
+ import type { Node , SlateEditor } from '@udecode/plate' ;
7
5
8
6
import { getCurrentNodeEntry } from './getCurrentNodeEntry' ;
9
7
import { insertEmptyParagraph } from './insertEmptyParagraph' ;
@@ -40,7 +38,7 @@ function insertNormalizedNodes(editor: SlateEditor, nodes: Node[], options: Opti
40
38
// In case we're inserting things into an empty paragraph, we will want to replace that paragraph.
41
39
const initialSelection = editor . selection ;
42
40
const isInitialSelectionAtEmptyBlock = isAtEmptyBlock ( editor ) ;
43
- const isAppendingToCurrentNode = Text . isText ( nodes [ 0 ] ) || isInline ( editor , nodes [ 0 ] ) ;
41
+ const isAppendingToCurrentNode = TextApi . isText ( nodes [ 0 ] ) || editor . api . isInline ( nodes [ 0 ] ) ;
44
42
const isInsertingBlockNodes = nodes . some ( ( node ) => isBlock ( editor , node ) ) ;
45
43
46
44
for ( const node of nodes ) {
@@ -53,7 +51,7 @@ function insertNormalizedNodes(editor: SlateEditor, nodes: Node[], options: Opti
53
51
insertEmptyParagraph ( editor ) ;
54
52
}
55
53
56
- if ( isElement ( node ) && isInline ( editor , node ) ) {
54
+ if ( ElementApi . isElement ( node ) && editor . api . isInline ( node ) ) {
57
55
// Slate does not allow inline nodes next to inline nodes.
58
56
// Adding text nodes around it helps to prevent unwanted side-effects.
59
57
//
@@ -63,9 +61,9 @@ function insertNormalizedNodes(editor: SlateEditor, nodes: Node[], options: Opti
63
61
// > nor can it be next to another inline node in the children array.
64
62
// > If this is the case, an empty text node will be added to correct
65
63
// > this to be in compliance with the constraint.
66
- editor . insertFragment ( [ { text : '' } , node , { text : '' } ] ) ;
64
+ editor . tf . insertFragment ( [ { text : '' } , node , { text : '' } ] ) ;
67
65
} else {
68
- editor . insertNodes ( [ node ] , { mode } ) ;
66
+ editor . tf . insertNodes ( [ node ] , { mode } ) ;
69
67
}
70
68
}
71
69
}
@@ -85,11 +83,11 @@ function insertNormalizedNodes(editor: SlateEditor, nodes: Node[], options: Opti
85
83
// For example, if originally selected element was preceeded by a "list",
86
84
// the selection would move to the last "list-item-text" in that "list", and
87
85
// `element` would get inserted as a child of that "list-item-text".
88
- editor . removeNodes ( { at : initialSelection } ) ;
86
+ editor . tf . removeNodes ( { at : initialSelection } ) ;
89
87
}
90
88
91
89
// Some normalizing operations may not trigger follow-up normalizations, so we want
92
90
// to force one more loop of normalizations. This happens e.g. when fixing hierarchy
93
91
// when pasting lists.
94
- editor . normalize ( { force : true } ) ;
92
+ editor . tf . normalize ( { force : true } ) ;
95
93
}
0 commit comments