Allow more common mimetypes

This commit is contained in:
thiloho
2024-09-17 22:44:16 +02:00
parent a7a4942633
commit c97a6624d6
4 changed files with 18 additions and 8 deletions

View File

@@ -8,7 +8,7 @@ DECLARE
_website_id UUID := (_headers ->> 'x-website-id')::UUID; _website_id UUID := (_headers ->> 'x-website-id')::UUID;
_mimetype TEXT := _headers ->> 'x-mimetype'; _mimetype TEXT := _headers ->> 'x-mimetype';
_original_filename TEXT := _headers ->> 'x-original-filename'; _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; _max_file_size INT := 5 * 1024 * 1024;
_has_access BOOLEAN; _has_access BOOLEAN;
BEGIN BEGIN

View File

@@ -15,7 +15,14 @@ import type {
LegalInformation LegalInformation
} from "$lib/db-schema"; } 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) => { export const slugify = (string: string) => {
return string return string
@@ -24,8 +31,8 @@ export const slugify = (string: string) => {
.toLowerCase() // Convert to lowercase .toLowerCase() // Convert to lowercase
.trim() // Trim leading and trailing whitespace .trim() // Trim leading and trailing whitespace
.replace(/\s+/g, "-") // Replace spaces with hyphens .replace(/\s+/g, "-") // Replace spaces with hyphens
.replace(/[^\w\-]+/g, "") // Remove non-word characters (except hyphens) .replace(/[^\w-]+/g, "") // Remove non-word characters (except hyphens)
.replace(/\-\-+/g, "-") // Replace multiple hyphens with single hyphen .replace(/-+/g, "-") // Replace multiple hyphens with single hyphen
.replace(/^-+/, "") // Remove leading hyphens .replace(/^-+/, "") // Remove leading hyphens
.replace(/-+$/, ""); // Remove trailing hyphens .replace(/-+$/, ""); // Remove trailing hyphens
}; };
@@ -51,8 +58,8 @@ const createMarkdownParser = (showToc = true) => {
); );
const gfmHeadingId = ({ prefix = "", showToc = true } = {}) => { const gfmHeadingId = ({ prefix = "", showToc = true } = {}) => {
let headings: { text: string; level: number; id: string }[] = []; const headings: { text: string; level: number; id: string }[] = [];
let sectionStack: { level: number; id: string }[] = []; const sectionStack: { level: number; id: string }[] = [];
return { return {
renderer: { renderer: {

View File

@@ -21,6 +21,7 @@
const handlePaste = async (event: ClipboardEvent) => { const handlePaste = async (event: ClipboardEvent) => {
const newContent = await handleImagePaste(event, data.API_BASE_PREFIX); const newContent = await handleImagePaste(event, data.API_BASE_PREFIX);
if (newContent) { if (newContent) {
previewContent = newContent; previewContent = newContent;
} }

View File

@@ -34,11 +34,13 @@
let resources = $state({}); let resources = $state({});
if (data.website.content_type === "Blog") { if (data.website.content_type === "Blog") {
// eslint-disable-next-line @typescript-eslint/no-unused-vars
const { user, change_log, media, docs_category, ...restTables } = tables; const { user, change_log, media, docs_category, ...restTables } = tables;
resources = restTables; resources = restTables;
} }
if (data.website.content_type === "Docs") { if (data.website.content_type === "Docs") {
// eslint-disable-next-line @typescript-eslint/no-unused-vars
const { user, change_log, media, ...restTables } = tables; const { user, change_log, media, ...restTables } = tables;
resources = restTables; resources = restTables;
} }
@@ -253,8 +255,8 @@
margin-inline-start: auto; margin-inline-start: auto;
} }
button[disabled] { button:disabled {
opacity: 0.5;
pointer-events: none; pointer-events: none;
color: hsl(0 0% 50%);
} }
</style> </style>