diff --git a/app/src/protyle/util/hotKey.ts b/app/src/protyle/util/hotKey.ts index c4c38d24a..f14fdcc5b 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 a31442211..68683b7b5 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;