@@ -61,6 +61,8 @@ document.addEventListener("DOMContentLoaded", function () {
6161 const mobileThemeToggle = document . getElementById ( "mobile-theme-toggle" ) ;
6262 const shareButton = document . getElementById ( "share-button" ) ;
6363 const mobileShareButton = document . getElementById ( "mobile-share-button" ) ;
64+ const rtlToggleButton = document . getElementById ( "rtl-toggle" ) ;
65+ const mobileRtlToggle = document . getElementById ( "mobile-rtl-toggle" ) ;
6466 const githubImportModal = document . getElementById ( "github-import-modal" ) ;
6567 const githubImportTitle = document . getElementById ( "github-import-title" ) ;
6668 const githubImportUrlInput = document . getElementById ( "github-import-url" ) ;
@@ -1524,6 +1526,18 @@ This is a fully client-side application. Your content never leaves your browser
15241526 saveGlobalState ( { syncScrollingEnabled } ) ;
15251527 }
15261528
1529+ // RTL Preview Toggle
1530+ let rtlEnabled = false ;
1531+
1532+ function toggleRTL ( ) {
1533+ rtlEnabled = ! rtlEnabled ;
1534+ markdownPreview . setAttribute ( "dir" , rtlEnabled ? "rtl" : "ltr" ) ;
1535+ [ rtlToggleButton , mobileRtlToggle ] . forEach ( btn => {
1536+ if ( btn ) btn . classList . toggle ( "rtl-active" , rtlEnabled ) ;
1537+ } ) ;
1538+ saveGlobalState ( { rtlEnabled } ) ;
1539+ }
1540+
15271541 // View Mode Functions - Story 1.1 & 1.2
15281542 function setViewMode ( mode ) {
15291543 if ( mode === currentViewMode ) return ;
@@ -1745,6 +1759,7 @@ This is a fully client-side application. Your content never leaves your browser
17451759
17461760 initTabs ( ) ;
17471761 if ( loadGlobalState ( ) . syncScrollingEnabled === false ) toggleSyncScrolling ( ) ;
1762+ if ( loadGlobalState ( ) . rtlEnabled === true ) toggleRTL ( ) ;
17481763 updateMobileStats ( ) ;
17491764
17501765 // Initialize resizer - Story 1.3
@@ -1801,6 +1816,8 @@ This is a fully client-side application. Your content never leaves your browser
18011816 editorPane . addEventListener ( "scroll" , syncEditorToPreview ) ;
18021817 previewPane . addEventListener ( "scroll" , syncPreviewToEditor ) ;
18031818 toggleSyncButton . addEventListener ( "click" , toggleSyncScrolling ) ;
1819+ rtlToggleButton . addEventListener ( "click" , toggleRTL ) ;
1820+ mobileRtlToggle . addEventListener ( "click" , ( ) => { toggleRTL ( ) ; closeMobileMenu ( ) ; } ) ;
18041821 themeToggle . addEventListener ( "click" , function ( ) {
18051822 const theme =
18061823 document . documentElement . getAttribute ( "data-theme" ) === "dark"
0 commit comments