-
Notifications
You must be signed in to change notification settings - Fork 4.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Refactor File block to use block.json metadata #14862
Conversation
type: 'string', | ||
source: 'html', | ||
selector: 'a[download]', | ||
default: _x( 'Download', 'button label' ), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It was discussed on WordPress.org Slack last week (link requires registration):
https://wordpress.slack.com/archives/C5UNMSU4R/p1554217879115800
The conclusion was that:
This doesn't really sound like a "default" but an attribute set when the block is first inserted.
To make it work with block.json
I converted it to the static text. In the previous form, it was confusing enough. It wasn't triggering block validation when editing the same post with a different locale selected, however, it's worth pointing out that the locale of the website may differ from the one that the person editing uses. It's better to make it static and let the author update this value.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I guess the decision here was to set this initially to the value of the author's language. In other words, we could use componentDidMount
or useEffect
in the edit
function of the block to set its value when the block is first created. This has the downside of creating an "undo" level maybe but maybe that's fine?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'll give it a go and see how it works 👍
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This has the downside of creating an "undo" level maybe but maybe that's fine?
It is precisely what happens. Is there a way to skip adding undo level when calling setAttributes
? I noticed that this is an issue also when using drag & drop with files. Triggering undo
puts the block in a bizarre pulsing state in UI.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice, thanks for linking with the issue. It looks like it isn’t a blocker for this PR 👍
16a92f9
to
dd981c3
Compare
dd981c3
to
80e6f41
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Seems to work as intended.
Description
Partially implements #13693:
name
,category
andattributes
inblock.json
transforms
orsave
to their own filesHow has this been tested?
Ensure that File block still works as before.