diff --git a/webapp/src/lib/components/RawRenderer.svelte b/webapp/src/lib/components/RawRenderer.svelte new file mode 100644 index 0000000..f810ebd --- /dev/null +++ b/webapp/src/lib/components/RawRenderer.svelte @@ -0,0 +1,4 @@ +
+    
+
diff --git a/webapp/src/routes/note/[id].raw.svelte b/webapp/src/routes/note/[id].raw.svelte new file mode 100644 index 0000000..e69de29 diff --git a/webapp/src/routes/note/[id].svelte b/webapp/src/routes/note/[id].svelte index 420b1fa..bc93ea2 100644 --- a/webapp/src/routes/note/[id].svelte +++ b/webapp/src/routes/note/[id].svelte @@ -23,14 +23,15 @@ import IconEncrypted from 'svelte-icons/md/MdLockOutline.svelte'; import type { EncryptedNote } from '$lib/model/EncryptedNote'; import { browser } from '$app/env'; + import RawRenderer from '$lib/components/RawRenderer.svelte'; + import LogoDocument from 'svelte-icons/md/MdUndo.svelte'; // Auto-loaded from [id].ts endpoint export let note: EncryptedNote; let plaintext: string; let timeString: string; let decryptFailed = false; - // let downloadUrl: string; - let downloadRef: HTMLAnchorElement; + let showRaw = false; onMount(() => { if (browser) { @@ -47,23 +48,8 @@ timeString = msToString(diff_ms); } - // $: if (plaintext) { - // downloadUrl = downloadMd(plaintext); - // } - - // https://stackoverflow.com/questions/19327749/javascript-blob-filename-without-link - function downloadMd() { - if (plaintext === undefined) return; - // Make sure the browser reads the data as UTF-8 - // https://stackoverflow.com/questions/6672834/specifying-blob-encoding-in-google-chrome - const BOM = new Uint8Array([0xef, 0xbb, 0xbf]); - const blob = new Blob([BOM, plaintext], { type: 'text/plain' }); - const url = window.URL.createObjectURL(blob); - console.log(url); - downloadRef.href = url; - downloadRef.click(); - window.URL.revokeObjectURL(blob); - return url; + function toggleRaw() { + showRaw = !showRaw; } function msToString(ms: number): string { @@ -91,13 +77,21 @@ e2e encrypted | Shared {timeString} ago -

- + {#if showRaw} + {plaintext} + {:else} + + {/if} {/if}