grapesjs icon indicating copy to clipboard operation
grapesjs copied to clipboard

How to change the default selected panel?

Open rlopzc opened this issue 7 years ago • 12 comments

I'm trying to use defaultCommand: 'open-blocks' but the style manager is the default selected one

Thanks!

rlopzc avatar Nov 07 '19 14:11 rlopzc

Hi @romariolopezc did you try this:

  defaultCommand: 'select-comp',

cheers!

pouyamiralayi avatar Nov 07 '19 16:11 pouyamiralayi

Hello @pouyamiralayi

I just tried it and is not working

rlopzc avatar Nov 10 '19 17:11 rlopzc

@romariolopezc are you on the latest version?

pouyamiralayi avatar Nov 10 '19 19:11 pouyamiralayi

@pouyamiralayi I have this:

    "grapesjs": "^0.15.8",
    "grapesjs-mjml": "^0.1.15",

I'm using th MJML plugin, it may have something to do?

rlopzc avatar Nov 10 '19 21:11 rlopzc

@romariolopezc please do not use defaultCommand and give this a try:

editor.on('load', () => {
        editor.runCommand('open-blocks')
})

for other panels, replace open-blocks with open-layers for layers and open-tm for traits. the current problem is that style-manager will always be opened by default in all of above scenarios. it seems that this is a bug, i just tried using defaultCommand: 'open-layers' and it is not working; the same goes for 'open-traits'. i also tried all the alternatives like 'OpenTraitManager' @artf

pouyamiralayi avatar Nov 11 '19 11:11 pouyamiralayi

@pouyamiralayi it doesn't behave as expected.

If I use editor.runCommand('open-blocks') on load, the components icon is not selected. Is appended to the bottom of the style manager

2019-11-11-085143_409x567_scrot

2019-11-11-085307_530x515_scrot

Here the screenshots

rlopzc avatar Nov 11 '19 14:11 rlopzc

@romariolopezc unfortunately yes:

the current problem is that style-manager will always be opened by default in all of above scenarios.

pouyamiralayi avatar Nov 11 '19 15:11 pouyamiralayi

i will investigate on this matter.

pouyamiralayi avatar Nov 11 '19 16:11 pouyamiralayi

@pouyamiralayi it doesn't behave as expected.

If I use editor.runCommand('open-blocks') on load, the components icon is not selected. Is appended to the bottom of the style manager

2019-11-11-085143_409x567_scrot

2019-11-11-085307_530x515_scrot

Here the screenshots

@romariolopezc , Instead for running the command. Try activating blocks button on load. const blockBtn = editor.Panels.getButton('panel-id', 'block-button-name'); blockBtn.set('active', 1);

naveen-15697 avatar Nov 12 '19 04:11 naveen-15697

thanks @naveen-15697 your solution works pretty awesome! well done. @romariolopezc does this suit your situation? as suggested by @naveen-15697 you have to go like this:

editor.on('load', () => {
        const blockBtn = editor.Panels.getButton('views', 'open-layers');
        blockBtn.set('active', 1);
})

and the button ids for views panel are:

  • open-sm
  • open-tm
  • open-layers
  • open-blocks

cheers!

pouyamiralayi avatar Nov 12 '19 11:11 pouyamiralayi

@pouyamiralayi @naveen-15697 it works!!

I use it outside of the load, after initializing grapesjs. If I use it on load then I see a small delay when changing from the style manager to open-blocks. If its after the .init({..}) then when it renders is selected

rlopzc avatar Nov 12 '19 14:11 rlopzc

thanks @naveen-15697 your solution works pretty awesome! well done. @romariolopezc does this suit your situation? as suggested by @naveen-15697 you have to go like this:

editor.on('load', () => {
        const blockBtn = editor.Panels.getButton('views', 'open-layers');
        blockBtn.set('active', 1);
})

and the button ids for views panel are:

  • open-sm
  • open-tm
  • open-layers
  • open-blocks

cheers!

Actually i want to remove view code button so i write this code in angular this._editor.Panels.removeButton('options', 'export-template') but it's not working

sdchamoli avatar Oct 15 '21 09:10 sdchamoli