Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 13 additions & 2 deletions packages/block-editor/src/hooks/block-bindings.js
Original file line number Diff line number Diff line change
Expand Up @@ -342,9 +342,20 @@ export const BlockBindingsPanel = ( { name: blockName, metadata } ) => {
( select ) => {
const { __experimentalBlockBindingsSupportedAttributes } =
select( blockEditorStore ).getSettings();
const _bindableAttributes =
const supportedAttributes =
__experimentalBlockBindingsSupportedAttributes?.[ blockName ];
if ( ! _bindableAttributes || _bindableAttributes.length === 0 ) {
if ( ! supportedAttributes || supportedAttributes.length === 0 ) {
return EMPTY_OBJECT;
}

// Filter to only include attributes that have a source (UI compatible).
const blockAttributes = getBlockType( blockName ).attributes;
const _bindableAttributes = supportedAttributes.filter(
( attribute ) =>
blockAttributes[ attribute ]?.bindings?.ui === 'active'
);

if ( _bindableAttributes.length === 0 ) {
return EMPTY_OBJECT;
}

Expand Down
20 changes: 16 additions & 4 deletions packages/block-library/src/button/block.json
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,10 @@
"source": "attribute",
"selector": "a",
"attribute": "href",
"role": "content"
"role": "content",
"bindings": {
"ui": "active"
}
},
"title": {
"type": "string",
Expand All @@ -39,21 +42,30 @@
"type": "rich-text",
"source": "rich-text",
"selector": "a,button",
"role": "content"
"role": "content",
"bindings": {
"ui": "active"
}
},
"linkTarget": {
"type": "string",
"source": "attribute",
"selector": "a",
"attribute": "target",
"role": "content"
"role": "content",
"bindings": {
"ui": "active"
}
},
"rel": {
"type": "string",
"source": "attribute",
"selector": "a",
"attribute": "rel",
"role": "content"
"role": "content",
"bindings": {
"ui": "active"
}
},
"placeholder": {
"type": "string"
Expand Down
5 changes: 4 additions & 1 deletion packages/block-library/src/heading/block.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,10 @@
"type": "rich-text",
"source": "rich-text",
"selector": "h1,h2,h3,h4,h5,h6",
"role": "content"
"role": "content",
"bindings": {
"ui": "active"
}
},
"level": {
"type": "number",
Expand Down
20 changes: 16 additions & 4 deletions packages/block-library/src/image/block.json
Original file line number Diff line number Diff line change
Expand Up @@ -25,15 +25,21 @@
"source": "attribute",
"selector": "img",
"attribute": "src",
"role": "content"
"role": "content",
"bindings": {
"ui": "active"
}
},
"alt": {
"type": "string",
"source": "attribute",
"selector": "img",
"attribute": "alt",
"default": "",
"role": "content"
"role": "content",
"bindings": {
"ui": "active"
}
},
"caption": {
"type": "rich-text",
Expand All @@ -52,7 +58,10 @@
"source": "attribute",
"selector": "img",
"attribute": "title",
"role": "content"
"role": "content",
"bindings": {
"ui": "active"
}
},
"href": {
"type": "string",
Expand All @@ -75,7 +84,10 @@
},
"id": {
"type": "number",
"role": "content"
"role": "content",
"bindings": {
"ui": "active"
}
},
"width": {
"type": "string"
Expand Down
5 changes: 4 additions & 1 deletion packages/block-library/src/paragraph/block.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,10 @@
"type": "rich-text",
"source": "rich-text",
"selector": "p",
"role": "content"
"role": "content",
"bindings": {
"ui": "active"
}
},
"dropCap": {
"type": "boolean",
Expand Down
12 changes: 12 additions & 0 deletions schemas/json/block.json
Original file line number Diff line number Diff line change
Expand Up @@ -144,6 +144,18 @@
}
]
},
"bindings": {
"type": "object",
"description": "Defines if the attribute can be bound.",
"properties": {
"ui": {
"description": "Defines the bindings UI state for the attribute.",
"type": "string",
"enum": [ "hidden", "active" ],
"default": "hidden"
}
}
},
"enum": {
"description": "An attribute can be defined as one of a fixed set of values. This is specified by an enum, which contains an array of allowed values:",
"type": "array",
Expand Down
91 changes: 0 additions & 91 deletions test/e2e/specs/editor/various/block-bindings/post-data.spec.js

This file was deleted.

Loading