This commit is contained in:
parent
3485c507ec
commit
5b17896a49
3 changed files with 5 additions and 11 deletions
|
@ -1086,9 +1086,7 @@ export const imgMenu = (protyle: IProtyle, range: Range, assetElement: HTMLEleme
|
|||
window.siyuan.menus.menu.append(new MenuItem({type: "separator"}).element);
|
||||
openMenu(protyle.app, imgSrc, false, false);
|
||||
}
|
||||
/// #if !BROWSER
|
||||
window.siyuan.menus.menu.append(new MenuItem(exportAsset(imgElement.getAttribute("data-src"))).element);
|
||||
/// #endif
|
||||
if (protyle?.app?.plugins) {
|
||||
emitOpenMenu({
|
||||
plugins: protyle.app.plugins,
|
||||
|
@ -1220,11 +1218,9 @@ export const linkMenu = (protyle: IProtyle, linkElement: HTMLElement, focusText
|
|||
}
|
||||
if (linkAddress) {
|
||||
openMenu(protyle.app, linkAddress, false, true);
|
||||
/// #if !BROWSER
|
||||
if (linkAddress?.startsWith("assets/")) {
|
||||
window.siyuan.menus.menu.append(new MenuItem(exportAsset(linkAddress)).element);
|
||||
}
|
||||
/// #endif
|
||||
}
|
||||
if (!protyle.disabled) {
|
||||
if (linkAddress?.startsWith("assets/")) {
|
||||
|
@ -1583,9 +1579,7 @@ export const videoMenu = (protyle: IProtyle, nodeElement: Element, type: string)
|
|||
submenu: openMenu(protyle.app, VideoSrc, true, false) as IMenu[]
|
||||
});
|
||||
}
|
||||
/// #if !BROWSER
|
||||
subMenus.push(exportAsset(src));
|
||||
/// #endif
|
||||
return subMenus;
|
||||
};
|
||||
|
||||
|
|
|
@ -9,15 +9,17 @@ import {Constants} from "../constants";
|
|||
import {openNewWindowById} from "../window/openNewWindow";
|
||||
import {MenuItem} from "./Menu";
|
||||
import {App} from "../index";
|
||||
import {isInAndroid, updateHotkeyTip} from "../protyle/util/compatibility";
|
||||
import {isInAndroid, openByMobile, updateHotkeyTip} from "../protyle/util/compatibility";
|
||||
import {checkFold} from "../util/noRelyPCFunction";
|
||||
|
||||
export const exportAsset = (src: string) => {
|
||||
/// #if !BROWSER
|
||||
return {
|
||||
label: window.siyuan.languages.export,
|
||||
icon: "iconUpload",
|
||||
async click() {
|
||||
/// #if BROWSER
|
||||
openByMobile(src);
|
||||
/// #else
|
||||
const result = await ipcRenderer.invoke(Constants.SIYUAN_GET, {
|
||||
cmd: "showSaveDialog",
|
||||
defaultPath: getAssetName(src) + pathPosix().extname(src),
|
||||
|
@ -26,9 +28,9 @@ export const exportAsset = (src: string) => {
|
|||
if (!result.canceled) {
|
||||
fetchPost("/api/file/copyFile", {src, dest: result.filePath});
|
||||
}
|
||||
/// #endif
|
||||
}
|
||||
};
|
||||
/// #endif
|
||||
};
|
||||
|
||||
export const openEditorTab = (app: App, ids: string[], notebookId?: string, pathString?: string) => {
|
||||
|
|
|
@ -244,11 +244,9 @@ ${window.siyuan.languages.title}
|
|||
}
|
||||
});
|
||||
openMenu(protyle ? protyle.app : window.siyuan.ws.app, linkAddress, false, true);
|
||||
/// #if !BROWSER
|
||||
if (linkAddress?.startsWith("assets/")) {
|
||||
window.siyuan.menus.menu.append(new MenuItem(exportAsset(linkAddress)).element);
|
||||
}
|
||||
/// #endif
|
||||
const rect = target.getBoundingClientRect();
|
||||
menu.open({
|
||||
x: rect.right,
|
||||
|
|
Loading…
Add table
Reference in a new issue