-
Notifications
You must be signed in to change notification settings - Fork 4.2k
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
Fix: Embed Block: Match HTML in the editor and frontend #65478
Conversation
The following accounts have interacted with this PR and/or linked issues. I will continue to update these lists as activity occurs. You can also manually ask me to refresh this list by adding the If you're merging code through a pull request on GitHub, copy and paste the following into the bottom of the merge commit message.
To understand the WordPress project's expectations around crediting contributors, please review the Contributor Attribution page in the Core Handbook. |
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.
Thanks for the PR!
There are two things that need to be addressed in order for this PR to move forward.
Fix E2E tests
The figure
tag applies to the block itself, not inside it. Therefore, currenEmbedBlock.locator('figure')
can no longer find the figure
element.
The following changes are required:
diff --git a/test/e2e/specs/editor/various/embedding.spec.js b/test/e2e/specs/editor/various/embedding.spec.js
index fb9746dce5..fe488f9130 100644
--- a/test/e2e/specs/editor/various/embedding.spec.js
+++ b/test/e2e/specs/editor/various/embedding.spec.js
@@ -134,15 +134,15 @@ test.describe( 'Embedding content', () => {
'https://developer.wordpress.org/block-editor/reference-guides/block-api/block-attributes/'
);
await expect(
- currenEmbedBlock.locator( 'figure' ),
+ currenEmbedBlock,
'WordPress valid content. Should render valid figure element.'
- ).toHaveClass( 'wp-block-embed' );
+ ).toHaveClass( /wp-block-embed/ );
await embedUtils.insertEmbed(
'https://www.youtube.com/watch?v=lXMskKTw3Bc'
);
await expect(
- currenEmbedBlock.locator( 'figure' ),
+ currenEmbedBlock,
'Video content. Should render valid figure element, and include the aspect ratio class.'
).toHaveClass( /wp-embed-aspect-16-9/ );
Restore is-type-video
CSS class
On the frontend, the figure
tag may have classes like is-type-video
applied, but not in the editor. We need to restore the removed CSS to the block wrapper.
Thank You, @t-hamano for review. I would address the requested feedbacks. |
Hi @t-hamano, On adding the className to the block wrapper, some functionalities are breaking in the editor, for example, If I do not add the class, then if you click on the video, you can see the block controls, and you can update it, but on adding the class, block controls are not visible, and you would not able to update anything. Here is the screencast for the same. issue-embed.1.mov |
We cannot add the The We will probably need to add the class name via const blockProps = useBlockProps( {
className: clsx( {
'is-type-video': 'video' === type,
} ),
} ); |
Hi @t-hamano, I have added the requested changes, and added the fix by changing the Thank You, |
@hbhalodia Thanks for the update! I've tried several providers, or updating additional CSS classes, etc. and everything seems to work fine.
|
Hi @t-hamano, thanks for the feedback. I would update the PR with requested changes. |
Hi @t-hamano, I have updated the PR with the requested changes. Can you please review the same. |
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.
LGTM! Thanks for the update 👍
) * Add the fix for embed to resemeble exact markup as frontend and backend * Fix e2e test for updated embed block * Add the blockprops className to use the newClassname * Fix the code syntax for the same * Add the missing class on editor for the embed block * Add is-type-<typename> class to the editor embed block Co-authored-by: hbhalodia <hbhalodia@git.wordpress.org> Co-authored-by: t-hamano <wildworks@git.wordpress.org>
What?
Why?
How?
figure
as a wrapper, so it matches with frontend markup.Testing Instructions
Testing Instructions for Keyboard
Screenshots or screencast
Backend
Frontend