Skip to content
This repository was archived by the owner on Jul 9, 2026. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
38 commits
Select commit Hold shift + click to select a range
82b609f
Add empty mention implementation for demo app
mchowning Apr 16, 2020
2cbc40a
Update release notes
mchowning Apr 15, 2020
4b76cff
Update gutenberg ref
mchowning Apr 10, 2020
0d04a82
Add stub function for iOS
SergioEstevao Apr 16, 2020
ce88a8a
Implement delegate method for requesting mentions.
SergioEstevao Apr 16, 2020
a0a3ec5
Merge branch 'develop' into issue_331/mention_support
SergioEstevao Apr 17, 2020
fae7dc6
Merge branch 'develop' into issue_331/mention_support
SergioEstevao Apr 20, 2020
41dbe0a
User error domain and code information on the promise's rejecter
SergioEstevao Apr 20, 2020
8446c5b
Stub demo app to always mention "matt"
mchowning Apr 20, 2020
db492a3
Merge branch 'develop' into issue_331/mention_support
SergioEstevao Apr 21, 2020
7532fb4
Update GB reference.
SergioEstevao Apr 21, 2020
58d372e
Update bundles.
SergioEstevao Apr 21, 2020
c06e7b6
Update GB reference.
SergioEstevao Apr 22, 2020
411492e
Update GB reference.
SergioEstevao Apr 23, 2020
8eb2c1b
Update bundles.
SergioEstevao Apr 23, 2020
65383b8
Update GB reference.
SergioEstevao Apr 24, 2020
167a947
Merge branch 'develop' into issue_331/mention_support
SergioEstevao Apr 24, 2020
c9cfbb0
Add capabilities check support for mentions.
SergioEstevao Apr 24, 2020
3ec3a90
Update bundles.
SergioEstevao Apr 24, 2020
1a57491
Make sure there is a default value for capabilities when is not defined.
SergioEstevao Apr 24, 2020
e49d01b
Formating fix to make Prettier happy
mchowning Apr 24, 2020
08f760f
Add capabilities initial prop for Android
mchowning Apr 24, 2020
5c7bea0
Merge branch 'develop' into issue_331/mention_support
SergioEstevao Apr 27, 2020
166cca2
Update GB reference.
SergioEstevao Apr 27, 2020
4d923da
Update GB reference.
SergioEstevao Apr 27, 2020
94cca3d
Update GB reference.
SergioEstevao Apr 28, 2020
f145c1b
Update bundles.
SergioEstevao Apr 28, 2020
27411aa
Update gutenberg ref
mchowning Apr 28, 2020
f3552d1
Merge branch 'develop' into issue_331/mention_support
SergioEstevao Apr 30, 2020
4a0547e
Update GB reference.
SergioEstevao May 8, 2020
5980b5e
Merge branch 'develop' into issue_331/mention_support
SergioEstevao May 8, 2020
7b1cc91
Update bundles.
SergioEstevao May 11, 2020
b33bbb0
Merge branch 'develop' into issue_331/mention_support
SergioEstevao May 11, 2020
76e43cb
Update bundles.
SergioEstevao May 11, 2020
db05178
Update GB reference.
SergioEstevao May 19, 2020
f6346f6
Merge branch 'develop' into issue_331/mention_support
SergioEstevao May 19, 2020
a0df91e
Update GB reference.
SergioEstevao May 20, 2020
1f5ee28
Update bundles.
SergioEstevao May 20, 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
1 change: 1 addition & 0 deletions RELEASE-NOTES.txt
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@

1.27.0
------
* Block Editor: Add dialog for mentioning other users in your post
* Prefill caption for image blocks when available on the Media library
* New block: Buttons. From now you’ll be able to add the individual Button block only inside the Buttons block
* Fix bug where whitespaces at start of text blocks were being removed
Expand Down
22 changes: 22 additions & 0 deletions android/app/src/main/java/com/gutenberg/MainActivity.java
Original file line number Diff line number Diff line change
@@ -1,6 +1,13 @@
package com.gutenberg;

