@@ -110,6 +110,7 @@ export const createNodeShapeTools = (
110110 return class DiscourseNodeTool extends StateNode {
111111 static id = n . type ;
112112 static initial = "idle" ;
113+ static isLockable = true ;
113114 shapeType = n . type ;
114115
115116 override onEnter = ( ) => {
@@ -130,7 +131,6 @@ export const createNodeShapeTools = (
130131 props : { fontFamily : "sans" , size : "s" } ,
131132 } ) ;
132133 this . editor . setEditingShape ( shapeId ) ;
133- this . editor . setCurrentTool ( "select" ) ;
134134 } ;
135135 } ;
136136 } ) ;
@@ -519,6 +519,19 @@ export class BaseDiscourseNodeUtil extends BaseBoxShapeUtil<DiscourseNodeShape>
519519 this . updateProps ( shape . id , shape . type , { h, w, imageUrl } ) ;
520520 } ;
521521
522+ const wasToolLocked = this . editor . getInstanceState ( ) . isToolLocked ;
523+
524+ const restoreToolState = ( ) => {
525+ if ( wasToolLocked ) {
526+ this . editor . updateInstanceState ( { isToolLocked : true } ) ;
527+ this . editor . setCurrentTool ( shape . type ) ;
528+ } else {
529+ this . editor . setCurrentTool ( "select" ) ;
530+ }
531+ editor . setEditingShape ( null ) ;
532+ dialogRenderedRef . current = false ;
533+ } ;
534+
522535 renderModifyNodeDialog ( {
523536 mode : isCreating ? "create" : "edit" ,
524537 nodeType : shape . type ,
@@ -570,13 +583,14 @@ export class BaseDiscourseNodeUtil extends BaseBoxShapeUtil<DiscourseNodeShape>
570583 } ) ;
571584 }
572585 }
573-
574- editor . setEditingShape ( null ) ;
575- dialogRenderedRef . current = false ;
576586 } ,
577587 onClose : ( ) => {
578- editor . setEditingShape ( null ) ;
579- dialogRenderedRef . current = false ;
588+ if ( isCreating ) {
589+ restoreToolState ( ) ;
590+ } else {
591+ editor . setEditingShape ( null ) ;
592+ dialogRenderedRef . current = false ;
593+ }
580594 } ,
581595 } ) ;
582596
0 commit comments