Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 19 additions & 2 deletions inc/Services/Editor.php
Original file line number Diff line number Diff line change
Expand Up @@ -48,9 +48,21 @@ public function boot( Service_Container $container ): void {
$this->register_custom_block_styles();

/**
* Load editor JS for ADMIN
* Load editor JS
*
* WP 6.3+ isolates the editor canvas in an iframe (`iframe[name="editor-canvas"]`).
* This affects all blocks, but ACF Blocks V3 (`blockVersion: 3`) rely on it: their PHP
* render templates (and ARI lazyload markup) are injected into that iframe on each preview
* refresh — not into the admin shell where `enqueue_block_editor_assets` loads scripts.
*
* - `enqueue_block_editor_assets` → admin shell only (outside the iframe).
* - `enqueue_block_assets` → iframe + front end (guarded with is_admin() below).
*
* lazySizes must therefore load via `enqueue_block_assets` to unveil `.lazyload` images
* in ACF V3 block previews. Other blocks (e.g. ServerSideRender) may still work without
* this, but ACF V3 previews will stay invisible until a DOM mutation triggers lazySizes.
*/
add_action( 'enqueue_block_editor_assets', [ $this, 'admin_editor_script' ] );
add_action( 'enqueue_block_assets', [ $this, 'admin_editor_script' ] );
/**
* White list of gutenberg blocks
*/
Expand All @@ -77,6 +89,11 @@ private function style(): void {
* Editor script
*/
public function admin_editor_script(): void {
// enqueue_block_assets also runs on the front end; skip outside wp-admin.
if ( ! is_admin() ) {
return;
}
Comment thread
rsanchez-beapi marked this conversation as resolved.

$file = $this->assets->get_min_file( 'editor.js' ) ?: 'editor.js';
$filepath = 'dist/' . $file;

Expand Down
Loading