stevengharris / MarkupEditor

WYSIWYG editing for SwiftUI and UIKit apps
MIT License
338 stars 28 forks source link

Question: RTL language support #9

Open JohnKuan opened 2 years ago

JohnKuan commented 2 years ago

Hi @stevengharris, are you looking into the possibility of RTL language support in the future? I tested the editor with arabic language and while it does the basic BLU formatting, the bullet list and others are generally LTR supported only. The text carat is also on the right instead of the left for RTL language, but the characters are appended on the left.

https://user-images.githubusercontent.com/4402214/168764745-b925cfaf-521f-4ee0-88b9-e8ea6e169139.mp4

stevengharris commented 2 years ago

I have not looked into it and thought the standard WKWebView contenteditable behavior would just do the right thing. Do you know if it has the right cursor behavior. I don't think I am doing anything to override it but am not sure.

JohnKuan commented 2 years ago

Hi Steven, I was going through the built-in behaviour for RTL on default apps like Notes and Mail, they do have left cursor behaviour for RTL languages.

I went to check how others have been implementing it on web views. A quick solution I have found was to add dir="rtl" lang="" in the tag and this works. However I think this requires some form of javascript handling to detect a change to RTL keyboard.

Another method was to modify the semanticContentAttribute. This I have yet to experiment on.

https://stackoverflow.com/questions/49704617/how-to-support-rtl-text-in-webview https://stackoverflow.com/questions/35151038/changing-to-right-to-left-rtl-programmatically

stevengharris commented 2 years ago

Thank you very much! I will look into it.