The forum we are running is mainly in english but we have some pages recently that are RTL (arabic)
what is the recommended way to get a specific topic to have RTL direction
is this the only posibility ?
is this a plugin that can handle the tags [text-direction=rtl] [/text-direction]
I havenāt looked at that plugin in a while. I wouldnāt recommend using it. For now, the best way to get RTL content to display correctly when a LTR locale is being used is to wrap the content in <div dir="rtl"></div> tags. Doing this wonāt cause any trouble when support for mixed text direction is added. The ETA for that feature is early next week.
Sorry, the dir attribute is only whitelisted for <div> tags.
<div dir="rtl">this is a test</div> will work:
There is no setting to add attributes to the Discourse whitelist. It can be done through a plugin. Thatās what the plugin that you linked to is doing.
Itās doesnāt get inherited, so it would need to be applied to every element in a cooked post. Also, Internet Explorer doesnāt support it. If weāre not concerned about supporting IE, there are places in the code that it would be useful (titles, category descriptions, etc.), but itās easy enough to add a helper function that sets the direction of those elements based on their text content.
It automatically applies the correct direction to text in the preview window, cooked posts, titles etc. It sets the direction of text fields based on the text that is entered. It doesnāt automatically set the direction of the composerās textarea. To make it easier to type, you can switch the direction of the textarea by clicking a button. Changing the textareaās direction doesnāt affect its final output. It will be formatted correctly regardless of the direction the textarea is set to.
Facebookās editor handles text direction very well. They can do this because their editor is using contenteditable. This lets them set the text direction on individual elements in the editor. Itās possible to get behaviour similar to this by adding the attribute dir="auto"to the composerās textarea, but doing that has some strange side effects.
It is available in the master branch now. Enable it by selecting the support_mixed_text_direction setting. Iāll write a topic about it soon.
There are a few improvements that could be made to the way itās setting the text direction for topics. The biggest problem Iām seeing with it is that usernames need to be treated as a special case.
To get category descriptions to display correctly on the categories page, you need to add this css to your theme. Iāll make a pull request to add that to the main code.
The button for toggling the editorās direction is found here. Toggling the editorās direction doesnāt affect the editorās output, it just makes it easier to type.
There are still a few areas where mixed text could be displayed that are not having their text-direction set. If you come across any, please let us know.
I would love to support partial ltr/rtl to be visible in the composer but it will require a pretty big change to the composer cause we can no longer use a text area and would have to use a content editable div
So maybe removing that button is better. because at least for my community, it is confusing the ppl. they think that it is that button that decides the direction of text.
I realized that to change the direction of text, rtl and ltr contents should be separated by two enters. Can you also support correct direction with one enter?
I think it is possible, but Iām not sure how efficient it will be. Iāll give it a try.
The easiest non-technical explanation for the difference between one and two enters is that two enters (a blank line) creates a new paragraph. The direction is being set at the paragraph level.
@simon, I found that there is a great performance drop in long topics containing mixed text direction. First I thought its because of rating plugin. However after further examination, I turned off this feature in our forum, and found that everything was back to normal.