When rendering <tr> tags inside <template> tags, tags are trimmed off and only string content is remained.
This is indeed a known behavior when dealing with HTML fragments that are not valid in a standalone context, such as <tr> or <td> tags outside of a <table> element. GrapesJS, like many HTML parsers, relies on browser-native DOM parsing mechanisms (e.g., innerHTML on a div or DOMParser). Root Cause The default HTML par...
Read full answer below βQuestion
GrapesJS version[X] I confirm to use the latest version of GrapesJSWhat browser are you using? Chrome v121Reproducible demo link https://jsfiddle.net/L27powtg/30/ (the fix it also there, commented out)Describe the bug How to reproduce the bug?Create a custom GJS component for template tags as explained here: https://github.com/GrapesJS/grapesjs/issues/244#issuecomment-324449748Add a template component that has a table row as a child. eg: check the result of editor.toHTML(). What is the expected behavior? The result of toHTML should not trim of the tr, td tags. What is the current behavior? re...
Answers (1)
This is indeed a known behavior when dealing with HTML fragments that are not valid in a standalone context, such as <tr> or <td> tags outside of a <table> element. GrapesJS, like many HTML parsers, relies on browser-native DOM parsing mechanisms (e.g., innerHTML on a div or DOMParser). Root Cause...
Related Questions and Answers
Continue research with similar issue discussions.
Issue #3779
Editor.getSelected().toHTML() encodes inline javascript
GrapesJS version[X] I confirm to use the latest version of GrapesJSWhat browser are you using? latest (chrome)Reproducible demo link https:...
Issue #5245
Contents of component with editable:false are still editable
GrapesJS version [X] I confirm to use the latest version of GrapesJS What browser are you using? Chrome 114.0.5735.198 Reproducible demo li...
Issue #6603
Ampersand is not escaped in attribute value
GrapesJS version [x] I confirm to use the latest version of GrapesJS What browser are you using? Chrome v142.0.7392.0 (canary) Reproducible...
Issue #6409
Cannot drag to move components on mobile
GrapesJS version [x] I confirm to use the latest version of GrapesJS What browser are you using? Chrome v133 Reproducible demo link https:/...
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
GrapesJS DevTools: A Developer Panel Inside Your Editor
If you've ever debugged GrapesJS with console.log(editor.getSelected()) and a dozen throwaway event listeners β this post is for you.
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
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.