-
Notifications
You must be signed in to change notification settings - Fork 210
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: delete key functionality #272
Conversation
Codecov Report
@@ Coverage Diff @@
## main #272 +/- ##
==========================================
+ Coverage 70.30% 70.36% +0.06%
==========================================
Files 238 239 +1
Lines 9893 9935 +42
==========================================
+ Hits 6955 6991 +36
- Misses 2938 2944 +6
|
} | ||
|
||
final position = selection.start; | ||
final node = editorState.getNodeAtPath(position.path); |
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.
final delta = node?.delta;
if (node == null || delta == null) { return }
// use `delta` here instead of `node.delta!`
return KeyEventResult.ignored; | ||
} | ||
//TODO(Lucas): add logic for merging a bulletList or numberedList item. | ||
if (nextNode.next == null && nextNode.children.isEmpty) { |
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.
Why did you use nextNode.next
here?
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.
Can you list all the cases so that I can implement it more effectively?
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 wrote this because in the backspace_command.dart we check the children and next node of a node when we want to append that node to the previous node. I guess it is a bit confusing. I tried to basically duplicate the behavior of the backspace_command.dart.
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.
In backspace handler, when we are at the start of a line and we press backspace, we want the current line to merge with the previous line.
Eg:
Welcome to AppFlowy
|Welcome to AppFlowy
->
Welcome to AppFlowy | Welcome to AppFlowy
In delete handler, when we are at the end of a line and we press a delete, we want the next line to merge with the current line.
Eg:
Welcome to AppFlowy|
Welcome to AppFlowy
->
Welcome to AppFlowy | Welcome to AppFlowy
// Before | ||
// Welcome to AppFlowy Editor 🔥!| | ||
// Welcome to AppFlowy Editor 🔥! | ||
// After | ||
// Welcome to AppFlowy Editor 🔥!|Welcome to AppFlowy Editor 🔥! | ||
// | ||
// test('''Delete the collapsed selection's next node when cursor is at end | ||
// and current node contains a delta | ||
// and the next node is the child of the current node''', () async { | ||
// final document = Document.blank().addParagraph( | ||
// initialText: text, |
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.
Why comment out this code?
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.
This is the only functionality that needs to be implemented, I have commented this test, because the functionality is not yet implemented. We will just have to un-comment it and modify it a little bit in the future.
@MayurSMahajan Nice try! Can you list all the cases that related to For example,
|
@LucasXu0 Here are the cases for the delete key: Collapsed Selection:
Non-Collapsed Selection: Just delete the selection entirely, implemented |
Very clear. So do you need me to implement the missing part? |
Yes, I can't wrap my head around it 😅, I guess if you can do it, that would be great. |
b1396d8
to
7fdd9ad
Compare
Solves: #335 and partially solves: #2888
Added functionalities: