Issue #628πŸ’¬ AnsweredOpened Dec 11, 2017by AH1N13 reactions

Exclude components from final html

Quick answerby ryandeba❀ 1

Hi @AH1N1, By "final html", do you mean the value returned from editor.getHtml()? And are you referring to a custom component? If the answer to both of those questions is yes, then you should just be able to override the toHTML method of your custom component to return nothing. The code to do that would be something l...

Read full answer below ↓

Question

Is there any ready solution to exclude some components from final html? Or any other mechanism that makes component exist only in view?

Answers (3)

ryandebaβ€’ Dec 12, 2017

Hi @AH1N1, By "final html", do you mean the value returned from editor.getHtml()? And are you referring to a custom component? If the answer to both of those questions is yes, then you should just be able to override the toHTML method of your custom component to return nothing. The code to do that...

ryandebaβ€’ Dec 12, 2017

@AH1N1 Here's a working code example: https://jsfiddle.net/tt32z2uz/2/. Open up you browser console and you should see this logged out: <div>here's some normal content</div><div>...more normal content</div>. Does that give you what you need to debug your code? If not, can you provide a live code ex...

artfβ€’ Dec 21, 2017

Hi @afotey What about if I wanted to return just the ID of a div as entered using the Component Settings panel? Id assigned from component settings goes directly inside attributes therefore you can use this Is there a way to have the export be ONLY those IDs and NOT any of the accompanying HTML/CSS...

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.