11#import " TextInsertionUtils.h"
22#import " UIView+React.h"
3-
3+ # import " ReactNativeRichTextEditorView.h "
44
55@implementation TextInsertionUtils
6- + (void )insertText : (NSString *)text inView : (UITextView*)textView at : (NSInteger )index additionalAttributes : (NSDictionary <NSAttributedStringKey, id>*)additionalAttrs editor : (ReactNativeRichTextEditorView * )editor {
6+ + (void )insertText : (NSString *)text inView : (UITextView*)textView at : (NSInteger )index additionalAttributes : (NSDictionary <NSAttributedStringKey, id>*)additionalAttrs editor : (id )editor {
77 NSMutableDictionary <NSAttributedStringKey , id > *copiedAttrs = [textView.typingAttributes mutableCopy ];
88 if (additionalAttrs != nullptr ) {
99 [copiedAttrs addEntriesFromDictionary: additionalAttrs];
@@ -15,12 +15,13 @@ + (void)insertText:(NSString*)text inView:(UITextView*)textView at:(NSInteger)in
1515 [textView reactFocus ];
1616 textView.selectedRange = NSMakeRange (index + text.length , 0 );
1717
18- if (editor != nullptr ) {
19- editor->recentlyChangedRange = NSMakeRange (index, text.length );
18+ ReactNativeRichTextEditorView *typedEditor = (ReactNativeRichTextEditorView *)editor;
19+ if (typedEditor != nullptr ) {
20+ typedEditor->recentlyChangedRange = NSMakeRange (index, text.length );
2021 }
2122}
2223
23- + (void )replaceText : (NSString *)text inView : (UITextView*)textView at : (NSRange )range additionalAttributes : (NSDictionary <NSAttributedStringKey, id>*)additionalAttrs editor : (ReactNativeRichTextEditorView * )editor {
24+ + (void )replaceText : (NSString *)text inView : (UITextView*)textView at : (NSRange )range additionalAttributes : (NSDictionary <NSAttributedStringKey, id>*)additionalAttrs editor : (id )editor {
2425 [textView.textStorage replaceCharactersInRange: range withString: text];
2526 if (additionalAttrs != nullptr ) {
2627 [textView.textStorage addAttributes: additionalAttrs range: NSMakeRange (range.location, [text length ])];
@@ -29,8 +30,9 @@ + (void)replaceText:(NSString*)text inView:(UITextView*)textView at:(NSRange)ran
2930 [textView reactFocus ];
3031 textView.selectedRange = NSMakeRange (range.location + text.length , 0 );
3132
32- if (editor != nullptr ) {
33- editor->recentlyChangedRange = NSMakeRange (range.location , text.length );
33+ ReactNativeRichTextEditorView *typedEditor = (ReactNativeRichTextEditorView *)editor;
34+ if (typedEditor != nullptr ) {
35+ typedEditor->recentlyChangedRange = NSMakeRange (range.location , text.length );
3436 }
3537}
3638@end
0 commit comments