[Gutenberg] Unsupported block fallback#11919
Conversation
# Conflicts: # libs/gutenberg-mobile
|
You can trigger optional UI/connected tests for these changes by visiting CircleCI here. |
|
@marecar3 the downloadable build task failed so I haven't been able to test this. |
|
Most likely pulling in the latest changes (with the no-jitpack updates) will get this passing CI. |
# Conflicts: # libs/gutenberg-mobile
thanks @mchowning! |
|
Hi there! |
|
You can test the changes on this Pull Request by downloading the APK here. |
Thanks @marecar3! |
|
Hey @marecar3, I installed the apk and got this error upon opening the editor:
I thought that if there was a problem with the React Native bundle, there was a UI test that would have caught that, so I'm not sure if it's an issue on my end or not. |
Yes you are right I am getting the same message. Maybe @hypest can help us? |
|
@marecar3 I took the liberty of updating this to 15.1 since 15.0 is being cut soon. |
cameronvoell
left a comment
There was a problem hiding this comment.
This is looking good so far, what a cool feature! I left a minor comment related to String constants.
I was able to use the Unsupported blocks feature first try to edit the core/social-links block from within the app and it worked great! jetpack/podcast-player worked well also.
For jetpack/markdown I saw some interesting behavior that prompted the following question:
For some content in the jetpack/markdown, the Unsupported fallback on iOS and Android shows "This block contains unexpected or invalid content" but that same block opens up fine in normal gutenberg Web, both on desktop and mobile browsers. Do we know what could account for the difference here?
This is the HTML view of the block that works on web but not in the unsupported fallback:
<!-- wp:jetpack/markdown {"source":"### This is Markdown\n*Test*"} -->
<div class="wp-block-jetpack-markdown"><h3>This is Markdown</h3>
<p><em>Test</em></p>
</div>
<!-- /wp:jetpack/markdown -->
| public static final String ARG_BLOCK_CONTENT = "block_content"; | ||
|
|
||
| public static final String RESULT_SAVED_CONTENT = "saved_content"; | ||
| public static final String RESULT_BLOCK_ID = "block_id"; |
There was a problem hiding this comment.
This is a little confusing that ARG_BLOCK_ID and RESULT_BLOCK_ID have the same value. Probably should be different to ensure that we use the right one in the right place, or we should just reuse ARG_* strings and remove the RESULT_* strings. See comment below.
There was a problem hiding this comment.
Agree. Fixed (we are now using only one type of param)
| protected void saveContent(String content) { | ||
| Intent savedContentIntent = new Intent(); | ||
| String blockId = getIntent().getExtras().getString(ARG_BLOCK_ID); | ||
| savedContentIntent.putExtra(ARG_BLOCK_ID, blockId); |
There was a problem hiding this comment.
This is a little confusing, I think in GutenbergEditorFragment you extract this value using RESULT_BLOCK_ID (L473 of GutenbergEditorFragment) and the only reason it works is because it has the same value as ARG_BLOCK_ID.
There was a problem hiding this comment.
Agree. Fixed (we are now using only one type of param)
Great catch @cameronvoell ! What is happening is that the I'm not sure why is this happening, on iOS we are escaping it in the html string we pass to JS (like Clearly it's happening on both platforms, so the solution might be on the Block insertion script (somehow). Will give it a try! |
So, I haven’t been able to find a good solution for this, but I can confirm that the problem is what I mentioned previously. The only thing that worked was to replace instances of Of course this looks quite ugly and it might break blocks with new lines on its content. I’m open to suggestions. |
Thanks @cameronvoell 🙇 |
That's true—what wasn't immediately obvious to me is that the content in the JSON object's For future reference here's an example of what worked for me: Like @etoledom said above, this isn't a good solution. I spent half a day yesterday digging into this but didn't make much progress. I understand that JSON requires new line characters, and what's in the It appears these have to be exactly the same string for the invalid content message to not appear. |

Proof of concept Unsupported block fallback on native side.
This opens a web view with a new-post editor, and insert the required block via "User Content Javascript" (JS code inserted to the web view).
We extract the final block content in the same way.
To clean up the canvas from unwanted UI elements we inject CSS that hides those elements.
gutenberg-mobileside PR: wordpress-mobile/gutenberg-mobile#2063PR submission checklist:
RELEASE-NOTES.txtif necessary.