TypeCellOS / BlockNote

A React Rich Text Editor that's block-based (Notion style) and extensible. Built on top of Prosemirror and Tiptap.
https://www.blocknotejs.org/
Mozilla Public License 2.0
5.9k stars 384 forks source link

feat: added support for uppy #842

Open ezhil56x opened 3 weeks ago

ezhil56x commented 3 weeks ago

Added support for uppy with an example

Closes #807 /claim #807

vercel[bot] commented 3 weeks ago

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Updated (UTC)
blocknote ❌ Failed (Inspect) Jul 3, 2024 3:40pm
vercel[bot] commented 3 weeks ago

@ezhil56x is attempting to deploy a commit to the TypeCell Team on Vercel.

A member of the Team first needs to authorize it.

ezhil56x commented 3 weeks ago

@YousefED

Click to expand [https://github.com/TypeCellOS/BlockNote/assets/103899034/fd6287a5-2f5d-4378-ab04-cdd154e0e659](https://github.com/TypeCellOS/BlockNote/assets/103899034/fd6287a5-2f5d-4378-ab04-cdd154e0e659)
rajeshj11 commented 2 weeks ago

This looks great already. I've left some comments inline but also have one main architectural request:

I don't think we want to add the uppy dependencies by default - otherwise users who don't need uppy will end up adding a lot of dependencies. This means all Uppy related code should live in the Example (or in a separate package (blocknote-uppy or sth), but I don't think that's necessary for now). The way to do this would be to in the example use a FilePanelController and pass in the Uppy tab as part of it's props. (the uppy tab should then also live in the configuration).

Secondly, I don't think we then need uploadFileUppy anymore in the configuration. We do need (see original requirements) to make sure that uploadFile uploads via Uppy. The reason for this is that while at this moment, it's true that uploadFile is only called from the upload tab (which we'll replace by the dashboard), but at a later point it's likely we'll call uploadFile from other places (like dropping files into the editor) as well.

@ezhil56x I have already made changes related to this. If needed any reference you can view my closed pr. https://github.com/TypeCellOS/BlockNote/pull/843

ezhil56x commented 2 weeks ago

Will update my PR soon and let you know

ezhil56x commented 2 weeks ago

@YousefED If we need uploadFile then we should create a similar uploadFileUppy for handing uppy uploads. Will that be fine?

YousefED commented 1 week ago

@YousefED If we need uploadFile then we should create a similar uploadFileUppy for handing uppy uploads. Will that be fine?

I think we just need something like this?


async function uploadFileViaUppy(file: File) {
uppy.addFile(file);
await uppy.upload();
}

...
uploadfile: uploadFileViaUppy

pseudo code, but I hope this clarifies the intended behavior for you

ezhil56x commented 1 week ago

@YousefED If we need uploadFile then we should create a similar uploadFileUppy for handing uppy uploads. Will that be fine?

I think we just need something like this?


async function uploadFileViaUppy(file: File) {
uppy.addFile(file);
await uppy.upload();
}

...
uploadfile: uploadFileViaUppy

pseudo code, but I hope this clarifies the intended behavior for you

I tried this though, uppy.addFile() needs the file as blob type rather than file type. Creating a new uploadFileUppy like uploadFile will be a good option, but uppy packages should be added for that which increases the size. I am confused about what to do. What do you suggest?

YousefED commented 1 week ago

@YousefED If we need uploadFile then we should create a similar uploadFileUppy for handing uppy uploads. Will that be fine?

I think we just need something like this?

async function uploadFileViaUppy(file: File) {
uppy.addFile(file);
await uppy.upload();
}

...
uploadfile: uploadFileViaUppy

pseudo code, but I hope this clarifies the intended behavior for you

I tried this though, uppy.addFile() needs the file as blob type rather than file type. Creating a new uploadFileUppy like uploadFile will be a good option, but uppy packages should be added for that which increases the size. I am confused about what to do. What do you suggest?

see https://stackoverflow.com/a/33855825