Skip to content
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

Unsupported block fallback #2063

Merged
merged 78 commits into from
Jun 6, 2020
Merged
Show file tree
Hide file tree
Changes from 72 commits
Commits
Show all changes
78 commits
Select commit Hold shift + click to select a range
b9f4e59
Receive unsupported block fallback message.
etoledom Mar 25, 2020
e19794b
Impement demo web-view to show unsupported block content.
etoledom Mar 25, 2020
aee264d
Implementing `replaceBlock` listener.
etoledom Apr 17, 2020
75c6441
Implement iOS bridge side of new `replaceBlock` Listener
etoledom Apr 17, 2020
d49be0c
Implement `replaceBlock` on Example Project
etoledom Apr 17, 2020
b0b2aa4
Fix lint issues
etoledom Apr 22, 2020
7360901
Update gutenberg ref
etoledom Apr 22, 2020
059425a
Bundle
etoledom Apr 22, 2020
52d7f05
Update gutenberg ref
etoledom Apr 27, 2020
0d9fea7
Sending block name to native on unsupported block fallback message
etoledom Apr 27, 2020
21144c1
[iOS] Unsupported fallback bridge improvements
etoledom Apr 27, 2020
9a074fa
Update gutenberg ref
etoledom Apr 27, 2020
58a7a86
Revert "Bundle"
etoledom Apr 27, 2020
f597aba
Update gutenberg ref
etoledom Apr 27, 2020
1444350
Merge remote-tracking branch 'origin/develop' into unsupported-fallba…
etoledom Apr 27, 2020
1785364
Bundle
etoledom Apr 27, 2020
d4cf849
Added android support for unsupported block
marecar3 Apr 28, 2020
9c3ce08
Remove ios condition
marecar3 Apr 28, 2020
b4a2930
Update gutenberg ref
etoledom Apr 28, 2020
9888787
Adding common scripts to inject in Gutenberg Web single block mode
etoledom Apr 29, 2020
2af0327
Open Gutenberg Web Fallback on iOS Example App
etoledom Apr 29, 2020
4b11299
Adding extra CSS rule for SelfHosted sites
etoledom Apr 30, 2020
5908934
Creating GutenbergWebDelegate
etoledom Apr 30, 2020
10abccb
[iOS] Changes to improve integration with parent app
etoledom Apr 30, 2020
4ebb245
Fix lint errors
etoledom Apr 30, 2020
0b8d17e
[iOS] Fix build of example app
etoledom Apr 30, 2020
d5ce912
[Gutenberg Web iOS] Adding transition animation when web content is r…
etoledom Apr 30, 2020
6140480
Revert "Bundle"
etoledom Apr 30, 2020
40240af
Bundle
etoledom Apr 30, 2020
e037023
[Unsupported Block Fallback] Improved compatibility with WP v5.0~v5.4
etoledom May 1, 2020
ccf4e48
Injecting new script to prevent autosaves to remote
etoledom May 1, 2020
20bc893
Change strategy to insert block.
etoledom May 1, 2020
b0b8ae2
Fix prevent autosave for WPOrg sites
etoledom May 5, 2020
6d0f990
Remove time-out from insert-block script
etoledom May 5, 2020
0c587b0
Revert "Bundle"
etoledom May 5, 2020
d4a5a1d
Update gutenberg ref
etoledom May 5, 2020
60550dd
Update gutenberg ref
etoledom May 5, 2020
79fac9e
Merge remote-tracking branch 'origin/develop' into unsupported-fallba…
etoledom May 5, 2020
887981c
Update gutenberg ref
etoledom May 5, 2020
b089e83
Fix lint issues
etoledom May 5, 2020
bdd44b3
fix argument names
marecar3 May 14, 2020
a03f7c8
[Gutenberg WebView] Adding CSS override to hide PostTitle on new Gute…
etoledom May 15, 2020
fb0760a
Update gutenberg ref
etoledom May 15, 2020
080c7dc
Merge remote-tracking branch 'origin/develop' into unsupported-fallba…
etoledom May 15, 2020
b1ad6a5
Commit Podfile.lock diff
etoledom May 15, 2020
d7c2eeb
Merge branch 'develop' into unsupported-fallback-spike
marecar3 May 19, 2020
c8f4e58
Update gutenberg ref
etoledom May 22, 2020
386695e
Merge remote-tracking branch 'origin/develop' into unsupported-fallba…
etoledom May 22, 2020
4181834
Merge branch 'develop' into unsupported-fallback-spike
marecar3 May 22, 2020
106302e
Merge branch 'develop' into unsupported-fallback-spike
marecar3 May 26, 2020
1b2865d
Move GutenbergWebViewActivity in gutenberg bridge so that we can shar…
marecar3 May 26, 2020
d76005b
Make webview visible to child classes
marecar3 May 26, 2020
610d818
Fix colors in android demo application
marecar3 May 26, 2020
fff0dc3
Add rn-get-random-values library
marecar3 May 26, 2020
7ade351
Merge branch 'unsupported-fallback-spike' of https://github.com/wordp…
marecar3 May 26, 2020
1d25b15
Merge branch 'develop' into unsupported-fallback-spike
marecar3 May 27, 2020
63308f3
small fix
marecar3 May 27, 2020
66bd63d
Merge branch 'unsupported-fallback-spike' of https://github.com/wordp…
marecar3 May 27, 2020
48ed5a2
Use version of react-native-get-random-values from forked repo
marecar3 May 27, 2020
2e07f4a
Add RNGetRandomValuesPackage in WPGlueCode
marecar3 May 27, 2020
72ac478
Fix Lint issues
etoledom May 27, 2020
873120c
Commit diff on Podfile.lock
etoledom May 27, 2020
a19b79f
Clean up inital HTML
etoledom May 27, 2020
c7bf175
fix lint error
marecar3 May 27, 2020
676c970
Removed unsupported block
marecar3 May 27, 2020
873d431
Merge branch 'unsupported-fallback-spike' of https://github.com/wordp…
marecar3 May 27, 2020
0e1ed18
Merge branch 'develop' into unsupported-fallback-spike
marecar3 May 28, 2020
550c643
Remove empty line
marecar3 May 28, 2020
4718779
remove react-native-get-random-values
marecar3 May 28, 2020
656c0c5
remove rn-get-random-values from package.json
marecar3 May 28, 2020
4ec1da9
Remove rn-get-random-values from index.js file
marecar3 May 28, 2020
5540ad0
remove rn-get-random-values from Pods
marecar3 May 28, 2020
81d5293
Update gb reference
marecar3 Jun 3, 2020
f3876a9
Merge branch 'develop' into unsupported-fallback-spike
marecar3 Jun 3, 2020
336e61a
Put unsupported block editor on dev builds
guarani Jun 5, 2020
b27baf7
Merge branch 'develop' into unsupported-fallback-spike
guarani Jun 5, 2020
1837d46
Reverted unnecessary change to .vscode/settings.json
guarani Jun 5, 2020
08192b7
Fixed bad merge conflict resolution error
guarani Jun 5, 2020
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion Gutenberg.podspec
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,11 @@ Pod::Spec.new do |s|
s.authors = 'Automattic'
s.platform = :ios, '11.0'
s.source = { :git => 'https://github.com/wordpress-mobile/gutenberg-mobile.git' }
s.source_files = 'react-native-gutenberg-bridge/ios/*.{h,m,swift}'
s.source_files = 'react-native-gutenberg-bridge/ios/**/*.{h,m,swift}'
s.requires_arc = true
s.preserve_paths = 'bundle/ios/*'
s.swift_version = '5.0'
s.resources = 'common/**/*.{js,css,json}'
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could the common folder be moved into react-native-gutenberg-bridge?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sounds good to me. What do you think @marecar3 ?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@etoledom, I'm not sure if we're planning on making this change or leaving it as-is.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I know it's a bit late but is it still possible to move it under react-native-gutenberg-bridge? or what steps should be taken to move it?
In the monorepo setup the whole react-native-gutenberg-bridge folder will be moved under gutenberg repo as a package and if common is already inside it, that would be easier.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In the monorepo setup the whole react-native-gutenberg-bridge folder will be moved under gutenberg repo as a package and if common is already inside it, that would be easier.

