@@ -54,6 +54,12 @@ export function getScript(vscode: VSCodeApi, document: Document, window: Window)
5454 root . addEventListener ( 'click' , ( e : MouseEvent ) => {
5555 const target = e . target instanceof Element ? e . target : null ;
5656 if ( ! target ) return ;
57+ const iconButton = target . closest ?.( '.icon-button' ) ;
58+ if ( iconButton && ! ( iconButton as HTMLButtonElement ) . disabled ) {
59+ iconButton . classList . remove ( 'icon-button-pop' ) ;
60+ void ( iconButton as HTMLElement ) . offsetWidth ;
61+ iconButton . classList . add ( 'icon-button-pop' ) ;
62+ }
5763
5864 // context section toggle
5965 const contextToggleButton = target . closest ?.( '.context-toggle-btn' ) ;
@@ -77,7 +83,8 @@ export function getScript(vscode: VSCodeApi, document: Document, window: Window)
7783
7884 const icon = contextToggleButton . querySelector ( '.context-toggle-icon' ) ;
7985 if ( icon ) {
80- icon . textContent = nextExpanded ? '▾' : '▸' ;
86+ icon . classList . toggle ( 'codicon-triangle-down' , nextExpanded ) ;
87+ icon . classList . toggle ( 'codicon-triangle-right' , ! nextExpanded ) ;
8188 }
8289
8390 return ;
@@ -143,7 +150,7 @@ export function getScript(vscode: VSCodeApi, document: Document, window: Window)
143150 }
144151
145152 // toggle diagram orientation
146- if ( target . id === ' diagram-orientation-btn') {
153+ if ( target . closest ?. ( '# diagram-orientation-btn') ) {
147154 e . stopPropagation ( ) ;
148155 diagramOrientation = diagramOrientation === "TB" ? "LR" : "TB" ;
149156 resetZoom ( document ) ;
@@ -152,40 +159,42 @@ export function getScript(vscode: VSCodeApi, document: Document, window: Window)
152159 }
153160
154161 // toggle diagram conditions
155- if ( target . id === 'diagram-conditions-btn' ) {
162+ const diagramConditionsButton = target . closest ?.( '#diagram-conditions-btn' ) ;
163+ if ( diagramConditionsButton ) {
156164 e . stopPropagation ( ) ;
157- if ( ( target as HTMLButtonElement ) . disabled ) return ;
165+ if ( ( diagramConditionsButton as HTMLButtonElement ) . disabled ) return ;
158166 showDiagramConditions = ! showDiagramConditions ;
159167 updateView ( ) ;
160168 return ;
161169 }
162170
163171 // zoom in
164- if ( target . id === ' zoom-in-btn') {
172+ if ( target . closest ?. ( '# zoom-in-btn') ) {
165173 e . stopPropagation ( ) ;
166174 zoomIn ( document ) ;
167175 return ;
168176 }
169177
170178 // zoom out
171- if ( target . id === ' zoom-out-btn') {
179+ if ( target . closest ?. ( '# zoom-out-btn') ) {
172180 e . stopPropagation ( ) ;
173181 zoomOut ( document ) ;
174182 return ;
175183 }
176184
177185 // reset zoom
178- if ( target . id === ' zoom-reset-btn') {
186+ if ( target . closest ?. ( '# zoom-reset-btn') ) {
179187 e . stopPropagation ( ) ;
180188 resetZoom ( document ) ;
181189 return ;
182190 }
183191
184192 // copy diagram source
185- if ( target . id === 'copy-diagram-btn' ) {
193+ const copyDiagramButton = target . closest ?.( '#copy-diagram-btn' ) ;
194+ if ( copyDiagramButton ) {
186195 e . stopPropagation ( ) ;
187196 if ( ! currentDiagram ) return
188- copyDiagramToClipboard ( target , currentDiagram ) ;
197+ copyDiagramToClipboard ( copyDiagramButton , currentDiagram ) ;
189198 return ;
190199 }
191200
@@ -315,7 +324,7 @@ export function getScript(vscode: VSCodeApi, document: Document, window: Window)
315324 case 'fsm' : {
316325 const diagram = createMermaidDiagram ( stateMachine , diagramOrientation , showDiagramConditions ) ;
317326 currentDiagram = diagram ;
318- root . innerHTML = renderStateMachineView ( stateMachine , diagram , diagramOrientation , showDiagramConditions ) ;
327+ renderStateMachineView ( root , stateMachine , diagram , diagramOrientation , showDiagramConditions ) ;
319328 if ( stateMachine ) renderMermaidDiagram ( document , window ) ;
320329 break ;
321330 }
0 commit comments