An open-source, privacy-first, self-hosted knowledge workspace where humans and AI agents work together 开源、隐私优先、自托管的知识工作空间,让人与智能体在此协作
TypeScript agentic-aiai-agentknowledge-baselocal-firstmarkdownmcpmindmapnote-takingself-hostedsiyuanworkspace
:art: Improve PDF heading page break options https://github.com/siyuan-note/siyuan/issues/20561
Daniel842044a825a4
diff --git a/app/src/protyle/export/headingPageBreaksUI.ts b/app/src/protyle/export/headingPageBreaksUI.tsindex 91dbc6c7d5..101e1e7109 100644--- a/app/src/protyle/export/headingPageBreaksUI.ts+++ b/app/src/protyle/export/headingPageBreaksUI.ts@@ -17,7 +17,7 @@ export const openHeadingPageBreakDialog = (onConfirm: () => void) => {title: window.siyuan.languages.print,content: `<div class="b3-dialog__content"><div>${window.siyuan.languages.pdfHeadingPageBreaks}</div>- <div class="b3-label__text">${window.siyuan.languages.pdfHeadingPageBreaksTip}</div>+ <div class="ft__smaller ft__on-surface">${window.siyuan.languages.pdfHeadingPageBreaksTip}</div><div class="fn__hr"></div><div data-heading-page-breaks>${headingPageBreakControls(localData.headingPageBreakLevels)}</div></div>diff --git a/app/src/protyle/export/index.ts b/app/src/protyle/export/index.tsindex 5ca921cfb1..04d2baabe5 100644--- a/app/src/protyle/export/index.ts+++ b/app/src/protyle/export/index.ts@@ -517,9 +517,9 @@ const renderPDF = async (id: string) => {<span class="fn__hr"></span><input id="paged" class="b3-switch" type="checkbox" ${localData.paged ? "checked" : ""}></label>- <div class="b3-label">+ <div id="headingPageBreakOptions" class="b3-label${localData.paged ? "" : " fn__none"}"><div>${window.siyuan.languages.pdfHeadingPageBreaks}</div>- <div class="b3-label__text">${window.siyuan.languages.pdfHeadingPageBreaksTip}</div>+ <div class="ft__smaller ft__on-surface">${window.siyuan.languages.pdfHeadingPageBreaksTip}</div><div class="fn__hr"></div><div id="headingPageBreaks">${headingPageBreakControls(localData.headingPageBreakLevels)}</div></div>@@ -545,6 +545,7 @@ ${getIconScript(servePath)}.map(input => Number(input.value));const updateHeadingPageBreaks = () => {const enabled = document.getElementById("paged").checked;+ document.getElementById("headingPageBreakOptions").classList.toggle("fn__none", !enabled);document.querySelectorAll("#headingPageBreaks input").forEach(input => {input.disabled = !enabled;});diff --git a/app/tests/pdfHeadingPageBreaks.test.js b/app/tests/pdfHeadingPageBreaks.test.jsindex b07ac22446..6cd320c650 100644--- a/app/tests/pdfHeadingPageBreaks.test.js+++ b/app/tests/pdfHeadingPageBreaks.test.js@@ -69,6 +69,9 @@ const browserCases = async (headingSource, uiSource, desktopSource, mobileSourcethrow new Error(name);});ui.openHeadingPageBreakDialog(() => confirmed++);+ check.ok(parseFloat(getComputedStyle(activeDialog.element.querySelector(".ft__smaller")).fontSize) <+ parseFloat(getComputedStyle(activeDialog.element.querySelector(".b3-dialog__content > div")).fontSize),+ "Mobile print descriptions use a smaller font than their titles");check.equal(activeDialog.element.querySelector('input[value="2"]').checked, true);activeDialog.element.querySelector('input[value="6"]').checked = true;activeDialog.element.querySelector(".b3-button--cancel").click();@@ -93,6 +96,11 @@ const browserCases = async (headingSource, uiSource, desktopSource, mobileSource"getPluginStyle", "fetchPost", "headingPageBreakControls", desktopSource + ";return renderPDF;")(Constants, {invoke: async () => 0}, async () => "", () => ({}), () => "", () => "", () => "", () => "{}",async () => "", async () => "", async () => "", (_url, data) => html = data.content, ui.headingPageBreakControls);+ window.siyuan.storage.pdf.paged = false;+ await renderPDF("root");+ check.ok(new DOMParser().parseFromString(html, "text/html").getElementById("headingPageBreakOptions")+ .classList.contains("fn__none"), "Unpaged preferences hide heading options before initialization");+ window.siyuan.storage.pdf.paged = true;await renderPDF("root");check.ok(html.includes('id="headingPageBreaks"'));const inline = html.match(/<script>\s*const previewElement[\s\S]*?<\/script>/)[0]@@ -108,12 +116,21 @@ const browserCases = async (headingSource, uiSource, desktopSource, mobileSourcecheck.deepEqual(Array.from(preview.querySelectorAll("[data-export-heading-page-break]")).map(element => element.getAttribute("data-node-id")), ["child-title", "deep-title"]);const paged = document.getElementById("paged");+ const options = document.getElementById("headingPageBreakOptions");+ check.notEqual(getComputedStyle(options).display, "none");+ check.ok(parseFloat(getComputedStyle(options.querySelector(".ft__smaller")).fontSize) <+ parseFloat(getComputedStyle(options.firstElementChild).fontSize),+ "Desktop export descriptions use a smaller font than their titles");paged.checked = false;paged.dispatchEvent(new Event("change"));+ check.equal(getComputedStyle(options).display, "none");check.equal(preview.querySelectorAll("[data-export-heading-page-break]").length, 0);check.ok(Array.from(document.querySelectorAll("#headingPageBreaks input")).every(input => input.disabled));paged.checked = true;paged.dispatchEvent(new Event("change"));+ check.notEqual(getComputedStyle(options).display, "none");+ check.deepEqual(Array.from(options.querySelectorAll("input:checked")).map(input => Number(input.value)), [2, 6],+ "Showing the heading options preserves selected levels");check.equal(preview.querySelectorAll("[data-export-heading-page-break]").length, 2);document.querySelector('#headingPageBreaks input[value="2"]').click();check.equal(preview.querySelectorAll("[data-export-heading-page-break]").length, 1);