nshenderov/strapi-plugin-ckeditor

When installed via a strapi plugin, it won't register the custom field.

kevinvugts opened this issue · 10 comments

Describe the bug
When installing this plugin with "yarn add @_sh/strapi-plugin-ckeditor" and build the plugin and strapi admin panel. It won't register the custom field in the Strapi instance. It only works when you instal the plugin globally in your root package.json.

To Reproduce
Steps to reproduce the behavior:

  1. Install the plugin inside a custom plugin
  2. Build the plugin
  3. Build the admin panel
  4. Run yarn develop
  5. See that nothing happens and the custom field is not registered.

Repeat these steps but install it in the root, and it works.

Expected behavior
It should obviously also register the custom field if it's installed inside a plugin. Because sometimes you have collection types referring to the custom field only from that plugin. So when someone else installs the plugin it should automatically work and not require them to install the npm package in their root package.json. It should be bundled with the plugin.

Screenshots
not applicable

please complete the following information:

  • plugins.js: Only a custom clean plugin
  • package.json: installed version 3.0.2 on Strapi 4.25.11
  • node version: version 18

Additional context
Not applicable

@kevinvugts
I’m not sure I understand what you mean by "Install the plugin inside a custom plugin" and "Build the plugin."
When you add this plugin to your Strapi project, all you need to do is rebuild the project, and that's it.

@kevinvugts I’m not sure I understand what you mean by "Install the plugin inside a custom plugin" and "Build the plugin." When you add this plugin to your Strapi project, all you need to do is rebuild the project, and that's it.

When installed inside a plugin for strapi, it does not work. So if you build a new plugin for strapi and install your plugin inside that plugins package.json it does not register the custom ck editor field.

It only works when installed in the root package.json of the Strapi project.

But plugin builders that want to use your custom field cannot use it solely inside their plugins code without installing it “globally”

you get what I mean?

Now I understand. This plugin is specifically meant to be used directly in a Strapi project. It utilizes the Custom Field API and doesn't do anything out of the ordinary with it. Have you tried using any other plugin that uses the Custom Field API?

Now I understand. This plugin is specifically meant to be used directly in a Strapi project. It utilizes the Custom Field API and doesn't do anything out of the ordinary with it. Have you tried using any other plugin that uses the Custom Field API?

Not yet, but it’s weird it doesn’t work since it’s just registering a custom field with strapi.register, roght?

Take a look at the Strapi documentation. When you add this plugin to another plugin's package.json, how would Strapi know that it needs to call this plugin’s register function? How could it even identify it as a Strapi plugin? I recommend asking for help in the Strapi Discord community.

Take a look at the Strapi documentation. When you add this plugin to another plugin's package.json, how would Strapi know that it needs to call this plugin’s register function? How could it even identify it as a Strapi plugin? I recommend asking for help in the Strapi Discord community.

I do get what you mean however it makes the custom field api not really usable for use in other plugins if it’s required to install it globally. What if you want a custom CK Editor field in a collection type from the plugin?

You would need to require the users of your plugin to:

  1. First instruct them to install the ck editor globally
  2. Install the plugin
  3. rebuild everything

While it could potentially be:

  1. Install CKEditor in the plugin package.json
  2. rebuild admin panel

Perhaps I can call the register and bootstrap of your plugin manually to achieve something like this? 🤔

If your plugin depends on this one, it sounds like a peer dependency to me. It seems unusual to use one Strapi plugin inside another, I haven't tried that before. I'll mark this issue as a question.

If your plugin depends on this one, it sounds like a peer dependency to me. It seems unusual to use one Strapi plugin inside another, I haven't tried that before. I'll mark this issue as a question.

If you install it as a peer dependency, without installing it in the root package.json of the Strapi project. You'll end up with errors such as the custom field does not exists. I don't think it's that unusual to have a custom fields functionality baked into another plugin. So that you don't have to install anything additionally, just the plugin.

Anyhow, it looks like this is not possible at the moment. So I might close this one.

It looks like this issue is no longer relevant, so I'm closing it.