mirror of
https://github.com/siyuan-note/siyuan.git
synced 2025-12-19 16:10:12 +01:00
🎨 支持合并子文档导出 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",
|
"exportPDF3": "Page Scale",
|
||||||
"exportPDF4": "Remove assets directory",
|
"exportPDF4": "Remove assets directory",
|
||||||
"exportPDF5": "Keep folded",
|
"exportPDF5": "Keep folded",
|
||||||
|
"exportPDF6": "Fusionar subdocumentos",
|
||||||
"upload": "Upload",
|
"upload": "Upload",
|
||||||
"reminderTip": "The reminder time cannot be less than the current time",
|
"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",
|
"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",
|
"export3": "Sólo texto de anclaje",
|
||||||
"export4": "Notas a pie de página",
|
"export4": "Notas a pie de página",
|
||||||
"export5": "Ref. de anotación en PDF",
|
"export5": "Ref. de anotación en PDF",
|
||||||
|
"export6": "Fusionar subdocumentos",
|
||||||
"export6": "Sobre el manejo del texto ancla en las anotaciones PDF al exportar",
|
"export6": "Sobre el manejo del texto ancla en las anotaciones PDF al exportar",
|
||||||
"export7": "Nombre de archivo - Número de página - Texto ancla",
|
"export7": "Nombre de archivo - Número de página - Texto ancla",
|
||||||
"export8": "Sólo texto ancla",
|
"export8": "Sólo texto ancla",
|
||||||
|
|
|
||||||
|
|
@ -170,6 +170,7 @@
|
||||||
"exportPDF3": "Échelle de page",
|
"exportPDF3": "Échelle de page",
|
||||||
"exportPDF4": "Supprimer le répertoire des actifs",
|
"exportPDF4": "Supprimer le répertoire des actifs",
|
||||||
"exportPDF5": "Garder plié",
|
"exportPDF5": "Garder plié",
|
||||||
|
"exportPDF6": "Fusionner les sous-documents",
|
||||||
"upload": "Télécharger",
|
"upload": "Télécharger",
|
||||||
"reminderTip": "The reminder time cannot be less than the current time",
|
"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.",
|
"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": "頁面縮放",
|
"exportPDF3": "頁面縮放",
|
||||||
"exportPDF4": "移除 assets 目錄",
|
"exportPDF4": "移除 assets 目錄",
|
||||||
"exportPDF5": "保持折疊狀態",
|
"exportPDF5": "保持折疊狀態",
|
||||||
|
"exportPDF6": "合併子文檔",
|
||||||
"upload": "上傳",
|
"upload": "上傳",
|
||||||
"reminderTip": "提醒時間不能小於當前時間",
|
"reminderTip": "提醒時間不能小於當前時間",
|
||||||
"wechatTip": "該內容塊將以明文形式發送到雲端,到期時通過微信公眾號模板消息進行推送",
|
"wechatTip": "該內容塊將以明文形式發送到雲端,到期時通過微信公眾號模板消息進行推送",
|
||||||
|
|
|
||||||
|
|
@ -170,6 +170,7 @@
|
||||||
"exportPDF3": "页面缩放",
|
"exportPDF3": "页面缩放",
|
||||||
"exportPDF4": "移除 assets 目录",
|
"exportPDF4": "移除 assets 目录",
|
||||||
"exportPDF5": "保持折叠状态",
|
"exportPDF5": "保持折叠状态",
|
||||||
|
"exportPDF6": "合并子文档",
|
||||||
"upload": "上传",
|
"upload": "上传",
|
||||||
"reminderTip": "提醒时间不能小于当前时间",
|
"reminderTip": "提醒时间不能小于当前时间",
|
||||||
"wechatTip": "该内容块将以明文形式发送到云端,到期时通过微信公众号模板消息进行推送",
|
"wechatTip": "该内容块将以明文形式发送到云端,到期时通过微信公众号模板消息进行推送",
|
||||||
|
|
|
||||||
|
|
@ -70,6 +70,7 @@ const renderPDF = (id: string) => {
|
||||||
pageSize: "A4",
|
pageSize: "A4",
|
||||||
removeAssets: true,
|
removeAssets: true,
|
||||||
keepFold: false,
|
keepFold: false,
|
||||||
|
mergeSubdocs: false,
|
||||||
}));
|
}));
|
||||||
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");
|
||||||
|
|
@ -204,6 +205,13 @@ const renderPDF = (id: string) => {
|
||||||
<span class="fn__hr"></span>
|
<span class="fn__hr"></span>
|
||||||
<input id="keepFold" class="b3-switch" type="checkbox" ${localData.keepFold ? "checked" : ""}>
|
<input id="keepFold" class="b3-switch" type="checkbox" ${localData.keepFold ? "checked" : ""}>
|
||||||
</label>
|
</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">
|
||||||
<div class="fn__flex-1"></div>
|
<div class="fn__flex-1"></div>
|
||||||
<button class="b3-button b3-button--cancel">${window.siyuan.languages.cancel}</button>
|
<button class="b3-button b3-button--cancel">${window.siyuan.languages.cancel}</button>
|
||||||
|
|
@ -316,6 +324,7 @@ const renderPDF = (id: string) => {
|
||||||
fetchPost("/api/export/exportPreviewHTML", {
|
fetchPost("/api/export/exportPreviewHTML", {
|
||||||
id: "${id}",
|
id: "${id}",
|
||||||
keepFold: ${localData.keepFold},
|
keepFold: ${localData.keepFold},
|
||||||
|
merge: ${localData.mergeSubdocs},
|
||||||
}, response => {
|
}, response => {
|
||||||
if (response.code === 1) {
|
if (response.code === 1) {
|
||||||
alert(response.msg)
|
alert(response.msg)
|
||||||
|
|
@ -359,10 +368,19 @@ const renderPDF = (id: string) => {
|
||||||
const actionElement = document.getElementById('action');
|
const actionElement = document.getElementById('action');
|
||||||
const keepFoldElement = actionElement.querySelector('#keepFold');
|
const keepFoldElement = actionElement.querySelector('#keepFold');
|
||||||
keepFoldElement.addEventListener('change', () => {
|
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", {
|
fetchPost("/api/export/exportPreviewHTML", {
|
||||||
id: "${id}",
|
id: "${id}",
|
||||||
keepFold: keepFoldElement.checked,
|
keepFold: keepFoldElement.checked,
|
||||||
|
merge: mergeSubdocsElement.checked,
|
||||||
}, response2 => {
|
}, response2 => {
|
||||||
if (response2.code === 1) {
|
if (response2.code === 1) {
|
||||||
alert(response2.msg)
|
alert(response2.msg)
|
||||||
|
|
@ -371,7 +389,8 @@ const renderPDF = (id: string) => {
|
||||||
setPadding();
|
setPadding();
|
||||||
renderPreview(response2.data.content);
|
renderPreview(response2.data.content);
|
||||||
})
|
})
|
||||||
})
|
};
|
||||||
|
|
||||||
actionElement.querySelector("#scale").addEventListener("input", () => {
|
actionElement.querySelector("#scale").addEventListener("input", () => {
|
||||||
actionElement.querySelector("#scaleTip").innerText = actionElement.querySelector("#scale").value;
|
actionElement.querySelector("#scaleTip").innerText = actionElement.querySelector("#scale").value;
|
||||||
})
|
})
|
||||||
|
|
@ -406,6 +425,7 @@ const renderPDF = (id: string) => {
|
||||||
pageSize: actionElement.querySelector("#pageSize").value,
|
pageSize: actionElement.querySelector("#pageSize").value,
|
||||||
},
|
},
|
||||||
keepFold: keepFoldElement.checked,
|
keepFold: keepFoldElement.checked,
|
||||||
|
mergeSubdocs: mergeSubdocsElement.checked,
|
||||||
removeAssets: actionElement.querySelector("#removeAssets").checked,
|
removeAssets: actionElement.querySelector("#removeAssets").checked,
|
||||||
rootId: "${id}",
|
rootId: "${id}",
|
||||||
rootTitle: response.data.name,
|
rootTitle: response.data.name,
|
||||||
|
|
|
||||||
|
|
@ -374,7 +374,8 @@ const initWindow = () => {
|
||||||
const msgId = showMessage(window.siyuan.languages.exporting, -1);
|
const msgId = showMessage(window.siyuan.languages.exporting, -1);
|
||||||
localStorage.setItem(Constants.LOCAL_EXPORTPDF, JSON.stringify(Object.assign(ipcData.pdfOptions, {
|
localStorage.setItem(Constants.LOCAL_EXPORTPDF, JSON.stringify(Object.assign(ipcData.pdfOptions, {
|
||||||
removeAssets: ipcData.removeAssets,
|
removeAssets: ipcData.removeAssets,
|
||||||
keepFold: ipcData.keepFold
|
keepFold: ipcData.keepFold,
|
||||||
|
merge: ipcData.mergeSubdocs,
|
||||||
})));
|
})));
|
||||||
try {
|
try {
|
||||||
window.siyuan.printWin.webContents.printToPDF(ipcData.pdfOptions).then((pdfData) => {
|
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"))})
|
heading.AppendChild(&ast.Node{Type: ast.NodeText, Tokens: []byte(tree.Root.IALAttr("title"))})
|
||||||
tree.Root.PrependChild(heading)
|
tree.Root.PrependChild(heading)
|
||||||
for c := tree.Root.FirstChild; nil != c; c = c.Next {
|
for c := tree.Root.FirstChild; nil != c; c = c.Next {
|
||||||
|
if ast.NodeParagraph == c.Type && nil == c.FirstChild {
|
||||||
|
// 剔除空段落
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
|
||||||
ret = append(ret, c)
|
ret = append(ret, c)
|
||||||
}
|
}
|
||||||
return
|
return
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue