improve splitListItem #7

Closed
lucywang000 wants to merge 1 commit from fix-split-list-item into master
lucywang000 commented 2022-01-02 13:56:00 +01:00 (Migrated from github.com)

Checking for a non-nested depths should use $from.depth == 3 instead of 2.

Checking for a non-nested depths should use `$from.depth == 3` instead of 2.
marijnh commented 2022-01-03 14:56:07 +01:00 (Migrated from github.com)

Should it? With depth == 3, calling .node(-3) returns a node, and it looks like this is guarding against that returning undefined.

Should it? With `depth == 3`, calling `.node(-3)` returns a node, and it looks like this is guarding against that returning undefined.
lucywang000 commented 2022-01-04 08:05:15 +01:00 (Migrated from github.com)

That makes sense. But I still don't think $from.depth could be any value less than 3, since it requires at least a doc(0)>ul(1)>li(2)>p(3) for this command to work.

Maybe we shall change the earlier check:

    if ((node && node.isBlock) || $from.depth < 2 || !$from.sameParent($to)) return false

to:

    if ((node && node.isBlock) || $from.depth < 3 || !$from.sameParent($to)) return false

?

That makes sense. But I still don't think $from.depth could be any value less than 3, since it requires at least a `doc(0)>ul(1)>li(2)>p(3)` for this command to work. Maybe we shall change the earlier check: ``` if ((node && node.isBlock) || $from.depth < 2 || !$from.sameParent($to)) return false ``` to: ``` if ((node && node.isBlock) || $from.depth < 3 || !$from.sameParent($to)) return false ``` ?
marijnh commented 2022-01-04 08:46:58 +01:00 (Migrated from github.com)

What is the problem you are looking to solve here?

What is the problem you are looking to solve here?
lucywang000 commented 2022-01-04 11:38:49 +01:00 (Migrated from github.com)

Nothing particular, I'm just trying to understand the implementation of splitListItem, and find it pretty challenging to do so.

Nothing particular, I'm just trying to understand the implementation of `splitListItem`, and find it pretty challenging to do so.
marijnh commented 2022-01-04 11:50:25 +01:00 (Migrated from github.com)

All right, if there's no actual bug that's being addressed, I'll close this.

All right, if there's no actual bug that's being addressed, I'll close this.

Pull request closed

Sign in to join this conversation.
No reviewers
No labels
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
prosemirror/prosemirror-schema-list!7
No description provided.