That's fair 👍
I was planning a PR specifically to do this change. For iOS is easy but will need help from @marecar3 for Android


s.dependency 'React', react_native_version
s.dependency 'React-CoreModules', react_native_version
Expand Down
33 changes: 32 additions & 1 deletion android/app/src/main/java/com/gutenberg/MainApplication.java
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package com.gutenberg;

import android.app.Application;
import android.content.Intent;
import android.content.res.Configuration;
import android.os.Bundle;
import android.util.Log;
Expand All @@ -18,7 +19,9 @@
import com.horcrux.svg.SvgPackage;

import org.wordpress.mobile.ReactNativeAztec.ReactAztecPackage;
import org.wordpress.mobile.ReactNativeGutenbergBridge.GutenbergBridgeInterface;
import org.wordpress.mobile.ReactNativeGutenbergBridge.GutenbergBridgeJS2Parent;
import org.wordpress.mobile.ReactNativeGutenbergBridge.GutenbergWebViewActivity;
import org.wordpress.mobile.ReactNativeGutenbergBridge.RNReactNativeGutenbergBridgePackage;

import com.facebook.react.ReactNativeHost;
Expand All @@ -30,12 +33,13 @@
import java.util.List;
import java.util.ArrayList;

public class MainApplication extends Application implements ReactApplication {
public class MainApplication extends Application implements ReactApplication, GutenbergBridgeInterface {

private static final String TAG = "MainApplication";

private ReactNativeHost mReactNativeHost;
private RNReactNativeGutenbergBridgePackage mRnReactNativeGutenbergBridgePackage;
private GutenbergBridgeJS2Parent.ReplaceUnsupportedBlockCallback mReplaceUnsupportedBlockCallback;

private ReactNativeHost createReactNativeHost() {
mRnReactNativeGutenbergBridgePackage = new RNReactNativeGutenbergBridgePackage(new GutenbergBridgeJS2Parent() {
Expand Down Expand Up @@ -144,6 +148,15 @@ public void editorDidEmitLog(String message, LogLevel logLevel) {
@Override
public void performRequest(String path, Consumer<String> onSuccess, Consumer<Bundle> onError) {}

@Override
public void gutenbergDidRequestUnsupportedBlockFallback(ReplaceUnsupportedBlockCallback replaceUnsupportedBlockCallback,
String content,
String blockId,
String blockName) {
mReplaceUnsupportedBlockCallback = replaceUnsupportedBlockCallback;
openGutenbergWebView(content, blockId, blockName);
}

@Override
public void onAddMention(Consumer<String> onSuccess) {
onSuccess.accept("matt");
Expand Down Expand Up @@ -184,6 +197,17 @@ private boolean isDarkMode() {
return currentNightMode == Configuration.UI_MODE_NIGHT_YES;
}

private void openGutenbergWebView(String content,
String blockId,
String blockName) {
Intent intent = new Intent(this, GutenbergWebViewActivity.class);
intent.putExtra(GutenbergWebViewActivity.ARG_BLOCK_CONTENT, content);
intent.putExtra(GutenbergWebViewActivity.ARG_BLOCK_ID, blockId);
intent.putExtra(GutenbergWebViewActivity.ARG_BLOCK_NAME, blockName);
intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
startActivity(intent);
}

@Override
public ReactNativeHost getReactNativeHost() {
if (mReactNativeHost == null) {
Expand All @@ -210,4 +234,11 @@ public void onOptionSelected() {
}
});
}

@Override
public void saveContent(String content, String blockId) {
if (mReplaceUnsupportedBlockCallback != null) {
mReplaceUnsupportedBlockCallback.replaceUnsupportedBlock(content, blockId);
}
}
}
27 changes: 27 additions & 0 deletions common/gutenberg-web-single-block/content-functions.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
window.blockEditorSelect = window.wp.data.select( 'core/block-editor' ) ||
window.wp.data.select( 'core/editor' ); // For WP v5.0 and v5.1

window.blockEditorDispatch = window.wp.data.dispatch( 'core/block-editor' ) ||
window.wp.data.dispatch( 'core/editor' ); // For WP v5.0 and v5.1

window.getHTMLPostContent = () => {
const blocks = window.blockEditorSelect.getBlocks();
const HTML = window.wp.blocks.serialize( blocks );
// Check if platform is iOS
if ( window.webkit ) {
window.webkit.messageHandlers.htmlPostContent.postMessage( HTML );
// Otherwise it\'s Android
} else {
window.wpwebkit.postMessage( HTML );
}
};

window.insertBlock = ( blockHTML ) => {
// Setup the editor with the inserted block
const post = window.wp.data.select( 'core/editor' ).getCurrentPost();
window.wp.data.dispatch( 'core/editor' ).setupEditor( post, { content: blockHTML } );

// Select the first block
const clientId = window.blockEditorSelect.getBlocks()[ 0 ].clientId;
window.blockEditorDispatch.selectBlock( clientId );
};
75 changes: 75 additions & 0 deletions common/gutenberg-web-single-block/editor-style-overrides.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
/* Remove Post Title */
#post-title-0 {
display: none;
}

/* Remove default block appender at the end of the post */
.block-list-appender {
display: none;
}

.edit-post-visual-editor__post-title-wrapper {
display: none;
}

/* Remove default block appender at the end of the post (WP v5.0~v5.1) */
.editor-default-block-appender {
display: none;
}

/*
Hiddes the top bar header by setting its height to 0
We can\'t remove it since the block toolbar is a child of it.
*/
.edit-post-header {
height: 0px;
padding: 0px;
overflow: hidden;
}

/* Move the block toolbar to the top */
.edit-post-header-toolbar__block-toolbar {
top: 0px;
}

.interface-interface-skeleton {
top: 0px;
}

/*
Moves the whole editor to the top.
There was an extra top margin after removing the WP Admin bar.
*/
.block-editor-editor-skeleton {
top: 0px;
}

/* Remove metaboxes from Self-Hosted sites */
.edit-post-layout__metaboxes {
display: none;
}

/* Remove tabs from sidebar panel, leaving the \'x\' button */
.edit-post-sidebar__panel-tabs {
display: none;
}

/* Remove \'(no-title)\' string from sidebar header */
.edit-post-sidebar-header__title {
display: none;
}

/* Move \'x\' close button to the end on sidebar header */
.edit-post-sidebar-header__small {
justify-content: flex-end;
}

/* Remove all buttons from the component menu group inside \'...\' button in block toolbar */
.components-menu-group > div > button:not(:first-child) {
display: none;
}

/* Remove \'delete block\' button inside \'...\' button in block toolbar */
.components-dropdown-menu__menu > div:not(:first-child) {
display: none;
}
16 changes: 16 additions & 0 deletions common/gutenberg-web-single-block/inject-css.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
const injectCss = `
window.injectCss = (css) => {
const style = document.createElement('style');
style.innerHTML = css;
style.type = 'text/css';
document.head.appendChild(style);
}
`;

const script = document.createElement( 'script' );
script.innerText = injectCss;
script.type = 'text/javascript';
document.head.appendChild( script );
// We need to return a string or null, otherwise executing this script will error.
// eslint-disable-next-line no-unused-expressions
'CSS injection function ready';
1 change: 1 addition & 0 deletions common/gutenberg-web-single-block/insert-block.js
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
window.insertBlock( `%@` );
31 changes: 31 additions & 0 deletions common/gutenberg-web-single-block/local-storage-overrides.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
{
"core/edit-post": {
"preferences": {
"isGeneralSidebarDismissed": true,
"features": {
"fixedToolbar": false,
"showInserterHelpPanel": false,
"fullscreenMode": true,
"welcomeGuide": false
},
"editorMode": "visual",
"pinnedPluginItems": {

},
"hiddenBlockTypes": [

],
"preferredStyleVariations": {

}
}
},
"core/nux": {
"preferences": {
"areTipsEnabled": false,
"dismissedTips": {

}
}
}
}
6 changes: 6 additions & 0 deletions common/gutenberg-web-single-block/prevent-autosaves.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
window.setTimeout( () => {
// Delaying autosaves we avoid creating drafts to remote
const settings = window.wp.data.select( 'core/editor' ).getEditorSettings();
settings.autosaveInterval = 60 * 60 * 24 * 7; //Let's wait a week for it to autosave.
window.wp.data.dispatch( 'core/editor' ).updateEditorSettings( settings );
}, 0 );
11 changes: 11 additions & 0 deletions common/gutenberg-web-single-block/wp-bar-override.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
#wpbody {
padding-top: 0px;
}

#wp-toolbar {
display: none;
}

#wpadminbar {
display: none;
}
2 changes: 1 addition & 1 deletion gutenberg
Submodule gutenberg updated 90 files
+1 −1 babel.config.js
+1 −1 bin/packages/get-babel-config.js
+1 −1 docs/designers-developers/developers/block-api/README.md
+19 −0 docs/designers-developers/developers/block-api/block-registration.md
+4 −4 package-lock.json
+2 −2 packages/annotations/src/store/selectors.js
+1 −1 packages/api-fetch/src/index.js
+3 −9 packages/api-fetch/src/middlewares/preloading.js
+12 −11 packages/autop/src/index.js
+1 −1 packages/babel-plugin-import-jsx-pragma/index.js
+1 −1 packages/babel-plugin-makepot/src/index.js
+1 −1 packages/babel-preset-default/index.js
+2 −2 packages/block-editor/src/components/block-breadcrumb/index.js
+1 −1 packages/block-editor/src/components/gradient-picker/control.js
+1 −1 packages/block-editor/src/components/url-popover/image-url-input-ui.js
+11 −14 packages/block-editor/src/utils/transform-styles/transforms/url-rewrite.js
+1 −1 packages/block-library/src/classic/edit.js
+1 −0 packages/block-library/src/cover/edit.js
+1 −1 packages/block-library/src/gallery/edit.js
+1 −1 packages/block-library/src/image/utils.js
+55 −4 packages/block-library/src/missing/edit.native.js
+8 −0 packages/block-library/src/missing/style.native.scss
+2 −2 packages/block-library/src/missing/test/edit.native.js
+2 −2 packages/block-library/src/social-links/edit.js
+1 −0 packages/block-library/src/style.scss
+1 −1 packages/blocks/src/api/raw-handling/blockquote-normaliser.js
+1 −1 packages/blocks/src/api/raw-handling/br-remover.js
+1 −1 packages/blocks/src/api/raw-handling/comment-remover.js
+1 −1 packages/blocks/src/api/raw-handling/empty-paragraph-remover.js
+1 −1 packages/blocks/src/api/raw-handling/figure-content-reducer.js
+1 −1 packages/blocks/src/api/raw-handling/google-docs-uid-remover.js
+1 −1 packages/blocks/src/api/raw-handling/head-remover.js
+1 −1 packages/blocks/src/api/raw-handling/html-formatting-remover.js
+1 −1 packages/blocks/src/api/raw-handling/iframe-remover.js
+1 −1 packages/blocks/src/api/raw-handling/image-corrector.js
+1 −1 packages/blocks/src/api/raw-handling/image-corrector.native.js
+1 −1 packages/blocks/src/api/raw-handling/is-inline-content.js
+1 −1 packages/blocks/src/api/raw-handling/list-reducer.js
+1 −1 packages/blocks/src/api/raw-handling/markdown-converter.js
+1 −1 packages/blocks/src/api/raw-handling/ms-list-converter.js
+1 −1 packages/blocks/src/api/raw-handling/normalise-blocks.js
+1 −1 packages/blocks/src/api/raw-handling/phrasing-content-reducer.js
+1 −1 packages/blocks/src/api/raw-handling/special-comment-converter.js
+27 −27 packages/components/src/form-token-field/test/index.js
+1 −1 packages/components/src/higher-order/with-focus-return/index.js
+2 −2 packages/compose/src/hooks/use-preferred-color-scheme/index.android.js
+1 −1 packages/core-data/src/utils/with-weak-map-cache.js
+1 −1 packages/create-block/lib/index.js
+1 −7 packages/create-block/lib/init-wp-scripts.js
+2 −2 packages/create-block/lib/scaffold.js
+2 −2 packages/data/src/namespace-store/index.js
+2 −2 packages/data/src/plugins/controls/index.js
+2 −2 packages/data/src/plugins/persistence/index.js
+1 −3 packages/docgen/src/get-dependency-path.js
+1 −1 packages/docgen/src/get-export-entries.js
+2 −2 packages/docgen/src/get-intermediate-representation.js
+1 −1 packages/docgen/src/get-jsdoc-from-token.js
+1 −1 packages/docgen/src/get-leading-comments.js
+3 −5 packages/docgen/src/get-type-as-string.js
+1 −1 packages/docgen/src/index.js
+1 −1 packages/docgen/src/markdown/embed.js
+2 −2 packages/docgen/src/markdown/formatter.js
+2 −8 packages/docgen/src/markdown/index.js
+19 −19 packages/docgen/src/test/get-export-entries.js
+15 −15 packages/docgen/src/test/get-intermediate-representation.js
+76 −0 packages/e2e-tests/specs/editor/blocks/gallery.test.js
+1 −1 packages/edit-post/src/components/editor-initialization/index.js
+1 −1 packages/edit-post/src/index.js
+18 −1 packages/editor/src/components/provider/index.native.js
+51 −52 packages/editor/src/store/selectors.js
+17 −18 packages/editor/src/store/selectors.native.js
+1 −1 packages/editor/src/utils/media-upload/index.js
+1 −1 packages/editor/src/utils/media-upload/index.native.js
+1 −1 packages/env/package.json
+1 −1 packages/list-reusable-blocks/src/utils/file.js
+2 −2 packages/postcss-themes/index.js
+1 −1 packages/redux-routine/src/test/is-action.js
+6 −6 packages/server-side-render/src/test/index.js
+1 −1 packages/warning/test/babel-plugin.js
+1 −1 packages/wordcount/src/stripConnectors.js
+1 −1 packages/wordcount/src/stripHTMLComments.js
+1 −1 packages/wordcount/src/stripHTMLEntities.js
+1 −1 packages/wordcount/src/stripRemovables.js
+1 −1 packages/wordcount/src/stripShortcodes.js
+1 −1 packages/wordcount/src/stripSpaces.js
+1 −1 packages/wordcount/src/stripTags.js
+1 −1 packages/wordcount/src/transposeAstralsToCountableChar.js
+4 −1 packages/wordcount/src/transposeHTMLEntitiesToCountableChars.js
+1 −1 test/native/babel.config.js
+2 −0 test/native/setup.js
1 change: 1 addition & 0 deletions ios/Podfile
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ target 'gutenberg' do
#pod 'WordPress-Aztec-iOS', :git => 'https://github.com/wordpress-mobile/WordPress-Aztec-iOS.git', :commit => '23e40905d673673d12b61976f1212f6d97cb47cd'
pod 'Gutenberg', :path => '../Gutenberg.podspec'


target 'gutenbergTests' do
inherit! :search_paths
# Pods for testing
Expand Down
4 changes: 2 additions & 2 deletions ios/Podfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -367,7 +367,7 @@ SPEC CHECKSUMS:
FBReactNativeSpec: 118d0d177724c2d67f08a59136eb29ef5943ec75
Folly: 30e7936e1c45c08d884aa59369ed951a8e68cf51
glog: 1f3da668190260b06b429bb211bfbee5cd790c28
Gutenberg: 76149a3f98afe2ef0b0293789b26881a676b07a2
Gutenberg: 5ec2064892ee100c16b55b6ea2bc69aa22f683f9
RCTRequired: b153add4da6e7dbc44aebf93f3cf4fcae392ddf1
RCTTypeSafety: 9aa1b91d7f9310fc6eadc3cf95126ffe818af320
React: b6a59ef847b2b40bb6e0180a97d0ca716969ac78
Expand Down Expand Up @@ -397,6 +397,6 @@ SPEC CHECKSUMS:
WordPress-Aztec-iOS: d01bf0c5e150ae6a046f06ba63b7cc2762061c0b
Yoga: f2a7cd4280bfe2cca5a7aed98ba0eb3d1310f18b

PODFILE CHECKSUM: 09209784e513c841038a9679c77beb957d40fda9
PODFILE CHECKSUM: a40f0d1bf814d64a65889a6b857b3a942c421017

COCOAPODS: 1.8.4
4 changes: 4 additions & 0 deletions ios/gutenberg.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
05908C6EA5B80A39F74C4FEF /* Pods_gutenberg.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 38E210A05B5C8829E0B3BE83 /* Pods_gutenberg.framework */; };
13B07FBD1A68108700A75B9A /* LaunchScreen.xib in Resources */ = {isa = PBXBuildFile; fileRef = 13B07FB11A68108700A75B9A /* LaunchScreen.xib */; };
13B07FBF1A68108700A75B9A /* Images.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 13B07FB51A68108700A75B9A /* Images.xcassets */; };
1E4F2E752459E6F200EB73E7 /* WebViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1E85944D2449D85A006CC6A0 /* WebViewController.swift */; };
2D02E4BD1E0B4A84006451C7 /* Images.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 13B07FB51A68108700A75B9A /* Images.xcassets */; };
2D16E6881FA4F8E400B85C8A /* libReact.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 2D16E6891FA4F8E400B85C8A /* libReact.a */; };
2DCD954D1E0B4F2C00145EB5 /* gutenbergTests.m in Sources */ = {isa = PBXBuildFile; fileRef = 00E356F21AD99517003FC87E /* gutenbergTests.m */; };
Expand Down Expand Up @@ -60,6 +61,7 @@
13B07FB21A68108700A75B9A /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.xib; name = Base; path = Base.lproj/LaunchScreen.xib; sourceTree = "<group>"; };
13B07FB51A68108700A75B9A /* Images.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; name = Images.xcassets; path = gutenberg/Images.xcassets; sourceTree = "<group>"; };
13B07FB61A68108700A75B9A /* Info.plist */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.xml; name = Info.plist; path = gutenberg/Info.plist; sourceTree = "<group>"; };
1E85944D2449D85A006CC6A0 /* WebViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; name = WebViewController.swift; path = gutenberg/WebViewController.swift; sourceTree = "<group>"; };
2D02E47B1E0B4A5D006451C7 /* gutenberg-tvOS.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = "gutenberg-tvOS.app"; sourceTree = BUILT_PRODUCTS_DIR; };
2D02E4901E0B4A5D006451C7 /* gutenberg-tvOSTests.xctest */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = "gutenberg-tvOSTests.xctest"; sourceTree = BUILT_PRODUCTS_DIR; };
2D16E6891FA4F8E400B85C8A /* libReact.a */ = {isa = PBXFileReference; explicitFileType = archive.ar; path = libReact.a; sourceTree = BUILT_PRODUCTS_DIR; };
Expand Down Expand Up @@ -159,6 +161,7 @@
F15198372100DC3C000F6E97 /* gutenberg-Bridging-Header.h */,
F15198392100DC3D000F6E97 /* AppDelegate.swift */,
7EC7328E21907E3F00FED2E6 /* GutenbergViewController.swift */,
1E85944D2449D85A006CC6A0 /* WebViewController.swift */,
FF9A6F1621FA8E2500D36D14 /* MediaPickCoordinator.swift */,
FF6836C722035EAB00A0C562 /* MediaUploadCoordinator.swift */,
F151983A2100DC3D000F6E97 /* MediaProvider.swift */,
Expand Down Expand Up @@ -653,6 +656,7 @@
FF83DAA92226905A00A34C93 /* CustomImageLoader.swift in Sources */,
FF9A6F4121FA8E2500D36D14 /* MediaPickCoordinator.swift in Sources */,
F151983D2100DC3D000F6E97 /* MediaProvider.swift in Sources */,
1E4F2E752459E6F200EB73E7 /* WebViewController.swift in Sources */,
FF6836C822035EAB00A0C562 /* MediaUploadCoordinator.swift in Sources */,
7EC7328F21907E3F00FED2E6 /* GutenbergViewController.swift in Sources */,
);
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>PreviewsEnabled</key>
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not sure what PreviewsEnabled does here in workspace settings cc @etoledom

