@@ -73,8 +73,25 @@ class ComboMarkdownEditor {
7373 // upstream bug: The role code is never executed in base MarkdownButtonElement https://github.com/github/markdown-toolbar-element/issues/70
7474 el . setAttribute ( 'role' , 'button' ) ;
7575 }
76- this . switchToEasyMDEButton = this . container . querySelector ( '.markdown-switch-easymde' ) ;
77- this . switchToEasyMDEButton ?. addEventListener ( 'click' , async ( e ) => {
76+
77+ const monospaceButton = this . container . querySelector ( '.markdown-switch-monospace' ) ;
78+ const monospaceEnabled = localStorage ?. getItem ( 'markdown-editor-monospace' ) === 'true' ;
79+ const monospaceText = monospaceButton . getAttribute ( monospaceEnabled ? 'data-disable-text' : 'data-enable-text' ) ;
80+ monospaceButton . setAttribute ( 'data-tooltip-content' , monospaceText ) ;
81+ monospaceButton . setAttribute ( 'aria-checked' , String ( monospaceEnabled ) ) ;
82+
83+ monospaceButton ?. addEventListener ( 'click' , ( e ) => {
84+ e . preventDefault ( ) ;
85+ const enabled = localStorage ?. getItem ( 'markdown-editor-monospace' ) !== 'true' ;
86+ localStorage . setItem ( 'markdown-editor-monospace' , String ( enabled ) ) ;
87+ this . textarea . classList . toggle ( 'gt-mono' , enabled ) ;
88+ const text = monospaceButton . getAttribute ( enabled ? 'data-disable-text' : 'data-enable-text' ) ;
89+ monospaceButton . setAttribute ( 'data-tooltip-content' , text ) ;
90+ monospaceButton . setAttribute ( 'aria-checked' , String ( enabled ) ) ;
91+ } ) ;
92+
93+ const easymdeButton = this . container . querySelector ( '.markdown-switch-easymde' ) ;
94+ easymdeButton ?. addEventListener ( 'click' , async ( e ) => {
7895 e . preventDefault ( ) ;
7996 this . userPreferredEditor = 'easymde' ;
8097 await this . switchToEasyMDE ( ) ;
0 commit comments