import android.os.Bundle;

import androidx.annotation.Nullable;

import com.facebook.react.ReactActivity;
import com.facebook.react.ReactActivityDelegate;

import org.wordpress.mobile.WPAndroidGlue.WPAndroidGlueCode;

public class MainActivity extends ReactActivity {

Expand All @@ -12,4 +19,19 @@ public class MainActivity extends ReactActivity {
protected String getMainComponentName() {
return "gutenberg";
}

@Override
protected ReactActivityDelegate createReactActivityDelegate() {
return new ReactActivityDelegate(this, getMainComponentName()) {
@Nullable
@Override
protected Bundle getLaunchOptions() {
Bundle bundle = new Bundle();
Bundle capabilities = new Bundle();
capabilities.putBoolean(WPAndroidGlueCode.PROP_NAME_CAPABILITIES_MENTIONS, true);
bundle.putBundle(WPAndroidGlueCode.PROP_NAME_CAPABILITIES, capabilities);
return bundle;
}
};
}
}
5 changes: 5 additions & 0 deletions android/app/src/main/java/com/gutenberg/MainApplication.java
Original file line number Diff line number Diff line change
Expand Up @@ -136,6 +136,11 @@ public void editorDidEmitLog(String message, LogLevel logLevel) {
@Override
public void performRequest(String path, Consumer<String> onSuccess, Consumer<Bundle> onError) {}

@Override
public void onAddMention(Consumer<String> onSuccess) {
onSuccess.accept("matt");
}

}, isDarkMode());

