Can't select the model using editor.select()
I am trying to select the first component in the editor by using editor.select(editor.DomComponents.getComponents().models[0]). It is not working.
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
i want to append dropped block at specific index. for example I want to append it at top of everything else. currently, I am doing this. but it is not working. Can anybody help? I am new to this.
editor.on('canvas:drop',(DataTransfer, model)=> {
if (model.is('header')) {
var index = 0;
editor.getComponents().add(model, {at: index});
}
})