Skip to content

Commit

Permalink
rename role to __experimentalRole
Browse files Browse the repository at this point in the history
  • Loading branch information
ntsekouras committed Apr 13, 2021
1 parent 081e257 commit edd5588
Show file tree
Hide file tree
Showing 11 changed files with 25 additions and 26 deletions.
9 changes: 4 additions & 5 deletions packages/block-editor/src/components/block-switcher/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -69,10 +69,6 @@ export const BlockSwitcherDropdownMenu = ( { clientIds, blocks } ) => {
? getBlockType( firstBlockName )?.icon
: stack;
}
const _patterns = __experimentalGetPatternTransformItems(
blocks,
rootClientId
);
return {
possibleBlockTransformations: getBlockTransformItems(
blocks,
Expand All @@ -81,7 +77,10 @@ export const BlockSwitcherDropdownMenu = ( { clientIds, blocks } ) => {
hasBlockStyles: !! styles?.length,
icon: _icon,
blockTitle: getBlockType( firstBlockName ).title,
patterns: _patterns,
patterns: __experimentalGetPatternTransformItems(
blocks,
rootClientId
),
};
},
[ clientIds, blocks, blockInformation?.icon ]
Expand Down
2 changes: 1 addition & 1 deletion packages/block-library/src/heading/block.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
"source": "html",
"selector": "h1,h2,h3,h4,h5,h6",
"default": "",
"role": "content"
"__experimentalRole": "content"
},
"level": {
"type": "number",
Expand Down
4 changes: 2 additions & 2 deletions packages/block-library/src/list/block.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
"ordered": {
"type": "boolean",
"default": false,
"role": "content"
"__experimentalRole": "content"
},
"values": {
"type": "string",
Expand All @@ -15,7 +15,7 @@
"multiline": "li",
"__unstableMultilineWrapperTags": [ "ol", "ul" ],
"default": "",
"role": "content"
"__experimentalRole": "content"
},
"type": {
"type": "string"
Expand Down
2 changes: 1 addition & 1 deletion packages/block-library/src/paragraph/block.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
"source": "html",
"selector": "p",
"default": "",
"role": "content"
"__experimentalRole": "content"
},
"dropCap": {
"type": "boolean",
Expand Down
2 changes: 1 addition & 1 deletion packages/block-library/src/preformatted/block.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
"selector": "pre",
"default": "",
"__unstablePreserveWhiteSpace": true,
"role": "content"
"__experimentalRole": "content"
}
},
"supports": {
Expand Down
4 changes: 2 additions & 2 deletions packages/block-library/src/pullquote/block.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,14 +8,14 @@
"source": "html",
"selector": "blockquote",
"multiline": "p",
"role": "content"
"__experimentalRole": "content"
},
"citation": {
"type": "string",
"source": "html",
"selector": "cite",
"default": "",
"role": "content"
"__experimentalRole": "content"
},
"mainColor": {
"type": "string"
Expand Down
4 changes: 2 additions & 2 deletions packages/block-library/src/quote/block.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,14 +9,14 @@
"selector": "blockquote",
"multiline": "p",
"default": "",
"role": "content"
"__experimentalRole": "content"
},
"citation": {
"type": "string",
"source": "html",
"selector": "cite",
"default": "",
"role": "content"
"__experimentalRole": "content"
},
"align": {
"type": "string"
Expand Down
6 changes: 3 additions & 3 deletions packages/block-library/src/search/block.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
"attributes": {
"label": {
"type": "string",
"role": "content"
"__experimentalRole": "content"
},
"showLabel": {
"type": "boolean",
Expand All @@ -14,7 +14,7 @@
"placeholder": {
"type": "string",
"default": "",
"role": "content"
"__experimentalRole": "content"
},
"width": {
"type": "number"
Expand All @@ -24,7 +24,7 @@
},
"buttonText": {
"type": "string",
"role": "content"
"__experimentalRole": "content"
},
"buttonPosition": {
"type": "string",
Expand Down
2 changes: 1 addition & 1 deletion packages/block-library/src/verse/block.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
"selector": "pre",
"default": "",
"__unstablePreserveWhiteSpace": true,
"role": "content"
"__experimentalRole": "content"
},
"textAlign": {
"type": "string"
Expand Down
13 changes: 6 additions & 7 deletions packages/blocks/src/api/test/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -321,15 +321,15 @@ describe( '__experimentalGetBlockAttributesNamesByRole', () => {
},
content: {
type: 'boolean',
role: 'content',
__experimentalRole: 'content',
},
level: {
type: 'number',
role: 'content',
__experimentalRole: 'content',
},
color: {
type: 'string',
role: 'other',
__experimentalRole: 'other',
},
},
save: noop,
Expand Down Expand Up @@ -365,10 +365,9 @@ describe( '__experimentalGetBlockAttributesNamesByRole', () => {
).toEqual( [] );
} );
it( 'should return all attribute names if no role is provided', () => {
const res = __experimentalGetBlockAttributesNamesByRole(
'core/test-block-1'
);
expect( res ).toEqual(
expect(
__experimentalGetBlockAttributesNamesByRole( 'core/test-block-1' )
).toEqual(
expect.arrayContaining( [ 'align', 'content', 'level', 'color' ] )
);
} );
Expand Down
3 changes: 2 additions & 1 deletion packages/blocks/src/api/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -290,6 +290,7 @@ export function __experimentalGetBlockAttributesNamesByRole( name, role ) {
const attributesNames = Object.keys( attributes );
if ( ! role ) return attributesNames;
return attributesNames.filter(
( attributeName ) => attributes[ attributeName ]?.role === role
( attributeName ) =>
attributes[ attributeName ]?.__experimentalRole === role
);
}

0 comments on commit edd5588

Please sign in to comment.