Open Style Manager when selecting an element
Question
trying to do this
editor.on('component:selected', (model) => {
editor.runCommand('open-sm');
});
gives the error this.sender.get is not a function
grapesjs.min.js toggleSm
Basically I want to open the style manager when clicking on an element.
Any help or info appreciated, thanks
Answers (2)
Hi Michael,
there is actually a kind of bug in 'open-sm' which doesn't allow calling the command with runCommand but the reason is that it was designed to be called just by its relative button, indeed I'd recommend doing this for your case
editor.on('component:selected', () => {
const openSmBtn = editor.Panels.getButton('views', 'open-sm');
openSmBtn.set('active', 1);
});
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.
Issue #1091
How to select the first Component
I want to launch the editor with the style manager visible and populated. Meaning that a component is selected by default and the style man...
Issue #1386
Is there any "Resize event" for components?
I want to read the resize event when an element is triggered for resizing. My current Code looks like this, editor.on("component:resize", f...
Issue #1904
Get change in property float
I'm trying to listen to the change in the 'float' property whether it was shifted to the 'left' or 'right' or 'none' in Style Manager using...
Issue #538
Clicking component always opens styles first, even if I override
When I click the component, I want the traits to open Clicking a component opens the styles. Clicking it one more time will finally open op...
Paid Plugins That Match This Issue
Curated by issue keywords and label relevance to help you ship faster.
Loading paid plugin recommendations...
Browse Plugin Categories
Jump directly to plugin category pages on the marketplace.