-
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
[Tiny PR] Paste: do not force blocks for empty rich text #17140
Conversation
3d98c3e
to
80173db
Compare
I can confirm (with limited testing) that this fixes my issue. |
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.
✅ Testing this branch using the same techniques I used in #16990 (comment) works as expected.
I don't know enough about __unstableEmbedURLOnPaste
or the rich text component to provide a code review I'm afraid. If I find myself at a loose end, I'll dive in to the code to see if I can figure it out but I can't promise that will happen.
@@ -195,6 +195,7 @@ class ParagraphBlock extends Component { | |||
onRemove={ onReplace ? () => onReplace( [] ) : undefined } | |||
aria-label={ content ? __( 'Paragraph block' ) : __( 'Empty block; start writing or type forward slash to choose a block' ) } | |||
placeholder={ placeholder || __( 'Start writing or type / to choose a block' ) } | |||
__unstableEmbedURLOnPaste |
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 this prop newly introduced in this PR? (Could not find its reference anywhere else in the codebase.) What is its purpose?
Not sure, what's the convention for such unstable new props. But can we add some doc on this? Maybe inline comment, readme, somewhere else? Maybe better prop naming to reflect its use case better?
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 can provide an inline comment, but I thought the name is quite clear: it enables embedding when the user pastes a URL. This prop should normally only be used on the core paragraph block. We shouldn't document unstable props in a readme file.
An unstable API is one which serves as a means to an end. It is not desired to ever be converted into a public API.
https://developer.wordpress.org/block-editor/contributors/develop/coding-guidelines/
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've done some further research on paste handling and modes since my earlier comment. Now feel confident enough to approve this.
Further testing based on my enhanced knowledge worked.
@peterwilsoncc Thank you very much! I'm happy you felt like exploring raw handling. :) |
80173db
to
eca8fc0
Compare
Description
Fixes #16990. There's probably similar older issues.
Also blocks introducing caption splitting as you wouldn't be able to paste in an empty caption.
Reverts some of #3326, introduced 2 years ago for embedding on URL paste. I've solved that problem differently here.
How has this been tested?
See #16990. Create an empty heading. Copy paste a piece of the URL in the address bar. Expect a heading with the pasted text. On master it would be converted to a paragraph.
Paste an embeddable URL in an empty paragraph. It should be converted to an embed block.
Screenshots
Types of changes
Checklist: