Skip to content

Commit 5773c2b

Browse files
authored
chore: gif support for editor (#6219)
1 parent e33bae2 commit 5773c2b

File tree

5 files changed

+25
-6
lines changed

5 files changed

+25
-6
lines changed

apiserver/plane/app/views/asset/v2.py

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -126,7 +126,13 @@ def post(self, request):
126126
)
127127

128128
# Check if the file type is allowed
129-
allowed_types = ["image/jpeg", "image/png", "image/webp", "image/jpg"]
129+
allowed_types = [
130+
"image/jpeg",
131+
"image/png",
132+
"image/webp",
133+
"image/jpg",
134+
"image/gif",
135+
]
130136
if type not in allowed_types:
131137
return Response(
132138
{

apiserver/plane/space/views/asset.py

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,13 @@ def post(self, request, anchor):
8686
)
8787

8888
# Check if the file type is allowed
89-
allowed_types = ["image/jpeg", "image/png", "image/webp"]
89+
allowed_types = [
90+
"image/jpeg",
91+
"image/png",
92+
"image/webp",
93+
"image/jpg",
94+
"image/gif",
95+
]
9096
if type not in allowed_types:
9197
return Response(
9298
{

packages/editor/src/core/constants/config.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,3 +5,6 @@ export const DEFAULT_DISPLAY_CONFIG: TDisplayConfig = {
55
fontSize: "large-font",
66
fontStyle: "sans-serif",
77
};
8+
9+
export const ACCEPTED_FILE_MIME_TYPES = ["image/jpeg", "image/jpg", "image/png", "image/webp", "image/gif"];
10+
export const ACCEPTED_FILE_EXTENSIONS = ACCEPTED_FILE_MIME_TYPES.map((type) => `.${type.split("/")[1]}`);

packages/editor/src/core/extensions/custom-image/components/image-uploader.tsx

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@ import { ChangeEvent, useCallback, useEffect, useMemo, useRef } from "react";
22
import { ImageIcon } from "lucide-react";
33
// plane utils
44
import { cn } from "@plane/utils";
5+
// constants
6+
import { ACCEPTED_FILE_EXTENSIONS } from "@/constants/config";
57
// hooks
68
import { useUploader, useDropZone, uploadFirstImageAndInsertRemaining } from "@/hooks/use-file-upload";
79
// extensions
@@ -166,7 +168,7 @@ export const CustomImageUploader = (props: CustomImageUploaderProps) => {
166168
ref={fileInputRef}
167169
hidden
168170
type="file"
169-
accept=".jpg,.jpeg,.png,.webp"
171+
accept={ACCEPTED_FILE_EXTENSIONS.join(",")}
170172
onChange={onFileChange}
171173
multiple
172174
/>

packages/editor/src/core/plugins/image/utils/validate-file.ts

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
1+
// constants
2+
import { ACCEPTED_FILE_MIME_TYPES } from "@/constants/config";
3+
14
type TArgs = {
25
file: File;
36
maxFileSize: number;
@@ -11,9 +14,8 @@ export const isFileValid = (args: TArgs): boolean => {
1114
return false;
1215
}
1316

14-
const allowedTypes = ["image/jpeg", "image/jpg", "image/png", "image/webp"];
15-
if (!allowedTypes.includes(file.type)) {
16-
alert("Invalid file type. Please select a JPEG, JPG, PNG, or WEBP image file.");
17+
if (!ACCEPTED_FILE_MIME_TYPES.includes(file.type)) {
18+
alert("Invalid file type. Please select a JPEG, JPG, PNG, WEBP or GIF file.");
1719
return false;
1820
}
1921

0 commit comments

Comments
 (0)