This package is custom image upload adapter for a rich text editor. It makes use of XHR under the hood in uploading images to your preferred web app.
Currently, this package offers two upload adapters for CKEditor5. Below are instructions for using each.
If you wish to upload the embedded images to a custom web app, all you need to provide is the upload url and other request headers that you may have.
npm i --save puff-puff
import { CustomUpload } from 'puff-puff/CKEditor';
imagePluginFactory(editor) {
editor.plugins.get( 'FileRepository' ).createUploadAdapter = ( loader ) => {
return new CustomUpload( <upload_url>, loader);
};
}
imagePluginFactory(editor) {
editor.plugins.get( 'FileRepository' ).createUploadAdapter = ( loader ) => {
return new CustomUpload( <upload_url>, loader, 'url');
};
}
imagePluginFactory(editor) {
editor.plugins.get( 'FileRepository' ).createUploadAdapter = ( loader ) => {
return new CustomUpload( <upload_url>, loader, '', <headers_object>);
};
}
If you wish to upload the embedded images to Cloudinary, you will need a cloud name and an unsigned upload preset.
npm i puff-puff
import { CloudinaryUnsigned } from 'puff-puff/CKEditor';
imagePluginFactory(editor) {
editor.plugins.get( 'FileRepository' ).createUploadAdapter = ( loader ) => {
return new CloudinaryUnsigned( loader, '<your_cloud_name>', '<your_unsigned_upload_preset>', [ 160, 500, 1000, 1052 ]);
};
}
imagePluginFactory(editor) {
editor.plugins.get( 'FileRepository' ).createUploadAdapter = ( loader ) => {
return new CloudinaryImageUploadAdapter(
loader,
'<your_cloud_name>',
'<your_unsigned_upload_preset>',
[ 160, 500, 1000, 1052 ]
);
};
}
Opeoluwa Iyi-Kuyoro: 👨🏿Profile - WebSite
As you can already tell, there is a whole lot more to be added to turn this into a goto library for all things embedded rich text image uploads. Please feel free to fork, add and raise a PR if you are so inclined. I am also open to discussing any challenges with you on twitter or via Email.