diff --git a/app/src/menus/commonMenuItem.ts b/app/src/menus/commonMenuItem.ts
index 2766f1212..f55ee7206 100644
--- a/app/src/menus/commonMenuItem.ts
+++ b/app/src/menus/commonMenuItem.ts
@@ -431,7 +431,7 @@ export const copySubMenu = (id: string, accelerator = true, focusElement?: Eleme
}];
};
-export const exportMd = (id: string) => {
+export const exportMd = (id: string, fileType = "NodeDocument") => {
return new MenuItem({
label: window.siyuan.languages.export,
type: "submenu",
@@ -532,7 +532,7 @@ export const exportMd = (id: string) => {
label: window.siyuan.languages.image,
icon: "iconImage",
click: () => {
- exportImage(id);
+ exportImage(id, fileType);
}
},
/// #if !BROWSER
@@ -540,26 +540,26 @@ export const exportMd = (id: string) => {
label: "PDF",
icon: "iconPDF",
click: () => {
- saveExport({type: "pdf", id});
+ saveExport({type: "pdf", id, fileType});
}
}, {
label: "HTML (SiYuan)",
iconClass: "ft__error",
icon: "iconHTML5",
click: () => {
- saveExport({type: "html", id});
+ saveExport({type: "html", id, fileType});
}
}, {
label: "HTML (Markdown)",
icon: "iconHTML5",
click: () => {
- saveExport({type: "htmlmd", id});
+ saveExport({type: "htmlmd", id, fileType});
}
}, {
label: "Word .docx",
icon: "iconExact",
click: () => {
- saveExport({type: "word", id});
+ saveExport({type: "word", id, fileType});
}
}, {
label: window.siyuan.languages.more,
diff --git a/app/src/protyle/export/index.ts b/app/src/protyle/export/index.ts
index 5933b41f7..ae7408f27 100644
--- a/app/src/protyle/export/index.ts
+++ b/app/src/protyle/export/index.ts
@@ -14,15 +14,15 @@ import {pathPosix} from "../../util/pathName";
import {replaceLocalPath} from "../../editor/rename";
import {setStorageVal} from "../util/compatibility";
-export const saveExport = (option: { type: string, id: string }) => {
+export const saveExport = (option: IExportOptions) => {
/// #if !BROWSER
if (option.type === "pdf") {
if (window.siyuan.config.appearance.mode === 1) {
confirmDialog(window.siyuan.languages.pdfTip, window.siyuan.languages.pdfConfirm, () => {
- renderPDF(option.id);
+ renderPDF(option.id, option.fileType);
});
} else {
- renderPDF(option.id);
+ renderPDF(option.id, option.fileType);
}
} else if (option.type === "word") {
const localData = window.siyuan.storage[Constants.LOCAL_EXPORTWORD];
@@ -69,7 +69,7 @@ export const saveExport = (option: { type: string, id: string }) => {
};
/// #if !BROWSER
-const renderPDF = (id: string) => {
+const renderPDF = (id: string, fileType:string) => {
const localData = window.siyuan.storage[Constants.LOCAL_EXPORTPDF];
const servePath = window.location.protocol + "//" + window.location.host;
const isDefault = (window.siyuan.config.appearance.mode === 1 && window.siyuan.config.appearance.themeDark === "midnight") || (window.siyuan.config.appearance.mode === 0 && window.siyuan.config.appearance.themeLight === "daylight");
@@ -243,7 +243,9 @@ const renderPDF = (id: string) => {
-
+
@@ -515,7 +517,7 @@ const renderPDF = (id: string) => {
});
};
-const getExportPath = (option: { type: string, id: string }, removeAssets?: boolean, mergeSubdocs?: boolean) => {
+const getExportPath = (option: IExportOptions, removeAssets?: boolean, mergeSubdocs?: boolean) => {
fetchPost("/api/block/getBlockInfo", {
id: option.id
}, async (response) => {
@@ -569,17 +571,17 @@ const getExportPath = (option: { type: string, id: string }, removeAssets?: bool
}
afterExport(path.join(savePath, replaceLocalPath(response.data.rootTitle)) + ".docx", msgId);
} else {
- onExport(exportResponse, savePath, option.type, removeAssets, msgId);
+ onExport(exportResponse, savePath, option, removeAssets, msgId);
}
});
}
});
};
-const onExport = (data: IWebSocketData, filePath: string, type: string, removeAssets?: boolean, msgId?: string) => {
+const onExport = (data: IWebSocketData, filePath: string, exportOption:IExportOptions, removeAssets?: boolean, msgId?: string) => {
let themeName = window.siyuan.config.appearance.themeLight;
let mode = 0;
- if (["html", "htmlmd"].includes(type) && window.siyuan.config.appearance.mode === 1) {
+ if (["html", "htmlmd"].includes(exportOption.type) && window.siyuan.config.appearance.mode === 1) {
themeName = window.siyuan.config.appearance.themeDark;
mode = 1;
}
@@ -607,7 +609,10 @@ const onExport = (data: IWebSocketData, filePath: string, type: string, removeAs
-
${data.data.content}
+
${data.data.content}
@@ -627,7 +632,7 @@ const onExport = (data: IWebSocketData, filePath: string, type: string, removeAs
};
const previewElement = document.getElementById('preview');
Protyle.highlightRender(previewElement, "stage/protyle");
- Protyle.mathRender(previewElement, "stage/protyle", ${type === "pdf"});
+ Protyle.mathRender(previewElement, "stage/protyle", ${exportOption.type === "pdf"});
Protyle.mermaidRender(previewElement, "stage/protyle");
Protyle.flowchartRender(previewElement, "stage/protyle");
Protyle.graphvizRender(previewElement, "stage/protyle");
diff --git a/app/src/protyle/export/util.ts b/app/src/protyle/export/util.ts
index fc49471f8..6663a884c 100644
--- a/app/src/protyle/export/util.ts
+++ b/app/src/protyle/export/util.ts
@@ -25,11 +25,14 @@ export const afterExport = (exportPath: string, msgId: string) => {
/// #endif
};
-export const exportImage = (id: string) => {
+export const exportImage = (id: string, fileType:string) => {
const exportDialog = new Dialog({
title: window.siyuan.languages.exportAsImage,
content: `
diff --git a/app/src/protyle/header/openTitleMenu.ts b/app/src/protyle/header/openTitleMenu.ts
index c4a4fcb46..a544e36eb 100644
--- a/app/src/protyle/header/openTitleMenu.ts
+++ b/app/src/protyle/header/openTitleMenu.ts
@@ -230,7 +230,7 @@ export const openTitleMenu = (protyle: IProtyle, position: IPosition) => {
}).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(exportMd(protyle.block.showAll ? protyle.block.id : protyle.block.rootID, protyle.wysiwyg.element.getAttribute("data-doc-type")));
if (protyle?.app?.plugins) {
emitOpenMenu({
diff --git a/app/src/types/index.d.ts b/app/src/types/index.d.ts
index ecaffbd9d..b32ee4cb6 100644
--- a/app/src/types/index.d.ts
+++ b/app/src/types/index.d.ts
@@ -498,6 +498,12 @@ interface IPluginDockTab {
show?: boolean
}
+interface IExportOptions {
+ type: string,
+ id: string,
+ fileType: string
+}
+
interface IOpenFileOptions {
app: import("../index").App,
searchData?: ISearchOption, // 搜索必填