From 30e4d5c87e33b22f093d26404ef5c418509d323f Mon Sep 17 00:00:00 2001 From: Simon Cambier Date: Sun, 26 Nov 2023 17:03:25 +0100 Subject: [PATCH] iframe layout --- src/app.html | 2 +- src/components/CodeView.svelte | 22 +++++++++ src/components/EditForm.svelte | 45 ++++++++++++++++--- src/components/TopBar.svelte | 2 +- src/lib/utils.ts | 3 ++ src/routes/+page.svelte | 59 ++++++++++++++++--------- src/routes/{create => new}/+page.svelte | 0 7 files changed, 105 insertions(+), 28 deletions(-) create mode 100644 src/components/CodeView.svelte rename src/routes/{create => new}/+page.svelte (100%) diff --git a/src/app.html b/src/app.html index 4036026..72dd2f5 100644 --- a/src/app.html +++ b/src/app.html @@ -23,7 +23,7 @@ npm/codemirror@5.65.16/theme/nord.min.css" - + + export let isMarkdown: boolean + export let isPlainText: boolean + export let decompressed: string + export let htmlContent: string + let cssClass = '' + export { cssClass as class } + + +
+ {#if isMarkdown} +
+ {@html htmlContent} +
+ {:else if isPlainText} +
+ {decompressed} +
+ {:else} +
{@html htmlContent}
+ {/if} +
diff --git a/src/components/EditForm.svelte b/src/components/EditForm.svelte index 6049fec..9676256 100644 --- a/src/components/EditForm.svelte +++ b/src/components/EditForm.svelte @@ -69,6 +69,25 @@ await updateShareUrl() isUrlInputVisible = true await tick() + urlInput.value = $shareUrl + urlInput.select() + } + + async function showMarkdownLink() { + await updateShareUrl() + isUrlInputVisible = true + await tick() + urlInput.value = `[Paste snippet](${$shareUrl})` + urlInput.select() + } + + async function showIframeCode() { + await updateShareUrl() + isUrlInputVisible = true + await tick() + // @ts-ignore + const height = Math.min(editor['doc'].height * 1.1 + 45, 500) + urlInput.value = `` urlInput.select() } @@ -95,10 +114,13 @@ bind:this={urlInput} type="text" class="border border-gray-300 bg-transparent p-1 grow" - value={$shareUrl} /> - - + + {:else}
@@ -109,8 +131,6 @@ class="bg-gray-700 border border-gray-300 p-1" />
- - + + + + + + + + +