Vanessa 2024-04-25 12:19:24 +08:00
parent a3ed8f6079
commit d24f6ba707
4 changed files with 100 additions and 8 deletions

View File

@ -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({

View File

@ -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);

View File

@ -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,

View File

@ -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,