-
Notifications
You must be signed in to change notification settings - Fork 4.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Comments block: Change ID to
core/comments
(#40506)
* Rename block id and add fallback * Update parent and ancestor fields * Update block ID in schema def * Add deprecation and bypass generated classname This is not a real fix. It's just a fast way to show where is the problem. * Add `apiVersion` to the comments block deprecation * Add inline comment to point to block deprecation * Support custom class names in deprecation * Refactor deprecation to its own file * Add fallback class of previous block name * Add legacy class name during block conversion * Update fixtures * Add test fixture for the deprecation * Fix deprecation * Add explanatory comment * Update a comment Co-authored-by: Bernie Reiter <[email protected]> Co-authored-by: Luis Herranz <[email protected]> Co-authored-by: Michal Czaplinski <[email protected]>
- Loading branch information
1 parent
62a2fa1
commit bbd198d
Showing
20 changed files
with
593 additions
and
202 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
/** | ||
* WordPress dependencies | ||
*/ | ||
import { InnerBlocks, useBlockProps } from '@wordpress/block-editor'; | ||
|
||
// v1: Deprecate the initial version of the block which was called "Comments | ||
// Query Loop" instead of "Comments". | ||
const v1 = { | ||
attributes: { | ||
tagName: { | ||
type: 'string', | ||
default: 'div', | ||
}, | ||
}, | ||
apiVersion: 2, | ||
supports: { | ||
align: [ 'wide', 'full' ], | ||
html: false, | ||
color: { | ||
gradients: true, | ||
link: true, | ||
__experimentalDefaultControls: { | ||
background: true, | ||
text: true, | ||
link: true, | ||
}, | ||
}, | ||
}, | ||
save( { attributes: { tagName: Tag } } ) { | ||
const blockProps = useBlockProps.save(); | ||
const { className } = blockProps; | ||
const classes = className?.split( ' ' ) || []; | ||
|
||
// The ID of the previous version of the block | ||
// didn't have the `wp-block-comments` class, | ||
// so we need to remove it here in order to mimic it. | ||
const newClasses = classes?.filter( | ||
( cls ) => cls !== 'wp-block-comments' | ||
); | ||
const newBlockProps = { | ||
...blockProps, | ||
className: newClasses.join( ' ' ), | ||
}; | ||
|
||
return ( | ||
<Tag { ...newBlockProps }> | ||
<InnerBlocks.Content /> | ||
</Tag> | ||
); | ||
}, | ||
}; | ||
|
||
export default [ v1 ]; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
33 changes: 0 additions & 33 deletions
33
test/integration/fixtures/blocks/core__comments-query-loop.html
This file was deleted.
Oops, something went wrong.
33 changes: 0 additions & 33 deletions
33
test/integration/fixtures/blocks/core__comments-query-loop.serialized.html
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
<!-- wp:comments {"className":"comments-post-extra"} --> | ||
<div class="wp-block-comments comments-post-extra"><!-- wp:comments-title /--> | ||
|
||
<!-- wp:comment-template --> | ||
<!-- wp:columns --> | ||
<div class="wp-block-columns"><!-- wp:column {"width":"40px"} --> | ||
<div class="wp-block-column" style="flex-basis:40px"><!-- wp:avatar {"size":40,"style":{"border":{"radius":"20px"}}} /--></div> | ||
<!-- /wp:column --> | ||
|
||
<!-- wp:column --> | ||
<div class="wp-block-column"><!-- wp:comment-author-name {"fontSize":"small"} /--> | ||
|
||
<!-- wp:group {"style":{"spacing":{"margin":{"top":"0px","bottom":"0px"}}},"layout":{"type":"flex"}} --> | ||
<div class="wp-block-group" style="margin-top:0px;margin-bottom:0px"><!-- wp:comment-date {"fontSize":"small"} /--> | ||
|
||
<!-- wp:comment-edit-link {"fontSize":"small"} /--></div> | ||
<!-- /wp:group --> | ||
|
||
<!-- wp:comment-content /--> | ||
|
||
<!-- wp:comment-reply-link {"fontSize":"small"} /--></div> | ||
<!-- /wp:column --></div> | ||
<!-- /wp:columns --> | ||
<!-- /wp:comment-template --> | ||
|
||
<!-- wp:comments-pagination /--> | ||
|
||
<!-- wp:post-comments-form /--></div> | ||
<!-- /wp:comments --> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.