Components name
Question
I have two questions.
-
Is there any way to change the built-in components name? I wanted to change the name "Box" to "Div". so the same name appears on select and on the layers/navigator panel. In simple term, if I drag and dropped a div, I need it to be named Div.
-
Any way to add an icon in front of the text of each item type in the layers panel? I mean a box for Div, A list icon for ULs etc...
Answers (3)
-
You can use data-gjs-custom-name on your components html.
<h1 data-gjs-custom-name="Your Name" ...> -
You can use data-gjs-icon on your components html.
<h1 data-gjs-icon='<i class="fa fa-arrows"></i>' ...>
Please change your title to something more meaningful so others can find already solved problems better :)
EDIT: you can use data-gjs-name instead of data-gjs-custom-name
I'd add that if you rely on HTML5 drag & drop, you can use canvas:dragdata event https://grapesjs.com/docs/api/editor.html#available-events
This allows you to make the editor understand "external drops", eg. by default GrapesJS can recognize images, by using canvas:dragdata you can make it recognize files like videos, PDFs, etc.
@NicoEngler Any other way to set default custom names for each type? If someone drag and drop content from outside, I want to display those div's names as "Divs" as well. :)
Related Questions and Answers
Continue research with similar issue discussions.
Issue #1902
[QUESTIONS] Disable/change build-in components behavior
Hey, Trying to get GrapesJs work for a project I'm currently working on. But is there a way to disable the built-in components that convert...
Issue #1428
[Question] Define or hide properties for specific components
Hi, I'm wondering if there is the possibility to define properties for specific components. I mean, when I select the component Image I wou...
Issue #1374
Default Component Properties
Is there any way I can change the default properties of components? I want almost everything to be copyable: false, resizable: false, dragg...
Issue #1579
Border Color Issue
@artf There is bug in the border color if you drag a button on the editor and paste color like rgb(255, 0, 0) in border color and select an...
Paid Plugins That Match This Issue
Curated by issue keywords and label relevance to help you ship faster.
Loading paid plugin recommendations...
Browse Plugin Categories
Jump directly to plugin category pages on the marketplace.