mirror of
https://github.com/siyuan-note/siyuan.git
synced 2025-05-20 19:10:49 +08:00
This commit is contained in:
parent
a3ed8f6079
commit
d24f6ba707
@ -692,6 +692,38 @@ const fileTreeKeydown = (app: App, event: KeyboardEvent) => {
|
|||||||
return true;
|
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)) {
|
if (matchHotKey(window.siyuan.config.keymap.editor.general.rename.custom, event)) {
|
||||||
window.siyuan.menus.menu.remove();
|
window.siyuan.menus.menu.remove();
|
||||||
rename({
|
rename({
|
||||||
|
@ -360,6 +360,10 @@ export class Files extends Model {
|
|||||||
}
|
}
|
||||||
target = target.parentElement;
|
target = target.parentElement;
|
||||||
}
|
}
|
||||||
|
} else {
|
||||||
|
this.element.querySelectorAll(".b3-list-item--focus").forEach((item: HTMLElement) => {
|
||||||
|
item.classList.remove("b3-list-item--focus");
|
||||||
|
});
|
||||||
}
|
}
|
||||||
if (needFocus) {
|
if (needFocus) {
|
||||||
setPanelFocus(this.element.parentElement);
|
setPanelFocus(this.element.parentElement);
|
||||||
|
@ -29,6 +29,8 @@ import {makeCard} from "../card/makeCard";
|
|||||||
import {transaction} from "../protyle/wysiwyg/transaction";
|
import {transaction} from "../protyle/wysiwyg/transaction";
|
||||||
import {emitOpenMenu} from "../plugin/EventBus";
|
import {emitOpenMenu} from "../plugin/EventBus";
|
||||||
import {openByMobile} from "../protyle/util/compatibility";
|
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 initMultiMenu = (selectItemElements: NodeListOf<Element>, app: App) => {
|
||||||
const fileItemElement = Array.from(selectItemElements).find(item => {
|
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(
|
window.siyuan.menus.menu.append(movePathToMenu(getTopPaths(
|
||||||
Array.from(selectItemElements)
|
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({
|
window.siyuan.menus.menu.append(new MenuItem({
|
||||||
icon: "iconTrashcan",
|
icon: "iconTrashcan",
|
||||||
label: window.siyuan.languages.delete,
|
label: window.siyuan.languages.delete,
|
||||||
@ -51,13 +90,6 @@ const initMultiMenu = (selectItemElements: NodeListOf<Element>, app: App) => {
|
|||||||
}
|
}
|
||||||
}).element);
|
}).element);
|
||||||
|
|
||||||
const blockIDs: string[] = [];
|
|
||||||
selectItemElements.forEach(item => {
|
|
||||||
const id = item.getAttribute("data-node-id");
|
|
||||||
if (id) {
|
|
||||||
blockIDs.push(id);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
if (blockIDs.length === 0) {
|
if (blockIDs.length === 0) {
|
||||||
return window.siyuan.menus.menu;
|
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(
|
window.siyuan.menus.menu.append(movePathToMenu(getTopPaths(
|
||||||
Array.from(fileElement.querySelectorAll(".b3-list-item--focus"))
|
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({
|
window.siyuan.menus.menu.append(new MenuItem({
|
||||||
icon: "iconTrashcan",
|
icon: "iconTrashcan",
|
||||||
label: window.siyuan.languages.delete,
|
label: window.siyuan.languages.delete,
|
||||||
|
@ -1032,7 +1032,7 @@ export const transaction = (protyle: IProtyle, doOperations: IOperation[], undoO
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (!protyle) {
|
if (!protyle) {
|
||||||
// 文档书中点开属性->数据库后的变更操作
|
// 文档树中点开属性->数据库后的变更操作 & 文档树添加到数据库
|
||||||
fetchPost("/api/transactions", {
|
fetchPost("/api/transactions", {
|
||||||
session: Constants.SIYUAN_APPID,
|
session: Constants.SIYUAN_APPID,
|
||||||
app: Constants.SIYUAN_APPID,
|
app: Constants.SIYUAN_APPID,
|
||||||
|
Loading…
Reference in New Issue
Block a user