mirror of
https://github.com/heyman/heynote.git
synced 2025-01-15 18:38:14 +01:00
Fix so that C-a (select all) in empty blocks doesn't select the whole buffer on first press
This commit is contained in:
parent
4d98d9c861
commit
17a52683e9
@ -56,6 +56,19 @@ export const selectAll = ({ state, dispatch }) => {
|
|||||||
const range = state.selection.asSingle().ranges[0]
|
const range = state.selection.asSingle().ranges[0]
|
||||||
const block = getActiveNoteBlock(state)
|
const block = getActiveNoteBlock(state)
|
||||||
|
|
||||||
|
// handle empty blocks separately
|
||||||
|
if (block.content.from === block.content.to) {
|
||||||
|
// check if C-a has already been pressed
|
||||||
|
if (range.from === block.content.from-1 && range.to === block.content.to) {
|
||||||
|
return defaultSelectAll({state, dispatch})
|
||||||
|
}
|
||||||
|
dispatch(state.update({
|
||||||
|
selection: {anchor: block.content.from-1, head: block.content.to},
|
||||||
|
userEvent: "select"
|
||||||
|
}))
|
||||||
|
return true
|
||||||
|
}
|
||||||
|
|
||||||
// check if all the text of the note is already selected, in which case we want to select all the text of the whole document
|
// check if all the text of the note is already selected, in which case we want to select all the text of the whole document
|
||||||
if (range.from === block.content.from && range.to === block.content.to) {
|
if (range.from === block.content.from && range.to === block.content.to) {
|
||||||
return defaultSelectAll({state, dispatch})
|
return defaultSelectAll({state, dispatch})
|
||||||
|
Loading…
Reference in New Issue
Block a user