mirror of
https://github.com/siyuan-note/siyuan.git
synced 2026-01-06 16:58:49 +01:00
This commit is contained in:
parent
c43869e612
commit
c138132a02
2 changed files with 36 additions and 3 deletions
|
|
@ -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…
Add table
Add a link
Reference in a new issue