Vanessa 2024-11-15 23:01:54 +08:00
parent 7b342fc004
commit f17e341dbc
2 changed files with 13 additions and 5 deletions

View file

@ -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) {

View file

@ -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 {