-
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: Add new Edit Comment Link block #35965
Conversation
There are some conflicts to resolve in |
$link_atts = ''; | ||
|
||
if ( ! empty( $attributes['linkTarget'] ) ) { | ||
$link_atts .= sprintf( 'target="%s"', $attributes['linkTarget'] ); |
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.
We should also escape the link target in case it gets updated manually in the post content.
Co-authored-by: Carolina Nymark <[email protected]>
Co-authored-by: Carolina Nymark <[email protected]>
5e9aea3
to
1299e3b
Compare
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.
Excellent work. Everything tests well.
There are two known bugs that I could observe here as well. They are related to how Global Styles work. A detailed explanation is included in the PR with the Comment Reply Link block: #35774 (comment).
As a follow-up, we can also add a text align control to mirror how the Comment Reply Link works.
import { __ } from '@wordpress/i18n'; | ||
|
||
export default function Edit( { | ||
attributes: { className, linkTarget }, |
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 the className
attribute passed always passed to the blocks's edit method in a way that I'm not aware of? Otherwise, I think you won't need it here because it's not defined in the block.json
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.
There are two features enabled by default for every block:
https://github.com/WordPress/gutenberg/blob/trunk/docs/reference-guides/block-api/block-supports.md#classname
https://github.com/WordPress/gutenberg/blob/trunk/docs/reference-guides/block-api/block-supports.md#customclassname
The second one injects a custom class name using a className
attribute. I think that the handling is now automated with useBlockProps
so you no longer need to explicitly pass it to useBlockProps
, but it was a requirement for blocks in the past. I think we should remove className
handling here to avoid confusion.
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.
I need to test it because I see the same usage as here also in other blocks. It's very inconsistent across blocks.
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, we can safely remove the className
handling from here. It is redundant. Well, it doesn't break anything. I'm opening a PR soon with more changes.
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.
oh, I see! Thanks, Greg!
Description
Fixes #30577
Replaces PR #30671. Props to @diedexx for the initial work.
Adds a Edit Comment Link block which can be used inside a Post Comment block which renders the edit link if the logged in user has the right capabilities to edit the comment.
How has this been tested?
I've placed a Post Comment block on a post and selected an id of an existing comment. In that block, I've placed the new Edit Comment block and modified all available properties in the sidebar and checked if these changes were reflected on the published post.->
Screenshots
Video summary:
https://www.loom.com/share/30e0fa4f01fb4f418ee16f1dcfca5aaa
Types of changes
New feature - New block type: Edit Comment.
Checklist: