Fix issue where deleteLine command could fuck up the Heynote block syntax

This commit is contained in:
Jonatan Heyman 2025-04-10 16:57:20 +02:00
parent 863a721bef
commit deedf24394

View File

@ -1,5 +1,5 @@
import { EditorSelection } from "@codemirror/state"
import { getActiveNoteBlock } from "./block"
import { getNoteBlockFromPos } from "./block"
function updateSel(sel, by) {
return EditorSelection.create(sel.ranges.map(by), sel.mainIndex);
@ -28,10 +28,10 @@ export const deleteLine = (view) => {
const { state } = view
const block = getActiveNoteBlock(view.state)
const selectedLines = selectedLineBlocks(state)
const changes = state.changes(selectedLines.map(({ from, to }) => {
const block = getNoteBlockFromPos(state, from)
if(from !== block.content.from || to !== block.content.to) {
if (from > 0) from--
else if (to < state.doc.length) to++