Issue #1091Opened May 7, 2018by mbleverage0 reactions

How to select the first Component

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: domComponents.getComponents().models it returns an empty array

I'm sure it's a simple answer but I've searched and attempted for a long time and can't figure it out, help is appreciated. Thank you.

Answers (3)

artfMay 10, 20180 reactions

Do it when the editor is loaded

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

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

lock[bot]September 17, 20190 reactions

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...

Browse Plugin Categories

Jump directly to plugin category pages on the marketplace.