Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
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;
Expand Down Expand Up @@ -293,6 +294,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
6 changes: 6 additions & 0 deletions ios/RNTAztecView/RCTAztecView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ class RCTAztecView: Aztec.TextView {
@objc var onSelectionChange: RCTBubblingEventBlock? = nil
@objc var onActiveFormatsChange: RCTBubblingEventBlock? = nil
@objc var onActiveFormatAttributesChange: RCTBubblingEventBlock? = nil
@objc var autoCorrect: Bool = false
@objc var blockType: NSDictionary? = nil {
didSet {
guard let block = blockType, let tag = block["tag"] as? String else {
Expand All @@ -29,6 +30,10 @@ class RCTAztecView: Aztec.TextView {
}
}

override func didSetProps(_ changedProps: [String]!) {
autocorrectionType = self.autoCorrect ? .yes : .no
}

private var previousContentSize: CGSize = .zero

private lazy var placeholderLabel: UILabel = {
Expand Down Expand Up @@ -66,6 +71,7 @@ class RCTAztecView: Aztec.TextView {
placeholderLabel.leadingAnchor.constraint(equalTo: leadingAnchor, constant: contentInset.left + textContainerInset.left + textContainer.lineFragmentPadding),
placeholderLabel.topAnchor.constraint(equalTo: topAnchor, constant: contentInset.top + textContainerInset.top)
])
autocorrectionType = autoCorrect ? .yes : .no;
}

// MARK - View Height: Match to content height
Expand Down
2 changes: 2 additions & 0 deletions ios/RNTAztecView/RCTAztecViewManager.m
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@ @interface RCT_EXTERN_MODULE(RCTAztecViewManager, NSObject)
RCT_EXPORT_VIEW_PROPERTY(placeholder, NSString)
RCT_EXPORT_VIEW_PROPERTY(placeholderTextColor, UIColor)

RCT_EXPORT_VIEW_PROPERTY(autoCorrect, BOOL)

RCT_EXTERN_METHOD(applyFormat:(nonnull NSNumber *)node format:(NSString *)format)
RCT_EXTERN_METHOD(setLink:(nonnull NSNumber *)node url:(nonnull NSString *)url title:(nullable NSString *)title)
RCT_EXTERN_METHOD(removeLink:(nonnull NSNumber *)node)
Expand Down
1 change: 1 addition & 0 deletions src/AztecView.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ class AztecView extends React.Component {
text: PropTypes.object,
placeholder: PropTypes.string,
placeholderTextColor: ColorPropType,
autoCorrect: PropTypes.boolean,
color: ColorPropType,
maxImagesWidth: PropTypes.number,
minImagesWidth: PropTypes.number,
Expand Down