-
Notifications
You must be signed in to change notification settings - Fork 167
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
[List Feature] Backspace on empty list. #2316
Conversation
const { paragraph, marker, path } = context.insertPoint; | ||
|
||
if (context.deleteResult == 'nothingToDelete' || context.deleteResult == 'notDeleted') { | ||
const index = getClosestAncestorBlockGroupIndex(path, ['ListItem']); |
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.
Please add the 3rd parameter "['TableCell']" so if there is table under list, do not delete list. And add test case for this scenario
(paragraph.segments.length == 2 && paragraph.segments[1].segmentType == 'Br')) | ||
) { | ||
item.levels = []; | ||
context.deleteResult = 'singleChar'; |
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 feel here it would be better to use 'range' so that undo snapshot will be added.
(paragraph.segments.length == 1 || | ||
(paragraph.segments.length == 2 && paragraph.segments[1].segmentType == 'Br')) | ||
) { | ||
item.levels = []; |
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.
Just curious, if the list is a nested list, should we remove all the list like right now, or should we outdent to the previous level? Probably with levels.pop()
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 personally am ok with either. Maybe @jvillalobos can comment 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.
When we delete a nested list, the delete result returns 'Range', then it not impacted by this code. I tested in word desktop and it removes the list.
If the content edit list features are turned off, it is not possible to delete a list with just one list item. Therefore, the
deleteList
step was added to delete list when the backspace key is pressed on a list with no content.How to test:
Turn off the content edit features: