How to open a sector when selecting a element?
Question
Hello everybody
How do i open a selector like general as i select the element.
I am new to javascript, but i tried something out like this.
editor.on('component:selected', function(component) {
if(component.attributes.tagName == 'div') {
const styleManager = editor.StyleManager;
styleManager.getSector('General',{
open: true,
});
}
});
what iam doing wrong?
Thx for help
Answers (3)
@ikenderham you were almost there
editor.StyleManager.getSector('general').set({ open: true })
I think you can see a working example here in the source code.
At the bottom.
Can you show me a example, if i click on a DIV then i need general to be opened, or when i click on a h1, then i need to open the "typography"?
Thanks alot im new to this.
Related Questions and Answers
Continue research with similar issue discussions.
Issue #3242
When Style Manager is in another div, the message "Select an element before using Style Manager" is not showing
Version: 0.16.34 What is the expected behavior? When the editor is initialized, no element is selected, so the style manager should say "Se...
Issue #3211
how to move components
Hello dear: I want move a component to first/end in the wrapper programmatically, i think something like editor.getWrapper().add(editor.sel...
Issue #2770
[QUESTION] Set selected element
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. H...
Issue #2696
[QUESTION]: How can I create block with background image with behavior like built-in "image"?
Hello, I'm trying to create block with background image (similar to Grapedrop Image Box). I added new component like this: And also I added...
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 โRelated tutorials
In-depth guides on the same topic.
Tutorial
How to Build a Production GrapesJS Editor: The Complete Walkthrough of Brief, Preset, Plugins, and Services
A complete walkthrough of building a production GrapesJS editor: how to choose a preset, pick plugins, and scope setup services without burning a sprint.
Tutorial
Embed GrapesJS in Your SaaS: A Weekend Guide
Embed GrapesJS in your SaaS and ship a white-label page builder over a weekend. Honest tradeoffs, real code, and the plugins that close the UX gap.
Tutorial
Big Updates: TinyMCE 8 and Placeholder 2.0 for GrapesJS
In May we shipped major updates to two of our most popular GrapesJS plugins โ TinyMCE Inline Text Editor and Placeholder.
Browse Plugin Categories
Jump directly to plugin category pages on the marketplace.