Skip to content

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

:art: https://github.com/siyuan-note/siyuan/issues/11581

Ved6efb89dae4
diff --git a/app/src/protyle/wysiwyg/keydown.ts b/app/src/protyle/wysiwyg/keydown.ts
index 11a8a8825c..2642f5ea7e 100644
--- a/app/src/protyle/wysiwyg/keydown.ts
+++ b/app/src/protyle/wysiwyg/keydown.ts
@@ -15,7 +15,8 @@ import {
hasClosestBlock,
hasClosestByAttribute,
hasClosestByMatchTag,
- hasTopClosestByAttribute, isInEmbedBlock
+ hasTopClosestByAttribute,
+ isInEmbedBlock
} from "../util/hasClosest";
import {removeBlock, removeImage} from "./remove";
import {
@@ -24,7 +25,8 @@ import {
getLastBlock,
getNextBlock,
getPreviousBlock,
- getTopAloneElement, hasNextSibling,
+ getTopAloneElement,
+ hasNextSibling,
hasPreviousSibling,
isNotEditBlock,
} from "./getBlock";
@@ -46,14 +48,7 @@ import {isLocalPath} from "../../util/pathName";
/// #if !MOBILE
import {openBy, openFileById} from "../../editor/util";
/// #endif
-import {
- alignImgCenter,
- alignImgLeft,
- commonHotkey,
- downSelect,
- getStartEndElement,
- upSelect
-} from "./commonHotkey";
+import {alignImgCenter, alignImgLeft, commonHotkey, downSelect, getStartEndElement, upSelect} from "./commonHotkey";
import {fileAnnotationRefMenu, inlineMathMenu, linkMenu, refMenu, setFold, tagMenu} from "../../menus/protyle";
import {openAttr} from "../../menus/commonMenuItem";
import {Constants} from "../../constants";
@@ -648,7 +643,7 @@ export const keydown = (protyle: IProtyle, editorElement: HTMLElement) => {
) ||
(!firstEditElement && nodeElement.isSameNode(protyle.wysiwyg.element.firstElementChild))) {
// 不能用\n判断,否则文字过长折行将错误 https://github.com/siyuan-note/siyuan/issues/6156
- if (getSelectionPosition(nodeElement, range).top - protyle.wysiwyg.element.getBoundingClientRect().top < 40 || position.start === 0 || nodeElement.classList.contains("av")) {
+ if (getSelectionPosition(nodeElement, range).top - parseInt(getComputedStyle(nodeElement).paddingTop) - protyle.wysiwyg.element.getBoundingClientRect().top < 40 || nodeElement.classList.contains("av")) {
if (protyle.title && protyle.title.editElement &&
(protyle.wysiwyg.element.firstElementChild.getAttribute("data-eof") === "1" ||
protyle.contentElement.scrollTop === 0)) {
@@ -670,7 +665,7 @@ export const keydown = (protyle: IProtyle, editorElement: HTMLElement) => {
if (previousElement) {
const foldElement = hasClosestByAttribute(previousElement, "fold", "1") as HTMLElement;
// 代码块或以软换行结尾的块移动光标 ↑ 会跳过 https://github.com/siyuan-note/siyuan/issues/5498
- if (getContenteditableElement(previousElement)?.textContent.endsWith("\n") && !foldElement) {
+ if (!foldElement) {
focusBlock(previousElement, undefined, false);
scrollCenter(protyle, previousElement);
event.stopPropagation();