Issue #2968πŸ’¬ AnsweredOpened August 24, 2020by gunslingor1 reactions

Trying to have 'Settings' sector under the style

Quick answerby gunslingor❀ 1

Okay, I think I understand. I need many different versions of grapejs canvases... each should be it's own plugin, maybe sharing common code in some cases. I was thinking differently, that presets were only settings that could be overridden but it's more like a preset is the complete solution itself... now I gotta lear...

Read full answer below ↓

Question

https://github.com/artf/grapesjs/issues/1627

I think the question is related to this line specifically, I have the same issue. I look thru the demo but this class only appears in css and this line, so this selector returns undefined does it not? What element has this so that it can then be appended?

traitsProps.append($('.gjs-trt-traits')); It does work in the demo but I don't understand how..

Trying to solve in KotlinJS, notice: - Make sure it is inside onload - Notice var $ = grapesjs.$; getElementBy doesn't work, but I don't understand what this is doing - Solved - "Load and show settings and style manager": this part of the demo apparently creates the div with that css class, then what follows moves it to the correct spot and wires up the drop down. Not sure why this one is different than everything configured in present plugin, why can't this be setup on init like those?

Answers (3)

gunslingorβ€’ August 28, 2020

Okay, I think I understand. I need many different versions of grapejs canvases... each should be it's own plugin, maybe sharing common code in some cases. I was thinking differently, that presets were only settings that could be overridden but it's more like a preset is the complete solution itself... now I gotta learn to make plugins, off I go!

Nikesh-hubβ€’ August 24, 2020

Hello @gunslingor before calling trait sector you need to make active both section settingButton && settingButton.set('active', 1); styleManagerButton && styleManagerButton.set('active', 1);

Code SnippetTEXT
and then you can call 


Β 
--
// Add Settings Sector
Β  | var traitsSector = $('<div class="gjs-sm-sector no-select">'+
Β  | '<div class="gjs-sm-title"><span class="icon-settings fa fa-cog"></span> Settings</div>' +
Β  | '<div class="gjs-sm-properties" style="display: none;"></div></div>');
Β  | var traitsProps = traitsSector.find('.gjs-sm-properties');
Β  | traitsProps.append($('.gjs-trt-traits'));
Β  | $('.gjs-sm-sectors').before(traitsSector);
Β  | traitsSector.find('.gjs-sm-title').on('click', function(){
Β  | var traitStyle = traitsProps.get(0).style;
Β  | var hidden = traitStyle.display == 'none';
Β  | if (hidden) {
Β  | traitStyle.display = 'block';
Β  | } else {
Β  | traitStyle.display = 'none';
Β  | }
Β  | });
Β  |
gunslingorβ€’ August 24, 2020

Yeah, I figured that out eventually. I don't get why I have to configure this section AFTER initialization instead of during like many other panels/sections. I think it's because I am using the presets plugin. I think init needs to be simple if your using it and then modified after, but I don't have confirmation and I don't know why. Is this correct, or can you use the presets plugin AND configure traits at init time (at the same time)?

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.