@@ -841,40 +841,51 @@ export class KeyBindsRegistrar {
841841 } ) ;
842842
843843 await this . project . keyBinds . create ( "splitTextNodes" , "k e i" , ( ) => {
844+ // 获取所有选中的文本节点
844845 const selectedTextNodes = this . project . stageManager
845846 . getSelectedEntities ( )
846847 . filter ( ( node ) => node instanceof TextNode ) ;
847848 selectedTextNodes . forEach ( ( node ) => {
848849 node . isSelected = false ;
849850 } ) ;
850- for ( const node of selectedTextNodes ) {
851- const text = node . text ;
852- const seps = [ " " , "\n" , "\t" , "." , "," , "," , "。" , "、" , ";" , ":" , "?" , "!" ] ;
853- const escapedSeps = seps . map ( ( sep ) => sep . replace ( / [ . * + ? ^ $ { } ( ) | [ \] \\ ] / g, "\\$&" ) ) ;
854- const regex = new RegExp ( escapedSeps . join ( "|" ) , "g" ) ;
855- const splitedTextList = text . split ( regex ) . filter ( ( item ) => item !== "" ) ;
856- const putLocation = node . collisionBox . getRectangle ( ) . location . clone ( ) ;
857- const newNodes = [ ] ;
858- for ( const splitedText of splitedTextList ) {
859- const newTextNode = new TextNode ( this . project , {
860- uuid : v4 ( ) ,
861- text : splitedText ,
862- collisionBox : new CollisionBox ( [ new Rectangle ( new Vector ( putLocation . x , putLocation . y ) , new Vector ( 1 , 1 ) ) ] ) ,
863- color : node . color . clone ( ) ,
864- } ) ;
865- newNodes . push ( newTextNode ) ;
866- this . project . stageManager . add ( newTextNode ) ;
867- putLocation . y += 100 ;
868- }
869- newNodes . forEach ( ( newNode ) => {
870- newNode . isSelected = true ;
871- } ) ;
872- this . project . layoutManager . alignTopToBottomNoSpace ( ) ;
873- newNodes . forEach ( ( newNode ) => {
874- newNode . isSelected = false ;
851+ setTimeout ( ( ) => {
852+ Dialog . input ( "请输入分割符" ) . then ( ( userInput ) => {
853+ if ( userInput === undefined || userInput === "" ) return ;
854+ userInput = userInput . replaceAll ( "n" , "\n" ) ;
855+ userInput = userInput . replaceAll ( "t" , "\t" ) ;
856+ for ( const node of selectedTextNodes ) {
857+ const text = node . text ;
858+ const seps = [ userInput ] ;
859+ const escapedSeps = seps . map ( ( sep ) => sep . replace ( / [ . * + ? ^ $ { } ( ) | [ \] \\ ] / g, "\\$&" ) ) ;
860+ const regex = new RegExp ( escapedSeps . join ( "|" ) , "g" ) ;
861+ const splitedTextList = text . split ( regex ) . filter ( ( item ) => item !== "" ) ;
862+ const putLocation = node . collisionBox . getRectangle ( ) . location . clone ( ) ;
863+ const newNodes = [ ] ;
864+ for ( const splitedText of splitedTextList ) {
865+ const newTextNode = new TextNode ( this . project , {
866+ uuid : v4 ( ) ,
867+ text : splitedText ,
868+ collisionBox : new CollisionBox ( [
869+ new Rectangle ( new Vector ( putLocation . x , putLocation . y ) , new Vector ( 1 , 1 ) ) ,
870+ ] ) ,
871+ color : node . color . clone ( ) ,
872+ } ) ;
873+ newNodes . push ( newTextNode ) ;
874+ this . project . stageManager . add ( newTextNode ) ;
875+ putLocation . y += 100 ;
876+ }
877+ newNodes . forEach ( ( newNode ) => {
878+ newNode . isSelected = true ;
879+ } ) ;
880+ this . project . layoutManager . alignTopToBottomNoSpace ( ) ;
881+ newNodes . forEach ( ( newNode ) => {
882+ newNode . isSelected = false ;
883+ } ) ;
884+ }
885+ // 删除所有选中的文本节点
886+ this . project . stageManager . deleteEntities ( selectedTextNodes ) ;
875887 } ) ;
876- }
877- this . project . stageManager . deleteEntities ( selectedTextNodes ) ;
888+ } ) ;
878889 } ) ;
879890
880891 await this . project . keyBinds . create ( "mergeTextNodes" , "r u a" , ( ) => {
0 commit comments