Roslovets-Inc/ckeditor5-build-strapi-wysiwyg

Questions About editor.config.get('strapiMediaLib');

richardgohcr opened this issue · 1 comments

Hi @roslovets!

What a wonderful plugin and amazing work! I just wish that I had discovered this earlier after spending around 3 days trying to develop my own plugin using the Strapi official documentation of replacing the WYSIWYG editors. It literally provided me with what I needed within 15minutes. Thank you so much!

Anyway, since I was already midway through the rabbit hole of developing my own plugin. After finding your package, I was wondering if you could point to me some documentation that explains how you managed to integrate the Strapi medialib with editor.config.get('strapiMediaLib'); and subsequently config.onToggle(editor); in the StrapiMediaLib class?

I have found a couple of resources that were guiding me towards developing a plugin for CKEditor 5 but couldn't find out how you figured out to add the strapiMediaLib.

export class StrapiMediaLib extends Plugin {
  
      static get pluginName() {
          return 'strapiMediaLib'
      }
  
      init() {
          const editor = this.editor;
          const config = editor.config.get('strapiMediaLib');
  
          editor.ui.componentFactory.add('strapiMediaLib', locale => {
              
              const view = new ButtonView(locale);
  
              view.set({
                  label: (config && config.label) ? config.label : "Media Library",
                  icon: imageIcon,
                  tooltip: true
              });
  
              view.on('execute', () => {
                  if (config && config.onToggle) {
                      config.onToggle(editor);
                  }
                  else {
                      alert('Properly integrate editor into Strapi to make button work');
                  };
              });
  
              return view;
          });
      }
  }

Thank you once again!

Hi Richard,
I believe that some clues I've found somewhere in docs/examples, but another stuff I have investigated while debugging in Chrome dev console.
Unfortunately I cannot point your out to documentation with clear answers.