editor icon indicating copy to clipboard operation
editor copied to clipboard

Block plugin crashes on custom folder name

Open tideg opened this issue 3 years ago • 3 comments

Describe the bug After changing the folder name of a custom block plugin, the editor field won´t show up in the panel anymore. The panel error is 'The field type "[name of the corresponding editor field]" does not exist'

To Reproduce Steps to reproduce the behavior:

  1. Copy one of the provided example blocks, i.e. 'info-block' into /site/plugins/
  2. Change the name of the block inside index.php, index.js (change to download-block for example)
  3. Rename /site/plugins/info-block/snippets/info.php accordingly (download.php)

The plugin should run as expected.

  1. Now change the plugin´s folder name from 'info-block' to 'download-block'
  2. The editor field in the panel will now be broken as described.

Kirby Version 3.4.3

Console output Uncaught ReferenceError: editor is not defined at index.js?1600444109:3

Desktop (please complete the following information):

  • OS: Windows 10
  • Browser: Chrome, Firefox, etc.

Tried on different server environments, too.

tideg avatar Sep 21 '20 13:09 tideg

I've had the same problem with a custom block for alerts. Within the plugins folder, my block's folder was alert-block. It seems like plugins are loaded in alphabetical order.

In your case download-block gets loaded before editor since the letter d comes before e, but the block depends on the editor plugin, so it breaks the panel. My workaround was to rename the block folder to anything starting with a letter after e. In my case I renamed alert-block to z-alert-block and everything worked correctly.

I'm not 100% sure this is the case, but this was my experience with the problem.

PaulMorel avatar Sep 28 '20 02:09 PaulMorel

That´s it. Thanks a lot @PaulMorel! I now renamed my plugins into editor-[feature]-block, so that they are loaded after the main editor-plugin. This should definitely be mentioned in the Block extensions page inside the wiki @bastianallgeier.

tideg avatar Sep 28 '20 07:09 tideg

I can confirm this issue and its workaround. The moment the folder of an editor plugin comes before e in the alphabet, editor is not available for the custom js. Seems like plugin folders are loaded in alphabetical order which can mess up dependencies. :/

milesleif avatar Sep 29 '20 11:09 milesleif