fix: JS error hitting up or down with entire document selection
closes #5863
This commit is contained in:
@@ -205,7 +205,9 @@ export default function Mermaid({
|
||||
switch (event.key) {
|
||||
case "ArrowDown": {
|
||||
const { selection } = view.state;
|
||||
const $pos = view.state.doc.resolve(selection.from + 1);
|
||||
const $pos = view.state.doc.resolve(
|
||||
Math.min(selection.from + 1, view.state.doc.nodeSize)
|
||||
);
|
||||
const nextBlock = $pos.nodeAfter;
|
||||
|
||||
if (
|
||||
@@ -229,7 +231,9 @@ export default function Mermaid({
|
||||
}
|
||||
case "ArrowUp": {
|
||||
const { selection } = view.state;
|
||||
const $pos = view.state.doc.resolve(selection.from - 1);
|
||||
const $pos = view.state.doc.resolve(
|
||||
Math.max(0, selection.from - 1)
|
||||
);
|
||||
const prevBlock = $pos.nodeBefore;
|
||||
|
||||
if (
|
||||
|
||||
Reference in New Issue
Block a user