Skip to content

An open-source, privacy-first, self-hosted knowledge workspace where humans and AI agents work together 开源、隐私优先、自托管的知识工作空间,让人与智能体在此协作

:art: fix https://github.com/siyuan-note/siyuan/issues/8083

Vanessae4e973e4b0b8
diff --git a/app/src/boot/globalShortcut.ts b/app/src/boot/globalShortcut.ts
index 8d751c3ee4..73f6666a9e 100644
--- a/app/src/boot/globalShortcut.ts
+++ b/app/src/boot/globalShortcut.ts
@@ -46,7 +46,7 @@ import {Backlink} from "../layout/dock/Backlink";
import {webFrame} from "electron";
/// #endif
import {openHistory} from "../history/history";
-import {openCard} from "../card/openCard";
+import {openCard, openCardByData} from "../card/openCard";
import {lockScreen} from "../dialog/processSystem";
import {isWindow} from "../util/functions";
import {reloadProtyle} from "../protyle/util/reload";
@@ -553,7 +553,7 @@ export const globalShortcut = () => {
return;
}
- if (event.key === "ArrowUp" || event.key === "ArrowDown" ) {
+ if (event.key === "ArrowUp" || event.key === "ArrowDown") {
const viewCardsDialog = window.siyuan.dialogs.find(item => {
if (item.element.getAttribute("data-key") === "viewCards") {
return true;
@@ -660,9 +660,6 @@ export const globalShortcut = () => {
}
if (!isTabWindow && matchHotKey(window.siyuan.config.keymap.general.dailyNote.custom, event)) {
newDailyNote();
- if (document.activeElement) {
- (document.activeElement as HTMLElement).blur();
- }
event.stopPropagation();
event.preventDefault();
return;
@@ -1095,6 +1092,13 @@ const editKeydown = (event: KeyboardEvent) => {
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(response.data, "doc", protyle.block.rootID, protyle.title.editElement.textContent);
+ });
+ event.preventDefault();
+ return true;
+ }
if (!isFileFocus && matchHotKey(window.siyuan.config.keymap.general.move.custom, event)) {
let range: Range;
let nodeElement: false | HTMLElement;
@@ -1207,6 +1211,20 @@ const fileTreeKeydown = (event: KeyboardEvent) => {
const notebookId = topULElement.getAttribute("data-url");
const pathString = liElements[0].getAttribute("data-path");
const isFile = liElements[0].getAttribute("data-type") === "navigation-file";
+
+ if (matchHotKey(window.siyuan.config.keymap.editor.general.spaceRepetition.custom, event)) {
+ if (isFile) {
+ const id = liElements[0].getAttribute("data-node-id");
+ fetchPost("/api/riff/getTreeRiffDueCards", {rootID: id}, (response) => {
+ openCardByData(response.data, "doc", id, getDisplayName(liElements[0].getAttribute("data-name"), false, true));
+ });
+ } else {
+ fetchPost("/api/riff/getNotebookRiffDueCards", {notebook: notebookId}, (response) => {
+ openCardByData(response.data, "notebook", notebookId, getNotebookName(notebookId));
+ });
+ }
+ }
+
if (matchHotKey(window.siyuan.config.keymap.editor.general.rename.custom, event)) {
window.siyuan.menus.menu.remove();
rename({
diff --git a/app/src/constants.ts b/app/src/constants.ts
index d143b2d511..afda6e32e5 100644
--- a/app/src/constants.ts
+++ b/app/src/constants.ts
@@ -182,6 +182,7 @@ export abstract class Constants {
outline: {default: "⌥O", custom: "⌥O"},
backlinks: {default: "⌥B", custom: "⌥B"},
graphView: {default: "⌥G", custom: "⌥G"},
+ spaceRepetition: {default: "⌥F", custom: "⌥F"},
fullscreen: {default: "⌥Y", custom: "⌥Y"},
alignLeft: {default: "⌥L", custom: "⌥L"},
alignCenter: {default: "⌥C", custom: "⌥C"},
diff --git a/app/src/menus/navigation.ts b/app/src/menus/navigation.ts
index 102350413e..c7e9a878e6 100644
--- a/app/src/menus/navigation.ts
+++ b/app/src/menus/navigation.ts
@@ -130,6 +130,7 @@ export const initNavigationMenu = (liElement: HTMLElement) => {
submenu: [{
iconHTML: Constants.ZWSP,
label: window.siyuan.languages.spaceRepetition,
+ accelerator: window.siyuan.config.keymap.editor.general.spaceRepetition.custom,
click: () => {
fetchPost("/api/riff/getNotebookRiffDueCards", {notebook: notebookId}, (response) => {
openCardByData(response.data, "notebook", notebookId, name);
@@ -339,6 +340,7 @@ export const initFileMenu = (notebookId: string, pathString: string, liElement:
submenu: [{
iconHTML: Constants.ZWSP,
label: window.siyuan.languages.spaceRepetition,
+ accelerator: window.siyuan.config.keymap.editor.general.spaceRepetition.custom,
click: () => {
fetchPost("/api/riff/getTreeRiffDueCards", {rootID: id}, (response) => {
openCardByData(response.data, "doc", id, name);
diff --git a/app/src/protyle/header/Title.ts b/app/src/protyle/header/Title.ts
index d8be7a82e4..ac4e417bd2 100644
--- a/app/src/protyle/header/Title.ts
+++ b/app/src/protyle/header/Title.ts
@@ -353,6 +353,7 @@ export class Title {
const riffCardMenu = [{
iconHTML: Constants.ZWSP,
label: window.siyuan.languages.spaceRepetition,
+ accelerator: window.siyuan.config.keymap.editor.general.spaceRepetition.custom,
click: () => {
fetchPost("/api/riff/getTreeRiffDueCards", {rootID: protyle.block.rootID}, (response) => {
openCardByData(response.data, "doc", protyle.block.rootID, this.editElement.textContent);
diff --git a/app/src/protyle/wysiwyg/commonHotkey.ts b/app/src/protyle/wysiwyg/commonHotkey.ts
index ff9d00f0d6..378b24206a 100644
--- a/app/src/protyle/wysiwyg/commonHotkey.ts
+++ b/app/src/protyle/wysiwyg/commonHotkey.ts
@@ -40,6 +40,12 @@ export const commonHotkey = (protyle: IProtyle, event: KeyboardEvent) => {
event.stopPropagation();
return;
}
+ if (matchHotKey(window.siyuan.config.keymap.editor.general.spaceRepetition.custom, event) ||
+ matchHotKey(window.siyuan.config.keymap.general.dailyNote.custom, event)) {
+ // 阻止输入 https://ld246.com/article/1679618995926
+ event.preventDefault();
+ return true;
+ }
/// #if !MOBILE
if (protyle.model) {
if (matchHotKey(window.siyuan.config.keymap.editor.general.backlinks.custom, event)) {