@@ -35,11 +35,25 @@ export enum ITextType {
3535 normal = 0 ,
3636 tagText = 2 ,
3737}
38+ interface PrivateItemData {
39+ type : ITextType ;
40+ text ?: string ;
41+ color ?: ProcessedColorValue | null | undefined ;
42+ tag ?: '@' | '#' ;
43+ name ?: string ;
44+ id ?: string ;
45+ img ?: ImageResolvedAssetSource ; //emoji图片
46+ emojiTag ?: string ; //[微笑] //emojitag
47+ }
3848export interface IInserTextAttachmentItem {
3949 type : ITextType ;
40- targData ?: ISendTagMensage ;
41- emojiData ?: IInsertEmojiConfig ;
4250 text ?: string ;
51+ color ?: ColorValue ;
52+ tag ?: '@' | '#' ;
53+ name ?: string ;
54+ id ?: string ;
55+ img ?: ImageResolvedAssetSource ; //emoji图片
56+ emojiTag ?: string ; //[微笑] //emojitag
4357}
4458interface IProps {
4559 onMention ?: ( ) => void ;
@@ -63,27 +77,11 @@ interface IProps {
6377 e : NativeSyntheticEvent < TextInputContentSizeChangeEventData >
6478 ) => void ;
6579}
66- interface IInsertTagConfig {
67- tag : '@' | '#' ;
68- name : string ;
69- id : string ;
70- color : ColorValue ;
71- }
72- interface ISendTagMensage {
73- color : ProcessedColorValue | null | undefined ;
74- tag : '@' | '#' ;
75- name : string ;
76- id : string ;
77- }
78- interface IInsertEmojiConfig {
79- img : ImageResolvedAssetSource ;
80- tag : string ; //[微笑]
81- }
8280export type IATTextViewBase = {
8381 focus : ( ) => void ;
8482 blur : ( ) => void ;
85- insertEmoji : ( img : IInsertEmojiConfig ) => void ;
86- insertMentions : ( data : IInsertTagConfig ) => void ;
83+ insertEmoji : ( img : IInserTextAttachmentItem ) => void ;
84+ insertMentions : ( data : IInserTextAttachmentItem ) => void ;
8785 changeAttributedText : ( data : IInserTextAttachmentItem [ ] ) => void ;
8886} ;
8987export type IATTextViewRef = React . ForwardedRef < IATTextViewBase > ;
@@ -119,34 +117,46 @@ const VariableTextInputView = forwardRef(
119117 UIManager . dispatchViewManagerCommand (
120118 reactTag ,
121119 commandId ,
122- ! ! data ? [ data ] : [ ]
120+ ! ! data ? data : [ ]
123121 ) ;
124122 } ;
125- const insertEmoji = ( data : IInsertEmojiConfig ) => {
123+ const insertEmoji = ( data : IInserTextAttachmentItem ) => {
124+ const sendData : PrivateItemData = {
125+ ...data ,
126+ color : processColor ( data . color ) ,
127+ } ;
126128 if ( Platform . OS === 'android' ) {
127- callNativeMethod ( 'insertEmoji' , data ) ;
129+ callNativeMethod ( 'insertEmoji' , [ sendData ] ) ;
128130 } else {
129- VariableTextInputViewManager . insertEmoji ( data ) ;
131+ VariableTextInputViewManager . insertEmoji ( sendData ) ;
130132 }
131133 } ;
132- const insertMentions = ( data : IInsertTagConfig ) => {
133- const sendData : ISendTagMensage = {
134+ const insertMentions = ( data : IInserTextAttachmentItem ) => {
135+ const sendData : PrivateItemData = {
136+ ...data ,
134137 color : processColor ( data . color ) ,
135- tag : data . tag ,
136- name : data . name ,
137- id : data . id ,
138138 } ;
139139 if ( Platform . OS === 'ios' ) {
140140 VariableTextInputViewManager . insertMentions ( sendData ) ;
141141 } else {
142- callNativeMethod ( 'insertMentions' , sendData ) ;
142+ callNativeMethod ( 'insertMentions' , [ sendData ] ) ;
143143 }
144144 } ;
145145 const changeAttributedText = ( data : IInserTextAttachmentItem [ ] ) => {
146+ const sendData : PrivateItemData [ ] = [ ] ;
147+ if ( data . length > 0 ) {
148+ data . forEach ( ( item ) => {
149+ const newItem : PrivateItemData = {
150+ ...item ,
151+ color : processColor ( item . color ) ,
152+ } ;
153+ sendData . push ( newItem ) ;
154+ } ) ;
155+ }
146156 if ( Platform . OS === 'android' ) {
147- callNativeMethod ( 'changeAttributedText' , data ) ;
157+ callNativeMethod ( 'changeAttributedText' , sendData ) ;
148158 } else {
149- VariableTextInputViewManager . changeAttributedText ( data ) ;
159+ VariableTextInputViewManager . changeAttributedText ( sendData ) ;
150160 }
151161 } ;
152162 const onContentSizeChange = ( event : any ) => {
0 commit comments