This commit is contained in:
Vanessa 2022-10-12 12:42:30 +08:00
parent 85f68e9817
commit b5df5e2f9a
2 changed files with 4 additions and 2 deletions

View file

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

View file

@ -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();