Set selected element
Question
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
Answers (2)
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')
Related Questions and Answers
Continue research with similar issue discussions.
Issue #4335
No way to upload background video component in the editor , Please suggest if there is any way to upload background video
GrapesJS version [X] I confirm to use the latest version of GrapesJS What browser are you using? Chrome v9 Reproducible demo link Not there...
Issue #6685
Custom component styles are not applied after deletion and re-addition
GrapesJS version [x] I confirm to use the latest version of GrapesJS What browser are you using? Chrome v143.0.7499.193 Reproducible demo l...
Issue #6152
CSS added via custom code persists after custom code component is removed
GrapesJS version [X] I confirm to use the latest version of GrapesJS What browser are you using? any Reproducible demo link https://grapesj...
Issue #3731
Text element not able to be selected twice after extended with events
Version: 0.17.25 Are you able to reproduce the bug from the demo?[ ] Yes[x] No What is the expected behavior? Update a existing component o...
Paid Plugins That Match This Issue
Curated by issue keywords and label relevance to help you ship faster.
Loading paid plugin recommendations...
Check the open-source GrapesJS plugins on GitHub or run a quick search in our free catalog.
Browse free plugins →Premium plugins ship with support, regular updates, and production-ready features — save days of integration work.
Browse premium plugins →Browse Plugin Categories
Jump directly to plugin category pages on the marketplace.