Skip to content

An open-source, privacy-first, self-hosted knowledge workspace where humans and AI agents work together 开源、隐私优先、自托管的知识工作空间,让人与智能体在此协作

:bug: Clear stale vertical navigation markers https://github.com/siyuan-note/siyuan/issues/19556

Danielf861bfe30436
diff --git a/app/src/protyle/wysiwyg/verticalNavigation.ts b/app/src/protyle/wysiwyg/verticalNavigation.ts
index 3c5ec6dc06..67ef94a416 100644
--- a/app/src/protyle/wysiwyg/verticalNavigation.ts
+++ b/app/src/protyle/wysiwyg/verticalNavigation.ts
@@ -92,6 +92,7 @@ export const prepareVerticalNavigation = (editorElement: HTMLElement, event: Key
};
const focusAtomicRegion = (editorElement: HTMLElement, element: HTMLElement, direction: TVerticalDirection) => {
+ let atomic = true;
if (element.classList.contains("custom-block")) {
editorElement.focus({preventScroll: true});
const range = document.createRange();
@@ -104,11 +105,17 @@ const focusAtomicRegion = (editorElement: HTMLElement, element: HTMLElement, dir
range.setStart(element, 0);
range.collapse(true);
focusByRange(range);
- } else if (!focusBlock(element, undefined, direction === "down")) {
- return false;
+ } else {
+ const range = focusBlock(element, undefined, direction === "down");
+ if (!range) {
+ return false;
+ }
+ atomic = !getContenteditableElement(element)?.contains(range.startContainer);
}
clearAtomicFocus(editorElement);
- element.classList.add(VERTICAL_NAVIGATION_ATOMIC_CLASS);
+ if (atomic) {
+ element.classList.add(VERTICAL_NAVIGATION_ATOMIC_CLASS);
+ }
return true;
};
diff --git a/app/tests/navigationLifecycle.cases.js b/app/tests/navigationLifecycle.cases.js
index 366e48a976..623b8a3bb7 100644
--- a/app/tests/navigationLifecycle.cases.js
+++ b/app/tests/navigationLifecycle.cases.js
@@ -101,6 +101,8 @@ module.exports = async () => {
mode + "/" + key + " expected " + expected.dataset.nodeId + " got " +
editor.querySelector("." + className)?.dataset.nodeId);
assert.equal(custom.querySelector("." + className), null);
+ assert.equal(editor.querySelectorAll(".protyle-wysiwyg--navigation").length,
+ expected === custom ? 1 : 0);
}
cases++;
}