Closed edenbd50 closed 10 months ago
I've provided a bunch of feedback here and on discord.
A) Deleting last char on RTL errors out I promised to gate keep the bugs away. So I was doing some smoke testing and found out that if you delete down to the last character on a RTL line, we get an error. It's very hard to say at first sight what's that about. Can you have a look on this one?
B) Shouldn't there be a button to also reverse back to LTR ?
C) If I tap at the end of RTL line (left side) the cursor goes after the first character instead of in front of it Clicking in front of it is really difficult (needs precision)
D) The arrows move the caret in an inverted fashion I am new to RTL so maybe I have the wrong bias. But I think left arrow should move carte to left. It moves to right -> And then it reverts again if it goes trough the latin characters
E) The selection behavior is really odd in mixed mode Image
F) The caret jumps wildly in mixed mode
G) When retrieving latest develop, use rebase. Now it's a merge. And it creates a complex history. I'm keeping it super trimmed down for ease of reading. I can't squash it as it is right now. I'll see if I can force it somehow. The easiest would be if you copy past everything on a new branch such that I can get the squashed version.
Looks like github/chrome has the same implementation... I guess I'm not too familiar with how it should work.
Nice work on setting up the tests ❤️ I'm curios, I see there was some RTL attempt in the legacy code. What happened there? Why id did not work? Was it even attempted? So, let me know, what you think of the feedback and if you wish to tackle any of them in this commit or make new tickets. I'll wait for your answer before merging. By the looks of the places you changed, I think I wont collide with your changes in my work.
Also, if you are so kind, please try to cherypick/squash somehow the changes on top of the latest develop so we can do one single clean commit.
I hope I don't ask too much. Thanks a lot for the patience! Great work!
H) What about bullets? Are they expected to be on the right side or left side? And code block numbers
I've provided a bunch of feedback here and on discord.
A) Deleting last char on RTL errors out I promised to gate keep the bugs away. So I was doing some smoke testing and found out that if you delete down to the last character on a RTL line, we get an error. It's very hard to say at first sight what's that about. Can you have a look on this one?
B) Shouldn't there be a button to also reverse back to LTR ?
C) If I tap at the end of RTL line (left side) the cursor goes after the first character instead of in front of it Clicking in front of it is really difficult (needs precision)
D) The arrows move the caret in an inverted fashion I am new to RTL so maybe I have the wrong bias. But I think left arrow should move carte to left. It moves to right -> And then it reverts again if it goes trough the latin characters
E) The selection behavior is really odd in mixed mode Image
F) The caret jumps wildly in mixed mode
G) When retrieving latest develop, use rebase. Now it's a merge. And it creates a complex history. I'm keeping it super trimmed down for ease of reading. I can't squash it as it is right now. I'll see if I can force it somehow. The easiest would be if you copy past everything on a new branch such that I can get the squashed version.
Looks like github/chrome has the same implementation... I guess I'm not too familiar with how it should work.
Nice work on setting up the tests ❤️ I'm curios, I see there was some RTL attempt in the legacy code. What happened there? Why id did not work? Was it even attempted? So, let me know, what you think of the feedback and if you wish to tackle any of them in this commit or make new tickets. I'll wait for your answer before merging. By the looks of the places you changed, I think I wont collide with your changes in my work.
Also, if you are so kind, please try to cherypick/squash somehow the changes on top of the latest develop so we can do one single clean commit.
- use the ticket code in the name of the commit. I've started this convention a few commits ago.
I hope I don't ask too much. Thanks a lot for the patience! Great work!
H) What about bullets? Are they expected to be on the right side or left side? And code block numbers
A) Deleting last char on RTL errors out I think I have an Idea why it occurs, the last character of each row from my rtl.json example is “\n” which holds the RTL and Alignment properties. It appears that you can not use direction attribute directly to a Text node, only to the “\n” at the end otherwise it throws an error. Maybe because direction is considered a block type. It should behave as Quote / code block type. How do you think we should approach it?
B) Shouldn't there be a button to also reverse back to LTR ? It depends.. you can create direction ltr button that triggers attribute direction ltr. Since the default of the editor is already ltr It doesn’t matter, the rtl can behave as on / off(=ltr).
C) If I tap at the end of RTL line (left side) the cursor goes after the first character instead of in front of it Didn’t quite get what do you mean by after and in front , care to share an example?
D+E+F) The arrows move the caret in an inverted fashion, The selection behavior is really odd in mixed mode, The caret jumps wildly in mixed mode
G) When retrieving latest develop, use rebase. Yeah absolutely right 👍🏻 H) What about bullets? Are they expected to be on the right side or left side? Absolutely on right side , bulletin, checkbox , number list should all start from right. I didnt try to fix it in this pr since it’s considered out of scope and would have been messy. From the research Ive made, the bulletin is printed as Paint and not part of the sentence therefore direction / text alignment doesn’t apply to it. It uses Offset( 0 , … ) in order to paint it, so we need to attach it to RTL check and change it to the widget’s width minus the left padding of the actual bulletin. I considered it a fixable yet different PR imo ofc.
Goal: Support Right-To-Left text alignment for Visual Editor.
Problem:
1) Currently Visual Editor changes the whole block's directionality and does not effect the actual text inside.
2) In Right-To-Left languages the default TextAlignment is reversed meaning Start to End and End to Start.
Solution:
How it should look like when fixing both problems:
TextAlignment.start
+Direction RTL
In order to fix internal RTL, I've changed in
editable-text-block
the textDirection from "textDirection" to "nodeTextDirection", so it will inherit from the ToolBar's direction and not the Directionality of the whole document.In order to fix TextAlignment issue I changed
TextLineStylesUtils.getTextAlign
logic to check if TextDirection isRTL
then invert the TextAlignmentRTLPage demo is added to Example pages:
RTLPAge.dart
rtl.json
/rtl
Tests:
Note: In order to make logic testable the signature function of
_textLineStylesUtils.getTextAlign
was changed from receiving aLineM
to receiveAttributeM
.