mjawad096 / laravel-grapesjs

This package provide an esay way to integrate GrapesJS into your laravel proejct.
MIT License
108 stars 54 forks source link

Access to Blockmanager #24

Closed MeatWant closed 2 years ago

MeatWant commented 2 years ago

Hi,

how can i access the Blockmanager, to add Blocks after editor is loaded. Maybe this way:

blockManager.add('1_row', { label: ' <i class="fas fa-window-maximize"></i> Zeile', // attributes: { class: 'total' }, category: { label: 'Struktur', open: false, order: 5, }, content: { tagName: 'div', name: 'Zeile', draggable: true, unstylable: ['font-family'], attributes: { 'class': 'row', 'data-gjs-droppable' : '.row-cell' }, components: [ { tagName: 'div', name: 'Spalte', attributes: { 'class': 'row-cell', 'data-gjs-draggable' : '.row' }, content: '' }, ] } });

Where is the blockmanager defined? or where can i define it? Thanks

ghost commented 2 years ago

Hi there,

You can modify the config before the editor is initialized, Please the issue #18 -- So use that method to add blocks via config.

You can read the documentation here to learn how to add blocks via config.

MeatWant commented 2 years ago

Thanks, pushed me in the right direction. Only thing i need was, set api to true

'expose_api' => true,

and get the BlockManager

window.gjsEditor.BlockManager.add( ....... )

ghost commented 2 years ago

Yes, this is a way but that is not recommended as you are exposing the editor API to the end-user.