Only allow one component of specific type on editor
is there way to not allow to drop any specific component more than one time on page? I have custom component and user cannot drop it more than one on page, so if component is already added on page then I want to display specific message and not allow to be dropped in editor
Hi @krunal039,
My best suggestion would be to listen for the component:add event. In the event listener function you could check to see if the added component is the type that you are looking for, and if more than one of those components now exist in the canvas then remove the one that was just added and inform the user.
@krunal039 Ryan's suggestion is the correct way to accomplish your request
@artf @ryandeba thanks for reply, can you please let me know where can I listen event for component:add
editor.on('component:add', model => {
// ... your logic goes here
if(remove){
model.destroy();
}
});
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.