diff --git a/src/editor/block/block.js b/src/editor/block/block.js index 4abd7eb..f3b2cd7 100644 --- a/src/editor/block/block.js +++ b/src/editor/block/block.js @@ -74,7 +74,7 @@ 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.range.from <= range.from && block.range.to >= range.from) + return state.facet(blockState).find(block => block.range.from <= range.head && block.range.to >= range.head) } export function getNoteBlockFromPos(state, pos) { diff --git a/src/editor/block/format-code.js b/src/editor/block/format-code.js index f2ea0f2..8c123ed 100644 --- a/src/editor/block/format-code.js +++ b/src/editor/block/format-code.js @@ -28,7 +28,7 @@ export const formatBlockContent = ({ state, dispatch }) => { return false // get current cursor position - const cursorPos = state.selection.asSingle().ranges[0].to + const cursorPos = state.selection.asSingle().ranges[0].head // get block content const content = state.sliceDoc(block.content.from, block.content.to)