diff --git a/src/main.tsx b/src/main.tsx index fff6f7b..b12fb6b 100644 --- a/src/main.tsx +++ b/src/main.tsx @@ -9,7 +9,6 @@ import { jsPDF } from "jspdf"; import html2canvas from "html2canvas"; import markdownMark from "markdown-it-mark"; - const propertyOptions = [ "Hide Page Properties", "Hide Brackets", @@ -76,7 +75,7 @@ export function downloadPDF() { // var getContent = "
"+document.body+"
"; pdf.html(document.getElementById("you are cool"), { - callback: (doc) => doc.save("logseqDownloaded.pdf"), + callback: (doc) => doc.save("download.pdf"), margin: 0, width: 595, windowWidth: 595, @@ -103,9 +102,7 @@ async function formatText(text2, template) { text = text.substring(0, text.indexOf("CLOCK: [")); } - if ( - logseq.settings[`${template}Options`].includes("Hide Page Properties") - ) { + if (logseq.settings[`${template}Options`].includes("Hide Page Properties")) { text = text.replaceAll(/((?<=::).*|.*::)/g, ""); } if (logseq.settings[`${template}Options`].includes("Hide Brackets")) { @@ -120,7 +117,6 @@ async function formatText(text2, template) { includeChildren: true, }); //optional based on setting enabled - if (block != null) { text = text.replace( @@ -165,7 +161,7 @@ export async function createPDF(templateName) { finalString = finalString.replaceAll("#+BEGIN_QUOTE", ""); finalString = finalString.replaceAll("#+END_QUOTE", ""); - + const baseCSS = "h1 { display: block; font-size: 2em; margin-block-start: 0.67__qem; margin-block-end: 0.67em; margin-inline-start: 0; margin-inline-end: 0; font-weight: bold; } :is(article, aside, nav, section) h1 { font-size: 1.5em; margin-block-start: 0.83__qem; margin-block-end: 0.83em; } :is(article, aside, nav, section) :is(article, aside, nav, section) h1 { font-size: 1.17em; margin-block-start: 1__qem; margin-block-end: 1em; } :is(article, aside, nav, section) :is(article, aside, nav, section) :is(article, aside, nav, section) h1 { font-size: 1.00em; margin-block-start: 1.33__qem; margin-block-end: 1.33em; } :is(article, aside, nav, section) :is(article, aside, nav, section) :is(article, aside, nav, section) :is(article, aside, nav, section) h1 { font-size: .83em; margin-block-start: 1.67__qem; margin-block-end: 1.67em; } :is(article, aside, nav, section) :is(article, aside, nav, section) :is(article, aside, nav, section) :is(article, aside, nav, section) :is(article, aside, nav, section) h1 { font-size: .67em; margin-block-start: 2.33__qem; margin-block-end: 2.33em; } h2 { display: block; font-size: 1.5em; margin-block-start: 0.83__qem; margin-block-end: 0.83em; margin-inline-start: 0; margin-inline-end: 0; font-weight: bold; } h3 { display: block; font-size: 1.17em; margin-block-start: 1__qem; margin-block-end: 1em; margin-inline-start: 0; margin-inline-end: 0; font-weight: bold; } h4 { display: block; margin-block-start: 1.33__qem; margin-block-end: 1.33em; margin-inline-start: 0; margin-inline-end: 0; font-weight: bold; } h5 { display: block; font-size: .83em; margin-block-start: 1.67__qem; margin-block-end: 1.67em; margin-inline-start: 0; margin-inline-end: 0; font-weight: bold; } h6 { display: block; font-size: .67em; margin-block-start: 2.33__qem; margin-block-end: 2.33em; margin-inline-start: 0; margin-inline-end: 0; font-weight: bold; } /* lists */ ul, menu, dir { display: block; margin-block-start: 1__qem; margin-block-end: 1em; margin-inline-start: 0; margin-inline-end: 0; padding-inline-start: 40px; } ol { display: block; list-style-type: decimal; margin-block-start: 1__qem; margin-block-end: 1em; margin-inline-start: 0; margin-inline-end: 0; padding-inline-start: 40px; } li { display: list-item; text-align: match-parent; } /* FIXME: this should also match ::before::marker and ::after::marker but we don't support this yet. When we do, we can remove the code specific to ::before and ::after in RenderListItem::computeMarkerStyle(), see bugs.webkit.org/b/218897. */ ::marker { unicode-bidi: isolate; font-variant-numeric: tabular-nums; white-space: pre; text-transform: none; transform-origin: 0px 5px 5px;} ul ul, ol ul { } ol ol ul, ol ul ul, ul ol ul, ul ul ul { } dd { display: block; margin-inline-start: 40px; } dl { display: block; margin-block-start: 1__qem; margin-block-end: 1em; margin-inline-start: 0; margin-inline-end: 0; } dt { display: block; } ol ul, ul ol, ul ul, ol ol { margin-block-start: 0; margin-block-end: 0; } .italic{font-style: italic;} .bold{font-weight: bold;} .codeme{font-family: Menlo, Consolas, Monaco, Liberation Mono, Lucida Console, monospace;}"; const settings = logseq.settings; @@ -176,7 +172,6 @@ export async function createPDF(templateName) { final3String = `
${final2String}
`; logseq.App.getCurrentGraph().then(async (graph) => { - var final4String = final3String .replaceAll("../assets", `${graph.path}/assets`) .replaceAll("", "") @@ -187,10 +182,9 @@ export async function createPDF(templateName) { .replaceAll("", "") .replaceAll("", "\n"); - if (logseq.settings[templateName+"Options"].includes("Hide Bullets")){ - final4String = final4String.replaceAll("

", "

•") - } - else(final4String = final4String.replaceAll("

", "

")) + if (logseq.settings[templateName + "Options"].includes("Hide Bullets")) { + final4String = final4String.replaceAll("

", "

•"); + } else final4String = final4String.replaceAll("

", "

"); handleClosePopup(); renderApp(final4String); }); @@ -212,7 +206,6 @@ function parseBlocksTree(obj) { } } const main = async () => { - logseq.App.registerUIItem("toolbar", { key: "logseq-plugin-react-boilerplate", template: @@ -220,14 +213,15 @@ const main = async () => { }); logseq.provideModel({ show() { - // renderApp('logseq') - // logseq.showMainUI() - // createPDF() - renderSecondApp(); - logseq.showMainUI(); - handleClosePopup(); + initializeApp(); }, }); + + function initializeApp() { + renderSecondApp(); + logseq.showMainUI(); + handleClosePopup(); + } function renderSecondApp() { ReactDOM.render( @@ -237,8 +231,7 @@ const main = async () => { ); } - - logseq.App.registerPageMenuItem("Download Page as PDF", renderSecondApp); + logseq.App.registerPageMenuItem("Download Page as PDF", initializeApp); }; logseq.ready(main).catch(console.error);