Mixed RTL and LTR

I registered the plugin for review
it will be available in the community plugins if Obsidian confirms it

here is the Github repo (version 0.1.0 is ready for manual installation(until obsidian confirms then you can install from app))
repo link

7 Likes

It is really awesome. Tashakore faravan

1 Like

@mwxgaf although the approach in this plugin forces a rendering of CodeMirror (the underlying editor used by Obsidian) in a way that overrides the behavior of the editor, it works better than I expected!

Two initial problems that I ran into when testing this out were that:

  • Arrow keys, End and Home badly misbehave (up to a point that I find editing text unusable).
  • RTL bullet lists are not rendered properly.

I’m not sure if these are fixable, and what other problems hide in this approach, since AFAIK CodeMirror was not meant to operate this way. It does, in turn, have its own mixed LTR/RTL mode that was introduced lately, and there’s an effort in the RTL plugin to incorporate this support.
(But naturally, if the “force auto direction” approach you took here proves doable, it’s considerably simpler!)

3 Likes

Over 99% of my work with editor is with a single CSS line that should not cause any performance problems.
Must of code is about reading mode in the registered markdown post processor.
Yes unfortunately navigation keys does not work as excepted:

  • Home & End are vice versa in RTL lines
  • For arrow keys you must go to the beginning of the line & continue pressing left arrow (or mixed with CRTL) in order to reach the desired position. (In summary they are vice versa too)

Mouse or touch pad will be helpful & this will not be a problem in mobile.
Unfortunately I don’t have a fix for this in my mind at the moment.

But about bullet points I didn’t understand what you mean. They work correctly!
Screenshot from 2022-09-18 21-48-38

2 Likes

Try to press Tab to create a list of different depths (sub-items), it doesn’t seem to work as expected.
Edit: actually it sometimes works, can’t figure out when exactly :thinking:

2 Likes

Yes, it seems there is a little problem in Editor with nested RTL bullet points that some times happens & some times don’t.
I played a little & couldn’t understand what is the problem.
But in reading mode evey thing is OK.

New version released that fixes nested bullet points problem, Conflicts with obsidian 1.0.0 & … :point_right: Version 0.2.0
Please check if does it have any other problems about bullet points …
I am still waiting for my pull request to be merged (Publishing in community plugins)

3 Likes

Plugin in published! Thank you Obsidian.

5 Likes

The Dynamic RTL plugin is awesome and works perfectly with Obsidian 1.0.0. If you have problems with cursor movements, you can use Dynamic RTL plugin along with the RTL Support plugin.

Here I defined CTRL + ALT + -> as the switch text direction hotkey for RTL support plugin and I can manually change the direction whenever necessary.
Carnac_8mgAE0rNt9

4 Likes

Foreign Farsi learner here! such a live saver plugin! thanks for the dedication!

2 Likes

dastet tala :pray:t4:

2 Likes

Yes! Great to see this, thank you. It always drives me INSANE to see how people discuss LTR-RTL problems forever in different apps but don’t pay attention to the simple <div dir="auto> solution. Thanks so much for implementing this! Works great!

2 Likes

@lingdocs by writing that you completely disregard the complexity of the actual problem.
dir="auto" applies to raw HTML but the CodeMirror editor that powers Obsidian is anything but raw HTML. It’s a very complicated and sophisticated editor that handles its own cursor movement, key maps, rendering and tons of other things, all with dozens of plugins added by Obsidian itself.
You can’t get such a piece of software to just obey dir="auto" if it is not built for it. It will cause rendering and cursor movement to be wrong in so many ways.
The only reason this became a possibility recently is because CodeMirror recently added support for it, which is a really awesome addition that we’ve all been wanting for a very long time. It was not just a “dir=auto” thing.

@esm90
@lingdocs
This is not correct completely
If i could modify the rendering system of code mirror in a way that all div.cm-lines became dir=auto every thing will be fixed completely without any cursor, performance, rendering or … problems.
I only used dir=auto for the reading view.
There is not any relations between dir=auto & cursor problem.
The cursor problem is because unicode-bidi css prop; Which is the only thing that I used for bidirectionalizing the editor.
The dir=auto is the best solution if I could apply it in CM rendering system.
The main inspiration for me to create this plugin was @lingdocs & his/her dir=auto idea :heart: :rose:

@mwxgaf I suggest to spend some time to get familiar with the CodeMirror code, including the (new) parts that allow your solution to work. The more you dive into it, the more things you can eventually do in this ecosystem :muscle:

1 Like

Very Amazing. Very Simple :heart_eyes::ok_hand::+1:
Thank you so much👋

For me I like it left alignment so, I added to your code just one line to achieve that:

* {
    unicode-bidi: plaintext;
    text-align: left;
}
2 Likes

althank you aghaye mwxgaf
you nejated my life and interested me in obsidian
:heart: :cupid: :cupid: :cupid: :cupid: :cupid: :heart:

1 Like

based on what @esm90 work on obsidian-rtl plugin following this issue I added auto direction feature. It works on both editing and reading view and changes the line direction based on first meaningful character of the line.
I made pull request here. It would be good if anyone other than me could test it.

2 Likes

For me on mobile, can you link the css file?

1 Like

Yes
Same as what you do in desktop