Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Upload adapter is not defined Issue with Image uploading in ckeditor5-angular

This question may have already answers but none of them is Angular specific. Here are some of them

I am using Angular 5 and following this documentation to implement ckeditor5-angular.

But I am having issue with image uploading, when I try uploading image it says in the browser console.

filerepository-no-upload-adapter: Upload adapter is not defined. Read more: https://docs.ckeditor.com/ckeditor5/latest/framework/guides/support/error-codes.html#error-filerepository-no-upload-adapter

I have tried searching for this issue and was able to find a lot of solutions, but literally I couldn't understand a single of them because they were not Angular specific.

Please help how can I upload image.

like image 424
Adnan Sheikh Avatar asked Aug 28 '18 07:08

Adnan Sheikh


2 Answers

Thank you for everyone answer. I create code snippet for anyone who want looking the example. But I used ckeditor inline build. Hope it help.

stackblitz

like image 52
DKKs Avatar answered Oct 15 '22 23:10

DKKs


I used the below seems to work

class UploadAdapter {
   constructor( loader ) {
      this.loader = loader;
   }

   upload() {
      return this.loader.file
            .then( file => new Promise( ( resolve, reject ) => {
                  var myReader= new FileReader();
                  myReader.onloadend = (e) => {
                     resolve({ default: myReader.result });
                  }

                  myReader.readAsDataURL(file);
            } ) );
   };
}
like image 31
zackhalil Avatar answered Oct 15 '22 23:10

zackhalil