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
10 changes: 7 additions & 3 deletions ios/EnrichedTextInputView.mm
Original file line number Diff line number Diff line change
Expand Up @@ -711,9 +711,6 @@ - (void)tryUpdatingActiveStyles {
if(detectedLinkData != nullptr) {
// emit onLinkeDetected event
[self emitOnLinkDetectedEvent:detectedLinkData.text url:detectedLinkData.url range:detectedLinkRange];

_recentlyActiveLinkData = detectedLinkData;
_recentlyActiveLinkRange = detectedLinkRange;
}

if(detectedMentionParams != nullptr) {
Expand Down Expand Up @@ -812,6 +809,13 @@ - (void)setValue:(NSString *)value {
- (void)emitOnLinkDetectedEvent:(NSString *)text url:(NSString *)url range:(NSRange)range {
auto emitter = [self getEventEmitter];
if(emitter != nullptr) {
// update recently active link info
LinkData *newLinkData = [[LinkData alloc] init];
newLinkData.text = text;
newLinkData.url = url;
_recentlyActiveLinkData = newLinkData;
_recentlyActiveLinkRange = range;

emitter->onLinkDetected({
.text = [text toCppString],
.url = [url toCppString],
Expand Down
14 changes: 7 additions & 7 deletions ios/styles/LinkStyle.mm
Original file line number Diff line number Diff line change
Expand Up @@ -167,7 +167,6 @@ - (void)addLink:(NSString*)text url:(NSString*)url range:(NSRange)range manual:(
}

[self manageLinkTypingAttributes];
[_input anyTextMayHaveBeenModified];
}

// get exact link data at the given location if it exists
Expand Down Expand Up @@ -224,20 +223,22 @@ - (NSRange)getFullLinkRangeAt:(NSUInteger)location {
}
}

[_input->textView.textStorage
NSString *manualLink = [_input->textView.textStorage
attribute:ManualLinkAttributeName
atIndex:searchLocation
longestEffectiveRange: &manualLinkRange
inRange:inputRange
];
[_input->textView.textStorage
NSString *automaticLink = [_input->textView.textStorage
attribute:AutomaticLinkAttributeName
atIndex:searchLocation
longestEffectiveRange: &automaticLinkRange
inRange:inputRange
];

return manualLinkRange.length == 0 ? automaticLinkRange : manualLinkRange;
return manualLink == nullptr
? automaticLink == nullptr ? NSMakeRange(0, 0) : automaticLinkRange
: manualLinkRange;
}

- (void)manageLinkTypingAttributes {
Expand Down Expand Up @@ -349,10 +350,9 @@ - (void)handleAutomaticLinks:(NSString *)word inRange:(NSRange)wordRange {
}
if(addStyle) {
[self addLink:word url:regexPassedUrl range:wordRange manual:NO];
// emit onLinkDetected if style was added
[_input emitOnLinkDetectedEvent:word url:regexPassedUrl range:wordRange];
}

// emit onLinkDetected
[_input emitOnLinkDetectedEvent:word url:regexPassedUrl range:wordRange];
}
}

Expand Down
Loading