Conversation
It was also needed to modify the JS injection code to make the external JS code strategy work.
|
Size Change: 0 B Total Size: 1.2 MB ℹ️ View Unchanged
|
|
Hey 👋 @etoledom |
…utenberg-mobile-repo
…utenberg-mobile-repo
|
@guarani could you please check the iOS side, and @mchowning the Android side please? 🙏 |
guarani
left a comment
There was a problem hiding this comment.
I tested the iOS side and it's working great. I tested from the main WP for iOS app and also from the Gutenberg iOS demo app.
I left some comments, but they're not blockers.
| @@ -1 +1,3 @@ | |||
| window.insertBlock( `%@` ); | |||
| if ( window.insertBlock && window.contentIncerted !== true ) { | |||
There was a problem hiding this comment.
| if ( window.insertBlock && window.contentIncerted !== true ) { | |
| if ( window.insertBlock && window.contentInserted !== true ) { |
|
Thank you so much for your review @guarani ! |
| String insertBlock = getFileContentFromAssets("gutenberg-web-single-block/insert-block.js").replace("%@","%s"); | ||
| String blockContent = getIntent().getExtras().getString(ARG_BLOCK_CONTENT); | ||
| insertBlock = String.format(insertBlock, blockContent); | ||
| evaluateJavaScript(removeNewLines(insertBlock.replace("\\n", "\\\\n"))); |
There was a problem hiding this comment.
Not a big deal and you didn't add this line in this PR, so feel free to leave it as-is, but there's a fair bit happening on this line, and it might be helpful to either add a comment or extract out a descriptively-named variable to make it clearer why we're adding the extra escaping and then removing new lines.
…utenberg-mobile-repo # Conflicts: # packages/react-native-bridge/android/src/main/java/org/wordpress/mobile/ReactNativeGutenbergBridge/GutenbergWebViewActivity.java
gb-mobile PR: wordpress-mobile/gutenberg-mobile#2561
WPiOS side PR: wordpress-mobile/WordPress-iOS#14683
WPAndroid side PR: wordpress-mobile/WordPress-Android#12795
Description
This PR removes some references to
window.wp.data.dispatch( 'automattic/nux' );and"automattic/nux":and implements a mechanism to insert custom JS to be injected from the client.To achieve this, some changes were needed on when the JS code is injected:
There's a new function
gutenbergObserverwhich will check when gutenberg is ready for the post content to be inserted. It will send agutenbergReadymessage to the native side."/wp-admin/post-new.php"in order to insert the content, making the whole system more robust.When the
gutenbergReadycall is received we:How has this been tested?
To test (On both WPiOS and WPAndroid apps):
<!-- wp:file /-->Checklist: