lula / ngx-summernote

Summernote editor for Angular :sunglasses:
MIT License
102 stars 42 forks source link

image upload #172

Open Seongseokwon opened 1 year ago

Seongseokwon commented 1 year ago

I want to use the image upload event, but how should I do it?

i tried this config: SummernoteOptions = { ...NOTICE_POPUP_SUMMERNOTE_CONFIG, callbacks: { onImageUpload: function(e: any) { console.log(e); } }, };

but onImageUpload is not working

MalonzaElkanah commented 8 months ago

Did you find a solution to this issue? I have the same problem. Am trying to use onImageUpload Callback and it is not working.

roy-ganz commented 6 days ago

Your callback is never called, because the directive overrides the onImageUpload callback.

See here: https://github.com/lula/ngx-summernote/blob/b2b1554144f57d19732dafd0790cdb09ea9fe906/projects/ngx-summernote/src/lib/ngx-summernote.directive.ts#L44

I think this is a bug and the directive should respect custom upload functions.

A simple solution would be probably to give priority to user options.

Instead of options.callbacks = { ...options.callbacks, onImageUpload: files => this.uploadImage(files), onMediaDelete: files => this.mediaDelete.emit({ url: $(files[0]).attr('src') }) };

Reorder to options.callbacks = { onImageUpload: files => this.uploadImage(files), onMediaDelete: files => this.mediaDelete.emit({ url: $(files[0]).attr('src') }), ...options.callbacks, };