File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -12,6 +12,8 @@ @implementation ImageStyle {
1212
1313+ (StyleType)getStyleType { return Image; }
1414
15+ + (BOOL )isParagraphStyle { return NO ; }
16+
1517- (instancetype )initWithInput : (id )input {
1618 self = [super init ];
1719 _input = (EnrichedTextInputView *)input;
@@ -114,11 +116,15 @@ - (void)addImage:(NSString *)uri {
114116 // This tells TextKit "something non-text goes here".
115117 NSString *imagePlaceholder = @" \uFFFC " ;
116118
117- [TextInsertionUtils replaceText: imagePlaceholder
118- at: _input->textView.selectedRange
119- additionalAttributes: _input->defaultTypingAttributes
120- input: _input
121- withSelection: YES ];
119+ if (_input->textView .selectedRange .length == 0 ) {
120+ [TextInsertionUtils insertText: imagePlaceholder at: _input->textView.selectedRange.location additionalAttributes: nullptr input: _input withSelection: YES ];
121+ } else {
122+ [TextInsertionUtils replaceText: imagePlaceholder
123+ at: _input->textView.selectedRange
124+ additionalAttributes: nullptr
125+ input: _input
126+ withSelection: YES ];
127+ }
122128
123129 NSRange newSelection = _input->textView .selectedRange ;
124130 NSRange imageRange = NSMakeRange (newSelection.location - 1 , 1 );
You can’t perform that action at this time.
0 commit comments