mirror of
https://github.com/heyman/heynote.git
synced 2024-11-21 23:43:22 +01:00
Use selection.head when instead of to/from when determining active block, and formatting code
This commit is contained in:
parent
e1fe26b881
commit
2c1e23c9f4
@ -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) {
|
||||
|
@ -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)
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user