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

Release/1.4.0 #951

Merged
merged 65 commits into from
May 3, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
65 commits
Select commit Hold shift + click to select a range
a521284
Update gutenberg ref
etoledom Apr 18, 2019
eb2fb33
Update GB reference
daniloercoli Apr 18, 2019
baa91a4
Merge branch 'develop' of https://github.com/wordpress-mobile/gutenbe…
daniloercoli Apr 19, 2019
c6ca773
Update gutenberg ref
etoledom Apr 19, 2019
abc09d1
Merge branch 'develop' into issue/autoscroll-on-list-block
etoledom Apr 19, 2019
d3b1eea
Upgrade GB ref
daniloercoli Apr 19, 2019
1a4f344
Update gutenberg ref
etoledom Apr 19, 2019
b19880e
Point to GB master without the list block suppression
hypest Apr 22, 2019
402bd87
Merge pull request #913 from wordpress-mobile/merge-v1.3.0-to-develop
hypest Apr 22, 2019
6c39fd5
Improving accessibility on Post Title (#916)
pinarol Apr 23, 2019
2372231
Signal if text has already been changed
hypest Apr 23, 2019
38cdc59
Use passed selection when Enter already altered text
hypest Apr 23, 2019
0e2bb58
Merge branch 'develop' of https://github.com/wordpress-mobile/gutenbe…
daniloercoli Apr 23, 2019
ac2c867
Update GB ref
daniloercoli Apr 23, 2019
61fb200
Update GB ref after merging companion PR
daniloercoli Apr 23, 2019
c71e081
Merge pull request #892 from wordpress-mobile/issue/887-History-stack…
daniloercoli Apr 23, 2019
98e51a1
Paragraph block accessibility improvements - unselected state (#923)
pinarol Apr 24, 2019
6290243
Improve image block accessibility on selected state (#920)
pinarol Apr 24, 2019
165b9a4
Improve accessibility on Heading block (#925)
pinarol Apr 24, 2019
8889b8d
Don't emit text changed event when Enter detected
hypest Apr 24, 2019
bbda142
Use the GB hash with the rich-text fix
hypest Apr 24, 2019
d17e5d2
Use Aztec ref with the Enter processing fix
hypest Apr 24, 2019
166b206
Remove temporary code
hypest Apr 25, 2019
1786fab
Use simplified access to EnterPressedUnderway
hypest Apr 25, 2019
91c222e
Update GB hash to use iOS regression fixes
hypest Apr 25, 2019
70112bf
Update GB hash
hypest Apr 25, 2019
7391049
Update GB hash
hypest Apr 25, 2019
c3f094a
Update GB hash
hypest Apr 25, 2019
cd97945
Update GB hash
hypest Apr 25, 2019
76678c9
Minimize diff
hypest Apr 25, 2019
2ffc512
Improve Screen Reader support for Inner Toolbar (#927)
pinarol Apr 25, 2019
7897f98
Update Aztec ref
hypest Apr 25, 2019
ce92f47
Update Aztec ref
hypest Apr 26, 2019
ab4f3e3
Use shortened hash version to try please JitPack
hypest Apr 26, 2019
57c8de0
Use a git tag to try please JitPack
hypest Apr 26, 2019
42d8443
Improve string concatenation for accessibility labels (#931)
pinarol Apr 26, 2019
61b52cb
Update gutenberg ref to master
etoledom Apr 30, 2019
09f1ca7
Merge branch 'develop' into issue/autoscroll-on-list-block
etoledom Apr 30, 2019
991f8a8
Use Aztec helper isEnterPressedUnderway
hypest Apr 30, 2019
ae67206
Use default line fragment padding on the start of lines.
SergioEstevao Apr 30, 2019
daf57e4
Configure spacing before and after paragraph lists.
SergioEstevao Apr 30, 2019
0417343
Utilize isEnterPressedUnderway
hypest Apr 30, 2019
ca2a93f
Update GB from its master
hypest Apr 30, 2019
897d272
Set Aztec t delete the Enter for paragraph block
hypest Apr 30, 2019
52832ce
Merge branch 'develop' into fix/list-handling-in-android
hypest Apr 30, 2019
04610cc
Need to include the kotlin plugin dep location
hypest Apr 30, 2019
d46cebd
Merge pull request #890 from wordpress-mobile/issue/autoscroll-on-lis…
etoledom May 1, 2019
c935c81
Don't use a lambda, to avoid bringing in Java8 features
hypest May 2, 2019
72f934e
Merge branch 'develop' into fix/list-handling-in-android
hypest May 2, 2019
6513ba8
Avoid sending extra `onFocus` messages.
etoledom May 2, 2019
2b34441
Update GB hash
hypest May 2, 2019
49ad83c
Merge pull request #943 from wordpress-mobile/issue/897_fix_spacing_i…
SergioEstevao May 2, 2019
dcff041
Update to the merged GB hash
hypest May 2, 2019
215d18b
Update Aztec hash
hypest May 2, 2019
48df9ab
Update to use Spannable as in Aztec
hypest May 2, 2019
105804b
Update Aztec ref
hypest May 2, 2019
faf4a26
Update Aztec ref to the merged one
hypest May 2, 2019
f4e91b9
Merge pull request #928 from wordpress-mobile/fix/list-handling-in-an…
hypest May 2, 2019
1e276ac
Merge branch 'develop' into issue/843-fix-move-selection-ios
etoledom May 3, 2019
82228c5
Merge pull request #948 from wordpress-mobile/issue/843-fix-move-sele…
etoledom May 3, 2019
d4f4084
Update gutenberg repo to point to `rnmobile/master-fork-before-richte…
pinarol May 3, 2019
498b7f9
Update AztecEditor-Android to 1.3.26
loremattei May 3, 2019
e08238d
Update AztecEditor-iOS to 1.6.1
loremattei May 3, 2019
b6cf496
Update version to 1.4.0
loremattei May 3, 2019
d50193c
Update JS bundle for 1.4.0
loremattei May 3, 2019
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
130 changes: 65 additions & 65 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.

124 changes: 62 additions & 62 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 package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "gutenberg-mobile",
"version": "1.3.0",
"version": "1.4.0",
"private": true,
"config": {
"jsfiles": "./*.js src/*.js src/**/*.js src/**/**/*.js",
Expand Down
7 changes: 5 additions & 2 deletions react-native-aztec/android/build.gradle
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
buildscript {
ext {
gradlePluginVersion = '3.3.1'
kotlinVersion = '1.2.31'
kotlinVersion = '1.3.11'
supportLibVersion = '28.0.0'
tagSoupVersion = '1.2.1'
glideVersion = '3.7.0'
Expand All @@ -12,7 +12,7 @@ buildscript {
wordpressUtilsVersion = '1.22'
espressoVersion = '3.0.1'

aztecVersion = 'v1.3.25'
aztecVersion = 'v1.3.26'
}

repositories {
Expand All @@ -23,10 +23,12 @@ buildscript {
dependencies {
classpath "com.android.tools.build:gradle:$gradlePluginVersion"
classpath 'com.github.dcendents:android-maven-gradle-plugin:2.1'
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlinVersion"
}
}

apply plugin: 'com.android.library'
apply plugin: 'kotlin-android'
apply plugin: 'com.github.dcendents.android-maven'

// import the `readReactNativeVersion()` function
Expand Down Expand Up @@ -62,6 +64,7 @@ android {
main {
dirs.each { dir ->
java.srcDirs "src/${dir}/java"
java.srcDirs += "src/${dir}/kotlin"
res.srcDirs "src/${dir}/res"
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,13 +15,16 @@ class ReactAztecEnterEvent extends Event<ReactAztecEnterEvent> {
private String mText;
private int mSelectionStart;
private int mSelectionEnd;
private boolean mFiredAfterTextChanged;
private int mEventCount;

public ReactAztecEnterEvent(int viewId, String text, int selectionStart, int selectionEnd, int eventCount) {
public ReactAztecEnterEvent(int viewId, String text, int selectionStart, int selectionEnd,
boolean firedAfterTextChanged, int eventCount) {
super(viewId);
mText = text;
mSelectionStart = selectionStart;
mSelectionEnd = selectionEnd;
mFiredAfterTextChanged = firedAfterTextChanged;
mEventCount = eventCount;
}

Expand All @@ -46,6 +49,7 @@ private WritableMap serializeEventData() {
eventData.putString("text", mText);
eventData.putInt("selectionStart", mSelectionStart);
eventData.putInt("selectionEnd", mSelectionEnd);
eventData.putBoolean("firedAfterTextChanged", mFiredAfterTextChanged);
eventData.putInt("eventCount", mEventCount);
return eventData;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -360,7 +360,7 @@ public void disableGBMode(final ReactAztecText view, boolean disable) {
view.setImageGetter(new GlideImageLoader(view.getContext()));
view.setVideoThumbnailGetter(new GlideVideoThumbnailLoader(view.getContext()));
// we need to restart the editor now
String content = view.toHtml(false);
String content = view.toHtml(view.getText(), false);
view.fromHtml(content, false);
}
}
Expand Down Expand Up @@ -414,6 +414,11 @@ public void setOnPasteHandling(final ReactAztecText view, boolean onPasteHandlin
view.shouldHandleOnPaste = onPasteHandling;
}

@ReactProp(name = "deleteEnter", defaultBoolean = false)
public void setShouldDeleteEnter(final ReactAztecText view, boolean shouldDeleteEnter) {
view.shouldDeleteEnter = shouldDeleteEnter;
}

@Override
public Map<String, Integer> getCommandsMap() {
return MapBuilder.<String, Integer>builder()
Expand Down Expand Up @@ -455,7 +460,7 @@ public void onFocusChange(View v, boolean hasFocus) {
eventDispatcher.dispatchEvent(
new ReactAztecEndEditingEvent(
editText.getId(),
editText.toHtml(false)));
editText.toHtml(editText.getText(), false)));
}
}
});
Expand Down Expand Up @@ -498,22 +503,26 @@ public void onTextChanged(CharSequence s, int start, int before, int count) {
return;
}

int currentEventCount = mEditText.incrementAndGetEventCounter();
// The event that contains the event counter and updates it must be sent first.
// TODO: t7936714 merge these events
mEventDispatcher.dispatchEvent(
new ReactTextChangedEvent(
mEditText.getId(),
mEditText.toHtml(false),
currentEventCount));

mEventDispatcher.dispatchEvent(
new ReactTextInputEvent(
mEditText.getId(),
newText,
oldText,
start,
start + before));
// if the "Enter" handling is underway, don't sent text change events. The ReactAztecEnterEvent will have
// the text (minus the Enter char itself).
if (!mEditText.isEnterPressedUnderway()) {
int currentEventCount = mEditText.incrementAndGetEventCounter();
// The event that contains the event counter and updates it must be sent first.
// TODO: t7936714 merge these events
mEventDispatcher.dispatchEvent(
new ReactTextChangedEvent(
mEditText.getId(),
mEditText.toHtml(mEditText.getText(), false),
currentEventCount));

mEventDispatcher.dispatchEvent(
new ReactTextInputEvent(
mEditText.getId(),
newText,
oldText,
start,
start + before));
}


if (mPreviousText.length() == 0
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@
import android.support.annotation.Nullable;
import android.text.Editable;
import android.text.InputType;
import android.text.Spannable;
import android.text.Spanned;
import android.text.TextUtils;
import android.text.TextWatcher;
import android.view.inputmethod.InputMethodManager;
Expand Down Expand Up @@ -60,6 +62,8 @@ public class ReactAztecText extends AztecText {
boolean shouldHandleOnSelectionChange = false;
boolean shouldHandleActiveFormatsChange = false;

boolean shouldDeleteEnter = false;

// This optional variable holds the outer HTML tag that will be added to the text when the user start typing in it
// This is required to keep placeholder text working, and start typing with styled text.
// Ref: https://github.com/wordpress-mobile/gutenberg-mobile/issues/707
Expand Down Expand Up @@ -88,16 +92,16 @@ public ReactAztecText(ThemedReactContext reactContext) {

this.setAztecKeyListener(new ReactAztecText.OnAztecKeyListener() {
@Override
public boolean onEnterKey() {
public boolean onEnterKey(Spannable text, boolean firedAfterTextChanged, int selStart, int selEnd) {
if (shouldHandleOnEnter && !isTextChangedListenerDisabled()) {
return onEnter();
return onEnter(text, firedAfterTextChanged, selStart, selEnd);
}
return false;
}
@Override
public boolean onBackspaceKey() {
if (shouldHandleOnBackspace && !isTextChangedListenerDisabled()) {
String content = toHtml(false);
String content = toHtml(getText(), false);
if (TextUtils.isEmpty(content)) {
return onBackspace();
}
Expand Down Expand Up @@ -296,7 +300,7 @@ private void propagateSelectionChanges(int selStart, int selEnd) {
if (!shouldHandleOnSelectionChange) {
return;
}
String content = toHtml(false);
String content = toHtml(getText(), false);
ReactContext reactContext = (ReactContext) getContext();
EventDispatcher eventDispatcher = reactContext.getNativeModule(UIManagerModule.class).getEventDispatcher();
eventDispatcher.dispatchEvent(
Expand Down Expand Up @@ -327,6 +331,16 @@ public void addTextChangedListener(TextWatcher watcher) {
if (mListeners == null) {
mListeners = new ArrayList<>();
super.addTextChangedListener(getTextWatcherDelegator());

// Keep the enter pressed watcher at the beginning of the watchers list.
// We want to intercept Enter.key as soon as possible, and before other listeners start modifying the text.
// Also note that this Watchers, when the AztecKeyListener is set, keep hold a copy of the content in the editor.
mListeners.add(new EnterPressedWatcher(this, new EnterDeleter() {
@Override
public boolean shouldDeleteEnter() {
return shouldDeleteEnter;
}
}));
}

mListeners.add(watcher);
Expand Down Expand Up @@ -355,16 +369,17 @@ public void setIsSettingTextFromJS(boolean mIsSettingTextFromJS) {
this.mIsSettingTextFromJS = mIsSettingTextFromJS;
}

private boolean onEnter() {
private boolean onEnter(Spannable text, boolean firedAfterTextChanged, int selStart, int selEnd) {
disableTextChangedListener();
String content = toHtml(false);
int cursorPositionStart = getSelectionStart();
int cursorPositionEnd = getSelectionEnd();
String content = toHtml(text, false);
int cursorPositionStart = firedAfterTextChanged ? selStart : getSelectionStart();
int cursorPositionEnd = firedAfterTextChanged ? selEnd : getSelectionEnd();
enableTextChangedListener();
ReactContext reactContext = (ReactContext) getContext();
EventDispatcher eventDispatcher = reactContext.getNativeModule(UIManagerModule.class).getEventDispatcher();
eventDispatcher.dispatchEvent(
new ReactAztecEnterEvent(getId(), content, cursorPositionStart, cursorPositionEnd, incrementAndGetEventCounter())
new ReactAztecEnterEvent(getId(), content, cursorPositionStart, cursorPositionEnd,
firedAfterTextChanged, incrementAndGetEventCounter())
);
return true;
}
Expand All @@ -378,7 +393,7 @@ private boolean onBackspace() {
}

disableTextChangedListener();
String content = toHtml(false);
String content = toHtml(getText(), false);
enableTextChangedListener();
ReactContext reactContext = (ReactContext) getContext();
EventDispatcher eventDispatcher = reactContext.getNativeModule(UIManagerModule.class).getEventDispatcher();
Expand Down Expand Up @@ -420,7 +435,7 @@ private boolean onPaste(boolean isPastedAsPlainText) {

// temporarily disable listener during call to toHtml()
disableTextChangedListener();
String content = toHtml(false);
String content = toHtml(getText(), false);
int cursorPositionStart = getSelectionStart();
int cursorPositionEnd = getSelectionEnd();
enableTextChangedListener();
Expand Down Expand Up @@ -456,6 +471,10 @@ public void setActiveFormats(Iterable<String> newFormats) {
updateToolbarButtons(newStylesList);
}

protected boolean isEnterPressedUnderway() {
return EnterPressedWatcher.Companion.isEnterPressedUnderway(getText());
}

/**
* This class will redirect *TextChanged calls to the listeners only in the case where the text
* is changed by the user, and not explicitly set by JS.
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
package org.wordpress.mobile.ReactNativeAztec

import android.text.Editable
import android.text.SpannableStringBuilder
import android.text.Spanned
import android.text.TextWatcher
import org.wordpress.aztec.AztecText
import org.wordpress.aztec.Constants
import java.lang.ref.WeakReference

// Class to be used as a span to temporarily denote that Enter was detected
class EnterPressedUnderway

interface EnterDeleter {
fun shouldDeleteEnter(): Boolean
}

class EnterPressedWatcher(aztecText: AztecText, var enterDeleter: EnterDeleter) : TextWatcher {

private val aztecTextRef: WeakReference<AztecText?> = WeakReference(aztecText)
private lateinit var textBefore : SpannableStringBuilder
private var start: Int = -1
private var selStart: Int = 0
private var selEnd: Int = 0
var done = false

override fun beforeTextChanged(text: CharSequence, start: Int, count: Int, after: Int) {
val aztecText = aztecTextRef.get()
if (aztecText?.getAztecKeyListener() != null && !aztecText.isTextChangedListenerDisabled()) {
// we need to make a copy to preserve the contents as they were before the change
textBefore = SpannableStringBuilder(text)
this.start = start
this.selStart = aztecText.selectionStart
this.selEnd = aztecText.selectionEnd
}
}

override fun onTextChanged(text: CharSequence, start: Int, before: Int, count: Int) {
val aztecText = aztecTextRef.get()
val aztecKeyListener = aztecText?.getAztecKeyListener()
if (aztecText != null && !aztecText.isTextChangedListenerDisabled() && aztecKeyListener != null) {
val newTextCopy = SpannableStringBuilder(text)
// if new text length is longer than original text by 1
if (textBefore?.length == newTextCopy.length - 1) {
// now check that the inserted character is actually a NEWLINE
if (newTextCopy[this.start] == Constants.NEWLINE) {
done = false
aztecText.editableText.setSpan(EnterPressedUnderway(), 0, 0, Spanned.SPAN_USER)
aztecKeyListener.onEnterKey(newTextCopy.replace(this.start, this.start+1, ""), true, selStart, selEnd)
}
}
}
}

override fun afterTextChanged(text: Editable) {
aztecTextRef.get()?.editableText?.getSpans(0, 0, EnterPressedUnderway::class.java)?.forEach {
if (!done) {
done = true
if (enterDeleter.shouldDeleteEnter())
text.replace(start, start + 1, "")
}
aztecTextRef.get()?.editableText?.removeSpan(it)
}
}

companion object {
fun isEnterPressedUnderway(spanned: Spanned?): Boolean {
return spanned?.getSpans(0, 0, EnterPressedUnderway::class.java)?.isNotEmpty() ?: false
}
}
}
2 changes: 1 addition & 1 deletion react-native-aztec/ios/Cartfile
Original file line number Diff line number Diff line change
@@ -1 +1 @@
github "wordpress-mobile/AztecEditor-iOS" "1.6.0"
github "wordpress-mobile/AztecEditor-iOS" "1.6.1"
2 changes: 1 addition & 1 deletion react-native-aztec/ios/Cartfile.resolved
Original file line number Diff line number Diff line change
@@ -1 +1 @@
github "wordpress-mobile/AztecEditor-iOS" "1.6.0"
github "wordpress-mobile/AztecEditor-iOS" "1.6.1"
8 changes: 5 additions & 3 deletions react-native-aztec/ios/RNTAztecView/RCTAztecView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,6 @@ class RCTAztecView: Aztec.TextView {
delegate = self
textContainerInset = .zero
contentInset = .zero
textContainer.lineFragmentPadding = 0
addPlaceholder()
}

Expand Down Expand Up @@ -533,8 +532,11 @@ extension RCTAztecView: UITextViewDelegate {
textView.setNeedsLayout()
}

func textViewDidBeginEditing(_ textView: UITextView) {
onFocus?([:])
override func becomeFirstResponder() -> Bool {
if !isFirstResponder && canBecomeFirstResponder {
onFocus?([:])
}
return super.becomeFirstResponder()
}

func textViewDidEndEditing(_ textView: UITextView) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ public class RCTAztecViewManager: RCTViewManager {
public override func view() -> UIView {
let view = RCTAztecView(
defaultFont: defaultFont,
defaultParagraphStyle: .default,
defaultParagraphStyle: defaultParagrahStyle,
defaultMissingImage: UIImage())

view.isScrollEnabled = false
Expand Down Expand Up @@ -60,4 +60,10 @@ public class RCTAztecViewManager: RCTViewManager {

return defaultFont
}
private var defaultParagrahStyle: ParagraphStyle {
let defaultStyle = ParagraphStyle.default
defaultStyle.textListParagraphSpacing = 5
defaultStyle.textListParagraphSpacingBefore = 5
return defaultStyle
}
}
Loading