Skip to content

Commit 7f51212

Browse files
fix: lists crash with image
1 parent cffd0a5 commit 7f51212

1 file changed

Lines changed: 1 addition & 20 deletions

File tree

ios/styles/ImageStyle.mm

Lines changed: 1 addition & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -106,15 +106,9 @@ - (void)addImage:(NSString *)uri {
106106
ImageData *data = [[ImageData alloc] init];
107107
data.uri = uri;
108108

109-
UIFont *usedFont = _input->textView.typingAttributes[NSFontAttributeName];
110-
if (!usedFont) {
111-
usedFont = [_input->config primaryFont];
112-
}
113-
114109
NSMutableDictionary *attributes = [@{
115110
NSAttachmentAttributeName: [self prepareSpacerAttachement],
116111
ImageAttributeName: data,
117-
NSFontAttributeName: usedFont,
118112
} mutableCopy];
119113

120114
// Use the Object Replacement Character for Image.
@@ -123,7 +117,7 @@ - (void)addImage:(NSString *)uri {
123117

124118
[TextInsertionUtils replaceText:imagePlaceholder
125119
at:_input->textView.selectedRange
126-
additionalAttributes:nil
120+
additionalAttributes:_input->defaultTypingAttributes
127121
input:_input
128122
withSelection:YES];
129123

@@ -132,19 +126,6 @@ - (void)addImage:(NSString *)uri {
132126

133127
[_input->textView.textStorage beginEditing];
134128
[_input->textView.textStorage addAttributes:attributes range:imageRange];
135-
136-
// remove typing attributes
137-
NSMutableDictionary *cleanTypingAttrs = [_input->textView.typingAttributes mutableCopy];
138-
[cleanTypingAttrs removeObjectForKey:ImageAttributeName];
139-
[cleanTypingAttrs removeObjectForKey:NSAttachmentAttributeName];
140-
141-
// Explicitly restore the font in typing attributes.
142-
// Specific Case: When the input is empty, there is no "previous character" to inherit the font from.
143-
// Without this, the cursor falls back to the system default (tiny 12pt), looking broken next to the image.
144-
cleanTypingAttrs[NSFontAttributeName] = usedFont;
145-
146-
_input->textView.typingAttributes = cleanTypingAttrs;
147-
148129
[_input->textView.textStorage endEditing];
149130
}
150131

0 commit comments

Comments
 (0)