Skip to content
Merged
Show file tree
Hide file tree
Changes from 5 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 @@ -54,6 +54,7 @@ class EnrichedTextInputView : AppCompatEditText {
val parametrizedStyles: ParametrizedStyles? = ParametrizedStyles(this)
var isDuringTransaction: Boolean = false
var isRemovingMany: Boolean = false
var scrollEnabled: Boolean = true

val mentionHandler: MentionHandler? = MentionHandler(this)
var htmlStyle: HtmlStyle = HtmlStyle(this, null)
Expand Down Expand Up @@ -137,6 +138,14 @@ class EnrichedTextInputView : AppCompatEditText {
return super.onTouchEvent(ev)
}

override fun canScrollVertically(direction: Int): Boolean {
return scrollEnabled
}

override fun canScrollHorizontally(direction: Int): Boolean {
return scrollEnabled
}

override fun onSelectionChanged(selStart: Int, selEnd: Int) {
super.onSelectionChanged(selStart, selEnd)
selection?.onSelection(selStart, selEnd)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -155,6 +155,11 @@ class EnrichedTextInputViewManager : SimpleViewManager<EnrichedTextInputView>(),
view?.setFontStyle(style)
}

@ReactProp(name = "scrollEnabled")
override fun setScrollEnabled(view: EnrichedTextInputView, scrollEnabled: Boolean) {
view.scrollEnabled = scrollEnabled
}

override fun onAfterUpdateTransaction(view: EnrichedTextInputView) {
super.onAfterUpdateTransaction(view)
view.updateTypeface()
Expand Down
4 changes: 4 additions & 0 deletions ios/EnrichedTextInputView.mm
Original file line number Diff line number Diff line change
Expand Up @@ -357,6 +357,10 @@ - (void)updateProps:(Props::Shared const &)props oldProps:(Props::Shared const &
stylePropChanged = YES;
}

if(newViewProps.scrollEnabled != oldViewProps.scrollEnabled || textView.scrollEnabled != newViewProps.scrollEnabled) {
[textView setScrollEnabled: newViewProps.scrollEnabled];
Comment thread
IvanIhnatsiuk marked this conversation as resolved.
Outdated
}

folly::dynamic oldMentionStyle = oldViewProps.htmlStyle.mention;
folly::dynamic newMentionStyle = newViewProps.htmlStyle.mention;
if(oldMentionStyle != newMentionStyle) {
Expand Down
10 changes: 6 additions & 4 deletions ios/inputParser/InputParser.mm
Original file line number Diff line number Diff line change
Expand Up @@ -597,10 +597,12 @@ - (NSArray *)getTextAndStylesFromHtml:(NSString *)fixedHtml {
} else if([tagName isEqualToString:@"code"]) {
[styleArr addObject:@([InlineCodeStyle getStyleType])];
} else if([tagName isEqualToString:@"a"]) {
[styleArr addObject:@([LinkStyle getStyleType])];
// cut only the url from the href="..." string
NSString *url = [params substringWithRange:NSMakeRange(6, params.length - 7)];
stylePair.styleValue = url;
[styleArr addObject:@([LinkStyle getStyleType])];
Comment thread
exploIF marked this conversation as resolved.
Outdated
NSRange hrefRange = [params rangeOfString:@"href="];
if(hrefRange.location != NSNotFound) {
Comment thread
exploIF marked this conversation as resolved.
Outdated
NSString *url = [params substringWithRange:NSMakeRange(6, params.length - 7)];
stylePair.styleValue = url;
}
} else if([tagName isEqualToString:@"mention"]) {
[styleArr addObject:@([MentionStyle getStyleType])];
// extract html expression into dict using some regex
Expand Down
3 changes: 3 additions & 0 deletions src/EnrichedTextInput.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -130,6 +130,7 @@ export interface EnrichedTextInputProps extends Omit<ViewProps, 'children'> {
autoCapitalize?: 'none' | 'sentences' | 'words' | 'characters';
htmlStyle?: HtmlStyle;
style?: ViewStyle | TextStyle;
scrollEnabled?: boolean;
onFocus?: () => void;
onBlur?: () => void;
onChangeText?: (e: NativeSyntheticEvent<OnChangeTextEvent>) => void;
Expand Down Expand Up @@ -192,6 +193,7 @@ export const EnrichedTextInput = ({
onEndMention,
onChangeSelection,
androidExperimentalSynchronousEvents = false,
scrollEnabled = true,
...rest
}: EnrichedTextInputProps) => {
const nativeRef = useRef<ComponentType | null>(null);
Expand Down Expand Up @@ -352,6 +354,7 @@ export const EnrichedTextInput = ({
androidExperimentalSynchronousEvents={
androidExperimentalSynchronousEvents
}
scrollEnabled={scrollEnabled}
{...rest}
/>
);
Expand Down
1 change: 1 addition & 0 deletions src/EnrichedTextInputNativeComponent.ts
Original file line number Diff line number Diff line change
Expand Up @@ -135,6 +135,7 @@ export interface NativeProps extends ViewProps {
selectionColor?: ColorValue;
autoCapitalize?: string;
htmlStyle?: HtmlStyleInternal;
scrollEnabled?: boolean;

// event callbacks
onInputFocus?: DirectEventHandler<null>;
Expand Down