This.get('content') returns empty string when trying to add custom component type
No, content property is only used in components like Text/Textnode. Replace your this.get('content') with this.components().map(comp => comp.toHTML())
Read full answer below βQuestion
Version: 0.16.18 Are you able to reproduce the bug from the demo?>> Demo <<< [ X ] Yes [ ] No What is the expected behavior? Expecting this.get('content') in the context of the model while creating a new component type (extending the default component type) should return the children as HTML. Describe the bug detailed Not sure if it's a but or I'm doing something wrong however in all of the examples I've come across in other issues it seems like this.get('content') should return it's children's HTML but instead it returns an empty string. What is the current behavior? It only returns the text...
Answers (3)
No, content property is only used in components like Text/Textnode.
Replace your this.get('content') with this.components().map(comp => comp.toHTML())
@artf does this look like a bug or am I doing something wrong?
@artf does this look like a bug or am I doing something wrong?
May be try model.components() insead of content
Related Questions and Answers
Continue research with similar issue discussions.
Issue #3352
Default Content is getting Inserted while using setComponents if Tag Body is empty
Version: Latest You can get the version by typing grapesjs.version into the console Are you able to reproduce the bug from the demo?[X] Yes...
Issue #3434
Using imported HTML/CSS/JS into the editor shows outlines, but no content, JS Fiddle inside
You can get the version by typing grapesjs.version into the console YES: https://jsfiddle.net/75a9u1cf/2/ What is the expected behavior? I...
Issue #2882
BUG: Problem with adding caption element block to the canvas
Version: 0.16.18 Are you able to reproduce the bug from the demo? [x ] Yes https://jsfiddle.net/triawarman/tmcoqxhp/ What is the expected b...
Issue #3435
Scrollable onStart/onEnd/updateTarget not Overridable
Version: 0.17.3 Are you able to reproduce the bug from the demo?[ ] Yes[X] No What is the expected behavior? Being able to override onStart...
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 βBrowse Plugin Categories
Jump directly to plugin category pages on the marketplace.