This commit is contained in:
parent
4f62adddc7
commit
b974eb08d6
5 changed files with 145 additions and 41 deletions
|
@ -3,9 +3,10 @@ import {Dialog} from "../dialog";
|
|||
import {isMobile} from "../util/functions";
|
||||
import {fetchPost} from "../util/fetch";
|
||||
|
||||
export const transferBlockRef = (id:string) => {
|
||||
export const transferBlockRef = (id: string) => {
|
||||
window.siyuan.menus.menu.append(new MenuItem({
|
||||
label: window.siyuan.languages.transferBlockRef,
|
||||
icon: "iconScrollHoriz",
|
||||
click() {
|
||||
const renameDialog = new Dialog({
|
||||
title: window.siyuan.languages.transferBlockRef,
|
||||
|
|
|
@ -488,7 +488,7 @@ export const initFileMenu = (app: App, notebookId: string, pathString: string, l
|
|||
return window.siyuan.menus.menu;
|
||||
};
|
||||
|
||||
const genImportMenu = (notebookId: string, pathString: string) => {
|
||||
export const genImportMenu = (notebookId: string, pathString: string) => {
|
||||
if (!window.siyuan.config.readonly) {
|
||||
/// #if !BROWSER
|
||||
const importstdmd = (label: string, isDoc?: boolean) => {
|
||||
|
|
|
@ -82,20 +82,18 @@ export const openEditorTab = (app: App, id: string, notebookId?: string, pathStr
|
|||
});
|
||||
/// #if !BROWSER
|
||||
openSubmenus.push({type: "separator"});
|
||||
if (!window.siyuan.config.readonly) {
|
||||
openSubmenus.push({
|
||||
label: window.siyuan.languages.showInFolder,
|
||||
click: () => {
|
||||
if (notebookId) {
|
||||
shell.showItemInFolder(path.join(window.siyuan.config.system.dataDir, notebookId, pathString));
|
||||
} else {
|
||||
fetchPost("/api/block/getBlockInfo", {id}, (response) => {
|
||||
shell.showItemInFolder(path.join(window.siyuan.config.system.dataDir, response.data.box, response.data.path));
|
||||
});
|
||||
}
|
||||
openSubmenus.push({
|
||||
label: window.siyuan.languages.showInFolder,
|
||||
click: () => {
|
||||
if (notebookId) {
|
||||
shell.showItemInFolder(path.join(window.siyuan.config.system.dataDir, notebookId, pathString));
|
||||
} else {
|
||||
fetchPost("/api/block/getBlockInfo", {id}, (response) => {
|
||||
shell.showItemInFolder(path.join(window.siyuan.config.system.dataDir, response.data.box, response.data.path));
|
||||
});
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
});
|
||||
/// #endif
|
||||
window.siyuan.menus.menu.append(new MenuItem({
|
||||
label: window.siyuan.languages.openBy,
|
||||
|
|
|
@ -31,6 +31,7 @@ import {openTitleMenu} from "../header/openTitleMenu";
|
|||
import {emitOpenMenu} from "../../plugin/EventBus";
|
||||
import {isInAndroid} from "../util/compatibility";
|
||||
import {resize} from "../util/resize";
|
||||
import {transferBlockRef} from "../../menus/block";
|
||||
|
||||
export class Breadcrumb {
|
||||
public element: HTMLElement;
|
||||
|
@ -511,14 +512,9 @@ export class Breadcrumb {
|
|||
}).element);
|
||||
}
|
||||
/// #endif
|
||||
window.siyuan.menus.menu.append(exportMd(protyle.block.showAll ? protyle.block.id : protyle.block.rootID));
|
||||
window.siyuan.menus.menu.append(new MenuItem({
|
||||
icon: "iconTrashcan",
|
||||
label: window.siyuan.languages.delete,
|
||||
click: () => {
|
||||
deleteFile(protyle.notebookId, protyle.path);
|
||||
}
|
||||
}).element);
|
||||
if (!protyle.disabled) {
|
||||
transferBlockRef(protyle.block.rootID);
|
||||
}
|
||||
if (protyle?.app?.plugins) {
|
||||
emitOpenMenu({
|
||||
plugins: protyle.app.plugins,
|
||||
|
@ -530,7 +526,6 @@ export class Breadcrumb {
|
|||
separatorPosition: "top",
|
||||
});
|
||||
}
|
||||
|
||||
window.siyuan.menus.menu.append(new MenuItem({type: "separator"}).element);
|
||||
window.siyuan.menus.menu.append(new MenuItem({
|
||||
iconHTML: Constants.ZWSP,
|
||||
|
|
|
@ -1,20 +1,32 @@
|
|||
import {fetchPost} from "../../util/fetch";
|
||||
import {fetchPost, fetchSyncPost} from "../../util/fetch";
|
||||
import {MenuItem} from "../../menus/Menu";
|
||||
import {copySubMenu, movePathToMenu, openFileAttr, openFileWechatNotify} from "../../menus/commonMenuItem";
|
||||
import {
|
||||
copySubMenu,
|
||||
exportMd,
|
||||
movePathToMenu,
|
||||
openFileAttr,
|
||||
openFileWechatNotify,
|
||||
} from "../../menus/commonMenuItem";
|
||||
import {deleteFile} from "../../editor/deleteFile";
|
||||
import {transferBlockRef} from "../../menus/block";
|
||||
import {updateHotkeyTip} from "../util/compatibility";
|
||||
/// #if !MOBILE
|
||||
import {openBacklink, openGraph, openOutline} from "../../layout/dock/util";
|
||||
import {shell} from "electron";
|
||||
import * as path from "path";
|
||||
/// #endif
|
||||
import {Constants} from "../../constants";
|
||||
import {openCardByData} from "../../card/openCard";
|
||||
import {viewCards} from "../../card/viewCards";
|
||||
import {getNotebookName, pathPosix} from "../../util/pathName";
|
||||
import {getDisplayName, getNotebookName, pathPosix} from "../../util/pathName";
|
||||
import {makeCard, quickMakeCard} from "../../card/makeCard";
|
||||
import {emitOpenMenu} from "../../plugin/EventBus";
|
||||
import * as dayjs from "dayjs";
|
||||
import {hideTooltip} from "../../dialog/tooltip";
|
||||
import {popSearch} from "../../mobile/menu/search";
|
||||
import {openSearch} from "../../search/spread";
|
||||
import {openDocHistory} from "../../history/doc";
|
||||
import {openNewWindowById} from "../../window/openNewWindow";
|
||||
import {genImportMenu} from "../../menus/navigation";
|
||||
|
||||
export const openTitleMenu = (protyle: IProtyle, position: {
|
||||
x: number
|
||||
|
@ -47,18 +59,6 @@ export const openTitleMenu = (protyle: IProtyle, position: {
|
|||
deleteFile(protyle.notebookId, protyle.path);
|
||||
}
|
||||
}).element);
|
||||
window.siyuan.menus.menu.append(new MenuItem({type: "separator"}).element);
|
||||
if (response.data.refCount && response.data.refCount > 0) {
|
||||
transferBlockRef(protyle.block.rootID);
|
||||
}
|
||||
window.siyuan.menus.menu.append(new MenuItem({
|
||||
label: window.siyuan.languages.attr,
|
||||
icon: "iconAttr",
|
||||
accelerator: window.siyuan.config.keymap.editor.general.attr.custom + "/" + updateHotkeyTip("⇧Click"),
|
||||
click() {
|
||||
openFileAttr(response.data.ial);
|
||||
}
|
||||
}).element);
|
||||
}
|
||||
/// #if !MOBILE
|
||||
window.siyuan.menus.menu.append(new MenuItem({type: "separator"}).element);
|
||||
|
@ -88,6 +88,14 @@ export const openTitleMenu = (protyle: IProtyle, position: {
|
|||
}).element);
|
||||
/// #endif
|
||||
window.siyuan.menus.menu.append(new MenuItem({type: "separator"}).element);
|
||||
window.siyuan.menus.menu.append(new MenuItem({
|
||||
label: window.siyuan.languages.attr,
|
||||
icon: "iconAttr",
|
||||
accelerator: window.siyuan.config.keymap.editor.general.attr.custom + "/" + updateHotkeyTip("⇧Click"),
|
||||
click() {
|
||||
openFileAttr(response.data.ial);
|
||||
}
|
||||
}).element);
|
||||
window.siyuan.menus.menu.append(new MenuItem({
|
||||
label: window.siyuan.languages.wechatReminder,
|
||||
icon: "iconMp",
|
||||
|
@ -155,7 +163,105 @@ export const openTitleMenu = (protyle: IProtyle, position: {
|
|||
separatorPosition: "top",
|
||||
});
|
||||
}
|
||||
|
||||
window.siyuan.menus.menu.append(new MenuItem({
|
||||
label: window.siyuan.languages.search,
|
||||
icon: "iconSearch",
|
||||
accelerator: window.siyuan.config.keymap.general.search.custom,
|
||||
async click() {
|
||||
const searchPath = getDisplayName(protyle.path, false, true);
|
||||
/// #if MOBILE
|
||||
const pathResponse = await fetchSyncPost("/api/filetree/getHPathByPath", {
|
||||
notebook: protyle.notebookId,
|
||||
path: searchPath + ".sy"
|
||||
});
|
||||
const localData = window.siyuan.storage[Constants.LOCAL_SEARCHDATA];
|
||||
popSearch(protyle.app, {
|
||||
removed: localData.removed,
|
||||
sort: localData.sort,
|
||||
group: localData.group,
|
||||
hasReplace: false,
|
||||
method: localData.method,
|
||||
hPath: pathPosix().join(getNotebookName(protyle.notebookId), pathResponse.data),
|
||||
idPath: [pathPosix().join(protyle.notebookId, searchPath)],
|
||||
k: localData.k,
|
||||
r: localData.r,
|
||||
page: 1,
|
||||
types: Object.assign({}, localData.types)
|
||||
});
|
||||
/// #else
|
||||
openSearch({
|
||||
app: protyle.app,
|
||||
hotkey: window.siyuan.config.keymap.general.search.custom,
|
||||
notebookId: protyle.notebookId,
|
||||
searchPath
|
||||
});
|
||||
/// #endif
|
||||
}
|
||||
}).element);
|
||||
if (!protyle.disabled) {
|
||||
window.siyuan.menus.menu.append(new MenuItem({
|
||||
label: window.siyuan.languages.replace,
|
||||
accelerator: window.siyuan.config.keymap.general.replace.custom,
|
||||
icon: "iconReplace",
|
||||
async click() {
|
||||
const searchPath = getDisplayName(protyle.path, false, true);
|
||||
/// #if MOBILE
|
||||
const pathResponse = await fetchSyncPost("/api/filetree/getHPathByPath", {
|
||||
notebook: protyle.notebookId,
|
||||
path: searchPath + ".sy"
|
||||
});
|
||||
const localData = window.siyuan.storage[Constants.LOCAL_SEARCHDATA];
|
||||
popSearch(protyle.app, {
|
||||
removed: localData.removed,
|
||||
sort: localData.sort,
|
||||
group: localData.group,
|
||||
hasReplace: true,
|
||||
method: localData.method,
|
||||
hPath: pathPosix().join(getNotebookName(protyle.notebookId), pathResponse.data),
|
||||
idPath: [pathPosix().join(protyle.notebookId, searchPath)],
|
||||
k: localData.k,
|
||||
r: localData.r,
|
||||
page: 1,
|
||||
types: Object.assign({}, localData.types)
|
||||
});
|
||||
/// #else
|
||||
openSearch({
|
||||
app: protyle.app,
|
||||
hotkey: window.siyuan.config.keymap.general.replace.custom,
|
||||
notebookId: protyle.notebookId,
|
||||
searchPath
|
||||
});
|
||||
/// #endif
|
||||
}
|
||||
}).element);
|
||||
}
|
||||
window.siyuan.menus.menu.append(new MenuItem({type: "separator"}).element);
|
||||
/// #if !BROWSER
|
||||
window.siyuan.menus.menu.append(new MenuItem({
|
||||
label: window.siyuan.languages.openByNewWindow,
|
||||
icon: "iconOpenWindow",
|
||||
click() {
|
||||
openNewWindowById(protyle.block.rootID);
|
||||
}
|
||||
}).element);
|
||||
window.siyuan.menus.menu.append(new MenuItem({
|
||||
label: window.siyuan.languages.showInFolder,
|
||||
click: () => {
|
||||
shell.showItemInFolder(path.join(window.siyuan.config.system.dataDir, protyle.notebookId, protyle.path));
|
||||
}
|
||||
}).element);
|
||||
/// #endif
|
||||
if (!protyle.disabled) {
|
||||
window.siyuan.menus.menu.append(new MenuItem({
|
||||
label: window.siyuan.languages.fileHistory,
|
||||
icon: "iconHistory",
|
||||
click() {
|
||||
openDocHistory({app: protyle.app, id: protyle.block.rootID, notebookId: protyle.notebookId, pathString: response.data.name});
|
||||
}
|
||||
}).element);
|
||||
}
|
||||
genImportMenu(protyle.notebookId, protyle.path);
|
||||
window.siyuan.menus.menu.append(exportMd(protyle.block.showAll ? protyle.block.id : protyle.block.rootID));
|
||||
window.siyuan.menus.menu.append(new MenuItem({type: "separator"}).element);
|
||||
window.siyuan.menus.menu.append(new MenuItem({
|
||||
iconHTML: Constants.ZWSP,
|
||||
|
@ -163,6 +269,10 @@ export const openTitleMenu = (protyle: IProtyle, position: {
|
|||
label: `${window.siyuan.languages.modifiedAt} ${dayjs(response.data.ial.updated).format("YYYY-MM-DD HH:mm:ss")}<br>
|
||||
${window.siyuan.languages.createdAt} ${dayjs(response.data.ial.id.substr(0, 14)).format("YYYY-MM-DD HH:mm:ss")}`
|
||||
}).element);
|
||||
/// #if MOBILE
|
||||
window.siyuan.menus.menu.fullscreen();
|
||||
/// #else
|
||||
window.siyuan.menus.menu.popup(position, position.isLeft);
|
||||
/// #endif
|
||||
});
|
||||
};
|
||||
|
|
Loading…
Add table
Reference in a new issue