From df76009648cda9bfbc035de19ffe43382f3bcf11 Mon Sep 17 00:00:00 2001 From: Botho <1258870+elbotho@users.noreply.github.com> Date: Fri, 18 Oct 2024 15:57:07 +0200 Subject: [PATCH 1/3] feat(image): add new upload code for testing --- .../plugins/image/controls/upload-button.tsx | 12 ++- packages/editor/src/plugins/image/editor.tsx | 7 +- .../src/plugins/image/utils/upload-file.ts | 73 +++++++++++++++++++ .../src/plugins/image/utils/validate-file.ts | 45 ++++++++++++ 4 files changed, 134 insertions(+), 3 deletions(-) create mode 100644 packages/editor/src/plugins/image/utils/upload-file.ts create mode 100644 packages/editor/src/plugins/image/utils/validate-file.ts diff --git a/packages/editor/src/plugins/image/controls/upload-button.tsx b/packages/editor/src/plugins/image/controls/upload-button.tsx index 33dda7c6c0..bb21a6da54 100644 --- a/packages/editor/src/plugins/image/controls/upload-button.tsx +++ b/packages/editor/src/plugins/image/controls/upload-button.tsx @@ -10,6 +10,7 @@ import { import { useState } from 'react' import type { ImageProps } from '..' +import { shouldUseNewUpload, uploadFile } from '../utils/upload-file' interface UploadButtonProps { config: ImageProps['config'] @@ -64,7 +65,10 @@ export function UploadButton({ const filesArray = Array.from(target.files) // Upload the first file like normal - void src.upload(filesArray[0], config.upload) + void src.upload( + filesArray[0], // eslint-disable-next-line @typescript-eslint/no-unsafe-argument + shouldUseNewUpload() ? uploadFile : config.upload + ) // If multiple upload is allowed, call the multiple upload callback // with the remaining files @@ -82,7 +86,11 @@ export function UploadButton({