Grapesjs: Can't select the model using editor.select()

Created on 11 Nov 2019  路  6Comments  路  Source: artf/grapesjs

I am trying to select the first component in the editor by using editor.select(editor.DomComponents.getComponents().models[0]). It is not working.

All 6 comments

select the first component in the editor

editor.select(editor.getComponents().models[0])

cheers!

select the first component in the editor

editor.select(editor.getComponents().models[0])

cheers!

@pouyamiralayi , I tried this too. But it is not working.

@artf , @pouyamiralayi :I need this condition inside the 'canvas:drop' event
editor.on('canvas:drop', ()=>{
...
... // My code to select the first component is here //...
...
})

@naveen-15697 you can achieve this with:

editor.on('block:drag:stop', (m) => {
    if(m){
       editor.select(editor.getComponents().models[0])
    }
})

cheers!

@pouyamiralayi Thanks! It's working now.

@artf , But, Why it is not working in 'canvas:drop' event?

I think the selection is cleared somewhere after canvas:drop, I'll try to check it later

Was this page helpful?
0 / 5 - 0 ratings

Related issues

adam-gpc picture adam-gpc  路  3Comments

faizansaiyed picture faizansaiyed  路  3Comments

nojacko picture nojacko  路  3Comments

Snarkly picture Snarkly  路  3Comments

kosirm picture kosirm  路  3Comments