Skip to content

[5.x] Fix text direction in the Markdown fieldtype when using RTL mode - #10931

Merged
jasonvarga merged 1 commit into
5.xfrom
fix/markdown-fieldtypes-rtl
Oct 18, 2024
Merged

[5.x] Fix text direction in the Markdown fieldtype when using RTL mode#10931
jasonvarga merged 1 commit into
5.xfrom
fix/markdown-fieldtypes-rtl

Conversation

@duncanmcclean

Copy link
Copy Markdown
Member

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.

@ebeauchamps

Copy link
Copy Markdown
Contributor

@peimn could probably provide with a feedback on this and on #10928

@peimn

peimn commented Oct 11, 2024

Copy link
Copy Markdown
Contributor

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.

@peimn

peimn commented Oct 11, 2024

Copy link
Copy Markdown
Contributor

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.

@jasonvarga

Copy link
Copy Markdown
Member

This CSS rule was updated in #9447. Maybe there's a reason for it.

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.

CleanShot 2024-10-18 at 14 09 33

The markdown characters like ## for h2s are on the right, and this seems to work fine. It's rendered properly on the frontend through the markdown package.

markdown_field: |-
  ## العنوان

  الع *نوان*
<h2>العنوان</h2>
<p>الع <em>نوان</em></p>

(Excuse the Arabic characters, I have no idea what I wrote.)

@jasonvarga
jasonvarga merged commit 467e09e into 5.x Oct 18, 2024
@jasonvarga
jasonvarga deleted the fix/markdown-fieldtypes-rtl branch October 18, 2024 18:20
@peimn

peimn commented Oct 18, 2024

Copy link
Copy Markdown
Contributor

For simple markups like headers, bold, and italic it is ok but for links, files, and images it is confusing...

@jasonvarga

Copy link
Copy Markdown
Member

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/
We could probably solve it properly eventually.

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Control Panel doesn't work correctly with RTL languages

4 participants