From f2d7e7e64b7c91b007f41e064b5c23d6d587592a Mon Sep 17 00:00:00 2001 From: Soltus Date: Thu, 12 Jan 2023 02:12:33 +0800 Subject: [PATCH 1/2] #12 --- .../Export_Helper/css/custom__split_byH1.css | 8 ++++ extension/plugin/Export_Helper/export.html | 41 +++++++++++-------- extension/plugin/Export_Helper/renderPDF.js | 38 ++++++++++++++++- 3 files changed, 68 insertions(+), 19 deletions(-) create mode 100644 extension/plugin/Export_Helper/css/custom__split_byH1.css diff --git a/extension/plugin/Export_Helper/css/custom__split_byH1.css b/extension/plugin/Export_Helper/css/custom__split_byH1.css new file mode 100644 index 0000000..6e29d2c --- /dev/null +++ b/extension/plugin/Export_Helper/css/custom__split_byH1.css @@ -0,0 +1,8 @@ +@media print { + .h1 { + page-break-before: always; + } +} +.h1 { + page-break-before: always; +} \ No newline at end of file diff --git a/extension/plugin/Export_Helper/export.html b/extension/plugin/Export_Helper/export.html index f9d7208..3e95303 100644 --- a/extension/plugin/Export_Helper/export.html +++ b/extension/plugin/Export_Helper/export.html @@ -1,26 +1,33 @@ + Document + + -
-

你好我是导出助手

-

 

-

我可以

-

 

-
    -
  1. 更好地预览导出效果
  2. -
  3. 选择不同的页脚
  4. -
  5. 敬请期待
  6. -
-
+
+

以下表格显示了额外的配置,修改它们请在主题设置面板>扩展>导出助手配置界面完成

+
+
- + + \ No newline at end of file diff --git a/extension/plugin/Export_Helper/renderPDF.js b/extension/plugin/Export_Helper/renderPDF.js index 551787c..ee41727 100644 --- a/extension/plugin/Export_Helper/renderPDF.js +++ b/extension/plugin/Export_Helper/renderPDF.js @@ -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 = ` + + + + + + + + + + + + + + + + + +
根据一级标题分页${custom__split_byH1}
+ `; if (!window.siyuan.printWin) { return; } @@ -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", () => { From 0658b8bd0814e319ba61964b6a9bd2b016993c18 Mon Sep 17 00:00:00 2001 From: Soltus Date: Thu, 12 Jan 2023 02:19:06 +0800 Subject: [PATCH 2/2] no message --- README.md | 17 +++++++++++++++++ theme.json | 2 +- 2 files changed, 18 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 614bdb7..235398b 100644 --- a/README.md +++ b/README.md @@ -28,6 +28,23 @@ ## ✨ 正式开启公测 +### v1.1 聚合说明 + +> 2023-01-?? released + +

+适配 SiYuan v2.6.2 +适配 Sofill- v1.5 +这是一个构建版本
+ + + +

+ +引入特性: + +1. [【导出助手】导出PDF支持根据一级标题分页 · Issue #12 · v1.1.2](https://github.com/Hi-Windom/lili/issues/12) + ### 主题设置界面入口指南 Step 1 确保在思源软件设置里关闭了【隐藏底部状态栏】 diff --git a/theme.json b/theme.json index 9228427..451a729 100644 --- a/theme.json +++ b/theme.json @@ -2,7 +2,7 @@ "name": "Sofill=", "author": "Soltus", "url": "https://github.com/Hi-Windom/lili", - "version": "1.1.1", + "version": "1.1.2", "modes": [ "light" ]