Vanessa 2024-10-07 19:45:34 +08:00
parent 86d2d1047d
commit 4de3649673

View file

@ -736,14 +736,14 @@ export const keydown = (protyle: IProtyle, editorElement: HTMLElement) => {
} else if (nodeEditableElement?.innerText.substr(position.end).indexOf("\n") === -1 || position.end >= nodeEditableElement.innerText.trimEnd().length) {
// 需使用 innerText否则 td 中的 br 无法转换为 \n; position.end 不能加1否则倒数第二行行末无法下移
range.collapse(false);
const nextFoldElement = getNextBlock(nodeElement) as HTMLElement;
if (nextFoldElement) {
if(nodeEditableElement.getBoundingClientRect().bottom - getSelectionPosition(nodeElement, range).top < 40) {
focusBlock(nextFoldElement);
scrollCenter(protyle, nextFoldElement);
event.stopPropagation();
event.preventDefault();
}
const nextElement = getNextBlock(nodeElement) as HTMLElement;
if (nextElement &&
(nextElement.getAttribute("fold") === "1" || nextElement.classList.contains("code-block")) &&
nodeEditableElement.getBoundingClientRect().bottom - getSelectionPosition(nodeElement, range).top < 40) {
focusBlock(nextElement);
scrollCenter(protyle, nextElement);
event.stopPropagation();
event.preventDefault();
}
}
}