Closed klemenoslaj closed 1 year ago
I am under the impression that on Windows, the convention is still to have arrow keys move by logical index rather than visual position. Chrome seems to do that on Linux nowadays too—not sure about MacOS. And, as you mentioned, LTR text within an RTL container will also make it harder to figure out which way the cursor should be moving.
I spent a bit of time looking into this, but it seems like a lot more is needed to solve it in a reliable way. Screen position queries (getBoundingClientRect
on text ranges) are also doing weird things in RTL text on both Chrome and Firefox, making those also unsuitable as a way to figure out the direction at a given document position. Deriving the direction from the surrounding text would require a full implementation of the bidi algorithm, it seems, as well as a more complicated model of cursor positions (bidi direction changes mean one document position can correspond to multiple visual positions).
So, unfortunately, it seems like decent bidi text support in ProseMirror is still quite far off. I'll try to put some more thought into how to make this case less annoying next week.
That took a lot longer than hoped—apologies. Attached patch, though not perfect, should improve this a lot.
That took a lot longer than hoped—apologies. Attached patch, though not perfect, should improve this a lot.
Yeah, using it for a while now with patch-package. I expect there are a bunch of things this does not cover tho.
Keyboard navigation gets locked around any mark when the direction is
rtl
.Steps to reproduce:
https://user-images.githubusercontent.com/121867569/214037664-41699aea-da07-423f-8bab-9e1feb498e08.mov
It looks like the
prosemirror-view
does not recognize the direction and keeps handling navigation to and from marks asltr
.The following patch appears to fix the
rtl
direction but doesn't changeltr
.NOTE: The patch accounts only for the root element direction. For a more robust solution the direction should probably be checked for the currently selected paragraph.