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) {
|
switch (event.key) {
|
||||||
case "ArrowDown": {
|
case "ArrowDown": {
|
||||||
const { selection } = view.state;
|
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;
|
const nextBlock = $pos.nodeAfter;
|
||||||
|
|
||||||
if (
|
if (
|
||||||
@@ -229,7 +231,9 @@ export default function Mermaid({
|
|||||||
}
|
}
|
||||||
case "ArrowUp": {
|
case "ArrowUp": {
|
||||||
const { selection } = view.state;
|
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;
|
const prevBlock = $pos.nodeBefore;
|
||||||
|
|
||||||
if (
|
if (
|
||||||
|
|||||||
Reference in New Issue
Block a user