Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Web Story Embed block for Gutenberg #1249

Merged
merged 91 commits into from
May 20, 2020
Merged

Web Story Embed block for Gutenberg #1249

merged 91 commits into from
May 20, 2020

Conversation

swissspidy
Copy link
Collaborator

@swissspidy swissspidy commented Apr 16, 2020

Summary

This PR adds a new web-stories/embed block to be used in Gutenberg. This new block can be used to display stories from the own site and other sites using amp-story-player.

Relevant Technical Choices

  • Dynamic block, makes it easier to only load the scripts & styles when needed. Makes future changes easier, too.
  • save.js is still used, as a fallback/cache should be plugin ever be disabled.
  • Styling is similar to regular embed blocks in Gutenberg, for better look and feel.
  • New REST API endpoint that returns the story title and poster for a given URL. That data is needed for the player.
  • The REST API controller short-circuits for URLs from the own site in order to not hit the own site with unnecessary HTTP requests.

To-do

Editor

  • WYSIWYG preview
  • REST API proxy endpoint
  • When entering a URL, fetch title and poster image via REST API proxy endpoint
  • Ability to resize the player using slider controls
  • Ability to override poster via sidebar
  • Ability to resize the player using input fields in sidebar
  • Make title editable in sidebar
  • Fix loading issue with amp-story-player ([AMP-STORY-PLAYER] Feature request : Control the player programmatically ampproject/amphtml#27331?)
    Suggestion: Implement in follow-up PR.
  • Dropdown to select posts from the stories editor?
    Suggestion: Implement in follow-up PR.

Frontend

  • Implement render_callback
  • Display Fullscreen toggle within player to navigate to story
    Got to URL? Or fullscreen iframe with history update?
    Suggestion: Implement in follow-up PR.

Code

Demo

Click below to expand:

Screenshots Screenshot 2020-04-16 at 16 41 28 Screenshot 2020-04-29 at 13 54 19 Screenshot 2020-05-04 at 16 56 52 Screenshot 2020-05-04 at 16 56 19

See #1118.

@swissspidy swissspidy added the Type: Enhancement New feature or improvement of an existing feature label Apr 16, 2020
@github-actions

This comment has been minimized.

@swissspidy

This comment has been minimized.

@codecov
Copy link

codecov bot commented Apr 28, 2020

Codecov Report

Merging #1249 into master will not change coverage.
The diff coverage is n/a.

Impacted file tree graph

@@            Coverage Diff            @@
##             master    #1249   +/-   ##
=========================================
  Coverage     63.78%   63.78%           
  Complexity      284      284           
=========================================
  Files           599      599           
  Lines          9888     9888           
=========================================
  Hits           6307     6307           
  Misses         3581     3581           

@swissspidy
Copy link
Collaborator Author

Add an embed story. Make the story bigger than the width of the content. Save post. Try and edit again.

Fixed. Max width has been reduced.

Poster image is not previewed in doc sidebar.

Fixed. Poster is now displayed in sidebar.

The embed in the feed doesn't work at all and output invalid html. For feeds, I think we should have a simple embed, like an image with a hyperlink.

Fixed. An image with link is now shown in feeds, or just a link if there is no poster.

If you align the story right, if doesn't clear fix correctly. Not sure if this is a theme issue.

Seems like a Gutenberg issue? e.g. WordPress/gutenberg#10299

Preview in block list breaks out of preview area. ( This really is a nit pick ).

Cannot reproduce this in current version of Gutenberg:

Screenshot 2020-05-18 at 13 53 21

Not sure we can do anything about this, but if there is not enough space, then our block edit doesn't really work.

Not really. It's a common issue in Gutenberg. Example:

Screenshot 2020-05-18 at 14 27 43

@spacedmonkey
Copy link
Contributor

Cannot reproduce this in current version of Gutenberg:

Screenshot 2020-05-18 at 13 53 21

I am not running the gutenberg plugin, I am just running whatever ships with 5.4.1

@spacedmonkey
Copy link
Contributor

I still have issues with selecting the stories block.

https://youtu.be/E8QJqDfyvS4

@swissspidy
Copy link
Collaborator Author

I am not running the Gutenberg plugin, I am just running whatever ships with 5.4.1

They must have since improved the BlockPreview component then 🤷 In WP 5.4.1 the preview only breaks out of the preview area because Gutenberg applies some margin there. Nothing we can really do something about.

I still have issues with selecting the stories block.

Mind checking out the latest version? I tried adding an invisible overlay like Gutenberg does for its own embed blocks. This makes selection a bit better.

@swissspidy swissspidy dismissed spacedmonkey’s stale review May 20, 2020 12:13

Lots of changes since then

Copy link
Contributor

@spacedmonkey spacedmonkey left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is great work @swissspidy . I am very happy to approve it!

@swissspidy swissspidy merged commit d288ca6 into master May 20, 2020
@swissspidy swissspidy deleted the add/gutenberg-block branch May 20, 2020 14:50
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Group: WordPress Changes related to WordPress or Gutenberg integration Type: Enhancement New feature or improvement of an existing feature
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants