Grapesjs: Is it possible to remove "views" of editor Panel

Created on 31 Jan 2018  路  7Comments  路  Source: artf/grapesjs

I wish to remove/hide the below mentioned "view" from the Panel. Is it possible via API or I need to externally hide using css ?

34

editor.Panels.getPanel("views").attributes.buttons.models[2].attributes.visible = false;

outdated

Most helpful comment

@anand-gopinath In case it's helpful, here's some code that I'm using to reorder those buttons (this also probably needs to run in a plugin):

var panelManager = editor.Panels;

// get the buttons
var styleManagerButton = panelManager.getButton("views", "open-sm");
var layersButton = panelManager.getButton("views", "open-layers");
var blocksButton = panelManager.getButton("views", "open-blocks");

// remove the buttons
panelManager.removeButton("views", "open-sm");
panelManager.removeButton("views", "open-layers");
panelManager.removeButton("views", "open-blocks");

// add the buttons back in a custom order
panelManager.addButton("views", blocksButton);
panelManager.addButton("views", styleManagerButton);
panelManager.addButton("views", layersButton);

All 7 comments

One of the demos does it like this:
$('#gjs-pn-views').find('.fa-bars').hide();

I couldn't find a way to do it through API.

@maxtacco That's fine but, it seems better to do through API because in future there will be a need for rearrangements among the 4 views in that panel.

@anand-gopinath - this code works for me in a plugin: editor.Panels.removeButton("views", "open-layers");

It doesn't seem to work for me after the editor has fully loaded...I suspect that it needs to get removed before the view is rendered, but I haven't confirmed that.

@anand-gopinath In case it's helpful, here's some code that I'm using to reorder those buttons (this also probably needs to run in a plugin):

var panelManager = editor.Panels;

// get the buttons
var styleManagerButton = panelManager.getButton("views", "open-sm");
var layersButton = panelManager.getButton("views", "open-layers");
var blocksButton = panelManager.getButton("views", "open-blocks");

// remove the buttons
panelManager.removeButton("views", "open-sm");
panelManager.removeButton("views", "open-layers");
panelManager.removeButton("views", "open-blocks");

// add the buttons back in a custom order
panelManager.addButton("views", blocksButton);
panelManager.addButton("views", styleManagerButton);
panelManager.addButton("views", layersButton);

Thanks Ryan, I'll add a new listener, in the next release, which should fix the issue

@ryandeba how to get the options. I want to replace the view code button with save button. Can you please tell me how to do that.
Thanks in advance :*

This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

Geczy picture Geczy  路  3Comments

Snarkly picture Snarkly  路  3Comments

adam-gpc picture adam-gpc  路  3Comments

applibs picture applibs  路  3Comments

kosirm picture kosirm  路  3Comments