GrapesJS / grapesjs

Free and Open source Web Builder Framework. Next generation tool for building templates without coding
https://grapesjs.com
BSD 3-Clause "New" or "Revised" License
22.37k stars 4.05k forks source link

Sort How Block Categories are displayed. #364

Closed cmcintosh closed 1 year ago

cmcintosh commented 7 years ago

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

artf commented 7 years ago

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

cmcintosh commented 6 years ago

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.

edwardjiawei commented 6 years ago

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

d3vr commented 6 years ago

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)
prosenjit-manna commented 5 years ago

Sort all blocks then render with block manager.

artf commented 1 year ago

Closing for inactivity