CKEditor 5 adding image upload plugin

Spread the love

CKEditor 5 is good because of easy installation and usage.

However when I tried to add image upload plugin, it wasn’t that easy.

I would like to share the tips how to add.

Below instruction was very helpful for figuring out how to:

  • Install CKEditor 5 classic
npm install --save @ckeditor/ckeditor5-build-classic 
yarn run build
  • Install image upload, simple upload plugin.
npm install --save @ckeditor/ckeditor5-upload 
npm install ckeditor5-simple-upload
  • Open src/ckeditor.js file and add below
import ImageUpload from '@ckeditor/ckeditor5-image/src/imageupload';
import SimpleuploadPlugin from 'ckeditor5-simple-upload/src/simpleupload'
  • After adding the plugin, run build command
yarn run build
  • Create test page.
<!DOCTYPE html>
<html lang="en">
  <meta charset="utf-8">
  <script src="/adm/ckeditor_classic/ckeditor5-build-classic/build/ckeditor.js"></script>
  <div id="editor"></div>
var cb = function() { return (new Date()).getTime() }
    .create( document.querySelector( '#editor' ), {
      simpleUpload: {
        uploadUrl: {url:'/adm/ckeditor_classic/upload_image.php', headers:{ 'x-header':'myhead', 'x-header-cb': cb } }
    } )
    .catch( error => {
        console.error( error );
    } );
Facebook Comments

Published by

Titus Choi

I love technology. Working for information technology. Interested in AVR technology. Playing with RC stuff.