diff --git a/src/lib/components/MessageEditor.svelte b/src/lib/components/MessageEditor.svelte index bba62cb..feb743e 100644 --- a/src/lib/components/MessageEditor.svelte +++ b/src/lib/components/MessageEditor.svelte @@ -2,6 +2,7 @@ import { tick } from "svelte"; import { uploadImage } from "$lib/blossom"; import { BLOSSOM_URL } from "$lib/config"; + import PostContent from "$lib/components/PostContent.svelte"; type Props = { value: string; @@ -24,11 +25,16 @@ let textareaEl = $state(null); let fileInputEl = $state(null); let uploadError = $state(null); + let previewing = $state(false); export function focus() { textareaEl?.focus(); } + function togglePreview() { + previewing = !previewing; + } + function onUploadClick() { fileInputEl?.click(); } @@ -66,22 +72,35 @@ } -
- +
+ {#if previewing} +
+ {#if value.trim()} + + {:else} +

Nothing to preview

+ {/if} +
+ {:else} + + {/if}
-
- {#each p.content.split(/\n{2,}/) as para} - {#each tokenize(para) as block} - {#if block.type === "image"} - - {:else} -

- {#each block.inlines as inline} - {#if inline.type === "link"} - {inline.label} - {:else if inline.type === "mention"} - {@const u = - profiles[inline.pubkey] ?? resolvedUsers[inline.pubkey]} - @{u?.shortName ?? inline.fallback} - {:else if inline.type === "entity"} - {inline.label} - {:else}{inline.value}{/if} - {/each} -

- {/if} - {/each} - {/each} -
+