<false/>
</dict>
</plist>
29 changes: 29 additions & 0 deletions ios/gutenberg/GutenbergViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,8 @@ class GutenbergViewController: UIViewController {
gutenberg.delegate = self
navigationController?.navigationBar.isTranslucent = false
registerLongPressGestureRecognizer()

_ = try! FallbackJavascriptInjection(blockHTML: "Hello", userId: "1")
guarani marked this conversation as resolved.
Show resolved Hide resolved
}

@objc func moreButtonPressed(sender: UIBarButtonItem) {
Expand Down Expand Up @@ -196,6 +198,13 @@ extension GutenbergViewController: GutenbergBridgeDelegate {
print("Gutenberg loged user event")
}

func gutenbergDidRequestUnsupportedBlockFallback(for block: Block) {
print("Requesting Fallback for \(block)")
let controller = try! WebViewController(block: block, userId: "0")
guarani marked this conversation as resolved.
Show resolved Hide resolved
controller.delegate = self
present(UINavigationController(rootViewController: controller), animated: true)
}

func gutenbergDidRequestMention(callback: @escaping (Result<String, NSError>) -> Void) {
callback(.success("matt"))
}
Expand All @@ -209,6 +218,26 @@ extension GutenbergViewController: GutenbergBridgeDelegate {
}
}

