An open-source, privacy-first, self-hosted knowledge workspace where humans and AI agents work together 开源、隐私优先、自托管的知识工作空间,让人与智能体在此协作
TypeScript agentic-aiai-agentknowledge-baselocal-firstmarkdownmcpmindmapnote-takingself-hostedsiyuanworkspace
:bug: fix https://github.com/siyuan-note/siyuan/issues/5637
Vanessab6cf45b0035a
diff --git a/app/src/menus/protyle.ts b/app/src/menus/protyle.tsindex fa45821e37..505c7e38ba 100644--- a/app/src/menus/protyle.ts+++ b/app/src/menus/protyle.ts@@ -36,6 +36,7 @@ import * as dayjs from "dayjs";import {blockRender} from "../protyle/markdown/blockRender";import {renameAsset} from "../editor/rename";import {hasNextSibling} from "../protyle/wysiwyg/getBlock";+import {electronUndo} from "../protyle/undo";export const refMenu = (protyle: IProtyle, element: HTMLElement) => {const nodeElement = hasClosestBlock(element);@@ -74,7 +75,9 @@ export const refMenu = (protyle: IProtyle, element: HTMLElement) => {inputElement.addEventListener("keydown", (event) => {if (event.key === "Enter" && !event.isComposing) {window.siyuan.menus.menu.remove();+ return;}+ electronUndo(event)});}}).element);@@ -642,11 +645,14 @@ export const linkMenu = (protyle: IProtyle, linkElement: HTMLElement, focusTextfocusByRange(protyle.toolbar.range);}window.siyuan.menus.menu.remove();+ return;} else if (event.key === "Tab" && !event.isComposing) {event.preventDefault();event.stopPropagation();element.nextElementSibling.querySelector("input").focus();+ return;}+ electronUndo(event)});}}).element);@@ -682,6 +688,7 @@ export const linkMenu = (protyle: IProtyle, linkElement: HTMLElement, focusTextfocusByRange(protyle.toolbar.range);}window.siyuan.menus.menu.remove();+ return;} else if (event.key === "Tab" && !event.isComposing) {event.preventDefault();event.stopPropagation();@@ -690,7 +697,9 @@ export const linkMenu = (protyle: IProtyle, linkElement: HTMLElement, focusText} else {element.nextElementSibling.querySelector("input").focus();}+ return;}+ electronUndo(event)});}}).element);@@ -720,11 +729,14 @@ export const linkMenu = (protyle: IProtyle, linkElement: HTMLElement, focusTextfocusByRange(protyle.toolbar.range);}window.siyuan.menus.menu.remove();+ return;} else if (event.key === "Tab" && event.shiftKey && !event.isComposing) {event.preventDefault();event.stopPropagation();element.previousElementSibling.querySelector("input").focus();+ return;}+ electronUndo(event)});}}).element);diff --git a/app/src/protyle/toolbar/index.ts b/app/src/protyle/toolbar/index.tsindex 4194cc9727..ee30225a5d 100644--- a/app/src/protyle/toolbar/index.ts+++ b/app/src/protyle/toolbar/index.ts@@ -39,6 +39,7 @@ import {escapeHtml} from "../../util/escape";import {hideElements} from "../ui/hideElements";import {linkMenu} from "../../menus/protyle";import {renderAssetsPreview} from "../../asset/renderAssets";+import {electronUndo} from "../undo";export class Toolbar {public element: HTMLElement;@@ -866,18 +867,7 @@ export class Toolbar {if (event.isComposing) {return;}- /// #if !BROWSER- if (matchHotKey(window.siyuan.config.keymap.editor.general.undo.custom, event)) {- getCurrentWindow().webContents.undo();- event.preventDefault();- return;- }- if (matchHotKey(window.siyuan.config.keymap.editor.general.redo.custom, event)) {- getCurrentWindow().webContents.redo();- event.preventDefault();- return;- }- /// #endif+ electronUndo(event);if (event.key === "Escape" || matchHotKey("⌘↩", event)) {this.subElement.classList.add("fn__none");this.subElement.querySelector('[data-type="pin"]').classList.remove("block__icon--active");diff --git a/app/src/protyle/undo/index.ts b/app/src/protyle/undo/index.tsindex 3a7f10e366..11528bdbdf 100644--- a/app/src/protyle/undo/index.ts+++ b/app/src/protyle/undo/index.ts@@ -3,13 +3,17 @@ import {preventScroll} from "../scroll/preventScroll";import {Constants} from "../../constants";import {hideElements} from "../ui/hideElements";import {scrollCenter} from "../../util/highlightById";+/// #if !BROWSER+import {getCurrentWindow} from "@electron/remote";+/// #endif+import {matchHotKey} from "../util/hotKey";interface IOperations {doOperations: IOperation[],undoOperations: IOperation[]}-class Undo {+export class Undo {private hasUndo = false;private redoStack: IOperations[];private undoStack: IOperations[];@@ -86,4 +90,17 @@ class Undo {}}-export {Undo};+export const electronUndo = (event: KeyboardEvent) => {+ /// #if !BROWSER+ if (matchHotKey(window.siyuan.config.keymap.editor.general.undo.custom, event)) {+ getCurrentWindow().webContents.undo();+ event.preventDefault();+ return;+ }+ if (matchHotKey(window.siyuan.config.keymap.editor.general.redo.custom, event)) {+ getCurrentWindow().webContents.redo();+ event.preventDefault();+ return;+ }+ /// #endif+}