Skip to content
This repository was archived by the owner on Sep 11, 2024. It is now read-only.

Commit 2064ccb

Browse files
committed
Add emoji handling for rich text mode
1 parent dd91250 commit 2064ccb

File tree

5 files changed

+16
-4
lines changed

5 files changed

+16
-4
lines changed

src/components/views/rooms/wysiwyg_composer/SendWysiwygComposer.tsx

+7-1
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,13 @@ export function SendWysiwygComposer(
5959
className="mx_SendWysiwygComposer"
6060
leftComponent={e2eStatus && <E2EIcon status={e2eStatus} />}
6161
// 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+
/>}
6369
{...props}
6470
>
6571
{ (ref, composerFunctions) => (

src/components/views/rooms/wysiwyg_composer/components/PlainTextComposer.tsx

+1-1
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ interface PlainTextComposerProps {
3333
initialContent?: string;
3434
className?: string;
3535
leftComponent?: ReactNode;
36-
rightComponent?: ReactNode;
36+
rightComponent?: (composerFunctions: ComposerFunctions) => ReactNode;
3737
children?: (
3838
ref: MutableRefObject<HTMLDivElement | null>,
3939
composerFunctions: ComposerFunctions,

src/components/views/rooms/wysiwyg_composer/components/WysiwygComposer.tsx

+4-2
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ interface WysiwygComposerProps {
3232
initialContent?: string;
3333
className?: string;
3434
leftComponent?: ReactNode;
35-
rightComponent?: ReactNode;
35+
rightComponent?: (composerFunctions: FormattingFunctions) => ReactNode;
3636
children?: (
3737
ref: MutableRefObject<HTMLDivElement | null>,
3838
wysiwyg: FormattingFunctions,
@@ -69,10 +69,12 @@ export const WysiwygComposer = memo(function WysiwygComposer(
6969
const { isFocused, onFocus } = useIsFocused();
7070
const computedPlaceholder = !content && placeholder || undefined;
7171

72+
// const rightComp = rightComponent(wysiwyg);
73+
7274
return (
7375
<div data-testid="WysiwygComposer" className={classNames(className, { [`${className}-focused`]: isFocused })} onFocus={onFocus} onBlur={onFocus}>
7476
<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} />
7678
{ children?.(ref, wysiwyg) }
7779
</div>
7880
);

src/components/views/rooms/wysiwyg_composer/hooks/useComposerFunctions.ts

+3
Original file line numberDiff line numberDiff line change
@@ -23,5 +23,8 @@ export function useComposerFunctions(ref: RefObject<HTMLDivElement>) {
2323
ref.current.innerHTML = '';
2424
}
2525
},
26+
insertText: (text: string) => {
27+
// TODO
28+
},
2629
}), [ref]);
2730
}

src/components/views/rooms/wysiwyg_composer/types.ts

+1
Original file line numberDiff line numberDiff line change
@@ -16,4 +16,5 @@ limitations under the License.
1616

1717
export type ComposerFunctions = {
1818
clear: () => void;
19+
insertText: (text: string) => void;
1920
};

0 commit comments

Comments
 (0)