I have developed a plugin for adding bidirectional text support for Logseq, helping users to be able to add their content in RTL and LTR directions. I hope one day this becomes the default behavior in Logseq but before that, with this plugin I want to ensure the right behavior is implemented.
Coming to the issue, it seems logseq manually handles events on key down event when it comes to pressing left/right arrow keys. I couldn’t find any way to change this behavior and as a result, when we are in RTL direction text, pressing left/right arrow keys, the cursor moves to the opposite direction. Surprisingly, there is no issue when the user use modifiers like Shift key.
I tried to use
event.preventDefault(). It works on all but the left/right keys. I think the issue resides in some logic within the Logseq core, but I couldn’t find it.
How do we fix this issue? Any workaround can be proposed till then?
My current workaround is to dispatch an event for pressing the opposite key, which is buggy if the user presses such keys at the beginning or the end of the text block (because it first moves in the opposite direction and then takes my moves and in such cases, it behaves abnormally).