Configuring onApply on image editor when using grapesjs studio sdk #16
Unanswered
canlasnikko
asked this question in
Q&A
Replies: 1 comment 1 reply
-
I think I'm able to find a way to do this and I want to share this. Might be helpful: First, installed and imported Then on the createStudioEditor({
...some other options
gjsOptions: {
plugins: [tuiImageEditorPlugin],
pluginsOpts: {
[tuiImageEditorPlugin]: {
labelApply: 'Test Apply',
onApply: async (imageEditor, imageModel) => {
// In my case, I need to convert it to a File for uploading. I've used dataUriToBuffer for this.
const file = base64ToFile(imageEditor.toDataURL());
// Upload file via API
const result = await uploadAsset(projectId, [file]);
},
addToAssets: false,
upload: true,
},
},
}
}) My next goal is to update the asset manager to show the edited image and also update the block. Will update this once I have some idea. |
Beta Was this translation helpful? Give feedback.
1 reply
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
Hi Community!
I have a custom logic when uploading images. I need to store them on a public location so it's always accessible when rendering the HTML.
The problem is when I use the image editor. When an edit is saved, it default save goes to "assets/xxxx123.png". This breaks the image when I use the HTML only outside the editor.
I can't seem to find the option to handle the logic on when the edits to the image is applied at least in the docs.
My goal is to apply my custom logic when an image is edited so I can save it to a public location too.
Any help and discussion is appreaciated :)
Beta Was this translation helpful? Give feedback.
All reactions