From c97a6624d669fe700c896e6fd0fe23054c8fd649 Mon Sep 17 00:00:00 2001 From: thiloho <123883702+thiloho@users.noreply.github.com> Date: Tue, 17 Sep 2024 22:44:16 +0200 Subject: [PATCH] Allow more common mimetypes --- .../20240810115846_image_upload_function.sql | 2 +- web-app/src/lib/utils.ts | 17 ++++++++++++----- .../articles/[articleId]/+page.svelte | 1 + .../website/[websiteId]/logs/+page.svelte | 6 ++++-- 4 files changed, 18 insertions(+), 8 deletions(-) diff --git a/rest-api/db/migrations/20240810115846_image_upload_function.sql b/rest-api/db/migrations/20240810115846_image_upload_function.sql index e94d73a..dd9af74 100644 --- a/rest-api/db/migrations/20240810115846_image_upload_function.sql +++ b/rest-api/db/migrations/20240810115846_image_upload_function.sql @@ -8,7 +8,7 @@ DECLARE _website_id UUID := (_headers ->> 'x-website-id')::UUID; _mimetype TEXT := _headers ->> 'x-mimetype'; _original_filename TEXT := _headers ->> 'x-original-filename'; - _allowed_mimetypes TEXT[] := ARRAY['image/png', 'image/jpeg', 'image/webp']; + _allowed_mimetypes TEXT[] := ARRAY['image/png', 'image/jpeg', 'image/webp', 'image/avif', 'image/gif', 'image/svg+xml']; _max_file_size INT := 5 * 1024 * 1024; _has_access BOOLEAN; BEGIN diff --git a/web-app/src/lib/utils.ts b/web-app/src/lib/utils.ts index 9307bb9..1af3833 100644 --- a/web-app/src/lib/utils.ts +++ b/web-app/src/lib/utils.ts @@ -15,7 +15,14 @@ import type { LegalInformation } from "$lib/db-schema"; -export const ALLOWED_MIME_TYPES = ["image/jpeg", "image/png", "image/webp"]; +export const ALLOWED_MIME_TYPES = [ + "image/jpeg", + "image/png", + "image/webp", + "image/avif", + "image/gif", + "image/svg+xml" +]; export const slugify = (string: string) => { return string @@ -24,8 +31,8 @@ export const slugify = (string: string) => { .toLowerCase() // Convert to lowercase .trim() // Trim leading and trailing whitespace .replace(/\s+/g, "-") // Replace spaces with hyphens - .replace(/[^\w\-]+/g, "") // Remove non-word characters (except hyphens) - .replace(/\-\-+/g, "-") // Replace multiple hyphens with single hyphen + .replace(/[^\w-]+/g, "") // Remove non-word characters (except hyphens) + .replace(/-+/g, "-") // Replace multiple hyphens with single hyphen .replace(/^-+/, "") // Remove leading hyphens .replace(/-+$/, ""); // Remove trailing hyphens }; @@ -51,8 +58,8 @@ const createMarkdownParser = (showToc = true) => { ); const gfmHeadingId = ({ prefix = "", showToc = true } = {}) => { - let headings: { text: string; level: number; id: string }[] = []; - let sectionStack: { level: number; id: string }[] = []; + const headings: { text: string; level: number; id: string }[] = []; + const sectionStack: { level: number; id: string }[] = []; return { renderer: { diff --git a/web-app/src/routes/(authenticated)/website/[websiteId]/articles/[articleId]/+page.svelte b/web-app/src/routes/(authenticated)/website/[websiteId]/articles/[articleId]/+page.svelte index 83d6147..4acbb9c 100644 --- a/web-app/src/routes/(authenticated)/website/[websiteId]/articles/[articleId]/+page.svelte +++ b/web-app/src/routes/(authenticated)/website/[websiteId]/articles/[articleId]/+page.svelte @@ -21,6 +21,7 @@ const handlePaste = async (event: ClipboardEvent) => { const newContent = await handleImagePaste(event, data.API_BASE_PREFIX); + if (newContent) { previewContent = newContent; } diff --git a/web-app/src/routes/(authenticated)/website/[websiteId]/logs/+page.svelte b/web-app/src/routes/(authenticated)/website/[websiteId]/logs/+page.svelte index c04e819..06e02a7 100644 --- a/web-app/src/routes/(authenticated)/website/[websiteId]/logs/+page.svelte +++ b/web-app/src/routes/(authenticated)/website/[websiteId]/logs/+page.svelte @@ -34,11 +34,13 @@ let resources = $state({}); if (data.website.content_type === "Blog") { + // eslint-disable-next-line @typescript-eslint/no-unused-vars const { user, change_log, media, docs_category, ...restTables } = tables; resources = restTables; } if (data.website.content_type === "Docs") { + // eslint-disable-next-line @typescript-eslint/no-unused-vars const { user, change_log, media, ...restTables } = tables; resources = restTables; } @@ -253,8 +255,8 @@ margin-inline-start: auto; } - button[disabled] { - opacity: 0.5; + button:disabled { pointer-events: none; + color: hsl(0 0% 50%); }