@@ -548,5 +548,70 @@ describe('List Commands', () => {
548548 expect ( listItem . content . childCount ) . toBe ( 2 ) ;
549549 } ) ;
550550 } ) ;
551+
552+ describe ( 'clipboard operations' , ( ) => {
553+ it ( 'maintains list structure when pasting list content' , ( ) => {
554+ // Setup source list
555+ const command = createListCommand (
556+ schema ,
557+ EditorMenuTypes . BulletList ,
558+ ) ;
559+ let tr = state . tr . insertText ( 'Source item' ) ;
560+ state = state . apply ( tr ) ;
561+ command ( state , dispatch ) ;
562+
563+ console . log (
564+ 'state before paste' ,
565+ JSON . stringify ( state . doc . toJSON ( ) , null , 2 ) ,
566+ ) ;
567+
568+ // Simulate copy-paste
569+ const copiedContent = state . doc . content . firstChild . copy ( ) ;
570+ tr = state . tr . insert ( state . selection . $from . pos , copiedContent ) ;
571+ state = state . apply ( tr ) ;
572+
573+ expect ( state . doc . firstChild . childCount ) . toBe ( 2 ) ;
574+ } ) ;
575+ } ) ;
576+
577+ describe ( 'cross-boundary selections' , ( ) => {
578+ it ( 'handles selection spanning list and non-list content' , ( ) => {
579+ // Setup mixed content
580+ let tr = state . tr
581+ . insertText ( 'Regular paragraph\n' )
582+ . insertText ( 'List item' ) ;
583+ state = state . apply ( tr ) ;
584+
585+ // Make second line a list
586+ const command = createListCommand (
587+ schema ,
588+ EditorMenuTypes . BulletList ,
589+ ) ;
590+ tr = state . tr . setSelection (
591+ TextSelection . create (
592+ state . doc ,
593+ state . doc . content . firstChild . nodeSize ,
594+ state . doc . content . size ,
595+ ) ,
596+ ) ;
597+ state = state . apply ( tr ) ;
598+ command ( state , dispatch ) ;
599+
600+ // Select across boundary
601+ tr = state . tr . setSelection (
602+ TextSelection . create (
603+ state . doc ,
604+ 5 ,
605+ state . doc . content . size - 5 ,
606+ ) ,
607+ ) ;
608+ state = state . apply ( tr ) ;
609+ command ( state , dispatch ) ;
610+
611+ expect ( state . doc . firstChild . type . name ) . toBe (
612+ EditorMenuTypes . BulletList ,
613+ ) ;
614+ } ) ;
615+ } ) ;
551616 } ) ;
552617} ) ;
0 commit comments