@@ -104,7 +104,7 @@ export function unindentListItem(editor: Editor): boolean {
104
104
export function getNode (
105
105
editor ,
106
106
match ,
107
- at : Location | undefined = undefined
107
+ at : Location | undefined = undefined ,
108
108
) : [ Element , number [ ] ] | [ undefined , undefined ] {
109
109
if ( at != null ) {
110
110
// First try the node at *specific* given position.
@@ -120,19 +120,23 @@ export function getNode(
120
120
// no such element, so try search below...
121
121
}
122
122
}
123
- for ( const elt of Editor . nodes ( editor , {
124
- match : ( node , path ) => Element . isElement ( node ) && match ( node , path ) ,
125
- mode : "lowest" ,
126
- at,
127
- } ) ) {
128
- return [ elt [ 0 ] as Element , elt [ 1 ] ] ;
123
+ try {
124
+ for ( const elt of Editor . nodes ( editor , {
125
+ match : ( node , path ) => Element . isElement ( node ) && match ( node , path ) ,
126
+ mode : "lowest" ,
127
+ at,
128
+ } ) ) {
129
+ return [ elt [ 0 ] as Element , elt [ 1 ] ] ;
130
+ }
131
+ } catch ( _err ) {
132
+ // no such element
129
133
}
130
134
return [ undefined , undefined ] ;
131
135
}
132
136
133
137
export function indentListItem (
134
138
editor : Editor ,
135
- at : Location | undefined = undefined
139
+ at : Location | undefined = undefined ,
136
140
) : boolean {
137
141
const [ item , path ] = getNode ( editor , ( node ) => node . type == "list_item" , at ) ;
138
142
if ( item == null || path == null ) {
@@ -188,7 +192,7 @@ export function indentListItem(
188
192
Transforms . wrapNodes (
189
193
editor ,
190
194
{ type : list . type , tight : true , children : [ ] } ,
191
- { at : to }
195
+ { at : to } ,
192
196
) ;
193
197
} ) ;
194
198
} catch ( err ) {
0 commit comments