WordPress / gutenberg

The Block Editor project for WordPress and beyond. Plugin is available from the official repository.
https://wordpress.org/gutenberg/
Other
10.52k stars 4.21k forks source link

Previews for Embeddable Facebook Content are not displayed #8360

Closed 7studio closed 3 years ago

7studio commented 6 years ago

Describe the bug When I try to use the Facebook Embed Block, the preview of a valid embeddable content is not displayed. Plus, when I try the same thing with the classic editor, it works very well.

Maybe this issue is relative to the #5530 one.

To Reproduce Steps to reproduce the behaviour:

  1. Create a new content.
  2. Add a Facebook Embed Block.
  3. Paste a valid content URL. E.g.: https://www.facebook.com/oohmyworld/videos/2324195200940031/
  4. See the error message "Previews for this are unavailable in the editor, sorry!".

Expected behaviour Gutenberg should display a preview of the embedable Facebook content or at least its HTML fallback. E.g.:

<div class="fb-post" data-href="https://www.facebook.com/oohmyworld/posts/1882552011810839" data-width="552">
    <blockquote cite="https://www.facebook.com/oohmyworld/posts/1882552011810839" class="fb-xfbml-parse-ignore">
        <p>Une petite rétrospective sur notre vie en Ecosse...</p>
        Publiée par <a href="https://www.facebook.com/oohmyworld/">Ooh My World - En Écosse et ailleurs</a> 
        sur&nbsp;<a href="https://www.facebook.com/oohmyworld/posts/1882552011810839">Dimanche 29 juillet 2018</a>
    </blockquote>
</div>

If for some security issues, you don't want to embed external scripts into Embeds Block Previews, you are able to add the omitscript parameter to the Facebook API endpoint: https://developers.facebook.com/docs/plugins/oembed-endpoints?locale=en_GB#parameters

Screenshots

Previews for Embeddable Facebook Content are not displayed

Additional note

danielbachhuber commented 6 years ago

Related https://github.com/WordPress/gutenberg/issues/8361#issuecomment-409652402

I think there's some difference between how Facebook posts are embedded within the Classic Editor vs. Gutenberg, which makes them not work in Gutenberg.

7studio commented 6 years ago

Thank you for your answer Daniel :relaxed:

I'm not sure there is a difference between the Classic Editor and Gutenberg about Facebook oEmbed insertion. Plus, it is really stange that other services work and Facebook doesn't :confused:

I hope Facebook oEmbeds will work when Gutenberg will be inserted in WordPress core.

7studio commented 6 years ago

I took the time to look into core-blocks/embed and the Sandbox component and now I understand why Facebook contents can't be included. There are so many differences between Gutenberg and Classic editor. I'm sorry for my quick previous answer.

Can you explain to me why the embeds are sandboxed? They are not in the classic editor and in front-end.

danielbachhuber commented 6 years ago

I took the time to look into core-blocks/embed and the Sandbox component and now I understand why Facebook contents can't be included. There are so many differences between Gutenberg and Classic editor. I'm sorry for my quick previous answer.

No worries! Glad you were able to come to some understanding.

Can you explain to me why the embeds are sandboxed? They are not in the classic editor and in front-end.

I don't know off the top of my head, to be honest. It may be related to admin authentication cookies; the Classic Editor TinyMCE instance exists within an <iframe>, and frontend rendering doesn't have access to /wp-admin/ cookies. I'm sure there's some rationale for it though.

danielbachhuber commented 6 years ago

Removing the REST API Interaction label because this doesn't need any changes from the REST API.

thebud15 commented 5 years ago

Reported in #10653779-hc with follow up at #1913555-zen

renatonascalves commented 5 years ago

@danielbachhuber Just to confirm, the preview is a no-no?

danielbachhuber commented 5 years ago

@renatonascalves I don't recall exactly. If I were to look into this again, I'd first see if it was possible to cleanly sandbox the embed within an <iframe> (keeping in mind that it will need to resize responsively). If it doesn't look like it would be feasible, then I'd look at clarifying the error message (specifically for Facebook) to explain why the embed doesn't work within the editor.

skorasaurus commented 3 years ago

This can be closed since facebook is no longer supported in the embed block because of their api changes. https://github.com/WordPress/gutenberg/commit/87c4dc536f52254975b4b5e192e36f7d98b6f0b7