Skip to content

Commit

Permalink
chore: remove console logs
Browse files Browse the repository at this point in the history
  • Loading branch information
Palanikannan1437 committed Sep 16, 2024
1 parent e297f7f commit 5c27a72
Show file tree
Hide file tree
Showing 5 changed files with 10 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,6 @@ export const CustomImageNode = (props: CustomImageNodeViewProps) => {
// @ts-expect-error - TODO: fix typings, and don't remove await from
// here for now
const url: string = await editor?.commands.uploadImage(file);
console.log("url drop", url);

if (!url) {
throw new Error("Something went wrong while uploading the image");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,6 @@ export const CustomImageExtension = (props: TFileHandler) => {
imageSources.forEach(async (src) => {
try {
const assetUrlWithWorkspaceId = new URL(src).pathname.substring(1);
console.log("assetUrlWithWorkspaceId restore ", this.name, assetUrlWithWorkspaceId);
await restoreImage(assetUrlWithWorkspaceId);
} catch (error) {
console.error("Error restoring image: ", error);
Expand Down
1 change: 0 additions & 1 deletion packages/editor/src/core/extensions/image/extension.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,6 @@ export const ImageExtension = (deleteImage: DeleteImage, restoreImage: RestoreIm
imageSources.forEach(async (src) => {
try {
const assetUrlWithWorkspaceId = new URL(src).pathname.substring(1);
console.log("assetUrlWithWorkspaceId restore ", this.name, assetUrlWithWorkspaceId);
await restoreImage(assetUrlWithWorkspaceId);
} catch (error) {
console.error("Error restoring image: ", error);
Expand Down
2 changes: 0 additions & 2 deletions packages/editor/src/core/hooks/use-file-upload.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ export const useUploader = ({ onUpload, editor }: { onUpload: (url: string) => v
// @ts-expect-error - TODO: fix typings, and don't remove await from
// here for now
const url: string = await editor?.commands.uploadImage(file);
console.log("url upload", url);

if (!url) {
throw new Error("Something went wrong while uploading the image");
Expand Down Expand Up @@ -40,7 +39,6 @@ export const useFileUpload = () => {

return { ref: fileInput, handleUploadClick };
};

export const useDropZone = ({ uploader }: { uploader: (file: File) => void }) => {
const [isDragging, setIsDragging] = useState<boolean>(false);
const [draggedInside, setDraggedInside] = useState<boolean>(false);
Expand Down
14 changes: 10 additions & 4 deletions packages/editor/src/core/plugins/image/utils/validate-file.ts
Original file line number Diff line number Diff line change
@@ -1,17 +1,23 @@
export function isFileValid(file: File): boolean {
export function isFileValid(file: File, showAlert = true): boolean {
if (!file) {
alert("No file selected. Please select a file to upload.");
if (showAlert) {
alert("No file selected. Please select a file to upload.");
}
return false;
}

const allowedTypes = ["image/jpeg", "image/jpg", "image/png", "image/webp"];
if (!allowedTypes.includes(file.type)) {
alert("Invalid file type. Please select a JPEG, JPG, PNG, or WEBP image file.");
if (showAlert) {
alert("Invalid file type. Please select a JPEG, JPG, PNG, or WEBP image file.");
}
return false;
}

if (file.size > 5 * 1024 * 1024) {
alert("File size too large. Please select a file smaller than 5MB.");
if (showAlert) {
alert("File size too large. Please select a file smaller than 5MB.");
}
return false;
}

Expand Down

0 comments on commit 5c27a72

Please sign in to comment.