From e4d4d11413dcc873a470baac7baf28ef46c09b43 Mon Sep 17 00:00:00 2001 From: Simon Cambier Date: Fri, 24 Nov 2023 20:17:40 +0100 Subject: [PATCH] Fixed auto wrapping --- src/components/EditForm.svelte | 14 +++++++++++--- src/components/TopBar.svelte | 4 ++-- src/routes/+page.svelte | 24 +++++++++++++----------- 3 files changed, 26 insertions(+), 16 deletions(-) diff --git a/src/components/EditForm.svelte b/src/components/EditForm.svelte index cc79ce7..7e44c13 100644 --- a/src/components/EditForm.svelte +++ b/src/components/EditForm.svelte @@ -29,6 +29,17 @@ selectedLanguage = languages.find((e) => e.value === $selectedLang)! }) + selectedLang.subscribe((lang) => { + textWrap = lang === 'plt' || lang === 'md' + }) + + $: { + if (editor) { + // Line wrapping + editor.setOption('lineWrapping', textWrap) + } + } + $: { if (editor) { languages = CodeMirror.modeInfo @@ -49,9 +60,6 @@ editor.setOption('mode', langData.mime) CodeMirror.autoLoadMode(editor, langData.mode) $selectedLang = selectedLanguage?.value ?? 'plt' - - // Line wrapping - editor.setOption('lineWrapping', textWrap) } } diff --git a/src/components/TopBar.svelte b/src/components/TopBar.svelte index c8ce1e6..f154190 100644 --- a/src/components/TopBar.svelte +++ b/src/components/TopBar.svelte @@ -1,11 +1,11 @@

Paste

About diff --git a/src/routes/+page.svelte b/src/routes/+page.svelte index 54fc127..7ff54ac 100644 --- a/src/routes/+page.svelte +++ b/src/routes/+page.svelte @@ -58,7 +58,7 @@ } -
+
{#if decompressed} -
- {#if isMarkdown} - {@html decompressed} - {:else if isPlainText} -
- {decompressed} -
- {:else} -
{@html decompressed}
- {/if} +
+
+ {#if isMarkdown} + {@html decompressed} + {:else if isPlainText} +
+ {decompressed} +
+ {:else} +
{@html decompressed}
+ {/if} +
{/if}