return new ReactNativeHost(this) {
Expand Down
2,308 changes: 1,160 additions & 1,148 deletions bundle/android/App.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion bundle/android/App.js.map

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,9 @@
},
"customGradient": {
"type": "string"
},
"contentPosition": {
"type": "string"
}
}
}
2 changes: 1 addition & 1 deletion bundle/android/raw/i18ncache_data_ar.json

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion bundle/android/raw/i18ncache_data_bg.json

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion bundle/android/raw/i18ncache_data_bo.json

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion bundle/android/raw/i18ncache_data_ca.json

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion bundle/android/raw/i18ncache_data_cs.json

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion bundle/android/raw/i18ncache_data_cy.json

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion bundle/android/raw/i18ncache_data_da.json

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion bundle/android/raw/i18ncache_data_de.json

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion bundle/android/raw/i18ncache_data_el.json

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion bundle/android/raw/i18ncache_data_enau.json

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion bundle/android/raw/i18ncache_data_enca.json

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion bundle/android/raw/i18ncache_data_engb.json

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion bundle/android/raw/i18ncache_data_ennz.json

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion bundle/android/raw/i18ncache_data_enza.json

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion bundle/android/raw/i18ncache_data_es.json

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion bundle/android/raw/i18ncache_data_esar.json

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion bundle/android/raw/i18ncache_data_escl.json

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion bundle/android/raw/i18ncache_data_escr.json

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion bundle/android/raw/i18ncache_data_fa.json

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion bundle/android/raw/i18ncache_data_fr.json

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion bundle/android/raw/i18ncache_data_gl.json

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion bundle/android/raw/i18ncache_data_he.json

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion bundle/android/raw/i18ncache_data_hr.json

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion bundle/android/raw/i18ncache_data_hu.json

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion bundle/android/raw/i18ncache_data_id.json

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion bundle/android/raw/i18ncache_data_is.json

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion bundle/android/raw/i18ncache_data_it.json

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion bundle/android/raw/i18ncache_data_ja.json

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion bundle/android/raw/i18ncache_data_ka.json

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion bundle/android/raw/i18ncache_data_ko.json

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion bundle/android/raw/i18ncache_data_nb.json

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion bundle/android/raw/i18ncache_data_nl.json

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion bundle/android/raw/i18ncache_data_nlbe.json

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion bundle/android/raw/i18ncache_data_pl.json

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion bundle/android/raw/i18ncache_data_pt.json

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion bundle/android/raw/i18ncache_data_ptbr.json

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion bundle/android/raw/i18ncache_data_ro.json

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion bundle/android/raw/i18ncache_data_ru.json

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion bundle/android/raw/i18ncache_data_sk.json

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion bundle/android/raw/i18ncache_data_sq.json

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion bundle/android/raw/i18ncache_data_sr.json

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion bundle/android/raw/i18ncache_data_sv.json

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion bundle/android/raw/i18ncache_data_th.json

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion bundle/android/raw/i18ncache_data_tr.json

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion bundle/android/raw/i18ncache_data_uk.json

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion bundle/android/raw/i18ncache_data_ur.json

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion bundle/android/raw/i18ncache_data_vi.json

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion bundle/android/raw/i18ncache_data_zhcn.json

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion bundle/android/raw/i18ncache_data_zhtw.json

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion bundle/android/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,6 @@
<string name="gutenberg_native_choose_from_device" tools:ignore="UnusedResources">Choose from device</string>
<!-- translators: sample content for "Contact" page template -->
<string name="gutenberg_native_city_10100" tools:ignore="UnusedResources">City, 10100</string>
<string name="gutenberg_native_clear_all_settings" tools:ignore="UnusedResources">Clear All Settings</string>
<string name="gutenberg_native_columns_settings" tools:ignore="UnusedResources">Columns Settings</string>
<string name="gutenberg_native_content" tools:ignore="UnusedResources">Content…</string>
<!-- translators: %s: current cell value. -->
Expand Down Expand Up @@ -87,6 +86,7 @@ translators: sample content for "Services" page template -->
<string name="gutenberg_native_hide_keyboard" tools:ignore="UnusedResources">Hide keyboard</string>
<!-- translators: accessibility text. %s: image caption. -->
<string name="gutenberg_native_image_caption_s" tools:ignore="UnusedResources">Image caption. %s</string>
<string name="gutenberg_native_insert_mention" tools:ignore="UnusedResources">Insert mention</string>
<!-- translators: sample content for "Services" page template -->
<string name="gutenberg_native_inspiration" tools:ignore="UnusedResources">Inspiration</string>
<!-- translators: sample content for "About" page template -->
Expand Down
2,322 changes: 1,167 additions & 1,155 deletions bundle/ios/App.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion bundle/ios/App.js.map

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion bundle/ios/GutenbergNativeTranslations.swift
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,6 @@ private func dummy() {
_ = NSLocalizedString("Blog", comment: "translators: title for \"Blog\" page template")
_ = NSLocalizedString("Choose from device", comment: "")
_ = NSLocalizedString("City, 10100", comment: "translators: sample content for \"Contact\" page template")
_ = NSLocalizedString("Clear All Settings", comment: "")
_ = NSLocalizedString("Columns Settings", comment: "")
_ = NSLocalizedString("Content…", comment: "")
_ = NSLocalizedString("Current value is %s", comment: "translators: %s: current cell value.")
Expand Down Expand Up @@ -68,6 +67,7 @@ private func dummy() {
_ = NSLocalizedString("Here is the panel content!", comment: "")
_ = NSLocalizedString("Hide keyboard", comment: "")
_ = NSLocalizedString("Image caption. %s", comment: "translators: accessibility text. %s: image caption.")
_ = NSLocalizedString("Insert mention", comment: "")
_ = NSLocalizedString("Inspiration", comment: "translators: sample content for \"Services\" page template")
_ = NSLocalizedString("It is our choices, Harry, that show what we truly are, far more than our abilities.", comment: "translators: sample content for \"About\" page template")
_ = NSLocalizedString("J.K. Rowling", comment: "translators: sample content for \"About\" page template")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,9 @@
},
"customGradient": {
"type": "string"
},
"contentPosition": {
"type": "string"
}
}
}
2 changes: 1 addition & 1 deletion bundle/ios/assets/i18n-cache/data/ar.json

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion bundle/ios/assets/i18n-cache/data/bg.json

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion bundle/ios/assets/i18n-cache/data/bo.json

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion bundle/ios/assets/i18n-cache/data/ca.json

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion bundle/ios/assets/i18n-cache/data/cs.json

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion bundle/ios/assets/i18n-cache/data/cy.json

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion bundle/ios/assets/i18n-cache/data/da.json

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion bundle/ios/assets/i18n-cache/data/de.json

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion bundle/ios/assets/i18n-cache/data/el.json

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion bundle/ios/assets/i18n-cache/data/en-au.json

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion bundle/ios/assets/i18n-cache/data/en-ca.json

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion bundle/ios/assets/i18n-cache/data/en-gb.json

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion bundle/ios/assets/i18n-cache/data/en-nz.json

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion bundle/ios/assets/i18n-cache/data/en-za.json

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion bundle/ios/assets/i18n-cache/data/es-ar.json

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion bundle/ios/assets/i18n-cache/data/es-cl.json

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion bundle/ios/assets/i18n-cache/data/es-cr.json

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion bundle/ios/assets/i18n-cache/data/es.json

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion bundle/ios/assets/i18n-cache/data/fa.json

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion bundle/ios/assets/i18n-cache/data/fr.json

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion bundle/ios/assets/i18n-cache/data/gl.json

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion bundle/ios/assets/i18n-cache/data/he.json

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion bundle/ios/assets/i18n-cache/data/hr.json

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion bundle/ios/assets/i18n-cache/data/hu.json

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion bundle/ios/assets/i18n-cache/data/id.json

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion bundle/ios/assets/i18n-cache/data/is.json

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion bundle/ios/assets/i18n-cache/data/it.json

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion bundle/ios/assets/i18n-cache/data/ja.json

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion bundle/ios/assets/i18n-cache/data/ka.json

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion bundle/ios/assets/i18n-cache/data/ko.json

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion bundle/ios/assets/i18n-cache/data/nb.json

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion bundle/ios/assets/i18n-cache/data/nl-be.json

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion bundle/ios/assets/i18n-cache/data/nl.json

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion bundle/ios/assets/i18n-cache/data/pl.json

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion bundle/ios/assets/i18n-cache/data/pt-br.json

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion bundle/ios/assets/i18n-cache/data/pt.json

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion bundle/ios/assets/i18n-cache/data/ro.json

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion bundle/ios/assets/i18n-cache/data/ru.json

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion bundle/ios/assets/i18n-cache/data/sk.json

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion bundle/ios/assets/i18n-cache/data/sq.json

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion bundle/ios/assets/i18n-cache/data/sr.json

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion bundle/ios/assets/i18n-cache/data/sv.json

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion bundle/ios/assets/i18n-cache/data/th.json

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion bundle/ios/assets/i18n-cache/data/tr.json

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion bundle/ios/assets/i18n-cache/data/uk.json

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion bundle/ios/assets/i18n-cache/data/ur.json

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion bundle/ios/assets/i18n-cache/data/vi.json

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion bundle/ios/assets/i18n-cache/data/zh-cn.json

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion bundle/ios/assets/i18n-cache/data/zh-tw.json

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion gutenberg
Submodule gutenberg updated 532 files
9 changes: 9 additions & 0 deletions ios/gutenberg/GutenbergViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ class GutenbergViewController: UIViewController {
}

