mirror of
https://github.com/heyman/heynote.git
synced 2025-02-25 06:32:21 +01:00
Change getActiveNoteBlock and getNoteBlockFromPos so that they return a block even if the cursor is hidden within a separator. Shouldn't happen, but this should make it more robust.
This commit is contained in:
parent
751dfa0a73
commit
b44b47991b
@ -38,6 +38,10 @@ function getBlocks(state) {
|
||||
from: type.from,
|
||||
to: type.to,
|
||||
},
|
||||
range: {
|
||||
from: type.node.from,
|
||||
to: contentNode.to,
|
||||
},
|
||||
})
|
||||
return false;
|
||||
}
|
||||
@ -69,11 +73,11 @@ export const blockState = StateField.define({
|
||||
export function getActiveNoteBlock(state) {
|
||||
// find which block the cursor is in
|
||||
const range = state.selection.asSingle().ranges[0]
|
||||
return state.facet(blockState).find(block => block.content.from <= range.from && block.content.to >= range.from)
|
||||
return state.facet(blockState).find(block => block.range.from <= range.from && block.range.to >= range.from)
|
||||
}
|
||||
|
||||
export function getNoteBlockFromPos(state, pos) {
|
||||
return state.facet(blockState).find(block => block.content.from <= pos && block.content.to >= pos)
|
||||
return state.facet(blockState).find(block => block.range.from <= pos && block.range.to >= pos)
|
||||
}
|
||||
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user