KevinBatdorf / code-block-pro

A Gutenberg code block with syntax highlighting powered by VS Code
https://code-block-pro.com
132 stars 10 forks source link

Fix: Correct block registration by adding proper namespace prefix #334

Closed bianqui149 closed 3 months ago

bianqui149 commented 3 months ago

This pull request addresses an issue where the block registration was causing an error due to the lack of a proper namespace prefix. The following changes were made:

This fix resolves the "Block type names must contain a namespace prefix" error and ensures that the block is registered correctly in WordPress.

Testing:

KevinBatdorf commented 3 months ago

The diff doesn't reflect your description. Did you forget to push some changes?

Also, I don't think the src directory is right there, although I doubt it matters since the block.kson file ends up in bloth places anyway. The core sub uses build though as well (link).

What errors did you see previously?

bianqui149 commented 3 months ago

I get this error "Function WP_Block_Type_Registry::register was called incorrectly." The plugin is pointing to a folder that does not exist in the root of the plugin, so it is generating a bad practice. The changes now pointing to the block.json with the correct name block "kevinbatdorf/code-block-pro"

KevinBatdorf commented 3 months ago

Did you get it from GitHub here? If so you need to build it first. Run npm ci && npm run build

If you only downloaded the GitHub zip then that also doens't include the build (I don't commit the build files).

Otherwise download it from WordPress https://wordpress.org/plugins/code-block-pro/

bianqui149 commented 3 months ago

Is from the wordpress org official repository, I tried the same code from here, If you need the see the error, try using the query monitor plugin(https://wordpress.org/plugins/query-monitor/) in a production site

KevinBatdorf commented 3 months ago

I'll check it, but the directory and file is there. I'm aslo following the official documentation. You can see it here: https://plugins.trac.wordpress.org/browser/code-block-pro/trunk/build/block.json

Some questions actually if you don't mind. This might be something that needs to be fixed in WordPress

  1. The plugin works for you either way? Or does it not load (maybe install crashed)?
  2. When did this happen? I do know what WP has an issue when installing a block from the block inserter where all the assets don't get loaded. Was this an error you saw when doing that? (i.e. you search "code block" in the editor and it lets you install and insert in one click)
bianqui149 commented 3 months ago

Weird, I see the file and the line in the wordpress repo, but it is not loading that file in my prod instance, it must be some config on my server, feel free to cancel the pull request. thanks!

KevinBatdorf commented 3 months ago

Could be a deployment situation. Maybe you have a .gitignore file somewhere that stops "build" from being pushed. Anyway, I appreciate the PR regardless.