GrapesJS / grapesjs

Free and Open source Web Builder Framework. Next generation tool for building templates without coding
https://grapesjs.com
BSD 3-Clause "New" or "Revised" License
22.36k stars 4.05k forks source link

BUG: Custom traits not showing up #3097

Closed vatsla1 closed 3 years ago

vatsla1 commented 3 years ago

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.

GoodPHP commented 3 years ago

Hi,

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

We specialise on GrapesJS.

artf commented 3 years ago

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