Issue #2943πŸ’¬ AnsweredOpened August 7, 2020by Joshmamroud1 reactions

This.get('content') returns empty string when trying to add custom component type

Quick answerby artf❀ 1

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)

artfβ€’ August 27, 2020

No, content property is only used in components like Text/Textnode. Replace your this.get('content') with this.components().map(comp => comp.toHTML())

Joshmamroudβ€’ August 11, 2020

@artf does this look like a bug or am I doing something wrong?

DmitryTar1β€’ August 13, 2020

@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.

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 β†’

Browse Plugin Categories

Jump directly to plugin category pages on the marketplace.