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/14638

Vanessac138132a0207
diff --git a/app/src/protyle/util/hotKey.ts b/app/src/protyle/util/hotKey.ts
index c4c38d24ab..f14fdcc5b5 100644
--- a/app/src/protyle/util/hotKey.ts
+++ b/app/src/protyle/util/hotKey.ts
@@ -184,3 +184,36 @@ export const matchHotKey = (hotKey: string, event: KeyboardEvent) => {
return false;
};
+export const isIncludesHotKey = (hotKey: string) => {
+ let isInclude = false;
+ Object.keys(window.siyuan.config.keymap).find(key => {
+ const item = window.siyuan.config.keymap[key as "editor"];
+ Object.keys(item).find(key2 => {
+ const item2 = item[key2 as "general"];
+ if (typeof item2.custom === "string") {
+ if (item2.custom === hotKey) {
+ isInclude = true;
+ return true;
+ }
+ } else {
+ Object.keys(item2).forEach(key3 => {
+ const item3: Config.IKey = item2[key3];
+ if (item3.custom === hotKey) {
+ isInclude = true;
+ return true;
+ }
+ });
+ if (isInclude) {
+ return true;
+ }
+ }
+ });
+
+ if (isInclude) {
+ return true;
+ }
+ });
+
+ return isInclude;
+};
+
diff --git a/app/src/protyle/wysiwyg/keydown.ts b/app/src/protyle/wysiwyg/keydown.ts
index a31442211a..68683b7b56 100644
--- a/app/src/protyle/wysiwyg/keydown.ts
+++ b/app/src/protyle/wysiwyg/keydown.ts
@@ -30,7 +30,7 @@ import {
hasPreviousSibling, isEndOfBlock,
isNotEditBlock,
} from "./getBlock";
-import {matchHotKey} from "../util/hotKey";
+import {isIncludesHotKey, matchHotKey} from "../util/hotKey";
import {enter, softEnter} from "./enter";
import {clearTableCell, fixTable} from "../util/table";
import {
@@ -1931,14 +1931,14 @@ export const keydown = (protyle: IProtyle, editorElement: HTMLElement) => {
}
if (!range.toString()) {
- if (event.key === "ArrowRight" && isEndOfBlock(range)) {
+ if (event.key === "ArrowRight" && isEndOfBlock(range) && !isIncludesHotKey("⌥⇧→")) {
event.preventDefault();
event.stopPropagation();
return;
}
const nodeEditableElement = getContenteditableElement(nodeElement);
const position = getSelectionOffset(nodeEditableElement, protyle.wysiwyg.element, range);
- if (position.start === 0 && event.key === "ArrowLeft") {
+ if (position.start === 0 && event.key === "ArrowLeft" && !isIncludesHotKey("⌥⇧←")) {
event.preventDefault();
event.stopPropagation();
return;