Closed g41n closed 7 years ago
Hi @g41n honestly, I've done some refactoring work on Assets so some bug might appear, but testing your snippet in the demo (editor
var is exposed to window globally so you can play with APIs) I can't reproduce it.
By the way, in the last release, I've introduced new "official" events for Assets
asset:add
- New asset addedasset:remove
- Asset removedasset:upload:start
- Before the upload is startedasset:upload:end
- After the upload is endedasset:upload:error
- On any error in upload, passes the error as an argumentasset:upload:response
- On upload response, passes the result as an argumentLet me know
Hi, I've tried to implement it in this manner
this.templateEditor = grapesjs.init({
container : '#HtmlTemplateEditorGjs:not(.gjs-editor-cont)',
storageManager: {
type: 'none'
},
plugins: ['gjs-preset-newsletter'],
assetManager: {
upload: '/asset'
}
});
this.templateEditor.on('asset:remove', (asset) => {
var filename = asset.get('src').split('/').reverse()[0];
this.http.DELETE(`/assets/${filename}`, (response) => {
console.log('asset remove', response);
});
});
but seems that the second time I open the AssetManager the upload is not fired anymore...
Maybe I use the editor in the wrong way? Every time I run that code I have a new item in grapesjs.editors array and that seems not so good to me. Any hint on how to initialize and reuse it in a complex application?
Thanks for the support.
Every time I run that code I have a new item in grapesjs.editors array and that seems not so good to me.
Why do you care about grapesjs.editors
? It just contains the initialized editor, nothing more.
Your configuration seems good, so can you explain more about the issue with the uploader, because I'm not able to reproduce it. The ajax is not firing?!? you're not able to select files?!?
With version 0.12.8 my previous implementation seems working. Thanks for the support :smile:
This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.
I assign a listener on AssetManager removal in this way
as suggested in #86
It worked like a charm for me with 0.9.8 version. Now I've upgraded to 0.9.32 and results in firing the function twice... That's a problem for me: the second time my app raise an error because the image was deleted the first time.
Any hint about that?
Thanks in advance for the support.