An open-source, privacy-first, self-hosted knowledge workspace where humans and AI agents work together 开源、隐私优先、自托管的知识工作空间,让人与智能体在此协作
TypeScript agentic-aiai-agentknowledge-baselocal-firstmarkdownmcpmindmapnote-takingself-hostedsiyuanworkspace
:sparkles: https://github.com/siyuan-note/siyuan/issues/7057 hotkey
Vanessa1525c6c899f4
diff --git a/app/src/card/makeCard.ts b/app/src/card/makeCard.tsindex 3941969ced..a2cee99625 100644--- a/app/src/card/makeCard.ts+++ b/app/src/card/makeCard.ts@@ -6,6 +6,7 @@ import {hideMessage, showMessage} from "../dialog/message";import {confirmDialog} from "../dialog/confirmDialog";import {hideElements} from "../protyle/ui/hideElements";import {viewCards} from "./viewCards";+import {Constants} from "../constants";export const genCardItem = (item: ICardPackage) => {return `<li data-id="${item.id}" class="b3-list-item b3-list-item--narrow${isMobile() ? "" : " b3-list-item--hide-action"}">@@ -181,7 +182,7 @@ export const quickMakeCard = (nodeElement: Element[]) => {ids.push(item.getAttribute("data-node-id"));});fetchPost("/api/riff/addRiffCards", {- deckID: "20230218211946-2kw8jgx",+ deckID: Constants.QUICK_DECK_ID,blockIDs: ids});}diff --git a/app/src/card/viewCards.ts b/app/src/card/viewCards.tsindex 7aad1be021..8c10a173f4 100644--- a/app/src/card/viewCards.ts+++ b/app/src/card/viewCards.ts@@ -116,7 +116,7 @@ export const viewCards = (deckID: string, title: string, cb:(response:IWebSocketbreak;} else if (type === "remove") {fetchPost("/api/riff/removeRiffCards", {- deckID: isDoc ? "20230218211946-2kw8jgx" : deckID,+ deckID: isDoc ? Constants.QUICK_DECK_ID : deckID,blockIDs: [target.getAttribute("data-id")]}, (removeResponse) => {let nextElment = target.parentElement.nextElementSibling;diff --git a/app/src/constants.ts b/app/src/constants.tsindex 1a67160ef7..9d18829498 100644--- a/app/src/constants.ts+++ b/app/src/constants.ts@@ -85,7 +85,7 @@ export abstract class Constants {public static readonly TIMEOUT_BLOCKLOAD = 300;public static readonly TIMEOUT_TRANSITION = 150;- // help path+ // idpublic static readonly HELP_PATH = {zh_CN: "20210808180117-czj9bvb",zh_CHT: "20211226090932-5lcq56f",@@ -93,6 +93,8 @@ export abstract class Constants {fr_FR: "20210808180117-6v0mkxr",};+ public static readonly QUICK_DECK_ID = "20230218211946-2kw8jgx"+public static readonly KEYCODE: { [key: string]: string[] } = {"186": [";", ":"],"187": ["=", "+"],@@ -108,7 +110,8 @@ export abstract class Constants {};// 冲突不使用 "⌘S/Q"// "⌘", "⇧", "⌥", "⌃"- // "⌘A", "⌘X", "⌘C", "⌘V", "⇧⌘V", "⌘/", "⇧↑", "⇧↓", "⇧→", "⇧←", "⇧⇥", "⇧⌘⇥", "⌃⇥", "⌘⇥", "⌃⌘⇥", "⇧⌘→", "⇧⌘←", "⌘Home", "⌘End", "⇧↩", "↩", "PageUp", "PageDown", "⌫", "⌦" 不可自定义+ // "⌘A", "⌘X", "⌘C", "⌘V", "⇧⌘V", "⌘/", "⇧↑", "⇧↓", "⇧→", "⇧←", "⇧⇥", "⇧⌘⇥", "⌃⇥", "⌘⇥", "⌃⌘⇥", "⇧⌘→", "⇧⌘←",+ // "⌘Home", "⌘End", "⇧↩", "↩", "PageUp", "PageDown", "⌫", "⌦" 不可自定义public static readonly SIYUAN_KEYMAP: IKeymap = {general: {editMode: {default: "⇧⌘G", custom: "⇧⌘G"},@@ -159,6 +162,7 @@ export abstract class Constants {openBy: {default: "⌥,", custom: "⌥,"},insertRight: {default: "⌥.", custom: "⌥."},attr: {default: "⌥⌘A", custom: "⌥⌘A"},+ quickMakeCard: {default: "⌥⌘F", custom: "⌥⌘F"},refresh: {default: "F5", custom: "F5"},copyBlockRef: {default: "⇧⌘C", custom: "⇧⌘C"},copyProtocol: {default: "⇧⌘H", custom: "⇧⌘H"},diff --git a/app/src/protyle/gutter/index.ts b/app/src/protyle/gutter/index.tsindex 1cdabd789f..8d1e197c63 100644--- a/app/src/protyle/gutter/index.ts+++ b/app/src/protyle/gutter/index.ts@@ -668,7 +668,8 @@ export class Gutter {window.siyuan.menus.menu.append(new MenuItem({type: "separator"}).element);window.siyuan.menus.menu.append(new MenuItem({label: window.siyuan.languages.quickMakeCard,- iconHTML:`<svg class="b3-menu__icon"><use xlink:href="#iconRiffCard"></use></svg>`,+ accelerator: window.siyuan.config.keymap.editor.general.quickMakeCard.custom,+ iconHTML: `<svg class="b3-menu__icon" style="color:var(--b3-theme-primary)"><use xlink:href="#iconRiffCard"></use></svg>`,icon: "iconRiffCard",click() {quickMakeCard(selectsElement);@@ -1440,7 +1441,8 @@ export class Gutter {if (type !== "NodeThematicBreak") {window.siyuan.menus.menu.append(new MenuItem({label: window.siyuan.languages.quickMakeCard,- iconHTML:`<svg class="b3-menu__icon"><use xlink:href="#iconRiffCard"></use></svg>`,+ accelerator: window.siyuan.config.keymap.editor.general.quickMakeCard.custom,+ iconHTML: `<svg class="b3-menu__icon" style="color:var(--b3-theme-primary)"><use xlink:href="#iconRiffCard"></use></svg>`,icon: "iconRiffCard",click() {quickMakeCard([nodeElement]);diff --git a/app/src/protyle/wysiwyg/keydown.ts b/app/src/protyle/wysiwyg/keydown.tsindex c870385344..88ff9f4f28 100644--- a/app/src/protyle/wysiwyg/keydown.ts+++ b/app/src/protyle/wysiwyg/keydown.ts@@ -70,6 +70,7 @@ import {preventScroll} from "../scroll/preventScroll";import {getSavePath} from "../../util/newFile";import {escapeHtml} from "../../util/escape";import {insertHTML} from "../util/insertHTML";+import {quickMakeCard} from "../../card/makeCard";export const keydown = (protyle: IProtyle, editorElement: HTMLElement) => {editorElement.addEventListener("keydown", (event: KeyboardEvent & { target: HTMLElement }) => {@@ -993,6 +994,33 @@ export const keydown = (protyle: IProtyle, editorElement: HTMLElement) => {return true;}+ if (matchHotKey(window.siyuan.config.keymap.editor.general.quickMakeCard.custom, event)) {+ const selectElement: Element[] = []+ nodeElement.classList.add("protyle-wysiwyg--select");+ let isRemove = true;+ const removeIds: string[] = [];+ protyle.wysiwyg.element.querySelectorAll(".protyle-wysiwyg--select").forEach(item => {+ selectElement.push(item);+ item.classList.remove("protyle-wysiwyg--select");+ removeIds.push(item.getAttribute("data-node-id"));+ if ((item.getAttribute("custom-riff-decks") || "").indexOf(Constants.QUICK_DECK_ID) > -1) {+ isRemove = false;+ }+ });++ if (isRemove) {+ fetchPost("/api/riff/removeRiffCards", {+ deckID: Constants.QUICK_DECK_ID,+ blockIDs: removeIds+ }, (removeResponse) => {+ });+ } else {+ quickMakeCard(selectElement);+ }+ event.preventDefault();+ event.stopPropagation();+ return true;+ }if (matchHotKey(window.siyuan.config.keymap.editor.general.attr.custom, event)) {const topElement = getTopAloneElement(nodeElement);if (selectText === "") {