Skip to content

Commit 1152ff9

Browse files
fix: review changes
1 parent 3ed3008 commit 1152ff9

4 files changed

Lines changed: 20 additions & 7 deletions

File tree

README.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -212,6 +212,9 @@ You can insert an image into the input using [setImage](docs/API_REFERENCE.md#se
212212

213213
The image will be put into a single line in the input and will affect the line's height as well as input's height. Keep in mind, that image will replace currently selected text or insert into the cursor position if there is no text selection.
214214

215+
> [!NOTE]
216+
> The iOS doesn't support inline images just yet, but it's planned in the near future!
217+
215218
## Style Detection
216219

217220
All of the above styles can be detected with the use of [onChangeState](docs/API_REFERENCE.md#onchangestate) event payload.

ios/EnrichedTextInputView.mm

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,7 @@ - (void)setDefaults {
104104
@([ItalicStyle getStyleType]) : @[],
105105
@([UnderlineStyle getStyleType]) : @[],
106106
@([StrikethroughStyle getStyleType]) : @[],
107-
@([InlineCodeStyle getStyleType]) : @[@([LinkStyle getStyleType]), @([MentionStyle getStyleType]), @([ImageStyle getStyleType])],
107+
@([InlineCodeStyle getStyleType]) : @[@([LinkStyle getStyleType]), @([MentionStyle getStyleType])],
108108
@([LinkStyle getStyleType]): @[@([InlineCodeStyle getStyleType]), @([LinkStyle getStyleType]), @([MentionStyle getStyleType])],
109109
@([MentionStyle getStyleType]): @[@([InlineCodeStyle getStyleType]), @([LinkStyle getStyleType])],
110110
@([H1Style getStyleType]): @[@([H2Style getStyleType]), @([H3Style getStyleType]), @([UnorderedListStyle getStyleType]), @([OrderedListStyle getStyleType]), @([BlockQuoteStyle getStyleType])],
@@ -117,10 +117,10 @@ - (void)setDefaults {
117117
};
118118

119119
_blockingStyles = @{
120-
@([BoldStyle getStyleType]) : @[],
121-
@([ItalicStyle getStyleType]) : @[],
122-
@([UnderlineStyle getStyleType]) : @[],
123-
@([StrikethroughStyle getStyleType]) : @[],
120+
@([BoldStyle getStyleType]) : @[@[@([ImageStyle getStyleType])]],
121+
@([ItalicStyle getStyleType]) : @[@[@([ImageStyle getStyleType])]],
122+
@([UnderlineStyle getStyleType]) : @[@[@([ImageStyle getStyleType])]],
123+
@([StrikethroughStyle getStyleType]) : @[@[@([ImageStyle getStyleType])]],
124124
@([InlineCodeStyle getStyleType]) : @[@([ImageStyle getStyleType])],
125125
@([LinkStyle getStyleType]): @[@([ImageStyle getStyleType])],
126126
@([MentionStyle getStyleType]): @[@([ImageStyle getStyleType])],

ios/inputParser/InputParser.mm

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -630,9 +630,20 @@ - (NSArray *)getTextAndStylesFromHtml:(NSString *)fixedHtml {
630630
} else if([tagName isEqualToString:@"i"]) {
631631
[styleArr addObject:@([ItalicStyle getStyleType])];
632632
} else if([tagName isEqualToString:@"img"]) {
633+
NSRegularExpression *srcRegex = [NSRegularExpression regularExpressionWithPattern:@"src=\".+\""
634+
options:0
635+
error:nullptr
636+
];
637+
NSTextCheckingResult* match = [srcRegex firstMatchInString:params options:0 range: NSMakeRange(0, params.length)];
638+
639+
if(match == nullptr) {
640+
continue;
641+
}
642+
643+
NSRange srcRange = match.range;
633644
[styleArr addObject:@([ImageStyle getStyleType])];
634645
// cut only the uri from the src="..." string
635-
NSString *uri = [params substringWithRange:NSMakeRange(5, params.length - 6)];
646+
NSString *uri = [params substringWithRange:NSMakeRange(srcRange.location + 5, srcRange.length - 6)];
636647
ImageData *imageData = [[ImageData alloc] init];
637648
imageData.uri = uri;
638649

ios/styles/ImageStyle.mm

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@
66
// custom NSAttributedStringKey to differentiate the image
77
static NSString *const ImageAttributeName = @"ImageAttributeName";
88

9-
109
@implementation ImageStyle {
1110
EnrichedTextInputView *_input;
1211
}

0 commit comments

Comments
 (0)