[5.x] Fix text direction in the Markdown fieldtype when using RTL mode - #10931
Conversation
|
Please ensure that CodeMirror is always set to left-to-right (LTR) to avoid any rendering issues in code editors. It’s important to note that the Markdown field type is also considered a code editor. The issue users are encountering in #10928 occurs because the locale does not change when switching sites. In #9452, I previously attempted to address this issue, but the proposal was declined. You can read in the comments that Jason had a different approach to resolving the problem. |
|
Based on my experience, I believe users may find an RTL Markdown editor uncomfortable to work with. As demonstrated in the issue screenshots, the placement of characters in RTL mode can be confusing, making it difficult to follow what is being written. Developing a better Markdown editor for RTL will require careful attention to detail in bidirectional (bidi) rendering and thoughtful consideration of these challenges. |
The reason was that some fields (like the slug fieldtype and code fieldtype) make sense to be LTR all the time, even when you have configured RTL. I think the argument to keep the markdown field as LTR is that markdown is "code". I think I disagree on this one. Here's the markdown fieldtype and the code fieldtype both working fine with the changes from this PR and the CP set to Arabic. The markdown characters like markdown_field: |-
## العنوان
الع *نوان*<h2>العنوان</h2>
<p>الع <em>نوان</em></p>(Excuse the Arabic characters, I have no idea what I wrote.) |
|
For simple markups like headers, bold, and italic it is ok but for links, files, and images it is confusing... |
|
I'm going to revert this. I agree. Code is super awkward. It looks like Codemirror has solutions for this though. https://codemirror.net/examples/bidi/ |

This pull request fixes an issue with the Markdown fieldtype when using the Control Panel with an RTL locale, like Persian.
I've fixed this by removing a CSS rule which was causing the text to show left-to-right, even when the CP is in right-to-left mode.
This CSS rule was updated in #9447. Maybe there's a reason for it... but it doesn't match how other fieldtypes (like the Textarea fieldtype) handle RTL.
Fixes #10928.