Skip to content

Conversation

@labomatik
Copy link

This pull request includes a change to the resources/views/components/paver.blade.php file. The change adds a new block registration feature to the Paver component, which allows blocks to be registered from the :config parameter if they exist.
This will allow creation of multiple editors with custom blocks

You can load blocks like this:

<x-paver :config="[
            'showSaveButton' => true,

            'blocks' => [
                \App\Blocks\Image::class,
            ]
]"/>
  • Added a check for the existence of 'blocks' in the configuration and registered each block with error handling. (resources/views/components/paver.blade.php)

Move the block content inside the config to mimic what is available in paver.php config file
@labomatik
Copy link
Author

Hum this seems to be not possible as the backend is not aware of the loaded blocks....
@jeffreyvr Do you have any idea how to do that?

@jeffreyvr
Copy link
Owner

Thanks for the PR! Currently this wont work, because the API endpoints need to be aware of which blocks exist. That's why they are loaded in the service provider.

https://github.com/jeffreyvr/paver-for-laravel/blob/main/src/PaverServiceProvider.php#L45

@labomatik
Copy link
Author

labomatik commented Jan 9, 2025

What do you think that instead of adding the blocks explicitly in the <x-paver component (like you did for dropblockeditor) we let the config load all available blocks, load them via the service provider, but we list all blocks that would be hidden in the editor?

like:

<x-paver :config="[
            'showSaveButton' => true,

            'hide_blocks' => [
                \App\Blocks\Image::class,
            ]
]"/>

This will allow personalized editors.

This will require a change in paver-for-laravel but also on paver (adding a function to hide blocks from the config)

@jeffreyvr
Copy link
Owner

jeffreyvr commented Jan 10, 2025

What would the use case be for wanting to hide blocks?

I did just (0.1.0) add a asChildOnly flag to blocks which hides blocks from the sidebar. Those will only become visible when a block is explicitly defined as an allowed nested/child block. Maybe that achieves what you want to do?

@labomatik
Copy link
Author

The use case is to have multiple editors with different blocks.

Let's say i want an editor for a newsletter with blocks : text, image, array
and another editor for a website with blocks: text, image, array, video, header, menu,...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants