Skip to content

Commit eafe33b

Browse files
committed
fix: mentions uneditable in codeblock
1 parent 7df0db1 commit eafe33b

1 file changed

Lines changed: 14 additions & 8 deletions

File tree

ios/styles/MentionStyle.mm

Lines changed: 14 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -329,16 +329,22 @@ - (void)manageMentionEditing {
329329
return;
330330
}
331331

332-
// get conflicting style classes
333-
LinkStyle* linkStyle = [_input->stylesDict objectForKey:@([LinkStyle getStyleType])];
334-
InlineCodeStyle* inlineCodeStyle = [_input->stylesDict objectForKey:@([InlineCodeStyle getStyleType])];
335-
if(linkStyle == nullptr || inlineCodeStyle == nullptr) {
336-
[self removeActiveMentionRange];
337-
return;
332+
// get style classes that the mention shouldn't be recognized in
333+
NSArray *conflicts = _input->conflictingStyles[@([MentionStyle getStyleType])];
334+
NSArray *blocks = _input->blockingStyles[@([MentionStyle getStyleType])];
335+
NSArray *allConflicts = [conflicts arrayByAddingObjectsFromArray:blocks];
336+
BOOL conflictingStyle = NO;
337+
338+
for(NSNumber *styleType in allConflicts) {
339+
id<BaseStyleProtocol> styleClass = _input->stylesDict[styleType];
340+
if(styleClass != nullptr && [styleClass anyOccurence:wordRange]) {
341+
conflictingStyle = YES;
342+
break;
343+
}
338344
}
339345

340-
// if there is any sign of conflicting style classes, stop editing a mention
341-
if([linkStyle anyOccurence:wordRange] || [inlineCodeStyle anyOccurence:wordRange]) {
346+
// if any of the conflicting styles were present, don't edit the mention
347+
if(conflictingStyle) {
342348
[self removeActiveMentionRange];
343349
return;
344350
}

0 commit comments

Comments
 (0)