Site Screenshot block: Update to support latest Interactivity API #268
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Merge alongside WordPress/wporg-mu-plugins#561, so that production has current Gutenberg version.
Update the dependencies so that we can use the
viewModule
block.json entry, which wp-scripts will correctly build as a module (required by the interactivity API script).The updated wp-scripts requires a more modern node version, so I've also updated the version for this project to 20 (see WordPress/wporg-parent-2021#122, we'll want to do this across all projects). I've pushed the package and node version updates to
main
, so this PR only contains the Interactivity API updates.The changes for the Interactivity API are mostly following the changelog recommendations. The exception is the change to how the screenshots are rendered. Rather than directly manipulating the DOM, the new method uses a combination of directives and state values to show/hide the image once it's loaded. This is more in line with expected behavior from the Interactivity API.
Fixes #267.
To test
composer update
nvm install
yarn
yarn build:theme
yarn wp-env start