This commit is contained in:
Vanessa 2023-09-27 17:05:12 +08:00
parent a9abf0ebcb
commit 81eaf66621
3 changed files with 20 additions and 18 deletions

View file

@ -60,6 +60,7 @@ import {Search} from "../../search";
import {Custom} from "../../layout/dock/Custom";
import {Protyle} from "../../protyle";
import {transaction} from "../../protyle/wysiwyg/transaction";
import {quickMakeCard} from "../../card/makeCard";
const switchDialogEvent = (app: App, event: MouseEvent) => {
event.preventDefault();
@ -253,6 +254,25 @@ const editKeydown = (app: App, event: KeyboardEvent) => {
event.preventDefault();
return true;
}
if (!isFileFocus && matchHotKey(window.siyuan.config.keymap.editor.general.quickMakeCard.custom, event)) {
if (protyle.title.editElement.contains(range.startContainer)) {
quickMakeCard(protyle, [protyle.title.element]);
} else {
const selectElement: Element[] = [];
protyle.wysiwyg.element.querySelectorAll(".protyle-wysiwyg--select").forEach(item => {
selectElement.push(item);
});
if (selectElement.length === 0) {
const nodeElement = hasClosestBlock(range.startContainer);
if (nodeElement) {
selectElement.push(nodeElement);
}
}
quickMakeCard(protyle, selectElement);
}
event.preventDefault();
return true;
}
if (!isFileFocus && matchHotKey(window.siyuan.config.keymap.editor.general.spaceRepetition.custom, event)) {
fetchPost("/api/riff/getTreeRiffDueCards", {rootID: protyle.block.rootID}, (response) => {
openCardByData(app, response.data, "doc", protyle.block.rootID, protyle.title.editElement.textContent || "Untitled");

View file

@ -144,11 +144,6 @@ export class Title {
});
event.preventDefault();
event.stopPropagation();
} else if (matchHotKey(window.siyuan.config.keymap.editor.general.quickMakeCard.custom, event)) {
quickMakeCard(protyle, [this.element]);
event.preventDefault();
event.stopPropagation();
return true;
} else if (matchHotKey("⌘A", event)) {
getEditorRange(this.editElement).selectNodeContents(this.editElement);
event.preventDefault();

View file

@ -1033,19 +1033,6 @@ export const keydown = (protyle: IProtyle, editorElement: HTMLElement) => {
return true;
}
if (matchHotKey(window.siyuan.config.keymap.editor.general.quickMakeCard.custom, event)) {
const selectElement: Element[] = [];
protyle.wysiwyg.element.querySelectorAll(".protyle-wysiwyg--select").forEach(item => {
selectElement.push(item);
});
if (selectElement.length === 0) {
selectElement.push(nodeElement);
}
quickMakeCard(protyle, selectElement);
event.preventDefault();
event.stopPropagation();
return true;
}
if (matchHotKey(window.siyuan.config.keymap.editor.general.attr.custom, event)) {
const topElement = getTopAloneElement(nodeElement);
if (selectText === "") {