Skip to content
Closed
Show file tree
Hide file tree
Changes from 1 commit
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
Prev Previous commit
Next Next commit
Revert temporary changes to files copied in the build process
  • Loading branch information
gziolo committed Jul 27, 2021
commit 6f0c9dfe658b2e224976fc072deeee7b67545fff
10 changes: 6 additions & 4 deletions src/wp-includes/blocks/file.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,17 +6,19 @@
*/

/**
* When the `core/file` block is rendering, check if we need to enqueue the `'wp-block-file-view` script.
* When the `core/file` block is rendering, check if we need to enqueue the `'wp-block-library-file` script.
*
* @param array $attributes The block attributes.
* @param array $content The block content.
*
* @return string Returns the block content.
*/
function render_block_core_file( $attributes, $content ) {
$should_load_view_script = ! empty( $attributes['displayPreview'] ) && ! wp_script_is( 'wp-block-file-view' );
if ( $should_load_view_script ) {
wp_enqueue_script( 'wp-block-file-view' );
if ( ! empty( $attributes['displayPreview'] ) ) {
// Check if it's already enqueued, so we don't add the inline script multiple times.
if ( ! wp_script_is( 'wp-block-library-file' ) ) {
wp_enqueue_script( 'wp-block-library-file', plugins_url( 'file/frontend.js', __FILE__ ) );
}
}

return $content;
Expand Down
3 changes: 1 addition & 2 deletions src/wp-includes/blocks/file/block.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
"title": "File",
"category": "media",
"description": "Add a link to a downloadable file.",
"keywords": ["document", "pdf", "download"],
"keywords": [ "document", "pdf", "download" ],
"textdomain": "default",
"attributes": {
"id": {
Expand Down Expand Up @@ -51,7 +51,6 @@
"anchor": true,
"align": true
},
"viewScript": "file:./view.min.js",
"editorStyle": "wp-block-file-editor",
"style": "wp-block-file"
}
4 changes: 2 additions & 2 deletions webpack.config.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
const mediaConfig = require( './tools/webpack/media' );
const blocksConfig = require( './tools/webpack/blocks' );
const mediaConfig = require( './tools/webpack/media' );
const packagesConfig = require( './tools/webpack/packages' );

module.exports = function( env = { environment: "production", watch: false, buildTarget: false } ) {
Expand All @@ -12,9 +12,9 @@ module.exports = function( env = { environment: "production", watch: false, buil
}

const config = [
blocksConfig( env ),
mediaConfig( env ),
packagesConfig( env ),
blocksConfig( env ),
];

return config;
Expand Down