@@ -953,7 +953,7 @@ export class Outline extends Model {
953953 label : window . siyuan . languages . insertSameLevelHeadingBefore ,
954954 click : ( ) => {
955955 fetchPost ( "/api/block/insertBlock" , {
956- data : "#" . repeat ( this . getHeadingLevel ( element ) ) + " " ,
956+ data : "#" . repeat ( currentLevel ) + " " ,
957957 dataType : "markdown" ,
958958 nextID : id
959959 } , ( response ) => {
@@ -975,7 +975,7 @@ export class Outline extends Model {
975975 id,
976976 } , ( deleteResponse ) => {
977977 fetchPost ( "/api/block/insertBlock" , {
978- data : "#" . repeat ( this . getHeadingLevel ( element ) ) + " " ,
978+ data : "#" . repeat ( currentLevel ) + " " ,
979979 dataType : "markdown" ,
980980 previousID : deleteResponse . data . doOperations [ deleteResponse . data . doOperations . length - 1 ] . id
981981 } , ( response ) => {
@@ -995,18 +995,30 @@ export class Outline extends Model {
995995 icon : "iconAdd" ,
996996 label : window . siyuan . languages . addChildHeading ,
997997 click : ( ) => {
998- fetchPost ( "/api/block/prependBlock" , {
999- data : "#" . repeat ( Math . min ( this . getHeadingLevel ( element ) + 1 , 6 ) ) + " " ,
1000- dataType : "markdown" ,
1001- parentID : id
1002- } , ( response ) => {
1003- if ( response . code === 0 && response . data && response . data . length > 0 ) {
1004- openFileById ( {
1005- app : this . app ,
1006- id : response . data [ 0 ] . doOperations [ 0 ] . id ,
1007- action : [ Constants . CB_GET_FOCUS , Constants . CB_GET_OUTLINE ]
1008- } ) ;
1009- }
998+ fetchPost ( "/api/block/getHeadingDeleteTransaction" , {
999+ id,
1000+ } , ( deleteResponse ) => {
1001+ let previousID = deleteResponse . data . doOperations [ deleteResponse . data . doOperations . length - 1 ] . id ;
1002+ deleteResponse . data . undoOperations . find ( ( operationsItem : IOperation , index : number ) => {
1003+ const startIndex = operationsItem . data . indexOf ( ' data-subtype="h' ) ;
1004+ if ( startIndex > - 1 && startIndex < 260 && parseInt ( operationsItem . data . substring ( startIndex + 16 , startIndex + 17 ) ) === currentLevel + 1 ) {
1005+ previousID = deleteResponse . data . undoOperations [ index - 1 ] . id ;
1006+ return true ;
1007+ }
1008+ } ) ;
1009+ fetchPost ( "/api/block/insertBlock" , {
1010+ data : "#" . repeat ( Math . min ( currentLevel + 1 , 6 ) ) + " " ,
1011+ dataType : "markdown" ,
1012+ previousID,
1013+ } , ( response ) => {
1014+ if ( response . code === 0 && response . data && response . data . length > 0 ) {
1015+ openFileById ( {
1016+ app : this . app ,
1017+ id : response . data [ 0 ] . doOperations [ 0 ] . id ,
1018+ action : [ Constants . CB_GET_FOCUS , Constants . CB_GET_OUTLINE ]
1019+ } ) ;
1020+ }
1021+ } ) ;
10101022 } ) ;
10111023 }
10121024 } ) . element ) ;
0 commit comments