An open-source, privacy-first, self-hosted knowledge workspace where humans and AI agents work together 开源、隐私优先、自托管的知识工作空间,让人与智能体在此协作
TypeScript agentic-aiai-agentknowledge-baselocal-firstmarkdownmcpmindmapnote-takingself-hostedsiyuanworkspace
:art: https://github.com/siyuan-note/siyuan/issues/10547
Vanessaedc256896c61
diff --git a/app/src/boot/globalEvent/keydown.ts b/app/src/boot/globalEvent/keydown.tsindex 36639f4ee6..af1146aa05 100644--- a/app/src/boot/globalEvent/keydown.ts+++ b/app/src/boot/globalEvent/keydown.ts@@ -75,6 +75,8 @@ import {searchKeydown} from "./searchKeydown";import {openNewWindow} from "../../window/openNewWindow";import {historyKeydown} from "../../history/keydown";import {zoomOut} from "../../menus/protyle";+import {openSearchAV} from "../../protyle/render/av/relation";+import * as dayjs from "dayjs";const switchDialogEvent = (app: App, event: MouseEvent) => {event.preventDefault();@@ -305,6 +307,64 @@ const editKeydown = (app: App, event: KeyboardEvent) => {event.preventDefault();return true;}+ if (!isFileFocus && matchHotKey(window.siyuan.config.keymap.general.addToDatabase.custom, event)) {+ if (protyle.title?.editElement.contains(range.startContainer)) {+ openSearchAV("", protyle.breadcrumb.element, (listItemElement) => {+ const sourceIds: string[] = [protyle.block.rootID];+ const avID = listItemElement.dataset.avId;+ transaction(protyle, [{+ action: "insertAttrViewBlock",+ avID,+ srcIDs: sourceIds,+ isDetached: false,+ blockID: listItemElement.dataset.nodeId+ }, {+ action: "doUpdateUpdated",+ id: listItemElement.dataset.nodeId,+ data: dayjs().format("YYYYMMDDHHmmss"),+ }], [{+ action: "removeAttrViewBlock",+ srcIDs: sourceIds,+ avID,+ }]);+ });+ } 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);+ }+ }+ openSearchAV("", selectElement[0] as HTMLElement, (listItemElement) => {+ const sourceIds: string[] = [];+ selectElement.forEach(item => {+ sourceIds.push(item.getAttribute("data-node-id"));+ });+ const avID = listItemElement.dataset.avId;+ transaction(protyle, [{+ action: "insertAttrViewBlock",+ avID,+ srcIDs: sourceIds,+ isDetached: false,+ blockID: listItemElement.dataset.blockId+ }, {+ action: "doUpdateUpdated",+ id: listItemElement.dataset.blockId,+ data: dayjs().format("YYYYMMDDHHmmss"),+ }], [{+ action: "removeAttrViewBlock",+ srcIDs: sourceIds,+ avID,+ }]);+ });+ }+ 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");diff --git a/app/src/constants.ts b/app/src/constants.tsindex 206c12ed38..e8e4ebcb88 100644--- a/app/src/constants.ts+++ b/app/src/constants.ts@@ -343,6 +343,7 @@ export abstract class Constants {closeLeft: {default: "", custom: ""},closeRight: {default: "", custom: ""},tabToWindow: {default: "", custom: ""},+ addToDatabase: {default: "", custom: ""},},editor: {general: {diff --git a/app/src/protyle/gutter/index.ts b/app/src/protyle/gutter/index.tsindex bf472a505b..111b5ea3df 100644--- a/app/src/protyle/gutter/index.ts+++ b/app/src/protyle/gutter/index.ts@@ -808,6 +808,7 @@ export class Gutter {}).element);window.siyuan.menus.menu.append(new MenuItem({label: window.siyuan.languages.addToDatabase,+ accelerator: window.siyuan.config.keymap.general.addToDatabase.custom,icon: "iconDatabase",click: () => {openSearchAV("", selectsElement[0] as HTMLElement, (listItemElement) => {@@ -1272,6 +1273,7 @@ export class Gutter {}).element);window.siyuan.menus.menu.append(new MenuItem({label: window.siyuan.languages.addToDatabase,+ accelerator: window.siyuan.config.keymap.general.addToDatabase.custom,icon: "iconDatabase",click: () => {openSearchAV("", nodeElement as HTMLElement, (listItemElement) => {diff --git a/app/src/protyle/header/openTitleMenu.ts b/app/src/protyle/header/openTitleMenu.tsindex b496e0b236..c8de29c1a2 100644--- a/app/src/protyle/header/openTitleMenu.ts+++ b/app/src/protyle/header/openTitleMenu.ts@@ -52,6 +52,7 @@ export const openTitleMenu = (protyle: IProtyle, position: IPosition) => {window.siyuan.menus.menu.append(movePathToMenu([protyle.path]));window.siyuan.menus.menu.append(new MenuItem({label: window.siyuan.languages.addToDatabase,+ accelerator: window.siyuan.config.keymap.general.addToDatabase.custom,icon: "iconDatabase",click: () => {openSearchAV("", protyle.breadcrumb.element, (listItemElement) => {diff --git a/app/src/protyle/wysiwyg/transaction.ts b/app/src/protyle/wysiwyg/transaction.tsindex e8aecd2473..356e8f578f 100644--- a/app/src/protyle/wysiwyg/transaction.ts+++ b/app/src/protyle/wysiwyg/transaction.ts@@ -494,7 +494,7 @@ export const onTransaction = (protyle: IProtyle, operation: IOperation, isUndo:} else if (key === "memo") {memoHTML = `<div class="protyle-attr--memo b3-tooltips b3-tooltips__sw" aria-label="${escapeHTML}"><svg><use xlink:href="#iconM"></use></svg></div>`;} else if (key === "custom-avs") {- avHTML = "<div class=\"protyle-attr--av\"><svg><use xlink:href=\"#iconDatabase\"></use></svg></div>";+ avHTML = '<div class="protyle-attr--av"><svg><use xlink:href="#iconDatabase"></use></svg></div>';}});let nodeAttrHTML = bookmarkHTML + nameHTML + aliasHTML + memoHTML + avHTML;