fix(BlockEditor): trigger select-all blocks when block content is empty on Ctrl+A

This commit is contained in:
2026-04-25 19:12:04 -04:00
parent 21634f5a38
commit d859874122
@@ -158,10 +158,13 @@ const Block = forwardRef(function Block(
e.preventDefault();
const sel = window.getSelection();
const txt = el.textContent ?? '';
if (txt.length === 0) {
onSelectAllBlocks?.();
} else {
const fullySelected =
!!sel && sel.rangeCount > 0 && !sel.isCollapsed &&
el.contains(sel.anchorNode) && el.contains(sel.focusNode) &&
sel.toString() === txt && txt.length > 0;
sel.toString() === txt;
if (fullySelected) {
onSelectAllBlocks?.();
} else {
@@ -171,6 +174,7 @@ const Block = forwardRef(function Block(
sel?.addRange(range);
}
}
}
return;
}