extension GutenbergViewController: GutenbergBridgeDelegate {

func gutenbergDidRequestFetch(path: String, completion: @escaping (Result<Any, NSError>) -> Void) {
completion(Result.success([:]))
}
Expand Down Expand Up @@ -194,6 +195,10 @@ extension GutenbergViewController: GutenbergBridgeDelegate {
func gutenbergDidLogUserEvent(_ event: GutenbergUserEvent) {
print("Gutenberg loged user event")
}

func gutenbergDidRequestMention(callback: @escaping (Result<String, NSError>) -> Void) {
callback(.success("matt"))

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I'd be in favor of "sergio" here for balance, but I guess the name "matt" get's special treatment around here ;-P

}
}

extension GutenbergViewController: GutenbergBridgeDataSource {
Expand All @@ -213,6 +218,10 @@ extension GutenbergViewController: GutenbergBridgeDataSource {
return nil
}

func gutenbergCapabilities() -> [String : Bool]? {
return ["mentions": true]
}

func aztecAttachmentDelegate() -> TextViewAttachmentDelegate {
return ExampleAttachmentDelegate()
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
package org.wordpress.mobile.ReactNativeGutenbergBridge;

import androidx.core.util.Consumer;

import com.facebook.react.bridge.ReadableArray;
import com.facebook.react.bridge.ReadableMap;
import com.facebook.react.bridge.WritableMap;
Expand Down Expand Up @@ -136,4 +138,6 @@ public static GutenbergUserEvent getEnum(String eventName) {
void requestMediaEditor(MediaUploadCallback mediaUploadCallback, String mediaUrl);

void logUserEvent(GutenbergUserEvent gutenbergUserEvent, ReadableMap eventProperties);

void onAddMention(Consumer<String> onSuccess);
}
Original file line number Diff line number Diff line change
Expand Up @@ -251,6 +251,11 @@ private OtherMediaOptionsReceivedCallback getNewOtherMediaReceivedCallback(final
};
}

@ReactMethod
public void addMention(Promise promise) {
mGutenbergBridgeJS2Parent.onAddMention(promise::resolve);
}

private GutenbergBridgeJS2Parent.MediaUploadCallback getNewUploadMediaCallback(final Boolean allowMultipleSelection, final Callback jsCallback) {
return new GutenbergBridgeJS2Parent.MediaUploadCallback() {
@Override
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
package org.wordpress.mobile.WPAndroidGlue;

import androidx.core.util.Consumer;

public interface AddMentionUtil {
void getMention(Consumer<String> onResult);
}
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
import android.view.ViewGroup;
import android.widget.FrameLayout.LayoutParams;

import androidx.annotation.Nullable;
import androidx.core.util.Consumer;
import androidx.fragment.app.Fragment;

Expand Down Expand Up @@ -90,13 +91,16 @@ public class WPAndroidGlueCode {
private CountDownLatch mGetContentCountDownLatch;
private WeakReference<View> mLastFocusedView = null;
private RequestExecutor mRequestExecutor;
private AddMentionUtil mAddMentionUtil;

private static final String PROP_NAME_INITIAL_DATA = "initialData";
private static final String PROP_NAME_INITIAL_TITLE = "initialTitle";
private static final String PROP_NAME_INITIAL_HTML_MODE_ENABLED = "initialHtmlModeEnabled";
private static final String PROP_NAME_POST_TYPE = "postType";
private static final String PROP_NAME_LOCALE = "locale";
private static final String PROP_NAME_TRANSLATIONS = "translations";
public static final String PROP_NAME_CAPABILITIES = "capabilities";
public static final String PROP_NAME_CAPABILITIES_MENTIONS = "mentions";

private static OkHttpHeaderInterceptor sAddCookiesInterceptor = new OkHttpHeaderInterceptor();
private static OkHttpClient sOkHttpClient = new OkHttpClient.Builder().addInterceptor(sAddCookiesInterceptor).build();
Expand Down Expand Up @@ -330,6 +334,10 @@ public void requestMediaEditor(MediaUploadCallback mediaUploadCallback, String m
public void logUserEvent(GutenbergUserEvent event, ReadableMap eventProperties) {
mOnLogGutenbergUserEventListener.onGutenbergUserEvent(event, eventProperties.toHashMap());
}

@Override public void onAddMention(Consumer<String> onSuccess) {
mAddMentionUtil.getMention(onSuccess);
}
}, mIsDarkMode);

return Arrays.asList(
Expand All @@ -352,17 +360,43 @@ private ImagePipelineConfig getImagePipelineConfig(OkHttpClient client) {
}

@Deprecated
public void onCreateView(Context initContext, boolean htmlModeEnabled,
Application application, boolean isDebug, boolean buildGutenbergFromSource,
boolean isNewPost, String localeString, Bundle translations, int colorBackground, boolean isDarkMode) {
onCreateView(initContext, htmlModeEnabled, application, isDebug, buildGutenbergFromSource, "post", isNewPost
, localeString, translations, colorBackground, isDarkMode);
}

public void onCreateView(Context initContext, boolean htmlModeEnabled,
Application application, boolean isDebug, boolean buildGutenbergFromSource,
String postType, boolean isNewPost, String localeString, Bundle translations,
int colorBackground, boolean isDarkMode) {
public void onCreateView(Context initContext,

ghost May 8, 2020

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I can't see any reason to keep this deprecated, overloaded onCreateView. Introduced 09367d3 but I'm not sure it was ever used for anything, maybe just added to be safe in that initial change I linked. But no real need to "refactor" and remove that in combination with this change if there's a small risk it breaks something that I'm just not imagining, could be removed in a future clean up/refactor PR, so up to you.

ghost May 8, 2020

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

I had the exact same thought. I was very tempted to just remove it, but ended up deciding not to lump that change in with these changes.

boolean htmlModeEnabled,
Application application,
boolean isDebug,
boolean buildGutenbergFromSource,
boolean isNewPost,
String localeString,
Bundle translations,
int colorBackground,
boolean isDarkMode) {
onCreateView(
initContext,
htmlModeEnabled,
application,
isDebug,
buildGutenbergFromSource,
"post",
isNewPost,
localeString,
translations,
colorBackground,
isDarkMode,
null);
}

public void onCreateView(Context initContext,
boolean htmlModeEnabled,
Application application,
boolean isDebug,
boolean buildGutenbergFromSource,
String postType,
boolean isNewPost,
String localeString,
Bundle translations,
int colorBackground,
boolean isDarkMode,
@Nullable Boolean isSiteUsingWpComRestApi) {
mIsDarkMode = isDarkMode;
mReactRootView = new ReactRootView(new MutableContextWrapper(initContext));
mReactRootView.setBackgroundColor(colorBackground);
Expand Down Expand Up @@ -393,6 +427,12 @@ public void onCreateView(Context initContext, boolean htmlModeEnabled,
initialProps.putString(PROP_NAME_LOCALE, localeString);
initialProps.putBundle(PROP_NAME_TRANSLATIONS, translations);

Bundle capabilities = new Bundle();
if (isSiteUsingWpComRestApi != null) {
capabilities.putBoolean(PROP_NAME_CAPABILITIES_MENTIONS, isSiteUsingWpComRestApi);
}
initialProps.putBundle(PROP_NAME_CAPABILITIES, capabilities);

// The string here (e.g. "MyReactNativeApp") has to match
// the string in AppRegistry.registerComponent() in index.js
mReactRootView.setAppProperties(initialProps);
Expand All @@ -407,6 +447,7 @@ public void attachToContainer(ViewGroup viewGroup, OnMediaLibraryButtonListener
OnImageFullscreenPreviewListener onImageFullscreenPreviewListener,
OnMediaEditorListener onMediaEditorListener,
OnLogGutenbergUserEventListener onLogGutenbergUserEventListener,
AddMentionUtil addMentionUtil,
boolean isDarkMode) {

MutableContextWrapper contextWrapper = (MutableContextWrapper) mReactRootView.getContext();
Expand All @@ -420,6 +461,7 @@ public void attachToContainer(ViewGroup viewGroup, OnMediaLibraryButtonListener
mOnImageFullscreenPreviewListener = onImageFullscreenPreviewListener;
mOnMediaEditorListener = onMediaEditorListener;
mOnLogGutenbergUserEventListener = onLogGutenbergUserEventListener;
mAddMentionUtil = addMentionUtil;

sAddCookiesInterceptor.setOnAuthHeaderRequestedListener(onAuthHeaderRequestedListener);

Expand Down
4 changes: 4 additions & 0 deletions react-native-gutenberg-bridge/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -136,4 +136,8 @@ export function logUserEvent( event, properties ) {
return RNReactNativeGutenbergBridge.logUserEvent( event, properties );
}

export function addMention() {
return RNReactNativeGutenbergBridge.addMention();
}

export default RNReactNativeGutenbergBridge;
4 changes: 4 additions & 0 deletions react-native-gutenberg-bridge/ios/Gutenberg.swift
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,10 @@ public class Gutenberg: NSObject {
initialProps["translations"] = translations
}

if let capabilities = dataSource.gutenbergCapabilities() {
initialProps["capabilities"] = capabilities
}

return initialProps
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,8 @@ public protocol GutenbergBridgeDataSource: class {

/// Asks the delegate for a list of Media Sources to show on the Media Source Picker.
func gutenbergMediaSources() -> [Gutenberg.MediaSource]

func gutenbergCapabilities() -> [String: Bool]?
}

public extension GutenbergBridgeDataSource {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -164,6 +164,10 @@ public protocol GutenbergBridgeDelegate: class {
/// Tells the delegate that the editor needs to log a custom event
/// - Parameter event: The event key to be logged
func gutenbergDidLogUserEvent(_ event: GutenbergUserEvent)

/// Tells the delegate that the editor requested a mention
/// - Parameter callback: Completion handler to be called with an user mention or an error
func gutenbergDidRequestMention(callback: @escaping (Swift.Result<String, NSError>) -> Void)
}

// MARK: - Optional GutenbergBridgeDelegate methods
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,5 +19,6 @@ @interface RCT_EXTERN_MODULE(RNReactNativeGutenbergBridge, NSObject)
RCT_EXTERN_METHOD(requestImageFullscreenPreview:(NSString *)currentImageUrlString originalImageUrlString:(NSString *)originalImageUrlString)
RCT_EXTERN_METHOD(requestMediaEditor:(NSString *)mediaUrl callback:(RCTResponseSenderBlock)callback)
RCT_EXTERN_METHOD(logUserEvent:(NSString *)event properties:(NSDictionary *)properties)
RCT_EXTERN_METHOD(addMention:(RCTPromiseResolveBlock)resolve rejecter:(RCTPromiseRejectBlock)rejecter)

@end
Original file line number Diff line number Diff line change
Expand Up @@ -230,6 +230,18 @@ public class RNReactNativeGutenbergBridge: RCTEventEmitter {
guard let logEvent = GutenbergUserEvent(event: event, properties: properties) else { return }
self.delegate?.gutenbergDidLogUserEvent(logEvent)
}

@objc
func addMention(_ resolver: @escaping RCTPromiseResolveBlock, rejecter: @escaping RCTPromiseRejectBlock) {
self.delegate?.gutenbergDidRequestMention(callback: { (result) in
switch result {
case .success(let mention):
resolver([mention])
case .failure(let error):
rejecter(error.domain, "\(error.code)", error)
}
})
}
}

// MARK: - RCTBridgeModule delegate
Expand Down
3 changes: 2 additions & 1 deletion src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ export class RootComponent extends React.Component {
}

render() {
const { initialHtmlModeEnabled } = this.props;
const { initialHtmlModeEnabled, capabilities = {} } = this.props;
let initialData = this.props.initialData;
let initialTitle = this.props.initialTitle;
let postType = this.props.postType;
Expand All @@ -88,6 +88,7 @@ export class RootComponent extends React.Component {
initialHtmlModeEnabled={ initialHtmlModeEnabled }
initialTitle={ initialTitle }
postType={ postType }
capabilities={ capabilities }
/>
);
}
Expand Down