Repository navigation
Content-only: remove mapping and args in favor of DataForm API
#74575
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
Changes from all commits
7252f85
93f4db5
4501bbf
7eff7cb
3a37a81
81e1ae0
6a6fae7
079123f
976c77b
808d49b
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -42,19 +42,25 @@ if ( window.__experimentalContentOnlyInspectorFields ) { | |
| id: 'audio', | ||
| label: __( 'Audio' ), | ||
| type: 'media', | ||
| mapping: { | ||
| id: 'id', | ||
| url: 'src', | ||
| }, | ||
| args: { | ||
| Edit: { | ||
| control: 'media', // TODO: replace with custom component | ||
| allowedTypes: [ 'audio' ], | ||
| multiple: false, | ||
| }, | ||
| getValue: ( { item } ) => ( { | ||
| id: item.id, | ||
| url: item.src, | ||
| } ), | ||
| setValue: ( { value } ) => ( { | ||
| id: value.id, | ||
| src: value.url, | ||
| } ), | ||
|
Comment on lines
+50
to
+57
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. One of the reasons I'd avoided moving these functions here is that a lot of this config would ideally be migrated to the attribute definition in block.json where it isn't possible to define a function. The same goes for
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Absolutely, we need this to be declarative, agree to that. The value of this direction is that it highlights as early as possible what we need to improve in the Fields/DataForm API to ship content-only. It is telling us the "problems to solve". Whereas, circumventing the APIs by using |
||
| }, | ||
| { | ||
| id: 'caption', | ||
| label: __( 'Caption' ), | ||
| type: 'richtext', | ||
| type: 'text', | ||
| Edit: 'rich-text', // TODO: replace with custom component | ||
| }, | ||
| ]; | ||
| settings[ formKey ] = { | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -66,19 +66,28 @@ if ( window.__experimentalContentOnlyInspectorFields ) { | |
| id: 'background', | ||
| label: __( 'Background' ), | ||
| type: 'media', | ||
| mapping: { | ||
| mediaType: 'backgroundType', | ||
| id: 'id', | ||
| url: 'url', | ||
| alt: 'alt', | ||
| featuredImage: 'useFeaturedImage', | ||
| }, | ||
| args: { | ||
| Edit: { | ||
| control: 'media', // TODO: replace with custom component | ||
| // TODO - How to support custom gradient? | ||
| // Build it into Media, or use a custom control? | ||
| allowedTypes: [ 'image', 'video' ], | ||
| multiple: false, | ||
| useFeaturedImage: true, | ||
| }, | ||
| getValue: ( { item } ) => ( { | ||
| id: item.id, | ||
| url: item.url, | ||
| alt: item.alt, | ||
| mediaType: item.backgroundType, | ||
| featuredImage: item.useFeaturedImage, | ||
| } ), | ||
| setValue: ( { value } ) => ( { | ||
| id: value.id, | ||
| url: value.url, | ||
| alt: value.alt, | ||
| mediaType: value.backgroundType, | ||
| useFeaturedImage: value.featuredImage, | ||
| } ), | ||
|
Comment on lines
+77
to
+90
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Similarly, the block attribute for this block is
Whereas it should be selected like this (trunk):
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Ah, thanks for the testing. I've got some mapping reversed, pushed some fixes. I'm going to test now .
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I've tested this block, and it's working as trunk. Note that there's an issue by which the second time you select a media (e.g., from image to video or vice versa) the second media doesn't show up. This also happens in This is trunk: Screen.Recording.2026-01-14.at.11.44.38.movThis is this branch: Screen.Recording.2026-01-14.at.11.49.53.mov |
||
| }, | ||
| ]; | ||
| settings[ formKey ] = { | ||
|
|
||



Uh oh!
There was an error while loading. Please reload this page.
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 is the kind of thing that's hidden behind a custom API: we were using the mapping instead of the Edit config to decide whether to enable featuredImage for the media control. See cover block.