Skip to content
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

fix: clear nodes when cursor at start of empty isolating parent #3943

Merged
merged 5 commits into from
Apr 5, 2023
Merged
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 8 additions & 1 deletion packages/core/src/extensions/keymap.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,14 @@ export const Keymap = Extension.create({
const { selection, doc } = tr
const { empty, $anchor } = selection
const { pos, parent } = $anchor
const isAtStart = Selection.atStart(doc).from === pos
const $parentPos = $anchor.parent.isTextblock ? tr.doc.resolve(pos - 1) : $anchor
const parentIsIsolating = $parentPos.parent.type.spec.isolating

const parentPos = $anchor.pos - $anchor.parentOffset

const isAtStart = (parentIsIsolating && $parentPos.parent.childCount === 1)
? parentPos === $anchor.pos
: Selection.atStart(doc).from === pos

if (!empty || !isAtStart || !parent.type.isTextblock || parent.textContent.length) {
return false
Expand Down