@@ -528,23 +528,24 @@ const dragSb = async (protyle: IProtyle, sourceElements: Element[], targetElemen
528528 if ( ! isCopy && oldSourceParentElement && oldSourceParentElement . classList . contains ( "sb" ) && oldSourceParentElement . childElementCount === 2 ) {
529529 // 拖拽后,sb 只剩下一个元素
530530 if ( isSameDoc ) {
531- const sbData = cancelSB ( protyle , oldSourceParentElement ) ;
531+ const sbData = await cancelSB ( protyle , oldSourceParentElement ) ;
532532 doOperations . push ( sbData . doOperations [ 0 ] , sbData . doOperations [ 1 ] ) ;
533533 undoOperations . splice ( 0 , 0 , sbData . undoOperations [ 0 ] , sbData . undoOperations [ 1 ] ) ;
534534 } else {
535535 /// #if !MOBILE
536536 const otherProtyleElement = hasClosestByClassName ( oldSourceParentElement , "protyle" , true ) ;
537537 if ( otherProtyleElement ) {
538- getAllEditor ( ) . find ( item => {
539- if ( item . protyle . element . isSameNode ( otherProtyleElement ) ) {
540- const otherSbData = cancelSB ( item . protyle , oldSourceParentElement ) ;
538+ const allEditor = getAllEditor ( )
539+ for ( let i = 0 ; i < allEditor . length ; i ++ ) {
540+ if ( allEditor [ i ] . protyle . element . isSameNode ( otherProtyleElement ) ) {
541+ const otherSbData = await cancelSB ( allEditor [ i ] . protyle , oldSourceParentElement ) ;
541542 doOperations . push ( otherSbData . doOperations [ 0 ] , otherSbData . doOperations [ 1 ] ) ;
542543 undoOperations . splice ( 0 , 0 , otherSbData . undoOperations [ 0 ] , otherSbData . undoOperations [ 1 ] ) ;
543544 // 需清空操作栈,否则撤销到移动出去的块的操作会抛异常
544- item . protyle . undo . clear ( ) ;
545+ allEditor [ i ] . protyle . undo . clear ( ) ;
545546 return true ;
546547 }
547- } ) ;
548+ }
548549 }
549550 /// #endif
550551 }
@@ -730,23 +731,23 @@ const dragSame = async (protyle: IProtyle, sourceElements: Element[], targetElem
730731 if ( ! isCopy && oldSourceParentElement && oldSourceParentElement . classList . contains ( "sb" ) && oldSourceParentElement . childElementCount === 2 ) {
731732 // 拖拽后,sb 只剩下一个元素
732733 if ( isSameDoc ) {
733- const sbData = cancelSB ( protyle , oldSourceParentElement ) ;
734+ const sbData = await cancelSB ( protyle , oldSourceParentElement ) ;
734735 doOperations . push ( sbData . doOperations [ 0 ] , sbData . doOperations [ 1 ] ) ;
735736 undoOperations . splice ( 0 , 0 , sbData . undoOperations [ 0 ] , sbData . undoOperations [ 1 ] ) ;
736737 } else {
737738 /// #if !MOBILE
738739 const otherProtyleElement = hasClosestByClassName ( oldSourceParentElement , "protyle" , true ) ;
739740 if ( otherProtyleElement ) {
740- getAllEditor ( ) . find ( item => {
741- if ( item . protyle . element . isSameNode ( otherProtyleElement ) ) {
742- const otherSbData = cancelSB ( item . protyle , oldSourceParentElement ) ;
741+ const allEditor = getAllEditor ( )
742+ for ( let i = 0 ; i < allEditor . length ; i ++ ) {
743+ if ( allEditor [ i ] . protyle . element . isSameNode ( otherProtyleElement ) ) {
744+ const otherSbData = await cancelSB ( allEditor [ i ] . protyle , oldSourceParentElement ) ;
743745 doOperations . push ( otherSbData . doOperations [ 0 ] , otherSbData . doOperations [ 1 ] ) ;
744746 undoOperations . splice ( 0 , 0 , otherSbData . undoOperations [ 0 ] , otherSbData . undoOperations [ 1 ] ) ;
745747 // 需清空操作栈,否则撤销到移动出去的块的操作会抛异常
746- item . protyle . undo . clear ( ) ;
747- return true ;
748+ allEditor [ i ] . protyle . undo . clear ( ) ;
748749 }
749- } ) ;
750+ }
750751 }
751752 /// #endif
752753 }
0 commit comments