-
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
Block library: Try to use Babel plugins to inline block.json metadata #14551
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
{ | ||
"name": "core/text-columns", | ||
"icon": "columns", | ||
"category": "layout", | ||
"attributes": { | ||
"content": { | ||
"type": "array", | ||
"source": "query", | ||
"selector": "p", | ||
"query": { | ||
"children": { | ||
"type": "string", | ||
"source": "html" | ||
} | ||
}, | ||
"default": [ {}, {} ] | ||
}, | ||
"columns": { | ||
"type": "number", | ||
"default": 2 | ||
}, | ||
"width": { | ||
"type": "string" | ||
} | ||
} | ||
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 feel like I have a lot to say about these :), can we start with something very small like the "category"? 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 know this PR is more about the way javascript consumes this file rather than about the content of the file directly and that's why I suggest to keep it to the minimum for the moment. 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 don't care what we include, I opted for everything that server is able to expose to the client: 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. Agreed it's not very important for now (to filter or not) but the shape of some of these properties might need to be changed later. 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.
|
||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -18,7 +18,14 @@ import { | |
} from '@wordpress/block-editor'; | ||
import deprecated from '@wordpress/deprecated'; | ||
|
||
export const name = 'core/text-columns'; | ||
/** | ||
* Internal dependencies | ||
*/ | ||
import metadata from './block.json'; | ||
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. |
||
|
||
const { name } = metadata; | ||
|
||
export { metadata, name }; | ||
|
||
export const settings = { | ||
// Disable insertion as this block is deprecated and ultimately replaced by the Columns block. | ||
|
@@ -30,32 +37,6 @@ export const settings = { | |
|
||
description: __( 'This block is deprecated. Please use the Columns block instead.' ), | ||
|
||
icon: 'columns', | ||
|
||
category: 'layout', | ||
|
||
attributes: { | ||
content: { | ||
type: 'array', | ||
source: 'query', | ||
selector: 'p', | ||
query: { | ||
children: { | ||
type: 'string', | ||
source: 'html', | ||
}, | ||
}, | ||
default: [ {}, {} ], | ||
}, | ||
columns: { | ||
type: 'number', | ||
default: 2, | ||
}, | ||
width: { | ||
type: 'string', | ||
}, | ||
}, | ||
|
||
transforms: { | ||
to: [ | ||
{ | ||
|
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.
Is this something that can be useful for our default preset?
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.
Yes, I think it would land there eventually once proved that we like this approach 👍
By the way, this plugin still depends on Babel 6. Not sure it's an issue, just noting.