Skip to content

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

:art: https://github.com/siyuan-note/siyuan/issues/11134

Vanessad24f6ba7075f
diff --git a/app/src/boot/globalEvent/keydown.ts b/app/src/boot/globalEvent/keydown.ts
index d6a2ea1190..9ec8c68603 100644
--- a/app/src/boot/globalEvent/keydown.ts
+++ b/app/src/boot/globalEvent/keydown.ts
@@ -692,6 +692,38 @@ const fileTreeKeydown = (app: App, event: KeyboardEvent) => {
return true;
}
+
+ if (matchHotKey(window.siyuan.config.keymap.general.addToDatabase.custom, event)) {
+ const srcs: IOperationSrcs[] = [];
+ liElements.forEach(item => {
+ const id = item.getAttribute("data-node-id");
+ if (id) {
+ srcs.push({
+ id,
+ isDetached: false
+ });
+ }
+ });
+ if (srcs.length > 0) {
+ openSearchAV("", liElements[0] as HTMLElement, (listItemElement) => {
+ const avID = listItemElement.dataset.avId;
+ transaction(undefined, [{
+ action: "insertAttrViewBlock",
+ avID,
+ ignoreFillFilter: true,
+ srcs,
+ blockID: listItemElement.dataset.blockId
+ }, {
+ action: "doUpdateUpdated",
+ id: listItemElement.dataset.blockId,
+ data: dayjs().format("YYYYMMDDHHmmss"),
+ }]);
+ });
+ }
+ event.preventDefault();
+ return true;
+ }
+
if (matchHotKey(window.siyuan.config.keymap.editor.general.rename.custom, event)) {
window.siyuan.menus.menu.remove();
rename({
diff --git a/app/src/layout/dock/Files.ts b/app/src/layout/dock/Files.ts
index 3efe0fd12c..f5e7c83384 100644
--- a/app/src/layout/dock/Files.ts
+++ b/app/src/layout/dock/Files.ts
@@ -360,6 +360,10 @@ export class Files extends Model {
}
target = target.parentElement;
}
+ } else {
+ this.element.querySelectorAll(".b3-list-item--focus").forEach((item: HTMLElement) => {
+ item.classList.remove("b3-list-item--focus");
+ });
}
if (needFocus) {
setPanelFocus(this.element.parentElement);
diff --git a/app/src/menus/navigation.ts b/app/src/menus/navigation.ts
index fcdd199ad8..dc81257eb6 100644
--- a/app/src/menus/navigation.ts
+++ b/app/src/menus/navigation.ts
@@ -29,6 +29,8 @@ import {makeCard} from "../card/makeCard";
import {transaction} from "../protyle/wysiwyg/transaction";
import {emitOpenMenu} from "../plugin/EventBus";
import {openByMobile} from "../protyle/util/compatibility";
+import {openSearchAV} from "../protyle/render/av/relation";
+import * as dayjs from "dayjs";
const initMultiMenu = (selectItemElements: NodeListOf<Element>, app: App) => {
const fileItemElement = Array.from(selectItemElements).find(item => {
@@ -42,6 +44,43 @@ const initMultiMenu = (selectItemElements: NodeListOf<Element>, app: App) => {
window.siyuan.menus.menu.append(movePathToMenu(getTopPaths(
Array.from(selectItemElements)
)));
+ const blockIDs: string[] = [];
+ selectItemElements.forEach(item => {
+ const id = item.getAttribute("data-node-id");
+ if (id) {
+ blockIDs.push(id);
+ }
+ });
+ if (blockIDs.length > 0) {
+ window.siyuan.menus.menu.append(new MenuItem({
+ label: window.siyuan.languages.addToDatabase,
+ accelerator: window.siyuan.config.keymap.general.addToDatabase.custom,
+ icon: "iconDatabase",
+ click: () => {
+ openSearchAV("", selectItemElements[0] as HTMLElement, (listItemElement) => {
+ const avID = listItemElement.dataset.avId;
+ const srcs: IOperationSrcs[] = []
+ blockIDs.forEach(id => {
+ srcs.push({
+ id,
+ isDetached: false
+ });
+ });
+ transaction(undefined, [{
+ action: "insertAttrViewBlock",
+ avID,
+ ignoreFillFilter: true,
+ srcs,
+ blockID: listItemElement.dataset.blockId
+ }, {
+ action: "doUpdateUpdated",
+ id: listItemElement.dataset.blockId,
+ data: dayjs().format("YYYYMMDDHHmmss"),
+ }]);
+ });
+ }
+ }).element);
+ }
window.siyuan.menus.menu.append(new MenuItem({
icon: "iconTrashcan",
label: window.siyuan.languages.delete,
@@ -51,13 +90,6 @@ const initMultiMenu = (selectItemElements: NodeListOf<Element>, app: App) => {
}
}).element);
- const blockIDs: string[] = [];
- selectItemElements.forEach(item => {
- const id = item.getAttribute("data-node-id");
- if (id) {
- blockIDs.push(id);
- }
- });
if (blockIDs.length === 0) {
return window.siyuan.menus.menu;
}
@@ -441,6 +473,30 @@ export const initFileMenu = (app: App, notebookId: string, pathString: string, l
window.siyuan.menus.menu.append(movePathToMenu(getTopPaths(
Array.from(fileElement.querySelectorAll(".b3-list-item--focus"))
)));
+ window.siyuan.menus.menu.append(new MenuItem({
+ label: window.siyuan.languages.addToDatabase,
+ accelerator: window.siyuan.config.keymap.general.addToDatabase.custom,
+ icon: "iconDatabase",
+ click: () => {
+ openSearchAV("", liElement as HTMLElement, (listItemElement) => {
+ const avID = listItemElement.dataset.avId;
+ transaction(undefined, [{
+ action: "insertAttrViewBlock",
+ avID,
+ ignoreFillFilter: true,
+ srcs: [{
+ id,
+ isDetached: false
+ }],
+ blockID: listItemElement.dataset.blockId
+ }, {
+ action: "doUpdateUpdated",
+ id: listItemElement.dataset.blockId,
+ data: dayjs().format("YYYYMMDDHHmmss"),
+ }]);
+ });
+ }
+ }).element);
window.siyuan.menus.menu.append(new MenuItem({
icon: "iconTrashcan",
label: window.siyuan.languages.delete,
diff --git a/app/src/protyle/wysiwyg/transaction.ts b/app/src/protyle/wysiwyg/transaction.ts
index 2bb908de76..823c958ffe 100644
--- a/app/src/protyle/wysiwyg/transaction.ts
+++ b/app/src/protyle/wysiwyg/transaction.ts
@@ -1032,7 +1032,7 @@ export const transaction = (protyle: IProtyle, doOperations: IOperation[], undoO
return;
}
if (!protyle) {
- // 文档书中点开属性->数据库后的变更操作
+ // 文档树中点开属性->数据库后的变更操作 & 文档树添加到数据库
fetchPost("/api/transactions", {
session: Constants.SIYUAN_APPID,
app: Constants.SIYUAN_APPID,