mirror of
https://github.com/siyuan-note/siyuan.git
synced 2025-12-18 15:40:12 +01:00
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 {isMobile} from "../util/functions";
|
||||||
import {fetchPost} from "../util/fetch";
|
import {fetchPost} from "../util/fetch";
|
||||||
|
|
||||||
export const transferBlockRef = (id:string) => {
|
export const transferBlockRef = (id: string) => {
|
||||||
window.siyuan.menus.menu.append(new MenuItem({
|
window.siyuan.menus.menu.append(new MenuItem({
|
||||||
label: window.siyuan.languages.transferBlockRef,
|
label: window.siyuan.languages.transferBlockRef,
|
||||||
|
icon: "iconScrollHoriz",
|
||||||
click() {
|
click() {
|
||||||
const renameDialog = new Dialog({
|
const renameDialog = new Dialog({
|
||||||
title: window.siyuan.languages.transferBlockRef,
|
title: window.siyuan.languages.transferBlockRef,
|
||||||
|
|
|
||||||
|
|
@ -488,7 +488,7 @@ export const initFileMenu = (app: App, notebookId: string, pathString: string, l
|
||||||
return window.siyuan.menus.menu;
|
return window.siyuan.menus.menu;
|
||||||
};
|
};
|
||||||
|
|
||||||
const genImportMenu = (notebookId: string, pathString: string) => {
|
export const genImportMenu = (notebookId: string, pathString: string) => {
|
||||||
if (!window.siyuan.config.readonly) {
|
if (!window.siyuan.config.readonly) {
|
||||||
/// #if !BROWSER
|
/// #if !BROWSER
|
||||||
const importstdmd = (label: string, isDoc?: boolean) => {
|
const importstdmd = (label: string, isDoc?: boolean) => {
|
||||||
|
|
|
||||||
|
|
@ -82,20 +82,18 @@ export const openEditorTab = (app: App, id: string, notebookId?: string, pathStr
|
||||||
});
|
});
|
||||||
/// #if !BROWSER
|
/// #if !BROWSER
|
||||||
openSubmenus.push({type: "separator"});
|
openSubmenus.push({type: "separator"});
|
||||||
if (!window.siyuan.config.readonly) {
|
openSubmenus.push({
|
||||||
openSubmenus.push({
|
label: window.siyuan.languages.showInFolder,
|
||||||
label: window.siyuan.languages.showInFolder,
|
click: () => {
|
||||||
click: () => {
|
if (notebookId) {
|
||||||
if (notebookId) {
|
shell.showItemInFolder(path.join(window.siyuan.config.system.dataDir, notebookId, pathString));
|
||||||
shell.showItemInFolder(path.join(window.siyuan.config.system.dataDir, notebookId, pathString));
|
} else {
|
||||||
} else {
|
fetchPost("/api/block/getBlockInfo", {id}, (response) => {
|
||||||
fetchPost("/api/block/getBlockInfo", {id}, (response) => {
|
shell.showItemInFolder(path.join(window.siyuan.config.system.dataDir, response.data.box, response.data.path));
|
||||||
shell.showItemInFolder(path.join(window.siyuan.config.system.dataDir, response.data.box, response.data.path));
|
});
|
||||||
});
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
});
|
}
|
||||||
}
|
});
|
||||||
/// #endif
|
/// #endif
|
||||||
window.siyuan.menus.menu.append(new MenuItem({
|
window.siyuan.menus.menu.append(new MenuItem({
|
||||||
label: window.siyuan.languages.openBy,
|
label: window.siyuan.languages.openBy,
|
||||||
|
|
|
||||||
|
|
@ -31,6 +31,7 @@ import {openTitleMenu} from "../header/openTitleMenu";
|
||||||
import {emitOpenMenu} from "../../plugin/EventBus";
|
import {emitOpenMenu} from "../../plugin/EventBus";
|
||||||
import {isInAndroid} from "../util/compatibility";
|
import {isInAndroid} from "../util/compatibility";
|
||||||
import {resize} from "../util/resize";
|
import {resize} from "../util/resize";
|
||||||
|
import {transferBlockRef} from "../../menus/block";
|
||||||
|
|
||||||
export class Breadcrumb {
|
export class Breadcrumb {
|
||||||
public element: HTMLElement;
|
public element: HTMLElement;
|
||||||
|
|
@ -511,14 +512,9 @@ export class Breadcrumb {
|
||||||
}).element);
|
}).element);
|
||||||
}
|
}
|
||||||
/// #endif
|
/// #endif
|
||||||
window.siyuan.menus.menu.append(exportMd(protyle.block.showAll ? protyle.block.id : protyle.block.rootID));
|
if (!protyle.disabled) {
|
||||||
window.siyuan.menus.menu.append(new MenuItem({
|
transferBlockRef(protyle.block.rootID);
|
||||||
icon: "iconTrashcan",
|
}
|
||||||
label: window.siyuan.languages.delete,
|
|
||||||
click: () => {
|
|
||||||
deleteFile(protyle.notebookId, protyle.path);
|
|
||||||
}
|
|
||||||
}).element);
|
|
||||||
if (protyle?.app?.plugins) {
|
if (protyle?.app?.plugins) {
|
||||||
emitOpenMenu({
|
emitOpenMenu({
|
||||||
plugins: protyle.app.plugins,
|
plugins: protyle.app.plugins,
|
||||||
|
|
@ -530,7 +526,6 @@ export class Breadcrumb {
|
||||||
separatorPosition: "top",
|
separatorPosition: "top",
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
window.siyuan.menus.menu.append(new MenuItem({type: "separator"}).element);
|
window.siyuan.menus.menu.append(new MenuItem({type: "separator"}).element);
|
||||||
window.siyuan.menus.menu.append(new MenuItem({
|
window.siyuan.menus.menu.append(new MenuItem({
|
||||||
iconHTML: Constants.ZWSP,
|
iconHTML: Constants.ZWSP,
|
||||||
|
|
|
||||||
|
|
@ -1,20 +1,32 @@
|
||||||
import {fetchPost} from "../../util/fetch";
|
import {fetchPost, fetchSyncPost} from "../../util/fetch";
|
||||||
import {MenuItem} from "../../menus/Menu";
|
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 {deleteFile} from "../../editor/deleteFile";
|
||||||
import {transferBlockRef} from "../../menus/block";
|
|
||||||
import {updateHotkeyTip} from "../util/compatibility";
|
import {updateHotkeyTip} from "../util/compatibility";
|
||||||
/// #if !MOBILE
|
/// #if !MOBILE
|
||||||
import {openBacklink, openGraph, openOutline} from "../../layout/dock/util";
|
import {openBacklink, openGraph, openOutline} from "../../layout/dock/util";
|
||||||
|
import {shell} from "electron";
|
||||||
|
import * as path from "path";
|
||||||
/// #endif
|
/// #endif
|
||||||
import {Constants} from "../../constants";
|
import {Constants} from "../../constants";
|
||||||
import {openCardByData} from "../../card/openCard";
|
import {openCardByData} from "../../card/openCard";
|
||||||
import {viewCards} from "../../card/viewCards";
|
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 {makeCard, quickMakeCard} from "../../card/makeCard";
|
||||||
import {emitOpenMenu} from "../../plugin/EventBus";
|
import {emitOpenMenu} from "../../plugin/EventBus";
|
||||||
import * as dayjs from "dayjs";
|
import * as dayjs from "dayjs";
|
||||||
import {hideTooltip} from "../../dialog/tooltip";
|
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: {
|
export const openTitleMenu = (protyle: IProtyle, position: {
|
||||||
x: number
|
x: number
|
||||||
|
|
@ -47,18 +59,6 @@ export const openTitleMenu = (protyle: IProtyle, position: {
|
||||||
deleteFile(protyle.notebookId, protyle.path);
|
deleteFile(protyle.notebookId, protyle.path);
|
||||||
}
|
}
|
||||||
}).element);
|
}).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
|
/// #if !MOBILE
|
||||||
window.siyuan.menus.menu.append(new MenuItem({type: "separator"}).element);
|
window.siyuan.menus.menu.append(new MenuItem({type: "separator"}).element);
|
||||||
|
|
@ -88,6 +88,14 @@ export const openTitleMenu = (protyle: IProtyle, position: {
|
||||||
}).element);
|
}).element);
|
||||||
/// #endif
|
/// #endif
|
||||||
window.siyuan.menus.menu.append(new MenuItem({type: "separator"}).element);
|
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({
|
window.siyuan.menus.menu.append(new MenuItem({
|
||||||
label: window.siyuan.languages.wechatReminder,
|
label: window.siyuan.languages.wechatReminder,
|
||||||
icon: "iconMp",
|
icon: "iconMp",
|
||||||
|
|
@ -155,7 +163,105 @@ export const openTitleMenu = (protyle: IProtyle, position: {
|
||||||
separatorPosition: "top",
|
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({type: "separator"}).element);
|
||||||
window.siyuan.menus.menu.append(new MenuItem({
|
window.siyuan.menus.menu.append(new MenuItem({
|
||||||
iconHTML: Constants.ZWSP,
|
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>
|
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")}`
|
${window.siyuan.languages.createdAt} ${dayjs(response.data.ial.id.substr(0, 14)).format("YYYY-MM-DD HH:mm:ss")}`
|
||||||
}).element);
|
}).element);
|
||||||
|
/// #if MOBILE
|
||||||
|
window.siyuan.menus.menu.fullscreen();
|
||||||
|
/// #else
|
||||||
window.siyuan.menus.menu.popup(position, position.isLeft);
|
window.siyuan.menus.menu.popup(position, position.isLeft);
|
||||||
|
/// #endif
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue