Commit 855f2f5 1 parent dba8484 commit 855f2f5 Copy full SHA for 855f2f5
File tree 1 file changed +20
-8
lines changed
1 file changed +20
-8
lines changed Original file line number Diff line number Diff line change @@ -184,14 +184,13 @@ const toggleNodeType = (
184
184
$from . sameParent ( $from . doc . resolve ( $to . pos ) )
185
185
) {
186
186
if ( $from . parent . type === nodeType ) {
187
+ const tr = state . tr
188
+ . setBlockType ( $from . pos , $to . pos , paragraphType )
189
+ . setMeta ( 'preserveWhitespace' , true ) ;
190
+ tr . replaceSelectionWith ( schema . text ( $from . parent . textContent ) ) ;
191
+
187
192
if ( dispatch ) {
188
- dispatch (
189
- state . tr . setBlockType (
190
- $from . pos ,
191
- $to . pos ,
192
- paragraphType ,
193
- ) ,
194
- ) ;
193
+ dispatch ( tr ) ;
195
194
}
196
195
197
196
return true ;
@@ -203,7 +202,20 @@ const toggleNodeType = (
203
202
if ( shouldWrap ) {
204
203
return wrapIn ( nodeType , attrs ) ( state , dispatch ) ;
205
204
} else {
206
- return setBlockType ( nodeType , attrs ) ( state , dispatch ) ;
205
+ const tr = state . tr
206
+ . setBlockType ( $from . pos , $to . pos , nodeType , attrs )
207
+ . setMeta ( 'preserveWhitespace' , true ) ;
208
+ if ( nodeType === paragraphType ) {
209
+ tr . replaceSelectionWith (
210
+ schema . text ( $from . parent . textContent ) ,
211
+ ) ;
212
+ }
213
+
214
+ if ( dispatch ) {
215
+ dispatch ( tr ) ;
216
+ }
217
+
218
+ return true ;
207
219
}
208
220
}
209
221
}
You can’t perform that action at this time.
0 commit comments