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({
|
return new MenuItem({
|
||||||
label: window.siyuan.languages.export,
|
label: window.siyuan.languages.export,
|
||||||
type: "submenu",
|
type: "submenu",
|
||||||
|
|
@ -532,7 +532,7 @@ export const exportMd = (id: string, fileType = "NodeDocument") => {
|
||||||
label: window.siyuan.languages.image,
|
label: window.siyuan.languages.image,
|
||||||
icon: "iconImage",
|
icon: "iconImage",
|
||||||
click: () => {
|
click: () => {
|
||||||
exportImage(id, fileType);
|
exportImage(id);
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
/// #if !BROWSER
|
/// #if !BROWSER
|
||||||
|
|
@ -540,26 +540,26 @@ export const exportMd = (id: string, fileType = "NodeDocument") => {
|
||||||
label: "PDF",
|
label: "PDF",
|
||||||
icon: "iconPDF",
|
icon: "iconPDF",
|
||||||
click: () => {
|
click: () => {
|
||||||
saveExport({type: "pdf", id, fileType});
|
saveExport({type: "pdf", id});
|
||||||
}
|
}
|
||||||
}, {
|
}, {
|
||||||
label: "HTML (SiYuan)",
|
label: "HTML (SiYuan)",
|
||||||
iconClass: "ft__error",
|
iconClass: "ft__error",
|
||||||
icon: "iconHTML5",
|
icon: "iconHTML5",
|
||||||
click: () => {
|
click: () => {
|
||||||
saveExport({type: "html", id, fileType});
|
saveExport({type: "html", id});
|
||||||
}
|
}
|
||||||
}, {
|
}, {
|
||||||
label: "HTML (Markdown)",
|
label: "HTML (Markdown)",
|
||||||
icon: "iconHTML5",
|
icon: "iconHTML5",
|
||||||
click: () => {
|
click: () => {
|
||||||
saveExport({type: "htmlmd", id, fileType});
|
saveExport({type: "htmlmd", id});
|
||||||
}
|
}
|
||||||
}, {
|
}, {
|
||||||
label: "Word .docx",
|
label: "Word .docx",
|
||||||
icon: "iconExact",
|
icon: "iconExact",
|
||||||
click: () => {
|
click: () => {
|
||||||
saveExport({type: "word", id, fileType});
|
saveExport({type: "word", id});
|
||||||
}
|
}
|
||||||
}, {
|
}, {
|
||||||
label: window.siyuan.languages.more,
|
label: window.siyuan.languages.more,
|
||||||
|
|
|
||||||
|
|
@ -19,10 +19,10 @@ export const saveExport = (option: IExportOptions) => {
|
||||||
if (option.type === "pdf") {
|
if (option.type === "pdf") {
|
||||||
if (window.siyuan.config.appearance.mode === 1) {
|
if (window.siyuan.config.appearance.mode === 1) {
|
||||||
confirmDialog(window.siyuan.languages.pdfTip, window.siyuan.languages.pdfConfirm, () => {
|
confirmDialog(window.siyuan.languages.pdfTip, window.siyuan.languages.pdfConfirm, () => {
|
||||||
renderPDF(option.id, option.fileType);
|
renderPDF(option.id);
|
||||||
});
|
});
|
||||||
} else {
|
} else {
|
||||||
renderPDF(option.id, option.fileType);
|
renderPDF(option.id);
|
||||||
}
|
}
|
||||||
} else if (option.type === "word") {
|
} else if (option.type === "word") {
|
||||||
const localData = window.siyuan.storage[Constants.LOCAL_EXPORTWORD];
|
const localData = window.siyuan.storage[Constants.LOCAL_EXPORTWORD];
|
||||||
|
|
@ -69,7 +69,7 @@ export const saveExport = (option: IExportOptions) => {
|
||||||
};
|
};
|
||||||
|
|
||||||
/// #if !BROWSER
|
/// #if !BROWSER
|
||||||
const renderPDF = (id: string, fileType: string) => {
|
const renderPDF = (id: string) => {
|
||||||
const localData = window.siyuan.storage[Constants.LOCAL_EXPORTPDF];
|
const localData = window.siyuan.storage[Constants.LOCAL_EXPORTPDF];
|
||||||
const servePath = window.location.protocol + "//" + window.location.host;
|
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");
|
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>
|
</div>
|
||||||
<div style="zoom:${localData.scale || 1}" class="protyle-wysiwyg${window.siyuan.config.editor.displayBookmarkIcon ? " protyle-wysiwyg--attr" : ""}"
|
<div style="zoom:${localData.scale || 1}" class="protyle-wysiwyg${window.siyuan.config.editor.displayBookmarkIcon ? " protyle-wysiwyg--attr" : ""}"
|
||||||
data-doc-type="${fileType}"
|
|
||||||
id="preview">
|
id="preview">
|
||||||
<div class="fn__loading" style="left:0"><img width="48px" src="${servePath}/stage/loading-pure.svg"></div>
|
<div class="fn__loading" style="left:0"><img width="48px" src="${servePath}/stage/loading-pure.svg"></div>
|
||||||
</div>
|
</div>
|
||||||
|
|
@ -359,8 +358,21 @@ id="preview">
|
||||||
cb(response);
|
cb(response);
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
const renderPreview = (html) => {
|
const renderPreview = (data) => {
|
||||||
previewElement.innerHTML = html;
|
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.mermaidRender(previewElement, "${servePath}/stage/protyle");
|
||||||
Protyle.flowchartRender(previewElement, "${servePath}/stage/protyle");
|
Protyle.flowchartRender(previewElement, "${servePath}/stage/protyle");
|
||||||
Protyle.graphvizRender(previewElement, "${servePath}/stage/protyle");
|
Protyle.graphvizRender(previewElement, "${servePath}/stage/protyle");
|
||||||
|
|
@ -439,7 +451,7 @@ id="preview">
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
setPadding();
|
setPadding();
|
||||||
renderPreview(response2.data.content);
|
renderPreview(response2.data);
|
||||||
})
|
})
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
@ -510,7 +522,7 @@ id="preview">
|
||||||
actionElement.remove();
|
actionElement.remove();
|
||||||
});
|
});
|
||||||
setPadding();
|
setPadding();
|
||||||
renderPreview(response.data.content);
|
renderPreview(response.data);
|
||||||
});
|
});
|
||||||
</script></body></html>`;
|
</script></body></html>`;
|
||||||
fetchPost("/api/export/exportTempContent", {content: html}, (response) => {
|
fetchPost("/api/export/exportTempContent", {content: html}, (response) => {
|
||||||
|
|
|
||||||
|
|
@ -25,13 +25,12 @@ export const afterExport = (exportPath: string, msgId: string) => {
|
||||||
/// #endif
|
/// #endif
|
||||||
};
|
};
|
||||||
|
|
||||||
export const exportImage = (id: string, fileType:string) => {
|
export const exportImage = (id: string) => {
|
||||||
const exportDialog = new Dialog({
|
const exportDialog = new Dialog({
|
||||||
title: window.siyuan.languages.exportAsImage,
|
title: window.siyuan.languages.exportAsImage,
|
||||||
content: `<div class="b3-dialog__content" style="${isMobile() ? "padding:8px;" : ""};background-color: var(--b3-theme-background)">
|
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);"
|
<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" : ""}"
|
class="export-img protyle-wysiwyg${window.siyuan.config.editor.displayBookmarkIcon ? " protyle-wysiwyg--attr" : ""}"
|
||||||
data-doc-type="${fileType}"
|
|
||||||
id="preview"></div>
|
id="preview"></div>
|
||||||
<div class="fn__hr--b"></div>
|
<div class="fn__hr--b"></div>
|
||||||
<div class="fn__hr--b"></div>
|
<div class="fn__hr--b"></div>
|
||||||
|
|
@ -92,6 +91,19 @@ id="preview"></div>
|
||||||
});
|
});
|
||||||
const refreshPreview = (response: IWebSocketData) => {
|
const refreshPreview = (response: IWebSocketData) => {
|
||||||
previewElement.innerHTML = response.data.content;
|
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);
|
processRender(previewElement);
|
||||||
highlightRender(previewElement);
|
highlightRender(previewElement);
|
||||||
previewElement.querySelectorAll("table").forEach((item: HTMLElement) => {
|
previewElement.querySelectorAll("table").forEach((item: HTMLElement) => {
|
||||||
|
|
|
||||||
|
|
@ -230,7 +230,7 @@ export const openTitleMenu = (protyle: IProtyle, position: IPosition) => {
|
||||||
}).element);
|
}).element);
|
||||||
}
|
}
|
||||||
genImportMenu(protyle.notebookId, protyle.path);
|
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) {
|
if (protyle?.app?.plugins) {
|
||||||
emitOpenMenu({
|
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 {
|
interface IExportOptions {
|
||||||
type: string,
|
type: string,
|
||||||
id: string,
|
id: string,
|
||||||
fileType: string
|
|
||||||
}
|
}
|
||||||
|
|
||||||
interface IOpenFileOptions {
|
interface IOpenFileOptions {
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue