File tree Expand file tree Collapse file tree 1 file changed +29
-1
lines changed
Expand file tree Collapse file tree 1 file changed +29
-1
lines changed Original file line number Diff line number Diff line change @@ -85,7 +85,11 @@ document.addEventListener("DOMContentLoaded", function () {
8585 } ) ;
8686 } ;
8787
88- initMermaid ( ) ;
88+ try {
89+ initMermaid ( ) ;
90+ } catch ( e ) {
91+ console . warn ( "Mermaid initialization failed:" , e ) ;
92+ }
8993
9094 const markedOptions = {
9195 gfm : true ,
@@ -712,6 +716,30 @@ This is a fully client-side application. Your content never leaves your browser
712716 } ) ;
713717
714718 markdownEditor . addEventListener ( "input" , debouncedRender ) ;
719+
720+ // Tab key handler to insert indentation instead of moving focus
721+ markdownEditor . addEventListener ( "keydown" , function ( e ) {
722+ if ( e . key === 'Tab' ) {
723+ e . preventDefault ( ) ;
724+
725+ const start = this . selectionStart ;
726+ const end = this . selectionEnd ;
727+ const value = this . value ;
728+
729+ // Insert 2 spaces
730+ const indent = ' ' ; // 2 spaces
731+
732+ // Update textarea value
733+ this . value = value . substring ( 0 , start ) + indent + value . substring ( end ) ;
734+
735+ // Update cursor position
736+ this . selectionStart = this . selectionEnd = start + indent . length ;
737+
738+ // Trigger input event to update preview
739+ this . dispatchEvent ( new Event ( 'input' ) ) ;
740+ }
741+ } ) ;
742+
715743 editorPane . addEventListener ( "scroll" , syncEditorToPreview ) ;
716744 previewPane . addEventListener ( "scroll" , syncPreviewToEditor ) ;
717745 toggleSyncButton . addEventListener ( "click" , toggleSyncScrolling ) ;
You can’t perform that action at this time.
0 commit comments