BUG: Grapesjs fails to recognize component types when setting innerHTML through script.
Question
GrapesJS version
- I confirm to use the latest version of GrapesJS
What browser are you using?
chrome v108.0.5359.98
Reproducible demo link
https://codesandbox.io/s/grapes-js-template-literal-forked-6kgvrb?file=/src/App.js
Describe the bug
I'm trying to create a custom component that recognizes inner html component types after injecting html code through script.
How to reproduce the bug?
- Just inject the html through script
const el = this;
el.innerHTML = `<div data-gjs-resizable="true" data-gjs-layerable="true" data-gjs-draggable="true" data-gjs-selectable="true" data-gjs-hoverable="true">
<img data-gjs-resizable="true" data-gjs-layerable="true" data-gjs-draggable="true" data-gjs-selectable="true" data-gjs-hoverable="true" src="" alt="">
<h5 data-gjs-resizable="true" data-gjs-layerable="true" data-gjs-draggable="true" data-gjs-selectable="true" data-gjs-hoverable="true">Lakshya</h5>
<h6 data-gjs-resizable="true" data-gjs-layerable="true" data-gjs-draggable="true" data-gjs-selectable="true" data-gjs-hoverable="true">Artist</h6>
</div>`;
What is the expected behavior? Canvas should be able to recognize component types like text, image, etc after injecting code.
What is the current behavior? Injected part is recognized as text component as whole.(Injected code may contain div element with image or text)
If is necessary to execute some code in order to reproduce the bug, paste it here below:
// your code here
Code of Conduct
- I agree to follow this project's Code of Conduct
Answers (1)
Read carefully this guide, everything inside script is outside of the editor scope. You can update the component itself by using component.components method or specify the components: '<div ....' directly in definition.
Related Questions and Answers
Continue research with similar issue discussions.
Issue #3939
BUG: Disabled drag and drop in preview
GrapesJS version[X] I confirm to use the latest version of GrapesJSWhat browser are you using? v95Reproducible demo link https://codesandbo...
Issue #4654
BUG: Custom component for text node including special characters
GrapesJS version [X] I confirm to use the latest version of GrapesJS What browser are you using? Chrome v105 Reproducible demo link https:/...
Issue #4416
BUG: Can't parse trait values using Template literals(String Interpolation)
GrapesJS version [X] I confirm to use the latest version of GrapesJS What browser are you using? Chrome v103.0.5060.53 Reproducible demo li...
Issue #6081
BUG: Custom Component not able to visible in grapsJs/studio at first rendering
GrapesJS version[X] I confirm to use the latest version of GrapesJSWhat browser are you using? chromeReproducible demo link https://stackbl...
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.