mirror of
https://github.com/siyuan-note/siyuan.git
synced 2025-05-03 00:12:42 +08:00
This commit is contained in:
parent
c43869e612
commit
c138132a02
@ -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;
|
||||
};
|
||||
|
||||
|
@ -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;
|
||||
|
Loading…
Reference in New Issue
Block a user