🎨 支持合并子文档导出 Word/PDF https://github.com/siyuan-note/siyuan/issues/3219
This commit is contained in:
parent
8400173cba
commit
2f9f9ec360
8 changed files with 34 additions and 3 deletions
|
@ -170,6 +170,7 @@
|
|||
"exportPDF3": "Page Scale",
|
||||
"exportPDF4": "Remove assets directory",
|
||||
"exportPDF5": "Keep folded",
|
||||
"exportPDF6": "Fusionar subdocumentos",
|
||||
"upload": "Upload",
|
||||
"reminderTip": "The reminder time cannot be less than the current time",
|
||||
"wechatTip": "The content block will be sent to the cloud in clear text, and pushed through the WeChat MP template message when it expires",
|
||||
|
|
|
@ -674,6 +674,7 @@
|
|||
"export3": "Sólo texto de anclaje",
|
||||
"export4": "Notas a pie de página",
|
||||
"export5": "Ref. de anotación en PDF",
|
||||
"export6": "Fusionar subdocumentos",
|
||||
"export6": "Sobre el manejo del texto ancla en las anotaciones PDF al exportar",
|
||||
"export7": "Nombre de archivo - Número de página - Texto ancla",
|
||||
"export8": "Sólo texto ancla",
|
||||
|
|
|
@ -170,6 +170,7 @@
|
|||
"exportPDF3": "Échelle de page",
|
||||
"exportPDF4": "Supprimer le répertoire des actifs",
|
||||
"exportPDF5": "Garder plié",
|
||||
"exportPDF6": "Fusionner les sous-documents",
|
||||
"upload": "Télécharger",
|
||||
"reminderTip": "The reminder time cannot be less than the current time",
|
||||
"wechatTip": "Le bloc de contenu sera envoyé au cloud en texte clair et transmis au message du modèle de compte officiel WeChat à son expiration.",
|
||||
|
|
|
@ -170,6 +170,7 @@
|
|||
"exportPDF3": "頁面縮放",
|
||||
"exportPDF4": "移除 assets 目錄",
|
||||
"exportPDF5": "保持折疊狀態",
|
||||
"exportPDF6": "合併子文檔",
|
||||
"upload": "上傳",
|
||||
"reminderTip": "提醒時間不能小於當前時間",
|
||||
"wechatTip": "該內容塊將以明文形式發送到雲端,到期時通過微信公眾號模板消息進行推送",
|
||||
|
|
|
@ -170,6 +170,7 @@
|
|||
"exportPDF3": "页面缩放",
|
||||
"exportPDF4": "移除 assets 目录",
|
||||
"exportPDF5": "保持折叠状态",
|
||||
"exportPDF6": "合并子文档",
|
||||
"upload": "上传",
|
||||
"reminderTip": "提醒时间不能小于当前时间",
|
||||
"wechatTip": "该内容块将以明文形式发送到云端,到期时通过微信公众号模板消息进行推送",
|
||||
|
|
|
@ -70,6 +70,7 @@ const renderPDF = (id: string) => {
|
|||
pageSize: "A4",
|
||||
removeAssets: true,
|
||||
keepFold: false,
|
||||
mergeSubdocs: false,
|
||||
}));
|
||||
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");
|
||||
|
@ -204,6 +205,13 @@ const renderPDF = (id: string) => {
|
|||
<span class="fn__hr"></span>
|
||||
<input id="keepFold" class="b3-switch" type="checkbox" ${localData.keepFold ? "checked" : ""}>
|
||||
</label>
|
||||
<label class="b3-label">
|
||||
<div>
|
||||
${window.siyuan.languages.exportPDF6}
|
||||
</div>
|
||||
<span class="fn__hr"></span>
|
||||
<input id="mergeSubdocs" class="b3-switch" type="checkbox" ${localData.mergeSubdocs ? "checked" : ""}>
|
||||
</label>
|
||||
<div class="fn__flex">
|
||||
<div class="fn__flex-1"></div>
|
||||
<button class="b3-button b3-button--cancel">${window.siyuan.languages.cancel}</button>
|
||||
|
@ -316,6 +324,7 @@ const renderPDF = (id: string) => {
|
|||
fetchPost("/api/export/exportPreviewHTML", {
|
||||
id: "${id}",
|
||||
keepFold: ${localData.keepFold},
|
||||
merge: ${localData.mergeSubdocs},
|
||||
}, response => {
|
||||
if (response.code === 1) {
|
||||
alert(response.msg)
|
||||
|
@ -359,10 +368,19 @@ const renderPDF = (id: string) => {
|
|||
const actionElement = document.getElementById('action');
|
||||
const keepFoldElement = actionElement.querySelector('#keepFold');
|
||||
keepFoldElement.addEventListener('change', () => {
|
||||
previewElement.innerHTML = '<div class="fn__loading" style="left:0"><img width="48px" src="${servePath}/stage/loading-pure.svg"></div>'
|
||||
refreshPreview();
|
||||
});
|
||||
const mergeSubdocsElement = actionElement.querySelector('#mergeSubdocs');
|
||||
mergeSubdocsElement.addEventListener('change', () => {
|
||||
refreshPreview();
|
||||
});
|
||||
|
||||
const refreshPreview = () => {
|
||||
previewElement.innerHTML = '<div class="fn__loading" style="left:0"><img width="48px" src="${servePath}/stage/loading-pure.svg"></div>'
|
||||
fetchPost("/api/export/exportPreviewHTML", {
|
||||
id: "${id}",
|
||||
keepFold: keepFoldElement.checked,
|
||||
merge: mergeSubdocsElement.checked,
|
||||
}, response2 => {
|
||||
if (response2.code === 1) {
|
||||
alert(response2.msg)
|
||||
|
@ -371,7 +389,8 @@ const renderPDF = (id: string) => {
|
|||
setPadding();
|
||||
renderPreview(response2.data.content);
|
||||
})
|
||||
})
|
||||
};
|
||||
|
||||
actionElement.querySelector("#scale").addEventListener("input", () => {
|
||||
actionElement.querySelector("#scaleTip").innerText = actionElement.querySelector("#scale").value;
|
||||
})
|
||||
|
@ -406,6 +425,7 @@ const renderPDF = (id: string) => {
|
|||
pageSize: actionElement.querySelector("#pageSize").value,
|
||||
},
|
||||
keepFold: keepFoldElement.checked,
|
||||
mergeSubdocs: mergeSubdocsElement.checked,
|
||||
removeAssets: actionElement.querySelector("#removeAssets").checked,
|
||||
rootId: "${id}",
|
||||
rootTitle: response.data.name,
|
||||
|
|
|
@ -374,7 +374,8 @@ const initWindow = () => {
|
|||
const msgId = showMessage(window.siyuan.languages.exporting, -1);
|
||||
localStorage.setItem(Constants.LOCAL_EXPORTPDF, JSON.stringify(Object.assign(ipcData.pdfOptions, {
|
||||
removeAssets: ipcData.removeAssets,
|
||||
keepFold: ipcData.keepFold
|
||||
keepFold: ipcData.keepFold,
|
||||
merge: ipcData.mergeSubdocs,
|
||||
})));
|
||||
try {
|
||||
window.siyuan.printWin.webContents.printToPDF(ipcData.pdfOptions).then((pdfData) => {
|
||||
|
|
|
@ -79,6 +79,11 @@ func loadTreeNodes(box string, p string, level int) (ret []*ast.Node, err error)
|
|||
heading.AppendChild(&ast.Node{Type: ast.NodeText, Tokens: []byte(tree.Root.IALAttr("title"))})
|
||||
tree.Root.PrependChild(heading)
|
||||
for c := tree.Root.FirstChild; nil != c; c = c.Next {
|
||||
if ast.NodeParagraph == c.Type && nil == c.FirstChild {
|
||||
// 剔除空段落
|
||||
continue
|
||||
}
|
||||
|
||||
ret = append(ret, c)
|
||||
}
|
||||
return
|
||||
|
|
Loading…
Add table
Reference in a new issue