mirror of
https://github.com/heyman/heynote.git
synced 2024-11-22 16:03:28 +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) {
|
export function getActiveNoteBlock(state) {
|
||||||
// find which block the cursor is in
|
// find which block the cursor is in
|
||||||
const range = state.selection.asSingle().ranges[0]
|
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) {
|
export function getNoteBlockFromPos(state, pos) {
|
||||||
|
@ -28,7 +28,7 @@ export const formatBlockContent = ({ state, dispatch }) => {
|
|||||||
return false
|
return false
|
||||||
|
|
||||||
// get current cursor position
|
// get current cursor position
|
||||||
const cursorPos = state.selection.asSingle().ranges[0].to
|
const cursorPos = state.selection.asSingle().ranges[0].head
|
||||||
// get block content
|
// get block content
|
||||||
const content = state.sliceDoc(block.content.from, block.content.to)
|
const content = state.sliceDoc(block.content.from, block.content.to)
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user