diff --git a/app/src/protyle/util/selection.ts b/app/src/protyle/util/selection.ts index 8a4745541..034820a9c 100644 --- a/app/src/protyle/util/selection.ts +++ b/app/src/protyle/util/selection.ts @@ -204,7 +204,8 @@ export const getSelectionPosition = (nodeElement: Element, range?: Range) => { } } } else { - cursorRect = range.getBoundingClientRect(); + const rects = range.getClientRects(); // 由于长度过长折行,光标在行首时有多个 rects https://github.com/siyuan-note/siyuan/issues/6156 + cursorRect = rects[rects.length - 1]; } return { diff --git a/app/src/protyle/wysiwyg/keydown.ts b/app/src/protyle/wysiwyg/keydown.ts index 63d358cd1..00ed71009 100644 --- a/app/src/protyle/wysiwyg/keydown.ts +++ b/app/src/protyle/wysiwyg/keydown.ts @@ -592,7 +592,8 @@ export const keydown = (protyle: IProtyle, editorElement: HTMLElement) => { nodeElement.contains(firstEditElement) ) || (!firstEditElement && nodeElement.isSameNode(protyle.wysiwyg.element.firstElementChild))) { - if (nodeEditableElement?.textContent.substr(0, position.end).indexOf("\n") === -1) { + // 不能用\n判断,否则文字过长折行将错误 https://github.com/siyuan-note/siyuan/issues/6156 + if (getSelectionPosition(nodeElement, range).top - protyle.wysiwyg.element.getBoundingClientRect().top < 40) { if (protyle.title && (protyle.wysiwyg.element.firstElementChild.getAttribute("data-eof") === "true" || protyle.contentElement.scrollTop === 0)) { protyle.title.editElement.focus();