This repository was archived by the owner on Sep 11, 2024. It is now read-only.
File tree 5 files changed +16
-4
lines changed
src/components/views/rooms/wysiwyg_composer
5 files changed +16
-4
lines changed Original file line number Diff line number Diff line change @@ -59,7 +59,13 @@ export function SendWysiwygComposer(
59
59
className = "mx_SendWysiwygComposer"
60
60
leftComponent = { e2eStatus && < E2EIcon status = { e2eStatus } /> }
61
61
// TODO add emoji support
62
- rightComponent = { < EmojiButton menuPosition = { menuPosition } addEmoji = { ( ) => false } /> }
62
+ rightComponent = { composerFunctions =>
63
+ < EmojiButton menuPosition = { menuPosition }
64
+ addEmoji = { ( unicode ) => {
65
+ composerFunctions . insertText ( unicode ) ;
66
+ return true ;
67
+ } }
68
+ /> }
63
69
{ ...props }
64
70
>
65
71
{ ( ref , composerFunctions ) => (
Original file line number Diff line number Diff line change @@ -33,7 +33,7 @@ interface PlainTextComposerProps {
33
33
initialContent ?: string ;
34
34
className ?: string ;
35
35
leftComponent ?: ReactNode ;
36
- rightComponent ?: ReactNode ;
36
+ rightComponent ?: ( composerFunctions : ComposerFunctions ) => ReactNode ;
37
37
children ?: (
38
38
ref : MutableRefObject < HTMLDivElement | null > ,
39
39
composerFunctions : ComposerFunctions ,
Original file line number Diff line number Diff line change @@ -32,7 +32,7 @@ interface WysiwygComposerProps {
32
32
initialContent ?: string ;
33
33
className ?: string ;
34
34
leftComponent ?: ReactNode ;
35
- rightComponent ?: ReactNode ;
35
+ rightComponent ?: ( composerFunctions : FormattingFunctions ) => ReactNode ;
36
36
children ?: (
37
37
ref : MutableRefObject < HTMLDivElement | null > ,
38
38
wysiwyg : FormattingFunctions ,
@@ -69,10 +69,12 @@ export const WysiwygComposer = memo(function WysiwygComposer(
69
69
const { isFocused, onFocus } = useIsFocused ( ) ;
70
70
const computedPlaceholder = ! content && placeholder || undefined ;
71
71
72
+ // const rightComp = rightComponent(wysiwyg);
73
+
72
74
return (
73
75
< div data-testid = "WysiwygComposer" className = { classNames ( className , { [ `${ className } -focused` ] : isFocused } ) } onFocus = { onFocus } onBlur = { onFocus } >
74
76
< FormattingButtons composer = { wysiwyg } actionStates = { actionStates } />
75
- < Editor ref = { ref } disabled = { ! isReady } leftComponent = { leftComponent } rightComponent = { rightComponent } placeholder = { computedPlaceholder } />
77
+ < Editor ref = { ref } disabled = { ! isReady } leftComponent = { leftComponent } rightComponent = { rightComponent ( wysiwyg ) } placeholder = { computedPlaceholder } />
76
78
{ children ?.( ref , wysiwyg ) }
77
79
</ div >
78
80
) ;
Original file line number Diff line number Diff line change @@ -23,5 +23,8 @@ export function useComposerFunctions(ref: RefObject<HTMLDivElement>) {
23
23
ref . current . innerHTML = '' ;
24
24
}
25
25
} ,
26
+ insertText : ( text : string ) => {
27
+ // TODO
28
+ } ,
26
29
} ) , [ ref ] ) ;
27
30
}
Original file line number Diff line number Diff line change @@ -16,4 +16,5 @@ limitations under the License.
16
16
17
17
export type ComposerFunctions = {
18
18
clear : ( ) => void ;
19
+ insertText : ( text : string ) => void ;
19
20
} ;
You can’t perform that action at this time.
0 commit comments