Skip to content

Commit

Permalink
#12
Browse files Browse the repository at this point in the history
  • Loading branch information
Soltus committed Jan 11, 2023
1 parent a4a7042 commit f2d7e7e
Show file tree
Hide file tree
Showing 3 changed files with 68 additions and 19 deletions.
8 changes: 8 additions & 0 deletions extension/plugin/Export_Helper/css/custom__split_byH1.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
@media print {
.h1 {
page-break-before: always;
}
}
.h1 {
page-break-before: always;
}
41 changes: 24 additions & 17 deletions extension/plugin/Export_Helper/export.html
Original file line number Diff line number Diff line change
@@ -1,26 +1,33 @@
<!DOCTYPE html>
<html>

<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Document</title>
<style>
#tell {
margin-bottom: 2em;
}

#configs table {
min-width: 100%;
font-size: 1.31em;
}

#configs th,
#configs td {
border: 1px #000000 solid;
padding: 3px;
}
</style>
</head>

<body>
<div>
<p style="font-size:10.5pt"><span style="font-family:'Microsoft JhengHei'">你好</span><span
style="font-family:'Courier New'"></span><span style="font-family:'Microsoft JhengHei'">我是导出助手</span></p>
<p style="font-size:10.5pt"><span style="font-family:'Courier New'; -aw-import:ignore">&nbsp;</span></p>
<p style="font-size:10.5pt"><span style="font-family:'Microsoft JhengHei'">我可以</span><span
style="font-family:'Courier New'"></span></p>
<p style="font-size:10.5pt"><span style="font-family:'Courier New'; -aw-import:ignore">&nbsp;</span></p>
<ol type="1" style="margin:0pt; padding-left:0pt">
<li style="margin-left:17.6pt; padding-left:7.6pt; font-family:'Courier New'; font-size:10.5pt"><span
style="font-family:'Microsoft JhengHei'">更好地预览导出效果</span></li>
<li style="margin-left:17.6pt; padding-left:7.6pt; font-family:'Courier New'; font-size:10.5pt"><span
style="font-family:'Microsoft JhengHei'">选择不同的页脚</span></li>
<li style="margin-left:17.6pt; padding-left:7.6pt; font-family:'Courier New'; font-size:10.5pt"><span
style="font-family:'Microsoft JhengHei'">敬请期待</span></li>
</ol>
</div>
<div id="tell">
<p>以下表格显示了额外的配置,修改它们请在主题设置面板>扩展>导出助手配置界面完成</p>
</div>
<div id="configs"></div>
</body>
</html>

</html>
38 changes: 36 additions & 2 deletions extension/plugin/Export_Helper/renderPDF.js
Original file line number Diff line number Diff line change
Expand Up @@ -658,11 +658,42 @@ export const renderPDF = (id) => {
await window.siyuan.printWin.webContents.insertCSS(css);
event.preventDefault();
} else {
window.siyuan.printWin.webContents.removeInsertedCSS(key_action_auto_folded);
window.siyuan.printWin.webContents.removeInsertedCSS(
key_action_auto_folded
);
key_action_auto_folded = null;
}
});
ipcMain.on("export-pdf-lili-more", (event, data) => {

let custom__split_byH1 = localStorage.getItem(
"SC_lili_cp_extension_plugin__Export_Helper__custom__split_byH1"
);
if (custom__split_byH1 == "true") {
let file = `${window.siyuan.config.system.confDir}/appearance/themes/Sofill=/extension/plugin/Export_Helper/css/custom__split_byH1.css`;
let css = fs.readFileSync(file).toString();
window.siyuan.printWin.webContents.insertCSS(css);
}
ipcMain.on("export-pdf-lili-more", async (event, data) => {
const configsHTML = `
<table>
<thead>
<tr>
<th>项</th>
<th>值</th>
</tr>
</thead>
<tbody>
<tr>
<td>根据一级标题分页</td>
<td>${custom__split_byH1}</td>
</tr>
<tr>
<td></td>
<td></td>
</tr>
</tbody>
</table>
`;
if (!window.siyuan.printWin) {
return;
}
Expand Down Expand Up @@ -693,6 +724,9 @@ export const renderPDF = (id) => {
`http://${host}:${port}/extension/plugin/Export_Helper/export.html`
);
child.once("ready-to-show", () => {
child.webContents.executeJavaScript(
`document.querySelector("#configs").innerHTML = \`${configsHTML}\`;`
);
child.show();
});
child.on("closed", () => {
Expand Down

0 comments on commit f2d7e7e

Please sign in to comment.