Add getActiveNoteBlock function

This commit is contained in:
Jonatan Heyman 2023-01-02 11:49:45 +01:00
parent f53a579614
commit 95328ba739
1 changed files with 6 additions and 0 deletions

View File

@ -54,6 +54,12 @@ 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)
}
class NoteBlockStart extends WidgetType {
constructor() {