Adding indication as a Trait without any input.
Question
I want to add an indication for a trait. For my component, I have the traits: and for the type 'dateformat-indication', I created the type: However, I get an input within this type that I created even if it wasn't on its template: Is there a way to disable default input of the trait?
Answers (2)
Using the method below works fine:
editor.TraitManager.addType('dateformat-indication', {
noLabel: true,
createInput({ trait }) {
const el = document.createElement('div');
el.innerHTML = `
//TEMPLATE
`;
return el;
},
Thanks for reporting this, @ahmedderkaoui. Great question about FEAT: adding indication as a Trait without any input.. The recommended approach with Components is to use the event-driven API. Start here: Check the GrapesJS documentation for your specific module Look for the on() event listener meth...
Related Questions and Answers
Continue research with similar issue discussions.
Issue #3185
[QUESTION] How to get the models trait of a component?
Hi there, I added a new type "array" to the TraitManager. So I can add several sub traits. On one point I have to check the traits of the m...
Issue #3233
Set Toolbar on every Component
Hi @artf Is there any standard way to add a new toolbar on every component I've tried this way When I run this code on the browser console...
Issue #3213
How to save the dynamically added traits
Hi, @artf, I have a custom component that has a button trait. When the button is pressed, I am adding a custom trait dynamically using comp...
Issue #3541
[QUESTION] What is the idiomatic way to append and remove classes from components?
Hey there š Love the editor! We're using traits to modify what classes a component has, but that feels a bit hacky as you have to redeclar...
Paid Plugins That Match This Issue
Curated by issue keywords and label relevance to help you ship faster.
Loading paid plugin recommendations...
Check the open-source GrapesJS plugins on GitHub or run a quick search in our free catalog.
Browse free plugins ā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.
Tutorial
How to Build a Production GrapesJS Editor: The Complete Walkthrough of Brief, Preset, Plugins, and Services
A complete walkthrough of building a production GrapesJS editor: how to choose a preset, pick plugins, and scope setup services without burning a sprint.
Tutorial
Embed GrapesJS in Your SaaS: A Weekend Guide
Embed GrapesJS in your SaaS and ship a white-label page builder over a weekend. Honest tradeoffs, real code, and the plugins that close the UX gap.
Tutorial
Big Updates: TinyMCE 8 and Placeholder 2.0 for GrapesJS
In May we shipped major updates to two of our most popular GrapesJS plugins ā TinyMCE Inline Text Editor and Placeholder.
Browse Plugin Categories
Jump directly to plugin category pages on the marketplace.