Skip to content

Pass the blockId to the uploadFile function of the editor #1637

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
QuentinNativel opened this issue Apr 24, 2025 · 2 comments
Closed

Pass the blockId to the uploadFile function of the editor #1637

QuentinNativel opened this issue Apr 24, 2025 · 2 comments
Labels
enhancement New feature or request

Comments

@QuentinNativel
Copy link
Contributor

Is your feature request related to a problem? Please describe.
I'm building a CMS with blocknote. I have a custom image block on which i want to save the width and the height of the uploaded file in the props

In order to do so i wrote a custom uploadFile function that i pass to the editor.
my uploadFile function does 2 things:

  • save the image to my cdn
  • get the height/width of the image and save it to my block props

The upload function that i submitted takes 2 argument a file and the blockId as described by the typescript type but if i log the blockId that my function receives it is undefined.

Describe the solution you'd like
The issue comes from the UploadTab.tsx l.53 where the block.id is not passed to the editor.uploadFile function
I would like to change

let updateData = await editor.uploadFile(file);

to the following

let updateData = await editor.uploadFile(file, block.id);

I tested it and it solved my problem.
More generally speaking, I also think it is kind of the expected behaviour to also pass the id of the block for which the file panel is opened so the function can have access to it and can modify it if needed

Thanks for all your nice work !

PS: I tried to open a PR but i don't have the right to create branches so i couldn't

@QuentinNativel QuentinNativel added the enhancement New feature or request label Apr 24, 2025
@nperez0111
Copy link
Contributor

I tried to open a PR but i don't have the right to create branches so i couldn't

You should be able to make a fork of the repo, push your branch there, and then PR that into our repo. See here for more info: https://docs.github.com/en/pull-requests/collaborating-with-pull-requests/proposing-changes-to-your-work-with-pull-requests/creating-a-pull-request?tool=cli

Happy to accept this change

@QuentinNativel
Copy link
Contributor Author

@nperez0111 Thanks for the answer
I open the PR

@YousefED YousefED closed this as completed May 5, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

3 participants