Skip to content

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

:art: arrowdown

Vanessad9c9b2dd6cea
diff --git a/app/src/block/popover.ts b/app/src/block/popover.ts
index 92e1272a8a..a4f33634b7 100644
--- a/app/src/block/popover.ts
+++ b/app/src/block/popover.ts
@@ -1,9 +1,5 @@
import {BlockPanel} from "./Panel";
-import {
- hasClosestBlock,
- hasClosestByAttribute,
- hasClosestByClassName,
-} from "../protyle/util/hasClosest";
+import {hasClosestBlock, hasClosestByAttribute, hasClosestByClassName,} from "../protyle/util/hasClosest";
import {fetchPost, fetchSyncPost} from "../util/fetch";
import {hideTooltip, showTooltip} from "../dialog/tooltip";
import {getIdFromSYProtocol, isLocalPath} from "../util/pathName";
@@ -177,7 +173,7 @@ const hidePopover = (event: MouseEvent & { path: HTMLElement[] }) => {
if (!popoverTargetElement && linkElement && linkElement.getAttribute("data-href")?.startsWith("siyuan://blocks")) {
popoverTargetElement = linkElement;
}
- if (!popoverTargetElement || window.siyuan.menus.menu?.data.isSameNode(popoverTargetElement)) {
+ if (!popoverTargetElement || (popoverTargetElement && window.siyuan.menus.menu.data?.isSameNode(popoverTargetElement))) {
// 移动到弹窗的 loading 元素上,但经过 settimeout 后 loading 已经被移除了
// https://ld246.com/article/1673596577519/comment/1673767749885#comments
let targetElement = target;
diff --git a/app/src/protyle/wysiwyg/keydown.ts b/app/src/protyle/wysiwyg/keydown.ts
index f5cca53770..49069ccd6e 100644
--- a/app/src/protyle/wysiwyg/keydown.ts
+++ b/app/src/protyle/wysiwyg/keydown.ts
@@ -5,8 +5,11 @@ import {
focusByRange,
focusByWbr,
getEditorRange,
- getSelectionOffset, getSelectionPosition,
- selectAll, setFirstNodeRange, setLastNodeRange,
+ getSelectionOffset,
+ getSelectionPosition,
+ selectAll,
+ setFirstNodeRange,
+ setLastNodeRange,
} from "../util/selection";
import {
hasClosestBlock,
@@ -28,11 +31,7 @@ import {
import {matchHotKey} from "../util/hotKey";
import {enter, softEnter} from "./enter";
import {fixTable} from "../util/table";
-import {
- turnsIntoOneTransaction, turnsIntoTransaction,
- updateBatchTransaction,
- updateTransaction
-} from "./transaction";
+import {turnsIntoOneTransaction, turnsIntoTransaction, updateBatchTransaction, updateTransaction} from "./transaction";
import {fontEvent} from "../toolbar/Font";
import {listIndent, listOutdent} from "./list";
import {newFileContentBySelect, rename, replaceFileName} from "../../editor/rename";
@@ -42,7 +41,8 @@ import {isLocalPath} from "../../util/pathName";
import {openBy, openFileById} from "../../editor/util";
/// #endif
import {
- alignImgCenter, alignImgLeft,
+ alignImgCenter,
+ alignImgLeft,
commonHotkey,
downSelect,
duplicateBlock,
@@ -674,6 +674,13 @@ export const keydown = (protyle: IProtyle, editorElement: HTMLElement) => {
}
}
if (event.key === "ArrowDown") {
+ if (nodeElement.isSameNode(protyle.wysiwyg.element.lastElementChild)) {
+ setLastNodeRange(getContenteditableElement(nodeEditableElement), range, false);
+ range.collapse(false)
+ event.stopPropagation();
+ event.preventDefault();
+ return;
+ }
const foldElement = hasClosestByAttribute(range.startContainer, "fold", "1");
if (foldElement) {
// 本身为折叠块
@@ -687,9 +694,6 @@ export const keydown = (protyle: IProtyle, editorElement: HTMLElement) => {
}
focusBlock(nextElement);
scrollCenter(protyle, nextElement);
- } else {
- setLastNodeRange(nodeEditableElement, range, false);
- range.collapse(false)
}
event.stopPropagation();
event.preventDefault();
@@ -699,12 +703,9 @@ export const keydown = (protyle: IProtyle, editorElement: HTMLElement) => {
if (nextFoldElement && nextFoldElement.getAttribute("fold") === "1") {
focusBlock(nextFoldElement);
scrollCenter(protyle, nextFoldElement);
- } else {
- setLastNodeRange(nodeEditableElement, range, false);
- range.collapse(false)
+ event.stopPropagation();
+ event.preventDefault();
}
- event.stopPropagation();
- event.preventDefault();
}
}
return;