-
Notifications
You must be signed in to change notification settings - Fork 4.8k
Block Bindings: Open the stable editor APIs #65713
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
40811d4
73840b2
ba6b920
3d36af7
1fbfde4
f3a9e4d
a1821c7
9de4c6b
a2872b5
a5792ef
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 |
|---|---|---|
| @@ -1,2 +1,3 @@ | ||
| export { default as transformStyles } from './transform-styles'; | ||
| export { default as getPxFromCssUnit } from './get-px-from-css-unit'; | ||
| export { useBlockBindingsUtils } from './block-bindings'; |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -115,6 +115,26 @@ _Returns_ | |
|
|
||
| - `string[]`: The attribute names that have the provided role. | ||
|
|
||
| ### getBlockBindingsSource | ||
|
|
||
| Returns a registered block bindings source by its name. | ||
|
|
||
| _Parameters_ | ||
|
|
||
| - _name_ `string`: Block bindings source name. | ||
|
|
||
| _Returns_ | ||
|
|
||
| - `?Object`: Block bindings source. | ||
|
|
||
| ### getBlockBindingsSources | ||
|
|
||
| Returns all registered block bindings sources. | ||
|
|
||
| _Returns_ | ||
|
|
||
| - `Array`: Block bindings sources. | ||
|
|
||
| ### getBlockContent | ||
|
|
||
| Given a block object, returns the Block's Inner HTML markup. | ||
|
|
@@ -492,6 +512,36 @@ _Returns_ | |
|
|
||
| - `Array`: A list of blocks. | ||
|
|
||
| ### registerBlockBindingsSource | ||
|
|
||
| Registers a new block bindings source with an object defining its behavior. Once registered, the source is available to be connected to the supported block attributes. | ||
|
|
||
| _Usage_ | ||
|
|
||
| ```js | ||
| import { _x } from '@wordpress/i18n'; | ||
| import { registerBlockBindingsSource } from '@wordpress/blocks'; | ||
|
|
||
| registerBlockBindingsSource( { | ||
| name: 'plugin/my-custom-source', | ||
| label: _x( 'My Custom Source', 'block bindings source' ), | ||
| usesContext: [ 'postType' ], | ||
| getValues: getSourceValues, | ||
| setValues: updateMyCustomValuesInBatch, | ||
| canUserEditValue: () => true, | ||
| } ); | ||
| ``` | ||
|
|
||
| _Parameters_ | ||
|
|
||
| - _source_ `Object`: Properties of the source to be registered. | ||
|
Member
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. Are all of the properties mandatory?
Contributor
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. No, they are not. I wrapped the optional ones with
Member
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, I missed that nuance. I would welcome the update to the description of the parameters to make it easier to discover that some params are optional.
Contributor
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. Added in this commit: a5792ef |
||
| - _source.name_ `string`: The unique and machine-readable name. | ||
| - _source.label_ `[string]`: Human-readable label. Optional when it is defined in the server. | ||
| - _source.usesContext_ `[Array]`: Optional array of context needed by the source only in the editor. | ||
| - _source.getValues_ `[Function]`: Optional function to get the values from the source. | ||
| - _source.setValues_ `[Function]`: Optional function to update multiple values connected to the source. | ||
| - _source.canUserEditValue_ `[Function]`: Optional function to determine if the user can edit the value. | ||
|
|
||
| ### registerBlockCollection | ||
|
|
||
| Registers a new block collection to group blocks in the same namespace in the inserter. | ||
|
|
@@ -793,6 +843,22 @@ _Returns_ | |
|
|
||
| - `Array`: Updated Block list. | ||
|
|
||
| ### unregisterBlockBindingsSource | ||
|
|
||
| Unregisters a block bindings source by providing its name. | ||
|
|
||
| _Usage_ | ||
|
|
||
| ```js | ||
| import { unregisterBlockBindingsSource } from '@wordpress/blocks'; | ||
|
|
||
| unregisterBlockBindingsSource( 'plugin/my-custom-source' ); | ||
| ``` | ||
|
|
||
| _Parameters_ | ||
|
|
||
| - _name_ `string`: The name of the block bindings source to unregister. | ||
|
|
||
| ### unregisterBlockStyle | ||
|
|
||
| Unregisters a block style for the given block. | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.