Issue : Adding scripts inside nested content showing different behavior when compared with a single content ta
Question
Hi ,
We are actually trying to add a own JS script that can read a file and preview the same on the html. But in doing so by adding a BlockManager we are noticing a different behavior where we are not able to perform actions like remove/copy nor are we able to edit the inner elements.
The content inside the content is considered as a single block element, and we had to follow this approach in order to add the script.
The following is the snippet that we tried adding :
editor.BlockManager.add('image_left_text_right',{
id: 'LiRt',
label: 'Left Text,Right Image',
attributes: { class:'gjs-fonts gjs-f-h1p'},
copyable:true,
content:
{
style:{ classes:"row,cell",droppable:true, draggable:true,copyable:true,removable:true,toolbar: [{
attributes: {class: 'fa fa-arrows'},
command: 'tlb-move',
},{
attributes: {class: 'fa fa-clone'},
command: 'tlb-clone',
}]},
content:
`
<div class="row" data-gjs-custom-name="Row">
<div class="cell" data-gjs-draggable="false" data-gjs-droppable=".buttonCss" data-gjs-droppable="false" data-gjs-copyable="false" data-gjs-removable="false" data-gjs-custom-name="Cell">
<h1 data-gjs-droppable="false" data-gjs-draggable="false" data-gjs-copyable="false" data-gjs-removable="false">Section Title</h1>
<div class="cell" data-gjs-draggable="false" data-gjs-droppable="false" data-gjs-copyable="false" data-gjs-removable="false" data-gjs-custom-name="Cell padd">Passage Description</div>
</div>
<div class="cell" data-gjs-draggable="false" data-gjs-droppable="false" data-gjs-copyable="false" data-gjs-removable="false" data-gjs-custom-name="Cell">
<input type="file" accept="image/*" id = "LiRtid" >
<img id="output" style="width:250px;height:250px" data-gjs-draggable="false" data-gjs-droppable="false" data-gjs-copyable="false" data-gjs-removable="false"/>
</div>
</div>
`,
script:
` var input1 = document.getElementById('LiRtid');
input1.addEventListener('change', function()
{
var output = document.getElementById('output');
alert(output);
output.src = URL.createObjectURL(this.files[0]);
});`,
droppable:false,
draggable:".panel",
},
})

Any help is appreciated . Thanks in advance!!...Answers (2)
Check your code, it's completly messed up, you're mixing component related stuff inside blocks and then you put everything inside style(???)

This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.
Related Questions and Answers
Continue research with similar issue discussions.
Issue #1733
How to remove script tag which is added by add block manager script
Hello @artf I want to export final/production based html content excluding the script(Only which is added by block manager). Suppose i am a...
Issue #1117
External Elements can drag and drop in canvas?
Hi Artf Actually there is no issue. we are using grapesjs in a different way. We are not using header and sidebars of grapesjs we are perfo...
Issue #1263
How can i embed a modal and be able to edit it in my html content
Good Day I am trying to add a modal into my html, I was able to add a modal in the blockmanager but i am struggling to find ways to edit th...
Issue #1538
Different content when exporting
Hi, I'm trying to use grapejs with dynamic contents. What i want to achieve is like wordpress, i want to have shortcodes / custom html tag...
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.