Closed Sudhin35 closed 2 years ago
@artf Please help me on this
I see no issue when I run editor.setComponents(...FB HTML..)
Please provide a reproducible demo.
@artf Thanks for the reply but you have added editor.setComponents(...FB HTML..) by default and then loaded the editor
Please create a component of FB HTML and Drag& drop the component in editor , it wont load
This way i have tried
const blockManager = editor.BlockManager;
blockManager.add('facebook-block', {
label: 'Facebook',
category: "Basic",
content: '<div id="fb-root"></div>
<script async defer crossorigin="anonymous" src="https://connect.facebook.net/en_US/sdk.js#xfbml=1&version=v13.0" nonce="aZMwnOeb"></script>
<div class="fb-page" style="width:100%" data-href="https://www.facebook.com/facebook" data-tabs="" data-width=""
data-height="" data-small-header="false" data-adapt-container-width="true" data-hide-cover="false" data-show-facepile="true">
<blockquote cite="https://www.facebook.com/facebook" class="fb-xfbml-parse-ignore">
<a href="https://www.facebook.com/facebook">Meta</a></blockquote></div>',
});
but you have added editor.setComponents(...FB HTML..) by default and then loaded the editor
No, I used the API directly from the console and it worked.
Please create a component of FB HTML and Drag& drop the component in editor , it wont load
As you're using an HTML string without any root element (eg. wrapping div
) the code is parsed and executed in order to understand where the component could be placed (without a wrapping element all children are executed, like FB script). From my understanding, the FB code wasn't made to execute itself multiple times, so when you actually drop it in the canvas, their JS doesn't work.
To avoid any kind of parsing on drag, you can place the HTML code inside a component definition.
editor.BlockManager.add('facebook-block', {
label: 'Facebook',
category: 'Basic',
content: {
components: `
<div id="fb-root"></div>
<script async defer crossorigin="anonymous" src="https://connect.facebook.net/en_US/sdk.js#xfbml=1&version=v13.0" nonce="aZMwnOeb"></script>
<div class="fb-page" style="width:100%" data-href="https://www.facebook.com/facebook" data-tabs="" data-width=""
data-height="" data-small-header="false" data-adapt-container-width="true" data-hide-cover="false" data-show-facepile="true">
<blockquote cite="https://www.facebook.com/facebook" class="fb-xfbml-parse-ignore">
<a href="https://www.facebook.com/facebook">Meta</a></blockquote></div>`
},
});
But in case you remove the component and drop the block again, it won't work, but that is due to the FB script.
GrapesJS version
What browser are you using?
Chrome v9
Reproducible demo link
Not there
Describe the bug
How to reproduce the bug?
What is the expected behavior? After dropping the facebook component it should display the facebook page in editor
What is the current behavior? After dropping the facebook component , it is not displaying the facebook page But after the tab reload the facebook page is displayed in the editor
If is necessary to execute some code in order to reproduce the bug, paste it here below:
Code of Conduct