This commit is contained in:
parent
f87ac01461
commit
edc256896c
5 changed files with 65 additions and 1 deletions
|
@ -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");
|
||||
|
|
|
@ -343,6 +343,7 @@ export abstract class Constants {
|
|||
closeLeft: {default: "", custom: ""},
|
||||
closeRight: {default: "", custom: ""},
|
||||
tabToWindow: {default: "", custom: ""},
|
||||
addToDatabase: {default: "", custom: ""},
|
||||
},
|
||||
editor: {
|
||||
general: {
|
||||
|
|
|
@ -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) => {
|
||||
|
|
|
@ -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) => {
|
||||
|
|
|
@ -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;
|
||||
|
|
Loading…
Add table
Reference in a new issue