mirror of
https://github.com/siyuan-note/siyuan.git
synced 2025-12-20 16:40:13 +01:00
This commit is contained in:
parent
f340a163f1
commit
bab0e764e2
5 changed files with 41 additions and 18 deletions
|
|
@ -431,7 +431,7 @@ export const copySubMenu = (id: string, accelerator = true, focusElement?: Eleme
|
|||
}];
|
||||
};
|
||||
|
||||
export const exportMd = (id: string, fileType = "NodeDocument") => {
|
||||
export const exportMd = (id: string) => {
|
||||
return new MenuItem({
|
||||
label: window.siyuan.languages.export,
|
||||
type: "submenu",
|
||||
|
|
@ -532,7 +532,7 @@ export const exportMd = (id: string, fileType = "NodeDocument") => {
|
|||
label: window.siyuan.languages.image,
|
||||
icon: "iconImage",
|
||||
click: () => {
|
||||
exportImage(id, fileType);
|
||||
exportImage(id);
|
||||
}
|
||||
},
|
||||
/// #if !BROWSER
|
||||
|
|
@ -540,26 +540,26 @@ export const exportMd = (id: string, fileType = "NodeDocument") => {
|
|||
label: "PDF",
|
||||
icon: "iconPDF",
|
||||
click: () => {
|
||||
saveExport({type: "pdf", id, fileType});
|
||||
saveExport({type: "pdf", id});
|
||||
}
|
||||
}, {
|
||||
label: "HTML (SiYuan)",
|
||||
iconClass: "ft__error",
|
||||
icon: "iconHTML5",
|
||||
click: () => {
|
||||
saveExport({type: "html", id, fileType});
|
||||
saveExport({type: "html", id});
|
||||
}
|
||||
}, {
|
||||
label: "HTML (Markdown)",
|
||||
icon: "iconHTML5",
|
||||
click: () => {
|
||||
saveExport({type: "htmlmd", id, fileType});
|
||||
saveExport({type: "htmlmd", id});
|
||||
}
|
||||
}, {
|
||||
label: "Word .docx",
|
||||
icon: "iconExact",
|
||||
click: () => {
|
||||
saveExport({type: "word", id, fileType});
|
||||
saveExport({type: "word", id});
|
||||
}
|
||||
}, {
|
||||
label: window.siyuan.languages.more,
|
||||
|
|
|
|||
|
|
@ -19,10 +19,10 @@ export const saveExport = (option: IExportOptions) => {
|
|||
if (option.type === "pdf") {
|
||||
if (window.siyuan.config.appearance.mode === 1) {
|
||||
confirmDialog(window.siyuan.languages.pdfTip, window.siyuan.languages.pdfConfirm, () => {
|
||||
renderPDF(option.id, option.fileType);
|
||||
renderPDF(option.id);
|
||||
});
|
||||
} else {
|
||||
renderPDF(option.id, option.fileType);
|
||||
renderPDF(option.id);
|
||||
}
|
||||
} else if (option.type === "word") {
|
||||
const localData = window.siyuan.storage[Constants.LOCAL_EXPORTWORD];
|
||||
|
|
@ -69,7 +69,7 @@ export const saveExport = (option: IExportOptions) => {
|
|||
};
|
||||
|
||||
/// #if !BROWSER
|
||||
const renderPDF = (id: string, fileType: string) => {
|
||||
const renderPDF = (id: 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");
|
||||
|
|
@ -244,7 +244,6 @@ const renderPDF = (id: string, fileType: string) => {
|
|||
</div>
|
||||
</div>
|
||||
<div style="zoom:${localData.scale || 1}" class="protyle-wysiwyg${window.siyuan.config.editor.displayBookmarkIcon ? " protyle-wysiwyg--attr" : ""}"
|
||||
data-doc-type="${fileType}"
|
||||
id="preview">
|
||||
<div class="fn__loading" style="left:0"><img width="48px" src="${servePath}/stage/loading-pure.svg"></div>
|
||||
</div>
|
||||
|
|
@ -359,8 +358,21 @@ id="preview">
|
|||
cb(response);
|
||||
})
|
||||
}
|
||||
const renderPreview = (html) => {
|
||||
previewElement.innerHTML = html;
|
||||
const renderPreview = (data) => {
|
||||
previewElement.innerHTML = data.content;
|
||||
previewElement.setAttribute("data-doc-type", data.type || "NodeDocument");
|
||||
if (data.attrs.memo) {
|
||||
previewElement.setAttribute("memo", data.attrs.memo);
|
||||
}
|
||||
if (data.attrs.name) {
|
||||
previewElement.setAttribute("name", data.attrs.name);
|
||||
}
|
||||
if (data.attrs.bookmark) {
|
||||
previewElement.setAttribute("bookmark", data.attrs.bookmark);
|
||||
}
|
||||
if (data.attrs.alias) {
|
||||
previewElement.setAttribute("alias", data.attrs.alias);
|
||||
}
|
||||
Protyle.mermaidRender(previewElement, "${servePath}/stage/protyle");
|
||||
Protyle.flowchartRender(previewElement, "${servePath}/stage/protyle");
|
||||
Protyle.graphvizRender(previewElement, "${servePath}/stage/protyle");
|
||||
|
|
@ -439,7 +451,7 @@ id="preview">
|
|||
return;
|
||||
}
|
||||
setPadding();
|
||||
renderPreview(response2.data.content);
|
||||
renderPreview(response2.data);
|
||||
})
|
||||
};
|
||||
|
||||
|
|
@ -510,7 +522,7 @@ id="preview">
|
|||
actionElement.remove();
|
||||
});
|
||||
setPadding();
|
||||
renderPreview(response.data.content);
|
||||
renderPreview(response.data);
|
||||
});
|
||||
</script></body></html>`;
|
||||
fetchPost("/api/export/exportTempContent", {content: html}, (response) => {
|
||||
|
|
|
|||
|
|
@ -25,13 +25,12 @@ export const afterExport = (exportPath: string, msgId: string) => {
|
|||
/// #endif
|
||||
};
|
||||
|
||||
export const exportImage = (id: string, fileType:string) => {
|
||||
export const exportImage = (id: string) => {
|
||||
const exportDialog = new Dialog({
|
||||
title: window.siyuan.languages.exportAsImage,
|
||||
content: `<div class="b3-dialog__content" style="${isMobile() ? "padding:8px;" : ""};background-color: var(--b3-theme-background)">
|
||||
<div style="${isMobile() ? "padding: 16px;margin: 16px 0" : "padding: 48px;margin: 8px 0 24px"};border: 1px solid var(--b3-border-color);border-radius: var(--b3-border-radius-b);"
|
||||
class="export-img protyle-wysiwyg${window.siyuan.config.editor.displayBookmarkIcon ? " protyle-wysiwyg--attr" : ""}"
|
||||
data-doc-type="${fileType}"
|
||||
id="preview"></div>
|
||||
<div class="fn__hr--b"></div>
|
||||
<div class="fn__hr--b"></div>
|
||||
|
|
@ -92,6 +91,19 @@ id="preview"></div>
|
|||
});
|
||||
const refreshPreview = (response: IWebSocketData) => {
|
||||
previewElement.innerHTML = response.data.content;
|
||||
previewElement.setAttribute("data-doc-type", response.data.type || "NodeDocument");
|
||||
if (response.data.attrs.memo) {
|
||||
previewElement.setAttribute("memo", response.data.attrs.memo);
|
||||
}
|
||||
if (response.data.attrs.name) {
|
||||
previewElement.setAttribute("name", response.data.attrs.name);
|
||||
}
|
||||
if (response.data.attrs.bookmark) {
|
||||
previewElement.setAttribute("bookmark", response.data.attrs.bookmark);
|
||||
}
|
||||
if (response.data.attrs.alias) {
|
||||
previewElement.setAttribute("alias", response.data.attrs.alias);
|
||||
}
|
||||
processRender(previewElement);
|
||||
highlightRender(previewElement);
|
||||
previewElement.querySelectorAll("table").forEach((item: HTMLElement) => {
|
||||
|
|
|
|||
|
|
@ -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, protyle.wysiwyg.element.getAttribute("data-doc-type")));
|
||||
window.siyuan.menus.menu.append(exportMd(protyle.block.showAll ? protyle.block.id : protyle.block.rootID));
|
||||
|
||||
if (protyle?.app?.plugins) {
|
||||
emitOpenMenu({
|
||||
|
|
|
|||
1
app/src/types/index.d.ts
vendored
1
app/src/types/index.d.ts
vendored
|
|
@ -501,7 +501,6 @@ interface IPluginDockTab {
|
|||
interface IExportOptions {
|
||||
type: string,
|
||||
id: string,
|
||||
fileType: string
|
||||
}
|
||||
|
||||
interface IOpenFileOptions {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue