Skip to content
This repository was archived by the owner on Mar 7, 2025. It is now read-only.
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
50 commits
Select commit Hold shift + click to select a range
a858144
Enabling scroll
ewindso Apr 26, 2021
7603a19
Commenting out missing method in Swift...
ewindso Apr 26, 2021
fc6ce90
Updating TextInputState
ewindso Apr 26, 2021
8742b8e
Not intercepting enter
ewindso Apr 26, 2021
f3ab763
Adding default MediaProvider
ewindso Apr 26, 2021
3c641c2
Defaulting attachmentDelegate and imageProvider...
ewindso Apr 26, 2021
e25882c
Removing autocorrection
ewindso Apr 27, 2021
750c5c8
Implementing hiding keyboard
ewindso Apr 27, 2021
3d7eba7
requireNativeComponent once
ewindso Apr 28, 2021
3740451
Adding support for underline
ewindso Apr 28, 2021
30dd116
Changing source for RNTAztecView.podspec
ewindso Apr 28, 2021
bee8044
Updating package.json
ewindso Apr 28, 2021
a39f381
Cleaning up
ewindso Apr 28, 2021
7f516a6
Making attachmentDelegate and imageProvider static, so can be set easier
ewindso Apr 28, 2021
fd41349
Defaulting to empty images...
ewindso Apr 28, 2021
733f60a
Updating fonts
ewindso Apr 29, 2021
6658ee5
Adding proper blur / focus
ewindso Apr 29, 2021
3558efe
Removing call to TextInputState
ewindso Apr 29, 2021
c441a40
Handling paste!
ewindso Apr 30, 2021
5f16c09
Focusing at end of document
ewindso Apr 30, 2021
2ca7f76
Propogating format changes from didChange
ewindso Apr 30, 2021
4ad5c95
Adding setHTML method
ewindso Apr 30, 2021
8c97786
Adding setHTML, focusEndOfDocument
ewindso Apr 30, 2021
926144e
Changing deployment target to 11.0
ewindso May 2, 2021
bc4b3d7
Updating to 11.0
ewindso May 3, 2021
378b826
Catching issue where dom node cannot be found
ewindso May 7, 2021
d3a3bd4
Updating android aztec version
ewindso May 10, 2021
fe13d1c
Updating ReactAztecText onEnterKey
ewindso May 11, 2021
d32b35a
Updating Gravity on ReactAztecText to be at the top / start
ewindso May 11, 2021
e84da80
Moving cursor to end of the TextEdit on JS focus
ewindso May 11, 2021
265852e
Scrolling to bottom when JS focuses on Aztec
ewindso May 11, 2021
6eb4eac
Adding support for underline
ewindso May 12, 2021
01ee26a
Adding setHTML for Android
ewindso May 18, 2021
5828d55
Putting in conditional call to propogateContentChanges() (for formatt…
ewindso May 24, 2021
559d776
Removing call to onEnter, was causing issues with Huawei
ewindso Jun 2, 2021
ee6342b
Adding scrollToBottom command for Android only
ewindso Jun 29, 2021
197d83d
Fixing issue where it doesn't scroll down all the way (adding 50 seem…
ewindso Jun 29, 2021
4aa0b30
Adding scrollToBottom for Android
ewindso Jun 29, 2021
b0b1b7f
Call scrollToBottom from AztecView.js in _onContentSizeChange, only f…
ewindso Jun 29, 2021
8f7d91d
[FIX] - Fixed an android bug where html format was not applied on the…
mathieu-clerici Jul 26, 2021
71287f8
Fixed a bug where scrolling was not working properly. (#2)
mathieu-clerici Jul 29, 2021
f31acaa
Added support for link click while editing. (#3)
mathieu-clerici Sep 27, 2021
2e9d057
Fixed build error, missing import (#4)
mathieu-clerici Sep 29, 2021
c27cbbe
feat: autoCorrect (iOS works, not Android yet...) (#5)
ewindso Nov 3, 2021
a36c335
feat: adding sendKeysSpaceAndBackspace
ewindso Jan 14, 2022
182ab5f
chore: updating method name, not calling right on focus as it didn't …
ewindso Jan 14, 2022
2d0fe6b
feat: exposing method to JS for sending space-backspace
ewindso Jan 14, 2022
214e303
feat: adding sendSpaceAndBackspace method call
ewindso Jan 14, 2022
2bd3916
feat: when editor is pressed, call sendSpaceAndBackspace on Android
ewindso Jan 15, 2022
6b85fe7
feat: updating layout to get it to work right
ewindso Jan 15, 2022
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
4 changes: 2 additions & 2 deletions RNTAztecView.podspec
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,11 @@ Pod::Spec.new do |s|
s.license = package['license']
s.homepage = 'https://github.com/wordpress-mobile/react-native-aztec'
s.authors = 'Automattic'
s.source = { :git => 'https://github.com/wordpress-mobile/react-native-aztec.git' }
s.source = { :git => 'https://github.com/ewindso/react-native-aztec' }
s.source_files = 'ios/RNTAztecView/*.{h,m,swift}'
s.public_header_files = 'ios/RNTAztecView/*.h'
s.requires_arc = true
s.platforms = { :ios => "10.0" }
s.platforms = { :ios => "11.0" }
s.xcconfig = {'OTHER_LDFLAGS' => '-lxml2',
'HEADER_SEARCH_PATHS' => '/usr/include/libxml2'}
s.dependency 'React'
Expand Down
2 changes: 1 addition & 1 deletion android/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ buildscript {
wordpressUtilsVersion = '1.22'
espressoVersion = '3.0.1'

aztecVersion = 'v1.3.14'
aztecVersion = 'v1.3.45'
}

repositories {
Expand Down

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,15 @@

import android.graphics.Color;
import android.graphics.Typeface;
import android.support.annotation.Nullable;
import androidx.annotation.Nullable;
import android.text.Editable;
import android.text.TextWatcher;
import android.text.InputType;
import android.text.util.Linkify;
import android.util.Log;
import android.util.TypedValue;
import android.view.View;
import android.view.ViewGroup.LayoutParams;

import com.facebook.infer.annotation.Assertions;
import com.facebook.react.bridge.ReactContext;
Expand Down Expand Up @@ -51,6 +54,9 @@ public class ReactAztecManager extends SimpleViewManager<ReactAztecText> {

private static final int FOCUS_TEXT_INPUT = 1;
private static final int BLUR_TEXT_INPUT = 2;
private static final int SET_HTML = 3;
private static final int SCROLL_TO_BOTTOM = 4;
private static final int SEND_SPACE_AND_BACKSPACE = 5;
private static final int COMMAND_NOTIFY_APPLY_FORMAT = 100;
private static final int UNSET = -1;

Expand All @@ -59,6 +65,9 @@ public class ReactAztecManager extends SimpleViewManager<ReactAztecText> {
// see https://github.com/wordpress-mobile/react-native-aztec/pull/79
private int mFocusTextInputCommandCode = FOCUS_TEXT_INPUT; // pre-init
private int mBlurTextInputCommandCode = BLUR_TEXT_INPUT; // pre-init
private int mSetHTMLCommandCode = SET_HTML;
private int mScrollToBottomCode = SCROLL_TO_BOTTOM;
private int mSendSpaceAndBackspaceCode = SEND_SPACE_AND_BACKSPACE;

private static final String TAG = "ReactAztecText";

Expand Down Expand Up @@ -87,6 +96,9 @@ protected ReactAztecText createViewInstance(ThemedReactContext reactContext) {
aztecText.setFocusableInTouchMode(true);
aztecText.setFocusable(true);
aztecText.setCalypsoMode(false);
aztecText.setLinksClickable(true);
aztecText.setAutoLinkMask(Linkify.WEB_URLS);
aztecText.setLayoutParams(new LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT));
return aztecText;
}

Expand Down Expand Up @@ -286,6 +298,15 @@ public void setPlaceholderTextColor(ReactAztecText view, @Nullable Integer color
}
}

@ReactProp(name = "autoCorrect")
public void setAutoCorrect(ReactAztecText view, Boolean autoCorrect) {
if (autoCorrect) {
view.setInputType(InputType.TYPE_CLASS_TEXT | InputType.TYPE_TEXT_FLAG_CAP_SENTENCES | InputType.TYPE_TEXT_FLAG_MULTI_LINE | InputType.TYPE_TEXT_FLAG_AUTO_CORRECT);
} else {
view.setInputType(InputType.TYPE_CLASS_TEXT | InputType.TYPE_TEXT_FLAG_CAP_SENTENCES | InputType.TYPE_TEXT_FLAG_MULTI_LINE | InputType.TYPE_TEXT_FLAG_NO_SUGGESTIONS);
}
}

@ReactProp(name = "maxImagesWidth")
public void setMaxImagesWidth(ReactAztecText view, int maxWidth) {
view.setMaxImagesWidth(maxWidth);
Expand Down Expand Up @@ -381,6 +402,9 @@ public Map<String, Integer> getCommandsMap() {
.put("applyFormat", COMMAND_NOTIFY_APPLY_FORMAT)
.put("focusTextInput", mFocusTextInputCommandCode)
.put("blurTextInput", mBlurTextInputCommandCode)
.put("setHTML", mSetHTMLCommandCode)
.put("scrollToBottom", mScrollToBottomCode)
.put("sendSpaceAndBackspace", mSendSpaceAndBackspaceCode)
.build();
}

Expand All @@ -398,6 +422,15 @@ public void receiveCommand(final ReactAztecText parent, int commandType, @Nullab
} else if (commandType == mBlurTextInputCommandCode) {
parent.clearFocusFromJS();
return;
} else if (commandType == mSetHTMLCommandCode) {
final String html = args.getString(0);
setTextfromJS(parent, html);
return;
} else if (commandType == mScrollToBottomCode) {
Log.d("SCROLLING", "1");
parent.scrollToBottom();
} else if (commandType == mSendSpaceAndBackspaceCode) {
parent.sendSpaceAndBackspace();
}
super.receiveCommand(parent, commandType, args);
}
Expand Down Expand Up @@ -465,14 +498,6 @@ public void onTextChanged(CharSequence s, int start, int before, int count) {
return;
}

// 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),
mEditText.incrementAndGetEventCounter()));

mEventDispatcher.dispatchEvent(
new ReactTextInputEvent(
mEditText.getId(),
Expand All @@ -484,6 +509,11 @@ public void onTextChanged(CharSequence s, int start, int before, int count) {

@Override
public void afterTextChanged(Editable s) {
mEventDispatcher.dispatchEvent(
new ReactTextChangedEvent(
mEditText.getId(),
mEditText.toHtml(false),
mEditText.incrementAndGetEventCounter()));
}
}

Expand Down Expand Up @@ -562,3 +592,4 @@ public void onScrollChanged(int horiz, int vert, int oldHoriz, int oldVert) {
}
}
}

Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,16 @@

import android.content.Context;
import android.graphics.Rect;
import android.support.annotation.Nullable;
import androidx.annotation.Nullable;
import android.text.Editable;
import android.text.InputType;
import android.text.TextWatcher;
import android.view.inputmethod.InputMethodManager;
import android.text.Spannable;
import android.view.Gravity;
import android.widget.TextView;
import android.view.inputmethod.BaseInputConnection;
import android.view.KeyEvent;

import com.facebook.infer.annotation.Assertions;
import com.facebook.react.bridge.ReactContext;
Expand All @@ -19,6 +24,7 @@
import com.facebook.react.views.textinput.ScrollWatcher;

import org.wordpress.aztec.AztecText;
import org.wordpress.aztec.AlignmentRendering;
import org.wordpress.aztec.AztecTextFormat;
import org.wordpress.aztec.ITextFormat;
import org.wordpress.aztec.plugins.IAztecPlugin;
Expand Down Expand Up @@ -56,10 +62,7 @@ public ReactAztecText(ThemedReactContext reactContext) {
super(reactContext);
this.setAztecKeyListener(new ReactAztecText.OnAztecKeyListener() {
@Override
public boolean onEnterKey() {
if (shouldHandleOnEnter) {
return onEnter();
}
public boolean onEnterKey(Spannable text, boolean firedAfterTextChanged, int selStart, int selEnd) {
return false;
}
@Override
Expand All @@ -80,6 +83,19 @@ public void onSelectionChanged(int selStart, int selEnd) {
}
});
this.setInputType(InputType.TYPE_CLASS_TEXT | InputType.TYPE_TEXT_FLAG_CAP_SENTENCES | InputType.TYPE_TEXT_FLAG_MULTI_LINE);
this.setGravity(Gravity.TOP | Gravity.START);

BetterLinkMovementMethod linkClick = BetterLinkMovementMethod.newInstance();

linkClick.setOnLinkClickListener(new BetterLinkMovementMethod.OnLinkClickListener() {
@Override
public boolean onClick(TextView textView, String url) {
hideSoftKeyboard();
return false;
}
});

this.setMovementMethod(linkClick);
}

@Override
Expand Down Expand Up @@ -127,10 +143,35 @@ public boolean requestFocus(int direction, Rect previouslyFocusedRect) {
}*/
setFocusableInTouchMode(true);
boolean focused = super.requestFocus(direction, previouslyFocusedRect);

final int scrollAmount = this.getLayout().getLineTop(this.getLineCount()) - this.getHeight();
if (scrollAmount > 0) {
this.scrollTo(0, scrollAmount + 50);
}

super.setSelection(this.length());

showSoftKeyboard();
return focused;
}

public void sendSpaceAndBackspace() {
BaseInputConnection inputConnection = new BaseInputConnection(this, true);
inputConnection.sendKeyEvent(new KeyEvent(KeyEvent.ACTION_DOWN, KeyEvent.KEYCODE_SPACE));
inputConnection.sendKeyEvent(new KeyEvent(KeyEvent.ACTION_DOWN, KeyEvent.KEYCODE_DEL));
}

public void scrollToBottom() {
final int scrollAmount = this.getLayout().getLineTop(this.getLineCount()) - this.getHeight() + 50;

// only scroll if the user is already at the bottom. ignore otherwise
if (scrollAmount > 0 && this.getSelectionStart() >= this.getText().toString().length() - 1) {
this.scrollTo(0, scrollAmount);

super.setSelection(this.length());
}
}

private boolean showSoftKeyboard() {
return mInputMethodManager.showSoftInput(this, 0);
}
Expand Down Expand Up @@ -194,6 +235,10 @@ private void updateToolbarButtons(ArrayList<ITextFormat> appliedStyles) {
if (currentStyle == AztecTextFormat.FORMAT_STRIKETHROUGH) {
formattingOptions.add("strikethrough");
}

if (currentStyle == AztecTextFormat.FORMAT_UNDERLINE) {
formattingOptions.add("underline");
}
}

// Check if the same formatting event was already sent
Expand Down Expand Up @@ -331,6 +376,9 @@ public void applyFormat(String format) {
case ("strikethrough"):
newFormats.add(AztecTextFormat.FORMAT_STRIKETHROUGH);
break;
case ("underline"):
newFormats.add(AztecTextFormat.FORMAT_UNDERLINE);
break;
}

if (newFormats.size() == 0) {
Expand Down Expand Up @@ -413,3 +461,4 @@ public void afterTextChanged(Editable s) {
}
}
}

4 changes: 4 additions & 0 deletions android/src/main/res/values/betterlinkmovementmethod.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
<?xml version="1.0" encoding="utf-8"?>
<resources>
<item name="bettermovementmethod_highlight_background_span" type="id" />
</resources>
8 changes: 6 additions & 2 deletions ios/RNTAztecView.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
objects = {

/* Begin PBXBuildFile section */
397407BB263770E700DE50C1 /* MediaProvider.swift in Sources */ = {isa = PBXBuildFile; fileRef = 397407BA263770E600DE50C1 /* MediaProvider.swift */; };
7ECFA93C21C39B5000FC131B /* HeadingBlockFormatHandler.swift in Sources */ = {isa = PBXBuildFile; fileRef = 7ECFA93B21C39B5000FC131B /* HeadingBlockFormatHandler.swift */; };
7ECFA94021C39BA000FC131B /* BlockFormatHandler.swift in Sources */ = {isa = PBXBuildFile; fileRef = 7ECFA93F21C39BA000FC131B /* BlockFormatHandler.swift */; };
7ECFA94221C39BBB00FC131B /* BlockModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = 7ECFA94121C39BBB00FC131B /* BlockModel.swift */; };
Expand Down Expand Up @@ -53,6 +54,7 @@
/* End PBXCopyFilesBuildPhase section */

/* Begin PBXFileReference section */
397407BA263770E600DE50C1 /* MediaProvider.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = MediaProvider.swift; sourceTree = "<group>"; };
7ECFA93B21C39B5000FC131B /* HeadingBlockFormatHandler.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = HeadingBlockFormatHandler.swift; sourceTree = "<group>"; };
7ECFA93F21C39BA000FC131B /* BlockFormatHandler.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = BlockFormatHandler.swift; sourceTree = "<group>"; };
7ECFA94121C39BBB00FC131B /* BlockModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = BlockModel.swift; sourceTree = "<group>"; };
Expand Down Expand Up @@ -105,6 +107,7 @@
7ECFA94121C39BBB00FC131B /* BlockModel.swift */,
7ECFA93B21C39B5000FC131B /* HeadingBlockFormatHandler.swift */,
7ECFA93F21C39BA000FC131B /* BlockFormatHandler.swift */,
397407BA263770E600DE50C1 /* MediaProvider.swift */,
);
path = RNTAztecView;
sourceTree = "<group>";
Expand Down Expand Up @@ -217,6 +220,7 @@
buildActionMask = 2147483647;
files = (
7ECFA94021C39BA000FC131B /* BlockFormatHandler.swift in Sources */,
397407BB263770E700DE50C1 /* MediaProvider.swift in Sources */,
7ECFA93C21C39B5000FC131B /* HeadingBlockFormatHandler.swift in Sources */,
F13BF4A020ECF5450047D3F9 /* RCTAztecViewManager.swift in Sources */,
F1A879D020EE90C000FABD31 /* RCTAztecView.swift in Sources */,
Expand Down Expand Up @@ -287,7 +291,7 @@
GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;
GCC_WARN_UNUSED_FUNCTION = YES;
GCC_WARN_UNUSED_VARIABLE = YES;
IPHONEOS_DEPLOYMENT_TARGET = 10.0;
IPHONEOS_DEPLOYMENT_TARGET = 11.0;
MTL_ENABLE_DEBUG_INFO = YES;
ONLY_ACTIVE_ARCH = YES;
SDKROOT = iphoneos;
Expand Down Expand Up @@ -341,7 +345,7 @@
GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;
GCC_WARN_UNUSED_FUNCTION = YES;
GCC_WARN_UNUSED_VARIABLE = YES;
IPHONEOS_DEPLOYMENT_TARGET = 10.0;
IPHONEOS_DEPLOYMENT_TARGET = 11.0;
MTL_ENABLE_DEBUG_INFO = NO;
SDKROOT = iphoneos;
SWIFT_COMPILATION_MODE = wholemodule;
Expand Down
14 changes: 7 additions & 7 deletions ios/RNTAztecView/HeadingBlockFormatHandler.swift
Original file line number Diff line number Diff line change
Expand Up @@ -11,15 +11,15 @@ struct HeadingBlockFormatHandler: BlockFormatHandler {
}
self.level = level
headerFormatter = HeaderFormatter(headerLevel: level)
}
}

func forceTypingFormat(on textView: RCTAztecView) {
var attributes = textView.typingAttributesSwifted

attributes = paragraphFormatter.remove(from: attributes)
attributes = headerFormatter.apply(to: attributes, andStore: nil)

textView.typingAttributesSwifted = attributes
// var attributes = textView.typingAttributesSwifted
//
// attributes = paragraphFormatter.remove(from: attributes)
// attributes = headerFormatter.apply(to: attributes, andStore: nil)
//
// textView.typingAttributesSwifted = attributes
}

private static func headerLevel(from levelString: String) -> Header.HeaderType? {
Expand Down
Loading