Issue #3482💬 AnsweredOpened May 25, 2021by Palash-Mandal0 reactions

Runtime updated traits not EDIT mode.

Quick answerby artf

Are you defining your custom component in a plugin?

Read full answer below ↓

Question

Hello @artf

I having issue with a traits. When I drag and drop the block to canvas it's traits showing fine in under settings section. but when I saved and edit the in 2nd time and selected that tag in canvas that traits is now populating in setting Section. Please Please Please HELP!.

`// Custom Heading Component blockManager.add('header', { label: 'Headings', category: 'Components', media: '<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24"><path d="M8.3 11.5h7.4V6.9l-.2-1.6a1 1 0 00-.5-.5c-.3-.2-.7-.3-1-.3h-.6v-.4h6.8v.4h-.6c-.4 0-.7.1-1 .3a1 1 0 00-.6.6L18 6.9v10.3c0 .8 0 1.3.2 1.6 0 .2.2.3.4.5.4.2.7.3 1.1.3h.6v.4h-6.8v-.4h.5c.7 0 1.2-.2 1.5-.6.2-.3.3-.9.3-1.8v-4.9H8.3v4.9l.1 1.6.5.5c.3.2.7.3 1 .3h.7v.4H3.7v-.4h.6c.7 0 1.1-.2 1.4-.6.2-.3.3-.9.3-1.8V6.9L6 5.3a1 1 0 00-.5-.5l-1-.3h-.7v-.4h6.9v.4H10c-.4 0-.8.1-1 .3a1 1 0 00-.6.6l-.1 1.5v4.6z"/></svg>',

Code SnippetTEXT
activate: 1,
        select: 1,
        removable: true, // Can't remove it
        draggable: true, // Can't move it
        copyable: true, // Disable copy/past
        content: {
            type: 'header',
            content: 'Insert your heading'
        },
    });
    dc.addType("header", {
        isComponent: function(t) {
            var e = t && t.tagName;
            if (e && ["H1", "H2", "H3", "H4", "H5", "H6"].indexOf(e) >= 0) return 1
        },
        extend: "text",
        model: {
            defaults: {
                name: "Heading",
                tagName: "h1",
                traits: [
                    'id',
                    'title',
                    {
                        type: "select",
                        options: [{
                            value: "h1",
                            name: "One (largest)"
                        }, {
                            value: "h2",
                            name: "Two"
                        }, {
                            value: "h3",
                            name: "Three"
                        }, {
                            value: "h4",
                            name: "Four"
                        }, {
                            value: "h5",
                            name: "Five"
                        }, {
                            value: "h6",
                            name: "Six (smallest)"
                        }, , {
                            value: "p",
                            name: "paragraph"
                        }],
                        label: "Heading Or paragraph",
                        name: "tagName",
                        changeProp: 1
                    }
                ]
            }
        }
    });
    

    
![image](https://user-images.githubusercontent.com/17553816/119492931-43bdb580-bd7d-11eb-96f5-3cfb7e44dc34.png)



After Saving in database when in edit mode the heading not show traits
![image](https://user-images.githubusercontent.com/17553816/119493374-c181c100-bd7d-11eb-9a21-7c4d0533322d.png)


Newly added heading show the traits 
![image](https://user-images.githubusercontent.com/17553816/119493464-d65e5480-bd7d-11eb-8631-73d1bac670a7.png)

Answers (4)

artfMay 25, 2021

Are you defining your custom component in a plugin?

Palash-MandalMay 25, 2021

Are you defining your custom component in a plugin?

No. Just Add in init function

editor = grapesjs.init({ const dc = editor.DomComponents; // Custom Heading Component blockManager.add('header', { label: 'Headings', category: 'Components', media: '<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24"><path d="M8.3 11.5h7.4V6.9l-.2-1.6a1 1 0 00-.5-.5c-.3-.2-.7-.3-1-.3h-.6v-.4h6.8v.4h-.6c-.4 0-.7.1-1 .3a1 1 0 00-.6.6L18 6.9v10.3c0 .8 0 1.3.2 1.6 0 .2.2.3.4.5.4.2.7.3 1.1.3h.6v.4h-6.8v-.4h.5c.7 0 1.2-.2 1.5-.6.2-.3.3-.9.3-1.8v-4.9H8.3v4.9l.1 1.6.5.5c.3.2.7.3 1 .3h.7v.4H3.7v-.4h.6c.7 0 1.1-.2 1.4-.6.2-.3.3-.9.3-1.8V6.9L6 5.3a1 1 0 00-.5-.5l-1-.3h-.7v-.4h6.9v.4H10c-.4 0-.8.1-1 .3a1 1 0 00-.6.6l-.1 1.5v4.6z"/></svg>',

Code SnippetTEXT
activate: 1,
        select: 1,
        removable: true, // Can't remove it
        draggable: true, // Can't move it
        copyable: true, // Disable copy/past
        content: {
            type: 'header',
            content: 'Insert your heading'
        },
    });
    dc.addType("header", {
        isComponent: function(t) {
            var e = t && t.tagName;
            if (e && ["H1", "H2", "H3", "H4", "H5", "H6"].indexOf(e) >= 0) return 1
        },
        extend: "text",
        model: {
            defaults: {
                name: "Heading",
                tagName: "h1",
                traits: [
                    'id',
                    'title',
                    {
                        type: "select",
                        options: [{
                            value: "h1",
                            name: "One (largest)"
                        }, {
                            value: "h2",
                            name: "Two"
                        }, {
                            value: "h3",
                            name: "Three"
                        }, {
                            value: "h4",
                            name: "Four"
                        }, {
                            value: "h5",
                            name: "Five"
                        }, {
                            value: "h6",
                            name: "Six (smallest)"
                        }, , {
                            value: "p",
                            name: "paragraph"
                        }],
                        label: "Heading Or paragraph",
                        name: "tagName",
                        changeProp: 1
                    }
                ]
            }
        }
    });

 });
artfMay 25, 2021

The first rule of defining new component types is to place the code inside a plugin.

From docs

ClaudeCodeMay 17, 2026

Thanks for reporting this, @Palash-Mandal.

Thanks for sharing your report about Runtime updated traits not EDIT mode.. To help the team investigate and prioritize this:

Please provide:

  1. A minimal reproducible example (CodeSandbox/JSFiddle)
  2. Your GrapesJS version number
  3. Browser and OS information
  4. Any error messages from the browser console
  5. Steps to reproduce the issue

What helps most:

  • Minimal code example (not your full project)
  • Screen recording or screenshot showing the issue
  • Expected vs actual behavior clearly stated
  • GrapesJS configuration you're using

With these details, the maintainers can identify and prioritize a fix much faster. The GrapesJS team is very responsive to well-documented issues.

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.