Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Share localization string between sendbox and editbox #4457

Merged
merged 7 commits into from
May 10, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ export const createDefaultChatHandlers = memoizeOne(
content,
senderDisplayName: chatClient.getState().displayName
};
await chatThreadClient.sendMessage(sendMessageRequest, options);
await chatThreadClient.sendMessage(sendMessageRequest, { ...options, type: 'html' });
Leah-Xia-Microsoft marked this conversation as resolved.
Show resolved Hide resolved
},
onUpdateMessage: async (
messageId: string,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2201,6 +2201,8 @@ export interface ComponentStrings {
participantsButton: ParticipantsButtonStrings;
raiseHandButton: RaiseHandButtonStrings;
reactionButton: ReactionButtonStrings;
// (undocumented)
richText: RichTextStrings;
richTextSendBox: RichTextSendBoxStrings;
screenShareButton: ScreenShareButtonStrings;
sendBox: SendBoxStrings;
Expand Down Expand Up @@ -3377,7 +3379,7 @@ export type MessageThreadSelector = (state: ChatClientState, props: ChatBaseSele
};

// @public
export interface MessageThreadStrings {
export interface MessageThreadStrings extends RichTextStrings {
Leah-Xia-Microsoft marked this conversation as resolved.
Show resolved Hide resolved
actionMenuMoreOptions?: string;
attachmentCardGroupMessage: string;
blockedWarningLinkText: string;
Expand Down Expand Up @@ -3893,7 +3895,13 @@ export interface RichTextSendBoxProps {
}

// @beta
export interface RichTextSendBoxStrings extends SendBoxStrings {
export interface RichTextSendBoxStrings extends RichTextStrings, SendBoxStrings {
}

// Warning: (ae-internal-missing-underscore) The name "RichTextStrings" should be prefixed with an underscore because the declaration is marked as @internal
//
// @internal (undocumented)
export interface RichTextStrings {
boldTooltip: string;
bulletListTooltip: string;
decreaseIndentTooltip: string;
Expand Down
2 changes: 1 addition & 1 deletion packages/communication-react/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -305,7 +305,7 @@ export type {
/* @conditional-compile-remove(rich-text-editor) */
export { RichTextSendBox } from '../../react-components/src';
/* @conditional-compile-remove(rich-text-editor) */
export type { RichTextSendBoxProps, RichTextSendBoxStrings } from '../../react-components/src';
export type { RichTextSendBoxProps, RichTextSendBoxStrings, RichTextStrings } from '../../react-components/src';
/* @conditional-compile-remove(spotlight) */
export type { Spotlight } from '../../react-components/src';
export type { ImageOverlayProps, ImageOverlayStrings } from '../../react-components/src';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -151,7 +151,7 @@ export const ChatMessageComponentAsRichTextEditBox = (
]);
const richTextLocaleStrings = useMemo(() => {
/* @conditional-compile-remove(rich-text-editor) */
return locale.richTextSendBox;
return strings || locale.richTextSendBox;
Leah-Xia-Microsoft marked this conversation as resolved.
Show resolved Hide resolved
return locale.sendBox;
}, [/* @conditional-compile-remove(rich-text-editor) */ locale.richTextSendBox, locale.sendBox]);
Leah-Xia-Microsoft marked this conversation as resolved.
Show resolved Hide resolved

Expand Down
5 changes: 3 additions & 2 deletions packages/react-components/src/components/MessageThread.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ import {
import { InlineImageOptions } from './ChatMessage/ChatMessageContent';
import { MessageStatusIndicatorInternal } from './MessageStatusIndicatorInternal';
import { Announcer } from './Announcer';
import { RichTextStrings } from './RichTextEditor/RichTextSendBox';

const isMessageSame = (first: ChatMessage, second: ChatMessage): boolean => {
return (
Expand Down Expand Up @@ -155,7 +156,7 @@ export interface MessageThreadStyles extends BaseCustomStyles {
*
* @public
*/
export interface MessageThreadStrings {
export interface MessageThreadStrings extends RichTextStrings {
/** String for Sunday */
sunday: string;
/** String for Monday */
Expand Down Expand Up @@ -681,7 +682,7 @@ export const MessageThreadWrapper = (props: MessageThreadProps): JSX.Element =>
/* @conditional-compile-remove(attachment-download) @conditional-compile-remove(attachment-upload) */
onRenderAttachmentDownloads,
/* @conditional-compile-remove(rich-text-editor) */
richTextEditor = false
richTextEditor = true
Leah-Xia-Microsoft marked this conversation as resolved.
Show resolved Hide resolved
} = props;
// We need this state to wait for one tick and scroll to bottom after messages have been initialized.
// Otherwise chatScrollDivRef.current.clientHeight is wrong if we scroll to bottom before messages are initialized.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,13 @@ import { FluentV9ThemeProvider } from '../../theming/FluentV9ThemeProvider';
*
* @beta
*/
export interface RichTextSendBoxStrings extends SendBoxStrings {
export interface RichTextSendBoxStrings extends RichTextStrings, SendBoxStrings {}

/**
*
* @internal
*/
export interface RichTextStrings {
/**
* Tooltip text for the bold button.
*/
Expand Down
2 changes: 1 addition & 1 deletion packages/react-components/src/components/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ export { ChatMessageComponentAsRichTextEditBox } from './ChatMessage/MyMessageCo
/* @conditional-compile-remove(rich-text-editor) */
export type { ChatMessageComponentAsRichTextEditBoxProps } from './ChatMessage/MyMessageComponents/ChatMessageComponentAsRichTextEditBox';
/* @conditional-compile-remove(rich-text-editor) */
export type { RichTextSendBoxProps, RichTextSendBoxStrings } from './RichTextEditor/RichTextSendBox';
export type { RichTextSendBoxProps, RichTextSendBoxStrings, RichTextStrings } from './RichTextEditor/RichTextSendBox';

/* @conditional-compile-remove(mention) */
export type {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ import { ImageOverlayStrings } from '../components/ImageOverlay';
/* @conditional-compile-remove(reaction) */
import { ReactionButtonStrings } from '../components';
/* @conditional-compile-remove(rich-text-editor) */
import { RichTextSendBoxStrings } from '../components/RichTextEditor/RichTextSendBox';
import { RichTextSendBoxStrings, RichTextStrings } from '../components/RichTextEditor/RichTextSendBox';

/**
* Locale information for all components exported from this library.
Expand Down Expand Up @@ -180,6 +180,7 @@ export interface ComponentStrings {
/* @conditional-compile-remove(total-participant-count) */
/** Strings for the participant list component */
ParticipantList: ParticipantListStrings;
richText: RichTextStrings;
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,27 @@
"uploadCompleted": "Upload completed",
"attachmentMoreMenu": "More Options"
},
"richText": {
"boldTooltip": "Bold",
"italicTooltip": "Italic",
"underlineTooltip": "Underline",
"bulletListTooltip": "Bulleted list",
"numberListTooltip": "Numbered list",
"increaseIndentTooltip": "Increase indent",
"decreaseIndentTooltip": "Decrease indent",
"insertTableTooltip": "Insert table",
"richTextFormatButtonTooltip": "Format",
"insertRowOrColumnMenu": "Insert",
"insertTableMenuTitle": "Insert {column} x {row} table",
"insertRowAboveMenu": "Insert above",
"insertRowBelowMenu": "Insert below",
"insertColumnLeftMenu": "Insert left",
"insertColumnRightMenu": "Insert right",
"deleteRowOrColumnMenu": "Delete",
"deleteColumnMenu": "Delete column",
"deleteRowMenu": "Delete row",
"deleteTableMenu": "Delete table"
},
"richTextSendBox": {
Leah-Xia-Microsoft marked this conversation as resolved.
Show resolved Hide resolved
"placeholderText": "Enter a message",
"textTooLong": "Your message length is over the maximum limit.",
Expand Down Expand Up @@ -199,7 +220,26 @@
"blockedWarningText": "This message was deleted due to organizational policy.",
"blockedWarningLinkText": "Details",
"attachmentCardGroupMessage": "The message has {attachmentCount} attachment",
"messageDeletedAnnouncementAriaLabel": "The message is deleted"
"messageDeletedAnnouncementAriaLabel": "The message is deleted",
"boldTooltip": "Bold",
"italicTooltip": "Italic",
"underlineTooltip": "Underline",
"bulletListTooltip": "Bulleted list",
"numberListTooltip": "Numbered list",
"increaseIndentTooltip": "Increase indent",
"decreaseIndentTooltip": "Decrease indent",
"insertTableTooltip": "Insert table",
"richTextFormatButtonTooltip": "Format",
"insertRowOrColumnMenu": "Insert",
"insertTableMenuTitle": "Insert {column} x {row} table",
"insertRowAboveMenu": "Insert above",
"insertRowBelowMenu": "Insert below",
"insertColumnLeftMenu": "Insert left",
"insertColumnRightMenu": "Insert right",
"deleteRowOrColumnMenu": "Delete",
"deleteColumnMenu": "Delete column",
"deleteRowMenu": "Delete row",
"deleteTableMenu": "Delete table"
},
"errorBar": {
"unableToReachChatService": "You are offline",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ import { SendBox } from '@internal/react-components';
import { useSelector } from './hooks/useSelector';
/* @conditional-compile-remove(attachment-upload) */
import { attachmentUploadsSelector } from './selectors/attachmentUploadsSelector';
import { RichTextSendBox } from '@internal/react-components';

/**
* @private
Expand Down Expand Up @@ -395,6 +396,7 @@ export const ChatScreen = (props: ChatScreenProps): JSX.Element => {
inlineImageOptions={inlineImageOptions}
numberOfChatMessagesToReload={defaultNumberOfChatMessagesToReload}
styles={messageThreadStyles}
strings={{ sunday: '134', editBoxSubmitButton: '456', boldTooltip: '123' }}
Leah-Xia-Microsoft marked this conversation as resolved.
Show resolved Hide resolved
/>
<Stack className={mergeStyles(sendboxContainerStyles)}>
<div className={mergeStyles(typingIndicatorContainerStyles)}>
Expand All @@ -411,6 +413,7 @@ export const ChatScreen = (props: ChatScreenProps): JSX.Element => {
</Stack>
)}
<Stack grow>
<RichTextSendBox {...sendBoxProps} autoFocus={options?.autoFocus} />
<SendBox
{...sendBoxProps}
autoFocus={options?.autoFocus}
Expand Down