An open-source, privacy-first, self-hosted knowledge workspace where humans and AI agents work together 开源、隐私优先、自托管的知识工作空间,让人与智能体在此协作
TypeScript agentic-aiai-agentknowledge-baselocal-firstmarkdownmcpmindmapnote-takingself-hostedsiyuanworkspace
:art: 支持 ctrl+s https://github.com/siyuan-note/siyuan/issues/5376
Vanessa5bdaa3d9fdcc
diff --git a/app/src/config/keymap.ts b/app/src/config/keymap.tsindex 3bc7893692..4b5ad9c0d3 100644--- a/app/src/config/keymap.ts+++ b/app/src/config/keymap.ts@@ -268,7 +268,7 @@ export const keymap = {}if (["⌘", "⇧", "⌥", "⌃"].includes(keymapStr.substr(keymapStr.length - 1, 1)) ||- ["⌘S", "⌘A", "⌘X", "⌘C", "⌘V", "⌘/", "⌘↑", "⌘↓", "⇧↑", "⇧↓", "⇧→", "⇧←", "⇧⇥", "⇧⌘⇥", "⌃⇥", "⌃⌘⇥", "⇧⌘→", "⇧⌘←", "⌘Home", "⌘End", "⇧↩", "↩", "PageUp", "PageDown", "⌫", "⌦"].includes(keymapStr)) {+ ["⌘A", "⌘X", "⌘C", "⌘V", "⌘/", "⌘↑", "⌘↓", "⇧↑", "⇧↓", "⇧→", "⇧←", "⇧⇥", "⇧⌘⇥", "⌃⇥", "⌃⌘⇥", "⇧⌘→", "⇧⌘←", "⌘Home", "⌘End", "⇧↩", "↩", "PageUp", "PageDown", "⌫", "⌦"].includes(keymapStr)) {showMessage(tip + "] " + window.siyuan.languages.invalid);return;}diff --git a/app/src/constants.ts b/app/src/constants.tsindex 18eda96251..7d9dbed0ad 100644--- a/app/src/constants.ts+++ b/app/src/constants.ts@@ -83,7 +83,7 @@ export abstract class Constants {};// "⌘", "⇧", "⌥", "⌃"- // "⌘S", "⌘A", "⌘X", "⌘C", "⌘V", "⌘/", "⌘↑", "⌘↓", "⇧↑", "⇧↓", "⇧→", "⇧←", "⇧⇥", "⇧⌘⇥", "⌃⇥", "⌃⌘⇥", "⇧⌘→", "⇧⌘←", "⌘Home", "⌘End", "⇧↩", "↩", "PageUp", "PageDown", "⌫", "⌦" 不可自定义+ // "⌘A", "⌘X", "⌘C", "⌘V", "⌘/", "⌘↑", "⌘↓", "⇧↑", "⇧↓", "⇧→", "⇧←", "⇧⇥", "⇧⌘⇥", "⌃⇥", "⌃⌘⇥", "⇧⌘→", "⇧⌘←", "⌘Home", "⌘End", "⇧↩", "↩", "PageUp", "PageDown", "⌫", "⌦" 不可自定义public static readonly SIYUAN_KEYMAP: IKeymap = {general: {syncNow: {default: "F9", custom: "F9"},diff --git a/app/src/protyle/wysiwyg/keydown.ts b/app/src/protyle/wysiwyg/keydown.tsindex 94dc66d51c..d2f6ff023e 100644--- a/app/src/protyle/wysiwyg/keydown.ts+++ b/app/src/protyle/wysiwyg/keydown.ts@@ -381,12 +381,14 @@ export const keydown = (protyle: IProtyle, editorElement: HTMLElement) => {topNodeElement = topNodeElement.parentElement;}zoomOut(protyle, topNodeElement.getAttribute("data-node-id"));+ event.preventDefault();event.stopPropagation();return;}if (matchHotKey(window.siyuan.config.keymap.general.enterBack.custom, event)) {zoomOut(protyle, protyle.block.parent2ID, nodeElement.getAttribute("data-node-id"));+ event.preventDefault();event.stopPropagation();return;}@@ -813,6 +815,7 @@ export const keydown = (protyle: IProtyle, editorElement: HTMLElement) => {}writeText(`siyuan://blocks/${actionElement.getAttribute("data-node-id")}`);event.preventDefault();+ event.stopPropagation();return true;}/// #if !MOBILE@@ -837,6 +840,7 @@ export const keydown = (protyle: IProtyle, editorElement: HTMLElement) => {});}event.preventDefault();+ event.stopPropagation();return true;}if (matchHotKey(window.siyuan.config.keymap.editor.general.copyBlockEmbed.custom, event)) {@@ -849,6 +853,7 @@ export const keydown = (protyle: IProtyle, editorElement: HTMLElement) => {}writeText(`{{select * from blocks where id='${actionElement.getAttribute("data-node-id")}'}}`);event.preventDefault();+ event.stopPropagation();return true;}@@ -876,6 +881,7 @@ export const keydown = (protyle: IProtyle, editorElement: HTMLElement) => {updateTransaction(protyle, topElement.getAttribute("data-node-id"), topElement.outerHTML, oldHTML);}event.preventDefault();+ event.stopPropagation();return true;}if (matchHotKey(window.siyuan.config.keymap.editor.general.rename.custom, event)) {@@ -899,18 +905,21 @@ export const keydown = (protyle: IProtyle, editorElement: HTMLElement) => {});}event.preventDefault();+ event.stopPropagation();return;}if (selectText.trim() && matchHotKey(window.siyuan.config.keymap.editor.general.newNameFile.custom, event)) {newFileBySelect(selectText, protyle);event.preventDefault();+ event.stopPropagation();return;}if (matchHotKey(window.siyuan.config.keymap.editor.general.newContentFile.custom, event)) {newFileContentBySelect(protyle);event.preventDefault();+ event.stopPropagation();return;}if (matchHotKey(window.siyuan.config.keymap.editor.general.alignLeft.custom, event)) {@@ -987,31 +996,37 @@ export const keydown = (protyle: IProtyle, editorElement: HTMLElement) => {if (matchHotKey(window.siyuan.config.keymap.editor.heading.heading1.custom, event)) {phTransaction(protyle, range, nodeElement, 1);event.preventDefault();+ event.stopPropagation();return true;}if (matchHotKey(window.siyuan.config.keymap.editor.heading.heading2.custom, event)) {phTransaction(protyle, range, nodeElement, 2);event.preventDefault();+ event.stopPropagation();return true;}if (matchHotKey(window.siyuan.config.keymap.editor.heading.heading3.custom, event)) {phTransaction(protyle, range, nodeElement, 3);event.preventDefault();+ event.stopPropagation();return true;}if (matchHotKey(window.siyuan.config.keymap.editor.heading.heading4.custom, event)) {phTransaction(protyle, range, nodeElement, 4);event.preventDefault();+ event.stopPropagation();return true;}if (matchHotKey(window.siyuan.config.keymap.editor.heading.heading5.custom, event)) {phTransaction(protyle, range, nodeElement, 5);event.preventDefault();+ event.stopPropagation();return true;}if (matchHotKey(window.siyuan.config.keymap.editor.heading.heading6.custom, event)) {phTransaction(protyle, range, nodeElement, 6);event.preventDefault();+ event.stopPropagation();return true;}if (matchHotKey(window.siyuan.config.keymap.editor.insert.code.custom, event) && nodeElement.getAttribute("data-type") !== "NodeCodeBlock") {@@ -1025,6 +1040,7 @@ export const keydown = (protyle: IProtyle, editorElement: HTMLElement) => {updateTransaction(protyle, id, newHTML, html);highlightRender(newNodeElement);event.preventDefault();+ event.stopPropagation();return true;}// toolbar action@@ -1064,10 +1080,12 @@ export const keydown = (protyle: IProtyle, editorElement: HTMLElement) => {if (selectElements.length > 0 && selectElements[0].getAttribute("data-type") === "NodeListItem") {listOutdent(protyle, Array.from(selectElements), range);event.preventDefault();+ event.stopPropagation();return true;} else if (nodeElement.parentElement.classList.contains("li") && nodeElement.getAttribute("data-type") !== "NodeCodeBlock") {listOutdent(protyle, [nodeElement.parentElement], range);event.preventDefault();+ event.stopPropagation();return true;}}@@ -1076,10 +1094,12 @@ export const keydown = (protyle: IProtyle, editorElement: HTMLElement) => {if (selectElements.length > 0 && selectElements[0].getAttribute("data-type") === "NodeListItem") {listIndent(protyle, Array.from(selectElements), range);event.preventDefault();+ event.stopPropagation();return true;} else if (nodeElement.parentElement.classList.contains("li") && nodeElement.getAttribute("data-type") !== "NodeCodeBlock") {listIndent(protyle, [nodeElement.parentElement], range);event.preventDefault();+ event.stopPropagation();return true;}}@@ -1088,6 +1108,7 @@ export const keydown = (protyle: IProtyle, editorElement: HTMLElement) => {protyle.hint.lastIndex = -1;protyle.hint.fill("* [ ] " + Lute.Caret, protyle);event.preventDefault();+ event.stopPropagation();return;}@@ -1096,6 +1117,7 @@ export const keydown = (protyle: IProtyle, editorElement: HTMLElement) => {protyle.hint.lastIndex = -1;protyle.hint.fill(`| col1${Lute.Caret} | col2 | col3 |\n| --- | --- | --- |\n| | | |\n| | | |`, protyle);event.preventDefault();+ event.stopPropagation();return;}@@ -1115,6 +1137,7 @@ export const keydown = (protyle: IProtyle, editorElement: HTMLElement) => {taskItemElement.setAttribute("updated", dayjs().format("YYYYMMDDHHmmss"));updateTransaction(protyle, taskItemElement.getAttribute("data-node-id"), taskItemElement.outerHTML, html);event.preventDefault();+ event.stopPropagation();return;}if (matchHotKey(window.siyuan.config.keymap.editor.general.insertBefore.custom, event)) {@@ -1125,6 +1148,7 @@ export const keydown = (protyle: IProtyle, editorElement: HTMLElement) => {if (matchHotKey(window.siyuan.config.keymap.editor.general.insertAfter.custom, event)) {insertEmptyBlock(protyle, "afterend");event.preventDefault();+ event.stopPropagation();return true;}@@ -1329,6 +1353,7 @@ export const keydown = (protyle: IProtyle, editorElement: HTMLElement) => {if (matchHotKey(window.siyuan.config.keymap.editor.general.vLayout.custom, event)) {event.preventDefault();+ event.stopPropagation();const selectsElement: HTMLElement[] = Array.from(protyle.wysiwyg.element.querySelectorAll(".protyle-wysiwyg--select"));if (selectsElement.length < 2) {return;@@ -1343,6 +1368,7 @@ export const keydown = (protyle: IProtyle, editorElement: HTMLElement) => {if (matchHotKey(window.siyuan.config.keymap.editor.general.hLayout.custom, event)) {event.preventDefault();+ event.stopPropagation();const selectsElement: HTMLElement[] = Array.from(protyle.wysiwyg.element.querySelectorAll(".protyle-wysiwyg--select"));if (selectsElement.length < 2) {return;@@ -1460,6 +1486,7 @@ export const keydown = (protyle: IProtyle, editorElement: HTMLElement) => {getCurrentWindow().webContents.pasteAndMatchStyle();}, 100);event.preventDefault();+ event.stopPropagation();return;}@@ -1470,6 +1497,7 @@ export const keydown = (protyle: IProtyle, editorElement: HTMLElement) => {if (isLocalPath(linkAddress)) {openBy(linkAddress, "folder");event.preventDefault();+ event.stopPropagation();}}return;diff --git a/app/src/util/globalShortcut.ts b/app/src/util/globalShortcut.tsindex 847b707e09..e2f5d2b21c 100644--- a/app/src/util/globalShortcut.ts+++ b/app/src/util/globalShortcut.ts@@ -352,8 +352,9 @@ export const globalShortcut = () => {});return;}-- if (event.key === window.siyuan.config.keymap.general.syncNow.custom) {+ if (matchHotKey(window.siyuan.config.keymap.general.syncNow.custom, event)) {+ event.preventDefault();+ event.stopPropagation();if (needSubscribe() || document.querySelector("#barSync svg").classList.contains("fn__rotate")) {return;}@@ -362,7 +363,6 @@ export const globalShortcut = () => {return;}fetchPost("/api/sync/performSync", {});- event.preventDefault();return;}if (matchHotKey(window.siyuan.config.keymap.general.lockScreen.custom, event)) {@@ -372,23 +372,20 @@ export const globalShortcut = () => {});});event.preventDefault();+ event.stopPropagation();return;}if (matchHotKey(window.siyuan.config.keymap.general.history.custom, event)) {openHistory();event.preventDefault();+ event.stopPropagation();return;}if (!window.siyuan.config.readonly && matchHotKey(window.siyuan.config.keymap.general.config.custom, event)) {openSetting();- event.preventDefault();- return;- }- // https://github.com/siyuan-note/insider/issues/445- if (matchHotKey("⌘S", event)) {event.preventDefault();event.stopPropagation();- return true;+ return;}const target = event.target as HTMLElement;if (matchHotKey("⌘A", event) && target.tagName !== "INPUT" && target.tagName !== "TEXTAREA") {@@ -404,6 +401,7 @@ export const globalShortcut = () => {target.blur();}event.preventDefault();+ event.stopPropagation();return true;}});@@ -418,11 +416,13 @@ export const globalShortcut = () => {target.blur();}event.preventDefault();+ event.stopPropagation();return;}if (matchHotKey(window.siyuan.config.keymap.general.newFile.custom, event)) {newFile(undefined, undefined, true);event.preventDefault();+ event.stopPropagation();return;}@@ -587,6 +587,7 @@ export const globalShortcut = () => {openGlobalSearch("", false);}event.preventDefault();+ event.stopPropagation();return;}@@ -615,8 +616,16 @@ export const globalShortcut = () => {openSearch(searchKey);}event.preventDefault();+ event.stopPropagation();return;}++ // https://github.com/siyuan-note/insider/issues/445+ if (matchHotKey("⌘S", event)) {+ event.preventDefault();+ event.stopPropagation();+ return true;+ }});window.addEventListener("blur", () => {@@ -717,6 +726,7 @@ const editKeydown = (event: KeyboardEvent) => {openSearch(searchKey);}event.preventDefault();+ event.stopPropagation();return true;}if (!isFileFocus && matchHotKey(window.siyuan.config.keymap.general.move.custom, event)) {@@ -732,6 +742,7 @@ const editKeydown = (event: KeyboardEvent) => {movePathTo(protyle.notebookId, protyle.path);}event.preventDefault();+ event.stopPropagation();return true;}const target = event.target as HTMLElement;@@ -741,6 +752,7 @@ const editKeydown = (event: KeyboardEvent) => {if (matchHotKey(window.siyuan.config.keymap.editor.general.preview.custom, event)) {setEditMode(protyle, "preview");event.preventDefault();+ event.stopPropagation();return true;}if (matchHotKey(window.siyuan.config.keymap.editor.general.wysiwyg.custom, event)) {@@ -753,17 +765,20 @@ const editKeydown = (event: KeyboardEvent) => {onGet(getResponse, protyle);});event.preventDefault();+ event.stopPropagation();return true;}// 没有光标时,无法撤销 https://ld246.com/article/1624021111567if (matchHotKey(window.siyuan.config.keymap.editor.general.undo.custom, event)) {protyle.undo.undo(protyle);event.preventDefault();+ event.stopPropagation();return true;}if (matchHotKey(window.siyuan.config.keymap.editor.general.redo.custom, event)) {protyle.undo.redo(protyle);event.preventDefault();+ event.stopPropagation();return true;}return false;@@ -777,6 +792,7 @@ const fileTreeKeydown = (event: KeyboardEvent) => {const files = dockFile.data.file as Files;if (matchHotKey(window.siyuan.config.keymap.general.selectOpen1.custom, event)) {event.preventDefault();+ event.stopPropagation();const element = document.querySelector(".layout__wnd--active > .layout-tab-bar > .item--focus") ||document.querySelector(".layout-tab-bar > .item--focus");if (element) {@@ -815,6 +831,8 @@ const fileTreeKeydown = (event: KeyboardEvent) => {name: isFile ? getDisplayName(liElement.getAttribute("data-name"), false, true) : getNotebookName(notebookId),type: isFile ? "file" : "notebook",});+ event.preventDefault();+ event.stopPropagation();return true;}if (matchHotKey("⌘/", event)) {@@ -832,6 +850,7 @@ const fileTreeKeydown = (event: KeyboardEvent) => {if (isFile && matchHotKey(window.siyuan.config.keymap.general.move.custom, event)) {movePathTo(notebookId, pathString, false);event.preventDefault();+ event.stopPropagation();return true;}let searchKey = "";@@ -847,6 +866,7 @@ const fileTreeKeydown = (event: KeyboardEvent) => {openSearch(searchKey, undefined, notebookId);}event.preventDefault();+ event.stopPropagation();return true;}const target = event.target as HTMLElement;