Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

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

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Open
ssuvamm wants to merge1 commit intodocsifyjs:develop
base:develop
Choose a base branch
Loading
fromssuvamm:feat/rtl-support

Conversation

@ssuvamm
Copy link

@ssuvammssuvamm commentedMay 27, 2025
edited by sy-records
Loading

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 optionrtl (default:false) towindow.$docsify configuration insrc/core/config.js. Setting this totrue enables RTL mode.
  • Styling:
    • Createdsrc/themes/shared/_rtl.css with specific styles for RTL layout, including adjustments for text direction, sidebar positioning, and content margins.
    • Imported_rtl.css intosrc/themes/shared/__index.css.
  • Behavior: Modifiedsrc/core/Docsify.js to add artl class to the<body> element whenconfig.rtl is true. This class activates the RTL-specific CSS rules.
  • Testing: Added a new end-to-end test suite intest/e2e/rtl.test.js to verify:
    • Thertl class is applied to the body.
    • The sidebar is positioned on the right.
    • Content margins are adjusted for the right-hand sidebar.
  • Documentation: Updateddocs/configuration.md to document the newrtl option, its type, default value, and usage.

For any code change,

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

Does this PR introduce a breaking change?

No

Tested in the following browsers:

  • Chrome
  • Firefox
  • Safari
  • Edge

This commit introduces a new feature enabling Right-to-Left (RTL) layout for docsify sites.Key changes:- **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.This feature addresses your request for better RTL support, allowing you to create documentation sites that cater to RTL languages.
@vercel
Copy link

vercelbot commentedMay 27, 2025
edited
Loading

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

NameStatusPreviewCommentsUpdated (UTC)
docsify-preview✅ Ready (Inspect)Visit Preview💬Add feedbackMay 27, 2025 4:49am

@sy-records
Copy link
Member

Thanks for your contribution.

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

Check screenshots

image
image

this.initFetch();// Fetch data

if(this.config.rtl){
document.body.classList.add('rtl');

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

Instead of adding a class, what about using thedir attribute?
<html dir="rtl"> and target the changes in the layout using that as the selector?[dir=rtl] .layout

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

Agree with@rrickay that usingdir="rtl" is more reasonable since it is the standard HTML attr for RTL contents layout.
But if it add-on onhtml level for all contents, there is no place to change non-RTL content(img, code...etc) to place as LTR.
Maybe the styling on RTL should be more specific either configurable.

Sign up for freeto join this conversation on GitHub. Already have an account?Sign in to comment

Reviewers

@Koooooo-7Koooooo-7Koooooo-7 left review comments

@paulhibbittspaulhibbittsAwaiting requested review from paulhibbitts

+1 more reviewer

@rrickayrrickayrrickay left review comments

Reviewers whose approvals may not affect merge requirements

At least 2 approving reviews are required to merge this pull request.

Assignees

No one assigned

Labels

None yet

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

Right to Left Layout

4 participants

@ssuvamm@sy-records@rrickay@Koooooo-7

[8]ページ先頭

©2009-2025 Movatter.jp