Skip to content

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

:bug: Prevent native undo after shortcut customization https://github.com/siyuan-note/siyuan/issues/18771

Daniel7b6fb53e63ba
diff --git a/app/src/protyle/wysiwyg/index.ts b/app/src/protyle/wysiwyg/index.ts
index 1f836bf330..04ca58cfcf 100644
--- a/app/src/protyle/wysiwyg/index.ts
+++ b/app/src/protyle/wysiwyg/index.ts
@@ -3840,6 +3840,11 @@ export class WYSIWYG {
});
this.element.addEventListener("beforeinput", async (event: InputEvent) => {
+ if (event.target === this.element &&
+ (event.inputType === "historyUndo" || event.inputType === "historyRedo")) {
+ event.preventDefault();
+ return;
+ }
const unidentifiedState = isInAndroid() ? takeMobileUnidentifiedKeyState() : undefined;
if (event.inputType === "deleteContentBackward" && unidentifiedState) {
unidentifiedState.placeholder?.remove();
diff --git a/app/src/protyle/wysiwyg/keydown.ts b/app/src/protyle/wysiwyg/keydown.ts
index d42e8d229a..8dd4c1b91f 100644
--- a/app/src/protyle/wysiwyg/keydown.ts
+++ b/app/src/protyle/wysiwyg/keydown.ts
@@ -253,6 +253,10 @@ export const keydown = (protyle: IProtyle, editorElement: HTMLElement) => {
event.stopPropagation();
return;
}
+ if (matchHotKey(Constants.SIYUAN_KEYMAP.editor.general.undo.default, event) ||
+ matchHotKey(Constants.SIYUAN_KEYMAP.editor.general.redo.default, event)) {
+ event.preventDefault();
+ }
if (protyle.disabled ||
(!protyle.selectElement.classList.contains("fn__none") &&
// 框选块时放行 ⌘C,以便复制选中的块 https://github.com/siyuan-note/siyuan/issues/18043