From 19ef894b2e0c45806c101d0c9a543263409b4599 Mon Sep 17 00:00:00 2001 From: Vanessa Date: Tue, 20 Jan 2026 18:22:16 +0800 Subject: [PATCH] :art: https://github.com/siyuan-note/siyuan/issues/16869 --- app/src/protyle/wysiwyg/keydown.ts | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/app/src/protyle/wysiwyg/keydown.ts b/app/src/protyle/wysiwyg/keydown.ts index cf381b357..26d963eff 100644 --- a/app/src/protyle/wysiwyg/keydown.ts +++ b/app/src/protyle/wysiwyg/keydown.ts @@ -626,6 +626,13 @@ export const keydown = (protyle: IProtyle, editorElement: HTMLElement) => { if (!event.altKey && !event.shiftKey && isNotCtrl(event) && !event.isComposing && (event.key.indexOf("Arrow") > -1)) { // 需使用 editabled,否则代码块会把语言字数算入 const tdElement = hasClosestByTag(range.startContainer, "TD") || hasClosestByTag(range.startContainer, "TH"); + let tdStatus; + if (tdElement) { + const cells = nodeElement.querySelectorAll('td, th'); + if (cells[cells.length - 1] === tdElement) { + tdStatus = "last"; + } + } const nodeEditableElement = (tdElement || getContenteditableElement(nodeElement) || nodeElement) as HTMLElement; const position = getSelectionOffset(nodeEditableElement, protyle.wysiwyg.element, range); if (nodeElement.classList.contains("code-block") && position.end === nodeEditableElement.innerText.length) { @@ -635,7 +642,7 @@ export const keydown = (protyle: IProtyle, editorElement: HTMLElement) => { } // 需使用 innerText 否则表格内 br 无法传唤为 /n if (event.key === "ArrowDown" && nodeEditableElement?.innerText.trimRight().substr(position.start).indexOf("\n") === -1 && ( - (tdElement && !tdElement.parentElement.nextElementSibling && nodeType === "NodeTable" && !getNextBlock(nodeElement)) || + (tdElement && tdStatus === "last" && nodeType === "NodeTable" && !getNextBlock(nodeElement)) || (nodeType === "NodeCodeBlock" && !getNextBlock(nodeElement)) || (nodeElement.parentElement.getAttribute("data-type") === "NodeBlockquote" && nodeElement.nextElementSibling.classList.contains("protyle-attr") && !getNextBlock(nodeElement.parentElement)) || (nodeElement.parentElement.classList.contains("callout-content") && !nodeElement.nextElementSibling && !getNextBlock(nodeElement.parentElement.parentElement)) @@ -731,7 +738,7 @@ export const keydown = (protyle: IProtyle, editorElement: HTMLElement) => { } if (event.key === "ArrowDown") { if (nodeEditableElement?.innerText.trimRight().substr(position.start).indexOf("\n") === -1 && - nodeElement === protyle.wysiwyg.element.lastElementChild) { + nodeElement === protyle.wysiwyg.element.lastElementChild && !tdElement) { setLastNodeRange(getContenteditableElement(nodeEditableElement), range, false); range.collapse(false); event.stopPropagation();