diff --git a/app/src/protyle/util/table.ts b/app/src/protyle/util/table.ts index 0af29ef26..36bfd37f4 100644 --- a/app/src/protyle/util/table.ts +++ b/app/src/protyle/util/table.ts @@ -6,7 +6,7 @@ import {isNotCtrl} from "./compatibility"; import {scrollCenter} from "../../util/highlightById"; import {insertEmptyBlock} from "../../block/util"; import {removeBlock} from "../wysiwyg/remove"; -import {hasPreviousSibling} from "../wysiwyg/getBlock"; +import {hasNextSibling, hasPreviousSibling} from "../wysiwyg/getBlock"; import * as dayjs from "dayjs"; const scrollToView = (nodeElement: Element, rowElement: HTMLElement, protyle: IProtyle) => { @@ -371,6 +371,15 @@ export const fixTable = (protyle: IProtyle, event: KeyboardEvent, range: Range) return false; } + if (event.key === "Backspace" && range.toString() === "") { + const previousElement = hasPreviousSibling(range.startContainer) as Element; + if (range.startOffset === 1 && previousElement.nodeType === 1 && previousElement.tagName === "BR" && + range.startContainer.textContent.length === 1 && !hasNextSibling(range.startContainer)) { + previousElement.insertAdjacentHTML("beforebegin", "
"); + return false; + } + } + // shift+enter 软换行 if (event.key === "Enter" && event.shiftKey && isNotCtrl(event) && !event.altKey) { const wbrElement = document.createElement("wbr");