extension GutenbergViewController: GutenbergWebDelegate {
func webController(controller: GutenbergWebSingleBlockViewController, didPressSave block: Block) {
gutenberg.replace(block: block)
dismiss(webController: controller)
}

func webControllerDidPressClose(controller: GutenbergWebSingleBlockViewController) {
dismiss(webController: controller)
}

func webController(controller: GutenbergWebSingleBlockViewController, didLog log: String) {
print("WebView: \(log)")
}

private func dismiss(webController: GutenbergWebSingleBlockViewController) {
webController.cleanUp()
dismiss(animated: true)
}
}

extension GutenbergViewController: GutenbergBridgeDataSource {
func gutenbergLocale() -> String? {
return Locale.preferredLanguages.first ?? "en"
Expand Down
5 changes: 5 additions & 0 deletions ios/gutenberg/WebViewController.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
import Gutenberg

class WebViewController: GutenbergWebSingleBlockViewController {

}
2 changes: 2 additions & 0 deletions react-native-gutenberg-bridge/android/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -147,6 +147,8 @@ dependencies {
// For animated GIF support
implementation 'com.facebook.fresco:animated-gif:2.0.0'

implementation 'com.google.android.material:material:1.1.0'

if (rootProject.ext.buildGutenbergFromSource) {
println "using gutenberg from source"
implementation project(':react-native-linear-gradient')
Expand Down
Loading