File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -20,21 +20,27 @@ export function insertValue(
2020 end : number ,
2121 useHtmlNormalizer : boolean | undefined
2222) : void {
23- if ( ! value ) return ;
24-
2523 const doc = editor . state . doc ;
2624 const docLength = nativeLeafText ( doc , 0 , doc . content . size ) . length ;
2725
28- if ( docLength === 0 && isPlainEmptyDoc ( doc ) ) {
29- editor . commands . setContent ( prepareHtmlForTiptap ( value , useHtmlNormalizer ) ) ;
30- return ;
31- }
32-
3326 const from = nativePosToTiptapPos ( doc , Math . min ( start , docLength ) ) ;
3427 const to = nativePosToTiptapPos (
3528 doc ,
3629 Math . min ( Math . max ( start , end ) , docLength )
3730 ) ;
31+
32+ if ( ! value ) {
33+ if ( start === end ) return ;
34+
35+ editor . chain ( ) . focus ( ) . deleteRange ( { from, to } ) . run ( ) ;
36+ return ;
37+ }
38+
39+ if ( docLength === 0 && isPlainEmptyDoc ( doc ) ) {
40+ editor . commands . setContent ( prepareHtmlForTiptap ( value , useHtmlNormalizer ) ) ;
41+ return ;
42+ }
43+
3844 const content = prepareHtmlForTiptap ( value , useHtmlNormalizer ) ;
3945
4046 const parsedRaw = createNodeFromContent ( content , editor . schema , {
You can’t perform that action at this time.
0 commit comments