Issue #780Opened January 19, 2018by JulyanoF2 reactions

How to reorder BlockManager Blocks?

Question

I'm trying to reorder these blocks, removing all of them from BlockManager and adding one by one in my order preference, but it's still not working.

Someone knows what is the rule to ordenate them?

Answers (3)

artfJanuary 22, 20181 reactions

Don't remove them, just update and render

const bm = editor.BlockManager;
const colmBlock = bm.get('column3').set({
	label: 'Clm label'
})
bm.render([
	colmBlock,
	//...
]);
chiqui3dJanuary 29, 20181 reactions

@artf It would not be ideal to add an order option like this for blocks and panels.

 bm.add('section-hero', {
        label: 'Hero section',
         order:1, // 1,2,3,4...
        category: 'Sections',
        content: '<header class="header-banner"> <div class="container-width">' +
            '<div class="logo-container"><div class="logo">GrapesJS</div></div>' +
            '<nav class="navbar">' +
            '<div class="menu-item">BUILDER</div><div class="menu-item">TEMPLATE</div><div class="menu-item">WEB</div>' +
            '</nav><div class="clearfix"></div>' +
            '<div class="lead-title">Build your templates without coding</div>' +
            '<div class="lead-btn">Try it now</div></div></header>',
        attributes: { class: 'gjs-fonts gjs-f-hero' }
    });
artfJanuary 19, 20180 reactions

@JulyanoF you can re-render them in this way

const bm = editor.BlockManager;
bm.render([
	bm.get('column3'), 
	bm.get('column2'), 
	bm.get('column1')
]);

or, if it's just about reordering inside their categories, you can rely on order css property as its container is flex

Related Questions and Answers

Continue research with similar issue discussions.

Paid Plugins That Match This Issue

Curated by issue keywords and label relevance to help you ship faster.

View all plugins

Loading paid plugin recommendations...

Browse Plugin Categories

Jump directly to plugin category pages on the marketplace.