Automattic / isolated-block-editor

Repackages Gutenberg's editor playground as a full-featured multi-instance editor that does not require WordPress.
344 stars 50 forks source link

extend documentation for standalone editor: registering custom blocks and gutenberg settings object #152

Closed BenniMooris closed 2 years ago

BenniMooris commented 2 years ago

to me its a bit hard to figure out what is meant by Gutenberg Settings Object since there is no link or anything referencing to it. and google won't show me a resource for this term.

i would like to know how i am able to extend the standalone module with custom blocks and what possible gutenberg settings are available

johngodley commented 2 years ago

There's no official documentation for it, so there's nothing really to link to. About the nearest is the code here:

https://github.com/WordPress/wordpress-develop/blob/trunk/src/wp-admin/edit-form-blocks.php#L190

That is probably not comprehensive and there may be other settings added elsewhere. It's one of those things you'll need to dig into.

Custom blocks can be registered the standard way and don't require any static settings.

BenniMooris commented 2 years ago

@johngodley it would help a lot if the wp object would expose the registerBlockType method within the standalone browser version of this package. like here: https://github.com/Automattic/isolated-block-editor/blob/trunk/src/browser/index.js

import { registerBlockType as registerBlock } from '@wordpress/blocks';
window.wp = {
    attachEditor,
    detachEditor,
        registerBlock,
};

since i am using the standalone version this would make my current task so much easier rn since i can just call

wp.registerBlock('wayne/batcave',{
    title: 'Batcave',
    edit: () => {
        return <p>batman is here</p>
    }, save: () => {
        return <p>batman is gone</p>
    }
});

to register a new block, which makes it a true standalone version to me.

johngodley commented 2 years ago

When using the bundled version you are expected to import functions and not access them using the wp global.