Skip to content
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

BUG: docs on asset is confusing #9

Open
1 task done
jordiyapz opened this issue Nov 16, 2024 · 1 comment
Open
1 task done

BUG: docs on asset is confusing #9

jordiyapz opened this issue Nov 16, 2024 · 1 comment

Comments

@jordiyapz
Copy link

What browser are you using?

Chrome

Describe the bug

The docs on "asset - custom storage" displaying irreproducible code because of wrong snippet provided.

// ...
<StudioEditor
  options={{
    // ...
    assets: {
      storageType: 'self',
      
      // `onUpload` ...
      
      onLoad: async ({ editor }) => {
        // TODO: implement myDownloadFilesLogic to fetch urls and metadata for each asset file
        const results: FileMetadataAndUrl[] = await myDownloadFilesLogic({ files });
    
        // return an array with the loaded assets
        return results.map(({ file, url }) => ({
          id: url,
          src: url,
          name: file.name,
          mimeType: file.type,
          size: file.size
        }));
      },

      // `onDelete` ...

The function myDownloadFilesLogic is supposed to get { files } as input but the onLoad function only provide editor. Where can we get the files ?

How to reproduce the bug?

See docs: https://app.grapesjs.com/docs-sdk/configuration/assets

What is the expected behavior?

It should provide from where we can get the files

What is the current behavior?

It doesn't provide files

If is necessary to execute some code in order to reproduce the bug, paste it here below:

Code of Conduct

  • I agree to follow this project's Code of Conduct
@artf
Copy link
Member

artf commented Dec 13, 2024

Thanks @jordiyapz you're right, the example is wrong there.
It should be more like:

const results = await myDownloadFilesLogic();

The myDownloadFilesLogic() should be all up to you how to fetch the list of assets for specific project that's why you don't have files there.
We'll update it 🙇‍♂️

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants