Issue #841✓ SolvedOpened February 6, 2018by kewilson3 reactions

Add default Trait (attribute) to model for all HTML Components (elements)

Quick answerby ryandeba3

Hi @kewilson, You've got a few different approaches for how to accomplish this...if every single component needs this custom trait, then I would probably override the initialize method of the default component type and add it there. Something like this: Alternatively, you might be able to get away with just adding you...

Read full answer below ↓

Question

Hi, I've read the Traits, Components and API wikis, grepped all the open & closed issues. I've even found the code where you are creating the defaults (ID, Title, Alt) you have today. There have been similar questions asked but none answer the question at hand. For every HTML component I want to add another default attribute (trait) in addition to the predefined default attributes (ID, Title, Alt, etc.). This includes adding the new trait to flexboxes, divs, inputs, images, etc. so that when Settings is selected we see (using the text type as an example): ID [Placeholder Text] Title [Placehol...

Answers (3)

👍 Most helpfulryandebaFebruary 6, 2018

Hi @kewilson, You've got a few different approaches for how to accomplish this...if every single component needs this custom trait, then I would probably override the initialize method of the default component type and add it there. Something like this: Alternatively, you might be able to get away...

kewilsonFebruary 7, 2018

Hey @ryandeba thanks so much for the suggestions. I put in the second one and it works for, well, the defaults as you would expect. Blocks like link, image, input just to name a few it doesn't add the attribute but those must be classified differently. Nonetheless an all around success in my book....

josefphMarch 8, 2018

@kewilson could you help me adding another default trait in a specific component?

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.