Skip to content

An open-source, privacy-first, self-hosted knowledge workspace where humans and AI agents work together 开源、隐私优先、自托管的知识工作空间,让人与智能体在此协作

:art: https://github.com/siyuan-note/siyuan/issues/15844

Vanessa5e4ac24a6498
diff --git a/app/src/protyle/util/table.ts b/app/src/protyle/util/table.ts
index 0af29ef260..36bfd37f4a 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", "<br>");
+ return false;
+ }
+ }
+
// shift+enter 软换行
if (event.key === "Enter" && event.shiftKey && isNotCtrl(event) && !event.altKey) {
const wbrElement = document.createElement("wbr");