grapesjs-custom-code icon indicating copy to clipboard operation
grapesjs-custom-code copied to clipboard

iframe being rendered strangely in the canvas view

Open quentin-bettoum opened this issue 1 year ago • 0 comments

Hello,

The issue described below can be reproduced on the official demo at https://grapesjs.com/demo.html

When I try to add an iframe in a custom code block, the view tends to replace the iframe by a div, which breaks the layout of the iframe. However, the model seems to have the correct iframe since it is shown correctly in the view code modal, or by using editor.getHtml().

For example, if I add this iframe which is an embed YouTube video:

<iframe width="560" height="315" src="https://www.youtube-nocookie.com/embed/dQw4w9WgXcQ?si=m6l8dvLYog_PS9a4" title="YouTube video player" frameborder="0" allow="accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture; web-share" referrerpolicy="strict-origin-when-cross-origin" allowfullscreen></iframe>

This is what the canvas view will use, parts of the iframe attributes are now on a parent div:

<div data-gjs-highlightable="true" id="i73h" data-gjs-type="custom-code" draggable="true">
  <div id="i5xd" data-gjs-type="video" draggable="true" allowfullscreen="" width="560" height="315" src="https://www.youtube-nocookie.com/embed/dQw4w9WgXcQ?si=m6l8dvLYog_PS9a4" title="YouTube video player" frameborder="0" allow="accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture; web-share" referrerpolicy="strict-origin-when-cross-origin" class="gjs-hovered">
    <iframe src="https://www.youtube-nocookie.com/embed/dQw4w9WgXcQ?" frameborder="0" allowfullscreen="true" class="gjs-no-pointer" style="height: 100%; width: 100%;"></iframe>
  </div>
</div>

quentin-bettoum avatar May 21 '24 07:05 quentin-bettoum