-
Notifications
You must be signed in to change notification settings - Fork 4.6k
[RNMobile] Embed block: Add undo/redo support #33218
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
Conversation
This will address the case when executing the undo action after setting an URL.
|
Size Change: +5 B (0%) Total Size: 1.05 MB
ℹ️ View Unchanged
|
| } | ||
|
|
||
| const embedPreview = getEmbedPreview( attributesUrl ); | ||
| const embedPreview = Platform.select( { |
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.
Not a blocker, but instead of changing the embedPreview maybe can we use the url that's already passed in to EmbedPreview instead of preview?
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.
The idea here was to mock the embed preview to imitate the same flow as it would do after fetching a real preview. The important part is to generate a valid value for populating the preview variable, otherwise, the embed preview component is not rendered.
gutenberg/packages/block-library/src/embed/edit.js
Lines 98 to 101 in de3b53f
| const validPreview = | |
| !! embedPreview && ! badEmbedProvider && ! wordpressCantEmbed; | |
| return { | |
| preview: validPreview ? embedPreview : undefined, |
gutenberg/packages/block-library/src/embed/edit.js
Lines 216 to 217 in de3b53f
| // No preview, or we can't embed the current URL, or we've clicked the edit button. | |
| const showEmbedPlaceholder = ! preview || cannotEmbed || isEditingURL; |
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.
Ah, I see 👍
ceyhun
left a comment
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.
Tested on iOS & Android simulators. LGTM 🎉
|
|
I've found the culprit of the issue, actually looks like it's a bug that is also happening in the web version, I've just filed an issue that I plan to resolve soon: EDIT: I implemented the fix in this PR, feel free to take a look, thanks 🙇 ! |
|
As mentioned in the previous comment, the issue will be fixed in a separate PR, so we can merge this 🎊 . |
* Use URL as embed preview in native version * Update styles of embed block * Display URL in embed preview * Rename style in embed preview * Submit embed URL even when the value didn't change This will address the case when executing the undo action after setting an URL.
gutenberg-mobilePR: wordpress-mobile/gutenberg-mobile#3700Description
This PR addresses the undo/redo case of the embed block, for this purpose I modified the preview getter for the native version so now it uses the URL as the content to preview. It's just a temporary workaround to test the embed block functionality until we provide a fallback UI for the first version of this block.
Additionally, I made a small refactor on the native styles and adopt the BEM naming convention.
How has this been tested?
Undo and edit
ADD LINKmessage within the block)Undo/redo
ADD LINKmessage within the block)Screenshots
embed-block-undo-redo.mp4
Types of changes
New feature
Checklist:
*.native.jsfiles for terms that need renaming or removal).