Skip to content

fix: keep VideoPress blocks unchanged when opening a post - #941

Draft
dcalhoun wants to merge 9 commits into
trunkfrom
fix/videopress-block-conversion
Draft

dcalhoun wants to merge 9 commits into
trunkfrom
fix/videopress-block-conversion

Conversation

@dcalhoun

@dcalhoun dcalhoun commented Nov 25, 2026 •

Copy link
Copy Markdown
Member

Description

Ref CMM-713.

When the editor doesn't allow videopress/video, the block parses as core/missing and Jetpack's videopress/jetpack-convert-from-v6-to-v5 filter replaces it with core/video on open. That drops the block's VideoPress settings and marks an untouched post as changed, which WP-Android saves without asking.

This change:

  • Removes Jetpack's conversion filter after plugin scripts load and before the editor first renders. Removing it later doesn't work: withFilters renders once more with the old filter.
  • Shows a placeholder for these blocks: the VideoPress player with a caption explaining that the settings can be edited on the web. As in core embeds, the first tap selects the block and later taps play the video. The block's markup is kept as is.
  • If the preview can't load, shows core embeds' "could not be embedded" message with a Try again button, instead of an empty box.
  • Logs a warning if Jetpack VideoPress is active but the filter is missing, in case it was renamed.

Nothing changes when the editor allows videopress/video.

Android, light theme Android, dark theme iOS, light theme
VideoPress placeholder on Android with a video poster and caption in a light theme VideoPress placeholder on Android with a loading player and caption in a dark theme VideoPress placeholder on iOS with a video poster and caption in a light theme

When the preview can't load (web editor):

Before After Retrying No guid
Empty black box above the caption after the preview fails Could-not-be-embedded message with a Try again button above the caption Spinner in the video frame while the preview is fetched again Could-not-be-embedded message without a Try again button for a block with no guid

Testing instructions

  1. On a site with Jetpack VideoPress, create a draft with a videopress/video block between two paragraphs (e.g. in WP Admin).
  2. Open it in the demo app with plugins enabled.
    • The block shows the video preview and the caption.
    • Tapping the video once selects the block; tapping again plays it.
    • Save stays disabled; closing without edits doesn't change the post.
  3. Edit a paragraph and save. Only that paragraph changes on the server; the videopress/video block comment is unchanged.
  4. Insert a Video block and upload a video. It uploads through VideoPress and gets a guid.
  5. In WP Admin, change the block's guid to one that doesn't exist (e.g. zzzzzzzz) and reopen the post. The block shows "Sorry, this content could not be embedded." with Try again.
Additional AI-generated details

Verified on the Android emulator and iOS simulator with the bundled editor, against a Simple site and an Atomic site:

  • On open, the block stays core/missing (originalName: videopress/video), Jetpack's conversion filter is gone, and Jetpack's core/video extension is intact.
  • getEditedPostContent() is byte-identical to the server's raw content; isEditedPostDirty() and getTitleAndContent().changed are false; Save is disabled.
  • After editing a paragraph and saving, the server copy differs only in that paragraph.
  • The preview box, the sandbox and the player are the same size, with no band under the video. The first tap selects the block without playing; the second plays; deselecting restores the overlay. The post stays clean throughout. On iPhone the video plays fullscreen, as other editor videos do, because the editor's web view doesn't allow inline playback.
  • A fresh screen recording uploaded into a new Video block got a VideoPress guid on all four platform/site pairs. On Android the requests went through videopress/upload-jwt and tus (rest/v1.1/video-uploads); iOS doesn't expose them to the page.
  • Preview failures were checked in Chrome against wp-env with Jetpack. With the first oEmbed proxy request blocked, the block shows the message; Try again fetches again, shows a spinner, then loads the player as a normal open does. A block without a guid sends no request and shows the message without the button. Core-data caches a failed preview, so before this change the box stayed empty until the editor reloaded.
  • With plugins disabled, Jetpack can't be present, so the placeholder's chunk and stylesheet aren't loaded.

Known limitation: a private video's preview shows VideoPress's "This video is private" overlay, because the editor never hands the player a playback token. core/video previews behave the same in GBK today; fixing it needs Jetpack changes and is out of scope.

🤖 Generated with Claude Code

dcalhoun and others added 4 commits November 24, 2026 20:42
Shows a read-only preview and an explanation in place of core's missing
block warning, so the block's markup is kept as is.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
With videopress/video disallowed, Jetpack converts each block to
core/video on open, dropping its VideoPress settings and marking the
post as changed. Warns if the filter goes missing while Jetpack
VideoPress is active, in case it was renamed.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Runs the initializer after plugin scripts load and before the first
render; removing the filter later doesn't stop the conversion.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The separate notice card read as its own block, apart from the video.
A themed caption joined to the video reads as one unit and follows the
theme's colors.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@dcalhoun dcalhoun added the [Type] Bug An existing feature does not function as intended label Nov 25, 2026
@wpmobilebot

wpmobilebot commented Nov 25, 2026 •

Copy link
Copy Markdown

XCFramework Build

This PR's XCFramework is available for testing. Add the following to your Package.swift:

.package(url: "https://github.com/wordpress-mobile/GutenbergKit", branch: "pr-build/941")

Built from 79d5eba

dcalhoun and others added 5 commits November 24, 2026 22:08
The sandbox sized itself to its content, which ran taller than the
player and left a black band under the video. Core embeds size by
aspect ratio for the same reason.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Users can check which video a block holds. As in core embeds, the first
tap selects the block and later taps reach the player.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Jetpack's v6-to-v5 conversion can't be present without plugins, so loading the chunk and its stylesheet only delayed first render.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Core-data caches a failed oEmbed fetch, so a flaky connection left an empty box until the editor reloaded. Mirrors core embeds' message and Try again button, reusing their translated strings.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Themes such as Twenty Twenty-One center figcaptions, which split the notice text from its icon. Colors and fonts still follow the theme.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

[Type] Bug An existing feature does not function as intended

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants