Skip to content

Commit

Permalink
Fix for inline scripts
Browse files Browse the repository at this point in the history
  • Loading branch information
ellatrix committed May 19, 2021
1 parent 7a17801 commit 7245466
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 5 deletions.
4 changes: 2 additions & 2 deletions lib/client-assets.php
Original file line number Diff line number Diff line change
Expand Up @@ -753,14 +753,14 @@ function gutenberg_extend_block_editor_styles_html() {

$scripts = ob_get_clean();

$editor_styles = wp_json_encode(
$editor_assets = wp_json_encode(
array(
'styles' => $styles,
'scripts' => $scripts,
)
);

echo "<script>window.__editorAssets = $editor_styles</script>";
echo "<script>window.__editorAssets = $editor_assets</script>";
}
add_action( 'admin_footer-toplevel_page_gutenberg-edit-site', 'gutenberg_extend_block_editor_styles_html' );
add_action( 'admin_footer-post.php', 'gutenberg_extend_block_editor_styles_html' );
Expand Down
10 changes: 7 additions & 3 deletions packages/block-editor/src/components/iframe/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -140,9 +140,13 @@ async function loadScript( doc, { id, src } ) {
return new Promise( ( resolve, reject ) => {
const script = doc.createElement( 'script' );
script.id = id;
script.src = src;
script.onload = () => resolve();
script.onerror = () => reject();
if ( src ) {
script.src = src;
script.onload = () => resolve();
script.onerror = () => reject();
} else {
resolve();
}
doc.head.appendChild( script );
} );
}
Expand Down

0 comments on commit 7245466

Please sign in to comment.