-
Notifications
You must be signed in to change notification settings - Fork 431
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat(portable-text-editor): determine if selection is made backward #5807
Conversation
The latest updates on your projects. Learn more about Vercel for Git ↗︎
1 Ignored Deployment
|
b0e18ea
to
b16d01e
Compare
No changes to documentation |
Component Testing Report Updated Feb 21, 2024 10:51 AM (UTC)
|
b16d01e
to
695fa9c
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is there any test case that we could add in which it covers the backward
selection?
Or maybe update some of the current selections and add backward: true
to be sure everything works in the same way even with the backward selection.
This is a good idea. I will add it. I think the rest of the tests will make sure that the existing functionality still works as expected. |
export type EditorSelection = { | ||
anchor: EditorSelectionPoint | ||
focus: EditorSelectionPoint | ||
backward?: boolean |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I wonder if it would be a bit more clear with direction: "forward" | "backward"
– what do you think?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It would be clearer, but then it would also have to be required imo.
The absence of "backward" means it's forward by default.
…ade backwards Add .backward? on EditorSelection to be able to tell if the selection was made backward.
695fa9c
to
d4db010
Compare
Added a new test that will test that |
Description
Add .backward? on EditorSelection to be able to tell if the selection was made backward in the content when returned by
PortableTextEditor.getSelection
This is needed in situations where the selection is made backward in the content, but we can only perform a task in the natural order (some for loop on text extractions or similar). By knowing that the selection is made backward, it's then just a matter of switching the anchor and focus points to have it in the natural order.
What to review
That the change looks good.
Testing
Should be covered by a lot of existing tests (see patch that updates them).
Notes for release
backward
property to the EditorSelection of the Portable Text Editor to tell if a selection was made backward in the content.