diff --git a/packages/block-library/src/file/block.json b/packages/block-library/src/file/block.json index 693fecc342161a..0c36a06aa9a55e 100644 --- a/packages/block-library/src/file/block.json +++ b/packages/block-library/src/file/block.json @@ -32,8 +32,7 @@ "downloadButtonText": { "type": "string", "source": "html", - "selector": "a[download]", - "default": "Download" + "selector": "a[download]" } } } diff --git a/packages/block-library/src/file/edit.js b/packages/block-library/src/file/edit.js index 3ce7211eceb854..9aa76977cc2cec 100644 --- a/packages/block-library/src/file/edit.js +++ b/packages/block-library/src/file/edit.js @@ -29,7 +29,7 @@ import { } from '@wordpress/block-editor'; import { mediaUpload } from '@wordpress/editor'; import { Component, Fragment } from '@wordpress/element'; -import { __ } from '@wordpress/i18n'; +import { __, _x } from '@wordpress/i18n'; /** * Internal dependencies @@ -55,8 +55,8 @@ class FileEdit extends Component { } componentDidMount() { - const { attributes, noticeOperations } = this.props; - const { href } = attributes; + const { attributes, noticeOperations, setAttributes } = this.props; + const { downloadButtonText, href } = attributes; // Upload a file drag-and-dropped into the editor if ( isBlobURL( href ) ) { @@ -73,6 +73,12 @@ class FileEdit extends Component { revokeBlobURL( href ); } + + if ( downloadButtonText === undefined ) { + setAttributes( { + downloadButtonText: _x( 'Download', 'button label' ), + } ); + } } componentDidUpdate( prevProps ) {