Grapesjs: [QUESTION] Set selected element

Created on 13 May 2020  路  2Comments  路  Source: artf/grapesjs

Hello,
is there a way to select an element after added to the body?
When i add a link, i want to open the Component Settings immediately.

How can i do it ?

Thank you in advance

Most helpful comment

I think this should work

editor.on('component:mount', function(model) {
    editor.select(model);
    const openBl = editor.Panels.getButton('views', 'open-tm');
    openBl && openBl.set('active', 1)
});

All 2 comments

I think this should work

editor.on('component:mount', function(model) {
    editor.select(model);
    const openBl = editor.Panels.getButton('views', 'open-tm');
    openBl && openBl.set('active', 1)
});

It works, thank you a lot.
I add the code only for links and button and it is perfect.

if model.is('link')

Was this page helpful?
0 / 5 - 0 ratings

Related issues

nojacko picture nojacko  路  3Comments

YashPrince picture YashPrince  路  3Comments

alibouaziz picture alibouaziz  路  3Comments

FlashPapa picture FlashPapa  路  3Comments

faizansaiyed picture faizansaiyed  路  3Comments