Issue #1091💬 AnsweredOpened May 7, 2018by mbleverage0 reactions

How to select the first Component

Quick answerby artf

Do it when the editor is loaded

Read full answer below ↓

Question

I want to launch the editor with the style manager visible and populated. Meaning that a component is selected by default and the style manager shows the styles related to that selected component. I have been struggling with how to access the model. var domComponents = editor.DomComponents; When I print the following to the console log, I see the models, I just cannot figure out how to access them. domComponents.getComponents() I'd like to do something like: editor.select(domComponents.getComponents().models[0]); But that doesn't do anything. I tried to print this to the console log: domCompo...

Answers (3)

artfMay 10, 2018

Do it when the editor is loaded

const dc = editor.DomComponents;
editor.on('load', () => editor.select(dc.getComponents().at(0)));
mbleverageJune 20, 2018

Thank you for your time. I just tried this and it is not working. Any other suggestion?

lock[bot]September 17, 2019

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.

Related Questions and Answers

Continue research with similar issue discussions.

Paid Plugins That Match This Issue

Curated by issue keywords and label relevance to help you ship faster.

View all plugins

Loading paid plugin recommendations...

Free option

Check the open-source GrapesJS plugins on GitHub or run a quick search in our free catalog.

Browse free plugins →
Premium option

Premium plugins ship with support, regular updates, and production-ready features — save days of integration work.

Browse premium plugins →

Related tutorials

In-depth guides on the same topic.

All tutorials →

Browse Plugin Categories

Jump directly to plugin category pages on the marketplace.