Issue #3097Opened October 26, 2020by vatsla10 reactions

BUG: Custom traits not showing up

Question

I am trying to make custom traits following the guidelines from Grapesjs Trait manager, and I have been through previous issues but the traits don't show up.

Expected result: custom traits like the ones below to show up. Actual result: default traits like id and title show up.

Currently, I'm using the trait manager website example code to test as shown below.

editor.DomComponents.addType('count', {
model: {
      defaults: {
        traits: [
          // Strings are automatically converted to text types
          'name', // Same as: { type: 'text', name: 'name' }
          'placeholder',
          {
            type: 'select', // Type of the trait
            label: 'Type', // The label you will see in Settings
            name: 'type', // The name of the attribute/property to use on component
            options: [
              { id: 'text', name: 'Text'},
              { id: 'email', name: 'Email'},
              { id: 'password', name: 'Password'},
              { id: 'number', name: 'Number'},
            ]
          }, {
            type: 'checkbox',
            name: 'required',
        }],
        // As by default, traits are binded to attributes, so to define
        // their initial value we can use attributes
        attributes: { type: 'text', required: true },
      },
    },
    });
    
editor.BlockManager.add( 'count', 
{	
label: 'count',	
category: 'Extra',	
content: '<div id="customdiv"></div>',	
attributes: {class:'fa fa-clock-o'},
});

Thank you for your help in advance. Please let me know if I need to provide more information.

Answers (2)

GoodPHPOctober 30, 20200 reactions

Hi,

If you didn't find answer here, you can contact with Devfuture Team: https://devfuture.pro/contact/

We specialise on GrapesJS.

artfNovember 9, 20200 reactions

Follow the issue template please and provide a live demo of the bug

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.