mirror of
https://github.com/whoswhip/Sharpbin.git
synced 2026-12-06 02:48:43 +00:00
feat: view raw button; paste header follows when scrolling; scroll to top button appears after scrolling far enough
chore: npm run format + lint
This commit is contained in:
@@ -3,6 +3,7 @@
|
|||||||
import { onMount } from 'svelte';
|
import { onMount } from 'svelte';
|
||||||
import type { PageData } from './$types';
|
import type { PageData } from './$types';
|
||||||
import {
|
import {
|
||||||
|
File,
|
||||||
FileBox,
|
FileBox,
|
||||||
Eye,
|
Eye,
|
||||||
EyeClosed,
|
EyeClosed,
|
||||||
@@ -19,7 +20,8 @@
|
|||||||
Copy,
|
Copy,
|
||||||
Check,
|
Check,
|
||||||
CalendarCog,
|
CalendarCog,
|
||||||
Flag
|
Flag,
|
||||||
|
ArrowUp
|
||||||
} from '@lucide/svelte/icons/index';
|
} from '@lucide/svelte/icons/index';
|
||||||
import {
|
import {
|
||||||
formatBytes,
|
formatBytes,
|
||||||
@@ -52,6 +54,8 @@
|
|||||||
let downloadedPaste = false;
|
let downloadedPaste = false;
|
||||||
let copiedPaste = false;
|
let copiedPaste = false;
|
||||||
|
|
||||||
|
let scrollY = 0;
|
||||||
|
|
||||||
let now = new Date();
|
let now = new Date();
|
||||||
$: isExpired =
|
$: isExpired =
|
||||||
data?.paste?.expiresAt && data.paste.expiresAt !== 0
|
data?.paste?.expiresAt && data.paste.expiresAt !== 0
|
||||||
@@ -306,6 +310,8 @@
|
|||||||
?.cf_turnstile_site_key ?? null;
|
?.cf_turnstile_site_key ?? null;
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
|
<svelte:window bind:scrollY />
|
||||||
|
|
||||||
<svelte:head>
|
<svelte:head>
|
||||||
<title
|
<title
|
||||||
>{data.paste
|
>{data.paste
|
||||||
@@ -344,9 +350,7 @@
|
|||||||
<main
|
<main
|
||||||
class="flex min-h-[calc(100vh-60px)] w-full flex-col items-center justify-center pt-5 pb-5 text-white"
|
class="flex min-h-[calc(100vh-60px)] w-full flex-col items-center justify-center pt-5 pb-5 text-white"
|
||||||
>
|
>
|
||||||
<div
|
<div class=" w-[95%] max-w-7xl rounded border-2 border-neutral-800 bg-neutral-900 p-4">
|
||||||
class="max-h-[90vh] w-[95%] max-w-7xl rounded border-2 border-neutral-800 bg-neutral-900 p-4"
|
|
||||||
>
|
|
||||||
{#if data.paste}
|
{#if data.paste}
|
||||||
<div class="mb-4 w-full text-center">
|
<div class="mb-4 w-full text-center">
|
||||||
<h1
|
<h1
|
||||||
@@ -412,7 +416,7 @@
|
|||||||
use:tooltip={`Created on ${
|
use:tooltip={`Created on ${
|
||||||
extractDateFromUUIDv7(data.paste.uuid)?.toLocaleString() ?? 'Unknown Date'
|
extractDateFromUUIDv7(data.paste.uuid)?.toLocaleString() ?? 'Unknown Date'
|
||||||
}
|
}
|
||||||
${dateToRelativeString(extractDateFromUUIDv7(data.paste.uuid) ?? new Date(), true, true, now, 3)}`}
|
${dateToRelativeString(extractDateFromUUIDv7(data.paste.uuid) ?? new Date(), true, true, now, 3)}`}
|
||||||
>
|
>
|
||||||
{extractDateFromUUIDv7(data.paste.uuid)?.toLocaleDateString() ?? 'Unknown Date'}
|
{extractDateFromUUIDv7(data.paste.uuid)?.toLocaleDateString() ?? 'Unknown Date'}
|
||||||
</span>
|
</span>
|
||||||
@@ -423,7 +427,7 @@
|
|||||||
<span
|
<span
|
||||||
class="text-neutral-400"
|
class="text-neutral-400"
|
||||||
use:tooltip={`Edited on ${new Date(data.paste.editedAt).toLocaleString()}
|
use:tooltip={`Edited on ${new Date(data.paste.editedAt).toLocaleString()}
|
||||||
${dateToRelativeString(new Date(data.paste.editedAt), true, true, now, 3)}`}
|
${dateToRelativeString(new Date(data.paste.editedAt), true, true, now, 3)}`}
|
||||||
>
|
>
|
||||||
{#if new Date(data.paste.editedAt).getTime() > new Date().getTime() - 86400000}
|
{#if new Date(data.paste.editedAt).getTime() > new Date().getTime() - 86400000}
|
||||||
Edited {dateToRelativeString(new Date(data.paste.editedAt), false, false, now)} ago
|
Edited {dateToRelativeString(new Date(data.paste.editedAt), false, false, now)} ago
|
||||||
@@ -440,7 +444,7 @@
|
|||||||
<span
|
<span
|
||||||
class="text-neutral-400"
|
class="text-neutral-400"
|
||||||
use:tooltip={`Expires on ${new Date(data.paste.expiresAt).toLocaleString()}
|
use:tooltip={`Expires on ${new Date(data.paste.expiresAt).toLocaleString()}
|
||||||
${dateToRelativeString(new Date(data.paste.expiresAt), true, true, now, 3)}`}
|
${dateToRelativeString(new Date(data.paste.expiresAt), true, true, now, 3)}`}
|
||||||
>
|
>
|
||||||
{isExpired ? 'Expired' : 'Expires in'}
|
{isExpired ? 'Expired' : 'Expires in'}
|
||||||
{dateToRelativeString(new Date(data.paste.expiresAt), false, false, now)}
|
{dateToRelativeString(new Date(data.paste.expiresAt), false, false, now)}
|
||||||
@@ -502,206 +506,223 @@
|
|||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
<div
|
||||||
|
class="sticky top-0 z-10 flex flex-col items-center justify-between gap-2 rounded-t-md border-b border-neutral-700 bg-neutral-800 px-3 py-2 md:flex-row"
|
||||||
|
>
|
||||||
|
<div class="flex items-center gap-2 text-sm text-neutral-300">
|
||||||
|
<span class="font-medium text-neutral-100"
|
||||||
|
>{formatNumber((editContent ?? decryptedContent ?? data.content).length)}</span
|
||||||
|
>
|
||||||
|
<span class="text-neutral-400">chars</span>
|
||||||
|
<span class="text-neutral-600">•</span>
|
||||||
|
<span class="font-medium text-neutral-100"
|
||||||
|
>{formatNumber(
|
||||||
|
(editing ? (editContent ?? '') : (decryptedContent ?? data.content)).split('\n')
|
||||||
|
.length
|
||||||
|
)}</span
|
||||||
|
>
|
||||||
|
<span class="text-neutral-400"
|
||||||
|
>line{(editing ? (editContent ?? '') : (decryptedContent ?? data.content)).split('\n')
|
||||||
|
.length !== 1
|
||||||
|
? 's'
|
||||||
|
: ''}</span
|
||||||
|
>
|
||||||
|
</div>
|
||||||
|
<div class="flex shrink-0 flex-wrap items-center gap-2 sm:flex-nowrap">
|
||||||
|
<button
|
||||||
|
type="button"
|
||||||
|
class="flex cursor-pointer items-center rounded-md bg-neutral-700 px-2 py-0.5 text-sm hover:bg-neutral-600"
|
||||||
|
on:click={() => {
|
||||||
|
navigator.clipboard.writeText(decryptedContent ?? data.content);
|
||||||
|
copiedPaste = true;
|
||||||
|
setTimeout(() => (copiedPaste = false), 1000);
|
||||||
|
}}
|
||||||
|
>
|
||||||
|
<div class="relative mr-1 h-5 w-5">
|
||||||
|
{#if copiedPaste}
|
||||||
|
<span
|
||||||
|
transition:fade={{ duration: 200 }}
|
||||||
|
class="absolute inset-0 flex items-center justify-center"
|
||||||
|
><Check class="h-5 w-5 text-green-400" /></span
|
||||||
|
>
|
||||||
|
{:else}
|
||||||
|
<span
|
||||||
|
transition:fade={{ duration: 200 }}
|
||||||
|
class="absolute inset-0 flex items-center justify-center"
|
||||||
|
><Copy class="h-5 w-5 text-neutral-400" /></span
|
||||||
|
>
|
||||||
|
{/if}
|
||||||
|
</div>
|
||||||
|
|
||||||
<div class="overflow-hidden">
|
<span class="text-neutral-300">Copy</span>
|
||||||
<div
|
</button>
|
||||||
class="flex flex-col items-center justify-between gap-2 rounded-t-md border-b border-neutral-700 bg-neutral-800 px-3 py-2 md:flex-row"
|
<button
|
||||||
>
|
type="button"
|
||||||
<div class="flex items-center gap-2 text-sm text-neutral-300">
|
class="flex cursor-pointer items-center rounded-md bg-neutral-700 px-2 py-0.5 text-sm hover:bg-neutral-600"
|
||||||
<span class="font-medium text-neutral-100"
|
on:click={() => {
|
||||||
>{formatNumber((editContent ?? decryptedContent ?? data.content).length)}</span
|
const blob = new Blob([decryptedContent ?? data.content], {
|
||||||
>
|
type: 'text/plain'
|
||||||
<span class="text-neutral-400">chars</span>
|
});
|
||||||
<span class="text-neutral-600">•</span>
|
const url = URL.createObjectURL(blob);
|
||||||
<span class="font-medium text-neutral-100"
|
const a = document.createElement('a');
|
||||||
>{formatNumber(
|
a.href = url;
|
||||||
(editing ? (editContent ?? '') : (decryptedContent ?? data.content)).split('\n')
|
a.download = data.paste?.title
|
||||||
.length
|
? data.paste.title.replace(/[^a-z0-9_\-.]/gi, '_').slice(0, 100) + '.txt'
|
||||||
)}</span
|
: `paste_${data.paste?.id}.txt`;
|
||||||
>
|
document.body.appendChild(a);
|
||||||
<span class="text-neutral-400"
|
a.click();
|
||||||
>line{(editing ? (editContent ?? '') : (decryptedContent ?? data.content)).split('\n')
|
document.body.removeChild(a);
|
||||||
.length !== 1
|
URL.revokeObjectURL(url);
|
||||||
? 's'
|
downloadedPaste = true;
|
||||||
: ''}</span
|
setTimeout(() => (downloadedPaste = false), 1000);
|
||||||
>
|
}}
|
||||||
</div>
|
>
|
||||||
<div class="flex shrink-0 flex-wrap items-center gap-2 sm:flex-nowrap">
|
<div class="relative mr-1 h-5 w-5">
|
||||||
|
{#if downloadedPaste}
|
||||||
|
<span
|
||||||
|
transition:fade={{ duration: 200 }}
|
||||||
|
class="absolute inset-0 flex items-center justify-center"
|
||||||
|
><Check class="h-5 w-5 text-green-400" /></span
|
||||||
|
>
|
||||||
|
{:else}
|
||||||
|
<span
|
||||||
|
transition:fade={{ duration: 200 }}
|
||||||
|
class="absolute inset-0 flex items-center justify-center"
|
||||||
|
><Download class="h-5 w-5 text-neutral-400" /></span
|
||||||
|
>
|
||||||
|
{/if}
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<span class="text-neutral-300">Download</span>
|
||||||
|
</button>
|
||||||
|
|
||||||
|
<a
|
||||||
|
href={resolve(`/raw/${data.paste.id}`)}
|
||||||
|
class="flex cursor-pointer items-center rounded-md bg-neutral-700 px-2 py-0.5 text-sm hover:bg-neutral-600"
|
||||||
|
>
|
||||||
|
<File class="mr-1 h-5 w-5 text-neutral-400" />
|
||||||
|
<span class="text-neutral-300">View Raw</span>
|
||||||
|
</a>
|
||||||
|
|
||||||
|
{#if $user !== null && $user.uuid !== data.paste?.author?.uuid}
|
||||||
<button
|
<button
|
||||||
type="button"
|
type="button"
|
||||||
class="flex cursor-pointer items-center rounded-md bg-neutral-700 px-2 py-0.5 text-sm hover:bg-neutral-600"
|
class="flex cursor-pointer items-center rounded-md bg-neutral-700 px-2 py-0.5 text-sm hover:bg-amber-600/50"
|
||||||
on:click={() => {
|
on:click={() => {
|
||||||
navigator.clipboard.writeText(decryptedContent ?? data.content);
|
promptUser('report');
|
||||||
copiedPaste = true;
|
|
||||||
setTimeout(() => (copiedPaste = false), 1000);
|
|
||||||
}}
|
}}
|
||||||
>
|
>
|
||||||
<div class="relative mr-1 h-5 w-5">
|
<Flag class="mr-1 h-5 w-5 text-amber-400" />
|
||||||
{#if copiedPaste}
|
<span class="text-amber-300">Report</span>
|
||||||
<span
|
|
||||||
transition:fade={{ duration: 200 }}
|
|
||||||
class="absolute inset-0 flex items-center justify-center"
|
|
||||||
><Check class="h-5 w-5 text-green-400" /></span
|
|
||||||
>
|
|
||||||
{:else}
|
|
||||||
<span
|
|
||||||
transition:fade={{ duration: 200 }}
|
|
||||||
class="absolute inset-0 flex items-center justify-center"
|
|
||||||
><Copy class="h-5 w-5 text-neutral-400" /></span
|
|
||||||
>
|
|
||||||
{/if}
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<span class="text-neutral-300">Copy</span>
|
|
||||||
</button>
|
</button>
|
||||||
<button
|
{/if}
|
||||||
type="button"
|
{#if $user && ($user.uuid === data.paste?.author?.uuid || $user.roles.some((r) => r === 1 || r === 255))}
|
||||||
class="flex cursor-pointer items-center rounded-md bg-neutral-700 px-2 py-0.5 text-sm hover:bg-neutral-600"
|
{#if !editing}
|
||||||
on:click={() => {
|
|
||||||
const blob = new Blob([decryptedContent ?? data.content], {
|
|
||||||
type: 'text/plain'
|
|
||||||
});
|
|
||||||
const url = URL.createObjectURL(blob);
|
|
||||||
const a = document.createElement('a');
|
|
||||||
a.href = url;
|
|
||||||
a.download = data.paste?.title
|
|
||||||
? data.paste.title.replace(/[^a-z0-9_\-.]/gi, '_').slice(0, 100) + '.txt'
|
|
||||||
: `paste_${data.paste?.id}.txt`;
|
|
||||||
document.body.appendChild(a);
|
|
||||||
a.click();
|
|
||||||
document.body.removeChild(a);
|
|
||||||
URL.revokeObjectURL(url);
|
|
||||||
downloadedPaste = true;
|
|
||||||
setTimeout(() => (downloadedPaste = false), 1000);
|
|
||||||
}}
|
|
||||||
>
|
|
||||||
<div class="relative mr-1 h-5 w-5">
|
|
||||||
{#if downloadedPaste}
|
|
||||||
<span
|
|
||||||
transition:fade={{ duration: 200 }}
|
|
||||||
class="absolute inset-0 flex items-center justify-center"
|
|
||||||
><Check class="h-5 w-5 text-green-400" /></span
|
|
||||||
>
|
|
||||||
{:else}
|
|
||||||
<span
|
|
||||||
transition:fade={{ duration: 200 }}
|
|
||||||
class="absolute inset-0 flex items-center justify-center"
|
|
||||||
><Download class="h-5 w-5 text-neutral-400" /></span
|
|
||||||
>
|
|
||||||
{/if}
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<span class="text-neutral-300">Download</span>
|
|
||||||
</button>
|
|
||||||
{#if $user !== null && $user.uuid !== data.paste?.author?.uuid}
|
|
||||||
<button
|
<button
|
||||||
type="button"
|
type="button"
|
||||||
class="flex cursor-pointer items-center rounded-md bg-neutral-700 px-2 py-0.5 text-sm hover:bg-amber-600/50"
|
class="flex cursor-pointer items-center rounded-md bg-neutral-700 px-2 py-0.5 text-sm hover:bg-neutral-600"
|
||||||
on:click={() => {
|
on:click={() => {
|
||||||
promptUser('report');
|
editContent = decryptedContent ?? data.content;
|
||||||
|
editError = '';
|
||||||
|
editing = true;
|
||||||
}}
|
}}
|
||||||
>
|
>
|
||||||
<Flag class="mr-1 h-5 w-5 text-amber-400" />
|
<Pencil class="mr-1 h-5 w-5 text-neutral-400" />
|
||||||
<span class="text-amber-300">Report</span>
|
<span class="text-neutral-300">Edit</span>
|
||||||
|
</button>
|
||||||
|
<button
|
||||||
|
type="button"
|
||||||
|
class="flex cursor-pointer items-center rounded-md bg-neutral-700 px-2 py-0.5 text-sm hover:bg-red-900"
|
||||||
|
on:click={() => {
|
||||||
|
promptUser('confirm').then(async (value) => {
|
||||||
|
if (value) {
|
||||||
|
const token = getToken();
|
||||||
|
if (!token) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
const res = await fetch(`/api/paste/${data.paste?.id}`, {
|
||||||
|
method: 'DELETE',
|
||||||
|
headers: {
|
||||||
|
Authorization: `Bearer ${token}`
|
||||||
|
}
|
||||||
|
});
|
||||||
|
if (res.ok) {
|
||||||
|
window.location.href = resolve('/');
|
||||||
|
} else {
|
||||||
|
alert('Failed to delete paste.');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}}
|
||||||
|
>
|
||||||
|
<Trash2 class="mr-1 h-5 w-5 text-red-400" />
|
||||||
|
<span class="text-red-300">Delete</span>
|
||||||
|
</button>
|
||||||
|
{:else}
|
||||||
|
<button
|
||||||
|
type="button"
|
||||||
|
class="flex cursor-pointer items-center rounded-md bg-neutral-700 px-2 py-0.5 text-sm hover:bg-neutral-600"
|
||||||
|
on:click={async () => {
|
||||||
|
if (editContent !== null || editMetadata !== null) {
|
||||||
|
await updatePaste(editContent, editMetadata);
|
||||||
|
}
|
||||||
|
}}
|
||||||
|
disabled={editLoading}
|
||||||
|
>
|
||||||
|
<PencilLine class="mr-1 h-5 w-5 text-neutral-400" />
|
||||||
|
<span class="text-neutral-300">{editLoading ? 'Saving...' : 'Save Edits'}</span>
|
||||||
|
</button>
|
||||||
|
<button
|
||||||
|
type="button"
|
||||||
|
class="flex cursor-pointer items-center rounded-md bg-neutral-700 px-2 py-0.5 text-sm hover:bg-neutral-600"
|
||||||
|
on:click={() => {
|
||||||
|
editing = false;
|
||||||
|
editError = '';
|
||||||
|
}}
|
||||||
|
>
|
||||||
|
<PencilOff class="mr-1 h-5 w-5 text-neutral-400" />
|
||||||
|
<span class="text-neutral-300">Cancel Edit</span>
|
||||||
</button>
|
</button>
|
||||||
{/if}
|
{/if}
|
||||||
{#if $user && ($user.uuid === data.paste?.author?.uuid || $user.roles.some((r) => r === 1 || r === 255))}
|
|
||||||
{#if !editing}
|
|
||||||
<button
|
|
||||||
type="button"
|
|
||||||
class="flex cursor-pointer items-center rounded-md bg-neutral-700 px-2 py-0.5 text-sm hover:bg-neutral-600"
|
|
||||||
on:click={() => {
|
|
||||||
editContent = decryptedContent ?? data.content;
|
|
||||||
editError = '';
|
|
||||||
editing = true;
|
|
||||||
}}
|
|
||||||
>
|
|
||||||
<Pencil class="mr-1 h-5 w-5 text-neutral-400" />
|
|
||||||
<span class="text-neutral-300">Edit</span>
|
|
||||||
</button>
|
|
||||||
<button
|
|
||||||
type="button"
|
|
||||||
class="flex cursor-pointer items-center rounded-md bg-neutral-700 px-2 py-0.5 text-sm hover:bg-red-900"
|
|
||||||
on:click={() => {
|
|
||||||
promptUser('confirm').then(async (value) => {
|
|
||||||
if (value) {
|
|
||||||
const token = getToken();
|
|
||||||
if (!token) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
const res = await fetch(`/api/paste/${data.paste?.id}`, {
|
|
||||||
method: 'DELETE',
|
|
||||||
headers: {
|
|
||||||
Authorization: `Bearer ${token}`
|
|
||||||
}
|
|
||||||
});
|
|
||||||
if (res.ok) {
|
|
||||||
window.location.href = resolve('/');
|
|
||||||
} else {
|
|
||||||
alert('Failed to delete paste.');
|
|
||||||
}
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}}
|
|
||||||
>
|
|
||||||
<Trash2 class="mr-1 h-5 w-5 text-red-400" />
|
|
||||||
<span class="text-red-300">Delete</span>
|
|
||||||
</button>
|
|
||||||
{:else}
|
|
||||||
<button
|
|
||||||
type="button"
|
|
||||||
class="flex cursor-pointer items-center rounded-md bg-neutral-700 px-2 py-0.5 text-sm hover:bg-neutral-600"
|
|
||||||
on:click={async () => {
|
|
||||||
if (editContent !== null || editMetadata !== null) {
|
|
||||||
await updatePaste(editContent, editMetadata);
|
|
||||||
}
|
|
||||||
}}
|
|
||||||
disabled={editLoading}
|
|
||||||
>
|
|
||||||
<PencilLine class="mr-1 h-5 w-5 text-neutral-400" />
|
|
||||||
<span class="text-neutral-300">{editLoading ? 'Saving...' : 'Save Edits'}</span>
|
|
||||||
</button>
|
|
||||||
<button
|
|
||||||
type="button"
|
|
||||||
class="flex cursor-pointer items-center rounded-md bg-neutral-700 px-2 py-0.5 text-sm hover:bg-neutral-600"
|
|
||||||
on:click={() => {
|
|
||||||
editing = false;
|
|
||||||
editError = '';
|
|
||||||
}}
|
|
||||||
>
|
|
||||||
<PencilOff class="mr-1 h-5 w-5 text-neutral-400" />
|
|
||||||
<span class="text-neutral-300">Cancel Edit</span>
|
|
||||||
</button>
|
|
||||||
{/if}
|
|
||||||
{/if}
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
{#if editing}
|
|
||||||
<textarea
|
|
||||||
class="mb-3 max-h-[40vh] min-h-10 w-full rounded-b bg-neutral-800 p-2 font-mono"
|
|
||||||
rows="14"
|
|
||||||
placeholder="Paste content"
|
|
||||||
bind:value={editContent}
|
|
||||||
></textarea>
|
|
||||||
{#if editError}
|
|
||||||
<div class="mb-3 rounded border border-red-900 bg-red-950 p-2 text-sm text-red-200">
|
|
||||||
{editError}
|
|
||||||
</div>
|
|
||||||
{/if}
|
{/if}
|
||||||
{:else}
|
{#if scrollY > 400 && contentRendered && !editing}
|
||||||
<div
|
<button
|
||||||
class="h-15 w-full rounded-b bg-neutral-800"
|
transition:fade={{ duration: 200 }}
|
||||||
class:hidden={contentRendered && !editing}
|
class="flex cursor-pointer items-center rounded-md bg-neutral-700 px-2 py-0.5 text-sm hover:bg-neutral-600"
|
||||||
></div>
|
on:click={() => window.scrollTo({ top: 0, behavior: 'smooth' })}
|
||||||
<code
|
aria-label="Scroll to top"
|
||||||
class="codeblock-with-lines overflow-x-auto overflow-y-auto"
|
>
|
||||||
class:hidden={!contentRendered}
|
<ArrowUp class="mr-1 h-5 w-5 text-neutral-400" />
|
||||||
>
|
<span class="text-neutral-300">Scroll to top</span>
|
||||||
<!-- eslint-disable-next-line svelte/no-at-html-tags -->
|
</button>
|
||||||
{@html pasteContent}
|
{/if}
|
||||||
</code>
|
</div>
|
||||||
{/if}
|
|
||||||
</div>
|
</div>
|
||||||
|
{#if editing}
|
||||||
|
<textarea
|
||||||
|
class="mb-3 max-h-[40vh] min-h-10 w-full rounded-b bg-neutral-800 p-2 font-mono"
|
||||||
|
rows="14"
|
||||||
|
placeholder="Paste content"
|
||||||
|
bind:value={editContent}
|
||||||
|
></textarea>
|
||||||
|
{#if editError}
|
||||||
|
<div class="mb-3 rounded border border-red-900 bg-red-950 p-2 text-sm text-red-200">
|
||||||
|
{editError}
|
||||||
|
</div>
|
||||||
|
{/if}
|
||||||
|
{:else}
|
||||||
|
<div
|
||||||
|
class="h-15 w-full rounded-b bg-neutral-800"
|
||||||
|
class:hidden={contentRendered && !editing}
|
||||||
|
></div>
|
||||||
|
<code
|
||||||
|
class="codeblock-with-lines overflow-x-auto overflow-y-auto"
|
||||||
|
class:hidden={!contentRendered}
|
||||||
|
>
|
||||||
|
<!-- eslint-disable-next-line svelte/no-at-html-tags -->
|
||||||
|
{@html pasteContent}
|
||||||
|
</code>
|
||||||
|
{/if}
|
||||||
{:else}
|
{:else}
|
||||||
<h1 class="mb-4 text-center text-4xl font-bold">Paste not found</h1>
|
<h1 class="mb-4 text-center text-4xl font-bold">Paste not found</h1>
|
||||||
<h2 class="mt-2 text-center text-xl">The paste you are looking for does not exist.</h2>
|
<h2 class="mt-2 text-center text-xl">The paste you are looking for does not exist.</h2>
|
||||||
@@ -732,7 +753,6 @@
|
|||||||
box-sizing: border-box;
|
box-sizing: border-box;
|
||||||
min-width: 0;
|
min-width: 0;
|
||||||
width: 100%;
|
width: 100%;
|
||||||
max-height: 40vh;
|
|
||||||
}
|
}
|
||||||
.code-row {
|
.code-row {
|
||||||
display: flex;
|
display: flex;
|
||||||
|
|||||||
@@ -27,7 +27,6 @@
|
|||||||
|
|
||||||
export let data: PageData;
|
export let data: PageData;
|
||||||
|
|
||||||
|
|
||||||
let currentPage = data.pastes?.pagination?.page ?? 1;
|
let currentPage = data.pastes?.pagination?.page ?? 1;
|
||||||
let pagination: Pagination = data.pastes?.pagination ?? {
|
let pagination: Pagination = data.pastes?.pagination ?? {
|
||||||
page: 1,
|
page: 1,
|
||||||
|
|||||||
Reference in New Issue
Block a user