|
3 | 3 | #import "EnrichedTextInputView.h" |
4 | 4 | #import "StyleHeaders.h" |
5 | 5 | #import "ParagraphsUtils.h" |
6 | | -#import "ImageData.h" |
7 | 6 |
|
8 | 7 | @implementation NSLayoutManager (LayoutManagerExtension) |
9 | 8 |
|
@@ -58,8 +57,6 @@ - (void)my_drawBackgroundForGlyphRange:(NSRange)glyphRange atPoint:(CGPoint)orig |
58 | 57 |
|
59 | 58 | NSRange inputRange = NSMakeRange(0, typedInput->textView.textStorage.length); |
60 | 59 |
|
61 | | - [self drawImages:typedInput origin:origin inputRange:inputRange]; |
62 | | - |
63 | 60 | // it isn't the most performant but we have to check for all the blockquotes each time and redraw them |
64 | 61 | NSArray *allBlockquotes = [bqStyle findAllOccurences:inputRange]; |
65 | 62 |
|
@@ -135,48 +132,6 @@ - (void)my_drawBackgroundForGlyphRange:(NSRange)glyphRange atPoint:(CGPoint)orig |
135 | 132 | } |
136 | 133 | } |
137 | 134 |
|
138 | | --(void)drawImages:(EnrichedTextInputView *)typedInput origin:(CGPoint)origin inputRange:(NSRange)inputRange |
139 | | -{ |
140 | | - ImageStyle *imgStyle = typedInput->stylesDict[@([ImageStyle getStyleType])]; |
141 | | - |
142 | | - if (imgStyle == nullptr) { return; } |
143 | | - NSArray *allImages = [imgStyle findAllOccurences:inputRange]; |
144 | | - |
145 | | - for (StylePair *pair in allImages) { |
146 | | - ImageData *imageData = (ImageData *)pair.styleValue; |
147 | | - NSRange imageCharRange = [pair.rangeValue rangeValue]; |
148 | | - |
149 | | - // Convert Character Range to Glyph Range |
150 | | - NSRange imageGlyphRange = [self glyphRangeForCharacterRange:imageCharRange actualCharacterRange:NULL]; |
151 | | - |
152 | | - // Get the Text Container (needed for rect calculation) |
153 | | - NSTextContainer *textContainer = [self textContainerForGlyphAtIndex:imageGlyphRange.location effectiveRange:NULL]; |
154 | | - |
155 | | - // boundingRectForGlyphRange gives us the calculated space for the \uFFFC character |
156 | | - CGRect imageRect = [self boundingRectForGlyphRange:imageGlyphRange inTextContainer:textContainer]; |
157 | | - |
158 | | - imageRect.origin.x += origin.x; |
159 | | - imageRect.origin.y += origin.y; |
160 | | - imageRect.size.width = [typedInput->config imageWidth]; |
161 | | - imageRect.size.height = [typedInput->config imageHeight]; |
162 | | - |
163 | | - UIImage *imageToDraw = nil; |
164 | | - |
165 | | - if (imageData.uri) { |
166 | | - NSURL *url = [NSURL URLWithString:imageData.uri]; |
167 | | - imageToDraw = [UIImage imageWithContentsOfFile:url.path]; |
168 | | - } |
169 | | - |
170 | | - if (imageToDraw) { |
171 | | - [imageToDraw drawInRect:imageRect]; |
172 | | - } else { |
173 | | - // Draw a placeholder box if image failed to load |
174 | | - [[UIColor lightGrayColor] setFill]; |
175 | | - UIRectFill(imageRect); |
176 | | - } |
177 | | - } |
178 | | -} |
179 | | - |
180 | 135 | - (NSString *)markerForList:(NSTextList *)list charIndex:(NSUInteger)index input:(EnrichedTextInputView *)input { |
181 | 136 | if(list.markerFormat == NSTextListMarkerDecimal) { |
182 | 137 | NSString *fullText = input->textView.textStorage.string; |
|
0 commit comments