Grapesjs: Sort How Block Categories are displayed.

Created on 2 Oct 2017  路  5Comments  路  Source: artf/grapesjs

Is there a method to set how the categories are shown in the Block tab?

enhancement

All 5 comments

Not currently. At the moment, are added in the order of insertion, but one possible trick might be the use of flexbox

We could look at something simple as adding a Weight parameter like CMS's like drupal do.
Ill look at the code to see how hard it would be to create a PR.

Should the plugin added components being sort.

        var editor = grapesjs.init(grapesjsoptions);
        plugins: [ 'gjs-plugin-placeholder'],
        pluginsOpts: {
            'gjs-plugin-placeholder': {/* ...options */},
        }
       //Also added some manually
       editor.BlockManager.add('grid-items', {
            label: 'Grid items',
            content: '<div>Grid code</div>'}
      });

should able to customized afterward like

editor.BlockManager.sort(filter) -- by filter of label, by any config of order in BlockManager.add

As a (not-so-great and hopefully temporary) workaround, I moved the category I wanted to move using jQuery after the editor was fully initialized:

setTimeout(function(){
    $(".gjs-block-categories>div:last").prependTo(".gjs-block-categories");
}, 1000)

Sort all blocks then render with block manager.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

YashPrince picture YashPrince  路  3Comments

krunal039 picture krunal039  路  3Comments

andre2 picture andre2  路  3Comments

FlashPapa picture FlashPapa  路  3Comments

desilvaNSP picture desilvaNSP  路  3Comments