docsify icon indicating copy to clipboard operation
docsify copied to clipboard

feat: Add Right-to-Left (RTL) layout support

Open ssuvamm opened this issue 6 months ago • 2 comments

Summary

This commit introduces a new feature enabling Right-to-Left (RTL) layout for docsify sites.

Related issue, if any:

Close #2511

What kind of change does this PR introduce?

  • Configuration: Added a new boolean option rtl (default: false) to window.$docsify configuration in src/core/config.js. Setting this to true enables RTL mode.
  • Styling:
    • Created src/themes/shared/_rtl.css with specific styles for RTL layout, including adjustments for text direction, sidebar positioning, and content margins.
    • Imported _rtl.css into src/themes/shared/__index.css.
  • Behavior: Modified src/core/Docsify.js to add a rtl class to the <body> element when config.rtl is true. This class activates the RTL-specific CSS rules.
  • Testing: Added a new end-to-end test suite in test/e2e/rtl.test.js to verify:
    • The rtl class is applied to the body.
    • The sidebar is positioned on the right.
    • Content margins are adjusted for the right-hand sidebar.
  • Documentation: Updated docs/configuration.md to document the new rtl option, its type, default value, and usage.

For any code change,

  • [x] Related documentation has been updated, if needed
  • [x] Related tests have been added or updated, if needed

Does this PR introduce a breaking change?

No

Tested in the following browsers:

  • [x] Chrome
  • [ ] Firefox
  • [ ] Safari
  • [x] Edge

ssuvamm avatar May 27 '25 04:05 ssuvamm

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
docsify-preview ✅ Ready (Inspect) Visit Preview 💬 Add feedback May 27, 2025 4:49am

vercel[bot] avatar May 27 '25 04:05 vercel[bot]

Thanks for your contribution.

I added some screenshots. There are some issues, such as search shortcut key prompts, etc.

Check screenshots

image image

sy-records avatar Jun 03 '25 02:06 sy-records