From 05cd7e50027413153166b68ffe876e4d514059d9 Mon Sep 17 00:00:00 2001 From: Ammar Ahmed <40239442+ammarahm-ed@users.noreply.github.com> Date: Fri, 6 Jan 2023 17:58:33 +0500 Subject: [PATCH] core: add proper styling to pdf & html exports (#1579) * mobile: fix exported pdf styling * core: move html template styles to core * core: inline prism-dracula styles Signed-off-by: Abdullah Atta Co-authored-by: Abdullah Atta --- apps/mobile/app/services/exporter.js | 309 +----------------- .../core/utils/templates/html/template.js | 168 ++++++++++ 2 files changed, 169 insertions(+), 308 deletions(-) diff --git a/apps/mobile/app/services/exporter.js b/apps/mobile/app/services/exporter.js index 6f48d3ce7..c22d3f3ed 100644 --- a/apps/mobile/app/services/exporter.js +++ b/apps/mobile/app/services/exporter.js @@ -28,309 +28,6 @@ import Storage from "../common/database/storage"; import { toTXT } from "../utils"; import { sanitizeFilename } from "../utils/sanitizer"; import { sleep } from "../utils/time"; -const defaultStyle = ``; const MIMETypes = { txt: "text/plain", @@ -406,11 +103,6 @@ async function makeHtml(note) { html = decode(html, { level: EntityLevel.HTML }); - if (html.indexOf("") > -1) { - let chunk1 = html.substring(0, html.indexOf("") + 6); - let chunk2 = html.substring(html.indexOf("") + 6); - html = chunk1 + defaultStyle + chunk2; - } return html; } @@ -432,6 +124,7 @@ async function exportAs(type, note, bulk) { case "pdf": { let html = await makeHtml(note); + console.log(html); let fileName = sanitizeFilename(note.title + Date.now(), { replacement: "_" }); diff --git a/packages/core/utils/templates/html/template.js b/packages/core/utils/templates/html/template.js index 164a68d86..9b0b97897 100644 --- a/packages/core/utils/templates/html/template.js +++ b/packages/core/utils/templates/html/template.js @@ -30,6 +30,174 @@ const template = (data) => ` ${data.tags ? `` : ""} +

${data.title}