Add new block to block manager: predefined content and editor content is different
Question
I try to use template engine with grapesjs. Add new block by this:
bm.add('promotion-lines', {
label: 'Promotion Lines',
category: c.labelCategory,
attributes: {class: 'fa fa-list-ol'},
content: `<ul>
<table style="box-sizing: border-box; height: 150px; margin: 0 auto 0 auto; padding: 0 0 0 0; width: 100%;">
<tbody style="box-sizing: border-box;"><tr style="box-sizing: border-box;">
{% for order_line in order.order_lines %}
<td style="box-sizing: border-box; padding: 0; margin: 0; vertical-align: top;" valign="top"/>
{% endfor %}
</tr>
</tbody>
</table>
</ul>`,
});
Drag new block to editor then the content of editor is different from above: (the {% for order_line in order.order_lines %} is moved up)
<ul style="box-sizing: border-box;">
{% for order_line in order.order_lines %}
<table id="imf58" style="box-sizing: border-box; height: 150px; margin: 0 auto 0 auto; padding: 0 0 0 0; width: 100%;" width="100%" height="150">
<tbody id="isbik" style="box-sizing: border-box;">
<tr id="ikbcn" style="box-sizing: border-box;">
<td valign="top" id="ipg0l" style="box-sizing: border-box; padding: 0; margin: 0; vertical-align: top;">
{% endfor %}
</td>
</tr>
</tbody>
</table>
</ul>
How can i prevent this? Thanks.
Answers (2)
If you drop a not valid HTML structure it will be rearranged by the browser, you can't prevent it
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 #1134
Add custom style in the style-sheet for a new class of existing block.
Hello @artf _("map") && i.add("map", { label: n.labelMap, category: n.category, attributes: { class: "fa fa-map-o" }, content: { type: "map...
Issue #1817
Change HTML content while block is render in editor
Hello @artf I have one block into block manager like As per above script inside the block, i want to add dynamic HTML content while this bl...
Issue #1471
[Question] Blockmanager and Image
Hi! I use this code to add a new block: blockManager.add("image", { label: 'Image', category: 'Basic', attributes: { class: "gjs-fonts gjs-...
Issue #1034
insert element or block inside parent element
Good day, i have component, have block i have Trait on listen changes, how can I add "h1 " inside that block "'<div class="container" style...
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.