kolkov / angular-editor

A simple native WYSIWYG editor component for Angular 6 -14+
https://angular-editor.kolkov.ru
MIT License
674 stars 361 forks source link

angular-editor-toolbar component crashes after successful file upload #178

Open autengu opened 4 years ago

autengu commented 4 years ago

Hi,

I get following error when I succesfully upload an image:

ERROR TypeError: Cannot read property 'nativeElement' of undefined at AngularEditorToolbarComponent.fileReset (angular-editor-toolbar.component.ts:339)

The problem is that myInputFile is always (ViewChild: fileInput) undefined.

So here:

` onFileChanged(event) { /* @type {?} / const file = event.target.files[0]; if (file.type.includes('image/')) { if (this.uploadUrl) { this.editorService.uploadImage(file).subscribe((/**

when calling:

fileReset() { this.myInputFile.nativeElement.value = ''; }

myInputFile does not exist.

kolkov commented 4 years ago

Hi! Thanks for reporting this issue. I will try to reproduce this situation.

kcs-renusuthar commented 4 years ago

Any update on this?

nesticle8bit commented 4 years ago

on fileReset() method, the variable this.myInputFile get always null

juangcarmona commented 4 years ago

**Hi there,

@kolkov , first of all, thank you for this editor.

I am still having that issue mentiuoned here. I paste the oputput I am getting in case it helps.

ERROR TypeError: Cannot read property 'nativeElement' of undefined
    at AngularEditorToolbarComponent.push../node_modules/@kolkov/angular-editor/fesm5/kolkov-angular-editor.js.AngularEditorToolbarComponent.fileReset (kolkov-angular-editor.js:1145)
    at SafeSubscriber._next (kolkov-angular-editor.js:1113)
    at SafeSubscriber.push../node_modules/rxjs/_esm5/internal/Subscriber.js.SafeSubscriber.__tryOrUnsub (Subscriber.js:192)
    at SafeSubscriber.push../node_modules/rxjs/_esm5/internal/Subscriber.js.SafeSubscriber.next (Subscriber.js:130)
    at Subscriber.push../node_modules/rxjs/_esm5/internal/Subscriber.js.Subscriber._next (Subscriber.js:76)
    at Subscriber.push../node_modules/rxjs/_esm5/internal/Subscriber.js.Subscriber.next (Subscriber.js:53)
    at MergeMapSubscriber.push../node_modules/rxjs/_esm5/internal/operators/mergeMap.js.MergeMapSubscriber.notifyNext (mergeMap.js:87)
    at InnerSubscriber.push../node_modules/rxjs/_esm5/internal/InnerSubscriber.js.InnerSubscriber._next (InnerSubscriber.js:15)
    at InnerSubscriber.push../node_modules/rxjs/_esm5/internal/Subscriber.js.Subscriber.next (Subscriber.js:53)
    at FinallySubscriber.push../node_modules/rxjs/_esm5/internal/Subscriber.js.Subscriber._next (Subscriber.js:76)**

Thanks,

Pastafarian commented 4 years ago

Getting the same issue here.

AyalaMan-Main commented 4 years ago

same issue too

asifisthiaq24 commented 4 years ago

Until new release to fix this issue: goto node_modules/@kolkov/angular-editor/__ivy_ngcc__/fesm2015/kolkov-angular-editor.js and do the followings:

if (e instanceof HttpResponse) { this.editorService.insertImage(e.body.imageUrl); // this.fileReset(); //comment out his line event.srcElement.value = null; // add this line } //comment this section of the code // /* // Reset Input // @return {?} // / // fileReset() { // this.myInputFile.nativeElement.value = ''; // }