grapesjs icon indicating copy to clipboard operation
grapesjs copied to clipboard

Sort How Block Categories are displayed.

Open cmcintosh opened this issue 8 years ago • 5 comments

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

cmcintosh avatar Oct 02 '17 12:10 cmcintosh

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

artf avatar Oct 03 '17 12:10 artf

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.

cmcintosh avatar Oct 16 '17 04:10 cmcintosh

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

edwardjiawei avatar Nov 14 '17 02:11 edwardjiawei

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)

d3vr avatar Apr 22 '18 01:04 d3vr

Sort all blocks then render with block manager.

prosenjit-manna avatar Jun 25 '19 15:06 prosenjit-manna

Closing for inactivity

artf avatar Jul 26 '23 11:07 artf