Skip to content

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

:bug: https://github.com/siyuan-note/siyuan/issues/13113

Vanessaf17e341dbc05
diff --git a/app/src/protyle/header/Title.ts b/app/src/protyle/header/Title.ts
index d006f1d250..dc8d1c2078 100644
--- a/app/src/protyle/header/Title.ts
+++ b/app/src/protyle/header/Title.ts
@@ -105,7 +105,8 @@ export class Title {
if (event.key === "ArrowDown") {
const rects = getSelection().getRangeAt(0).getClientRects();
// https://github.com/siyuan-note/siyuan/issues/11729
- if (this.editElement.getBoundingClientRect().bottom - rects[rects.length - 1].bottom < 25) {
+ if (rects.length === 0 // 标题为空时时
+ || this.editElement.getBoundingClientRect().bottom - rects[rects.length - 1].bottom < 25) {
const noContainerElement = getNoContainerElement(protyle.wysiwyg.element.firstElementChild);
// https://github.com/siyuan-note/siyuan/issues/4923
if (noContainerElement) {
diff --git a/app/src/protyle/util/selection.ts b/app/src/protyle/util/selection.ts
index 956e9f9e47..a6487b91f1 100644
--- a/app/src/protyle/util/selection.ts
+++ b/app/src/protyle/util/selection.ts
@@ -234,10 +234,17 @@ export const getSelectionPosition = (nodeElement: Element, range?: Range) => {
}
} else {
const rects = range.getClientRects(); // 由于长度过长折行,光标在行首时有多个 rects https://github.com/siyuan-note/siyuan/issues/6156
- return { // 选中多行不应遮挡第一行 https://github.com/siyuan-note/siyuan/issues/7541
- left: rects[rects.length - 1].left,
- top: rects[0].top
- };
+ if (range.toString()) {
+ return { // 选中多行不应遮挡第一行 https://github.com/siyuan-note/siyuan/issues/7541
+ left: rects[rects.length - 1].left,
+ top: rects[0].top
+ };
+ } else {
+ return { // 代码块首 https://github.com/siyuan-note/siyuan/issues/13113
+ left: rects[rects.length - 1].left,
+ top: rects[rects.length - 1].top
+ };
+ }
}
return {