Skip to content

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

:art: fix https://github.com/siyuan-note/siyuan/issues/12468

Vanessa862a9a6bebe7
diff --git a/app/src/protyle/wysiwyg/input.ts b/app/src/protyle/wysiwyg/input.ts
index e28f396596..0c9ba96bb0 100644
--- a/app/src/protyle/wysiwyg/input.ts
+++ b/app/src/protyle/wysiwyg/input.ts
@@ -54,14 +54,21 @@ export const input = async (protyle: IProtyle, blockElement: HTMLElement, range:
blockElement.setAttribute("updated", dayjs().format("YYYYMMDDHHmmss"));
const wbrElement: HTMLElement = document.createElement("wbr");
range.insertNode(wbrElement);
- if (event && event.inputType === "deleteContentForward") {
+ if (event) {
const wbrNextElement = hasNextSibling(wbrElement) as HTMLElement;
- if (wbrNextElement && wbrNextElement.nodeType === 1 && !wbrNextElement.textContent.startsWith(Constants.ZWSP)) {
- const nextType = (wbrNextElement.getAttribute("data-type") || "").split(" ");
- if (nextType.includes("code") || nextType.includes("kbd") || nextType.includes("tag")) {
- wbrNextElement.insertAdjacentElement("afterbegin", wbrElement);
+ if (event.inputType === "deleteContentForward") {
+ if (wbrNextElement && wbrNextElement.nodeType === 1 && !wbrNextElement.textContent.startsWith(Constants.ZWSP)) {
+ const nextType = (wbrNextElement.getAttribute("data-type") || "").split(" ");
+ if (nextType.includes("code") || nextType.includes("kbd") || nextType.includes("tag")) {
+ wbrNextElement.insertAdjacentElement("afterbegin", wbrElement);
+ }
}
}
+ // https://github.com/siyuan-note/siyuan/issues/12468
+ if ((event.inputType === "deleteContentBackward" || event.inputType === "deleteContentForward") &&
+ wbrNextElement && wbrNextElement.nodeType === 1 && wbrNextElement.tagName === "BR") {
+ wbrNextElement.remove();
+ }
}
const id = blockElement.getAttribute("data-node-id");
if ((type !== "NodeCodeBlock" && type !== "NodeHeading") && // https://github.com/siyuan-note/siyuan/issues/11851