Vanessa 2024-09-27 23:24:16 +08:00 committed by Daniel
parent 6ff4b621b2
commit 4dffc849c9
No known key found for this signature in database
GPG key ID: 86211BA83DF03017

View file

@ -623,6 +623,11 @@ export const keydown = (protyle: IProtyle, editorElement: HTMLElement) => {
const tdElement = hasClosestByMatchTag(range.startContainer, "TD") || hasClosestByMatchTag(range.startContainer, "TH");
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) {
// 代码块换最后一个 /n 肉眼是无法区分是否在其后的,因此统一在之前
position.end -= 1;
}
// 需使用 innerText 否则表格内 br 无法传唤为 /n
if (event.key === "ArrowDown" && nodeEditableElement?.innerText.trimRight().substr(position.start).indexOf("\n") === -1 && (
(tdElement && !tdElement.parentElement.nextElementSibling && nodeElement.getAttribute("data-type") === "NodeTable" && !getNextBlock(nodeElement)) ||