S
S
Sergey Zolotarev2022-03-05 12:21:10
CKEditor
Sergey Zolotarev, 2022-03-05 12:21:10

How to create and run custom plugins for CKEditor 5 if I load it in code from the official CDN?

Good day!

The admin area of ​​a large non-NPM project is using CKEditor 5, which is downloaded from the official CDN , and I wanted to create some plugins for the input field:

class SmartTitleUploader extends Plugin{
  init(){
    const editor = this.editor;
    
    editor.ui.componentFactory.add( 'smartTitleUploader', locale => {
            const view = new ButtonView( locale );
            ...
            view.on( 'execute', () => {} );

            return view;
        } );
  }
}
class SaveNews extends Plugin{
  init(){
    const editor = this.editor;
    
    editor.ui.componentFactory.add( 'saveNews', locale => {
            const view = new ButtonView( locale );
            ....
            view.on( 'execute', () => { } );

            return view;
        } );
  }
}


Plugins are stored in a separate js-file, and in the interface of the page with the form, when initializing CKEditor5, I attached the created plugins:
toolbar: {
    plugins: [ SmartTitleUploader, SaveNews ],
    items: ['heading', 'bold', 'link', 'smartTitleUploader', 'saveNews']
},

And when testing the launch of custom plugins in the browser, DevTools brought me the following surprises:
u0mDm8I.png

How to solve the problem of creating and running custom plugins for CKEditor5 if it is loaded from the official CDN and the project with it is not built on NPM?
Thanks in advance!

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question