From d537e787b624b11f8f97f90075afe6f824be025e Mon Sep 17 00:00:00 2001 From: vishtree Date: Thu, 26 Mar 2020 14:19:10 +0100 Subject: [PATCH 1/3] Fixing missing translation context consumer on Message HOC --- src/components/Message.js | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/components/Message.js b/src/components/Message.js index 0600b793c..eabaaddf0 100644 --- a/src/components/Message.js +++ b/src/components/Message.js @@ -5,6 +5,7 @@ import deepequal from 'deep-equal'; import { MessageSimple } from './MessageSimple'; import { Attachment } from './Attachment'; import { MESSAGE_ACTIONS } from '../utils'; +import { withTranslationContext } from '../context'; /** * Message - A high level component which implements all the logic required for a message. @@ -13,7 +14,7 @@ import { MESSAGE_ACTIONS } from '../utils'; * @example ./docs/Message.md * @extends Component */ -export class Message extends Component { +class Message extends Component { constructor(props) { super(props); this.state = { @@ -499,3 +500,7 @@ export class Message extends Component { ); } } + +Message = withTranslationContext(Message); + +export { Message }; From 5346f548f9080d2b178b7ad215425361d433f95f Mon Sep 17 00:00:00 2001 From: vishtree Date: Thu, 26 Mar 2020 14:21:07 +0100 Subject: [PATCH 2/3] Adding support for additionalTextareaProps prop to MessageInput component --- src/components/AutoCompleteTextarea/Textarea.js | 2 ++ src/components/ChatAutoComplete.js | 5 +++++ src/components/MessageInput.js | 11 +++++++++++ src/components/MessageInputFlat.js | 5 +++++ src/components/MessageInputLarge.js | 5 +++++ src/components/MessageInputSmall.js | 5 +++++ types/index.d.ts | 11 +++++++++++ 7 files changed, 44 insertions(+) diff --git a/src/components/AutoCompleteTextarea/Textarea.js b/src/components/AutoCompleteTextarea/Textarea.js index ae352ba2f..f2aa1c49a 100644 --- a/src/components/AutoCompleteTextarea/Textarea.js +++ b/src/components/AutoCompleteTextarea/Textarea.js @@ -482,6 +482,7 @@ class ReactTextareaAutocomplete extends React.Component { 'handleSubmit', 'replaceWord', 'grow', + 'additionalTextareaProps', ]; // eslint-disable-next-line @@ -774,6 +775,7 @@ class ReactTextareaAutocomplete extends React.Component { onFocus={this.props.onFocus} value={value} style={style} + {...this.props.additionalTextareaProps} /> ); diff --git a/src/components/ChatAutoComplete.js b/src/components/ChatAutoComplete.js index 244bf41c3..d278d3bbc 100644 --- a/src/components/ChatAutoComplete.js +++ b/src/components/ChatAutoComplete.js @@ -49,6 +49,10 @@ export class ChatAutoComplete extends PureComponent { commands: PropTypes.array, /** Listener for onfocus event on textarea */ onFocus: PropTypes.object, + /** + * Any additional attrubutes that you may want to add for underlying HTML textarea element. + */ + additionalTextareaProps: PropTypes.object, }; static defaultProps = { @@ -175,6 +179,7 @@ export class ChatAutoComplete extends PureComponent { value={this.props.value} grow={this.props.grow} disabled={this.props.disabled} + additionalTextareaProps={this.props.additionalTextareaProps} /> ); } diff --git a/src/components/MessageInput.js b/src/components/MessageInput.js index 5540fe9e3..e23f75159 100644 --- a/src/components/MessageInput.js +++ b/src/components/MessageInput.js @@ -130,6 +130,16 @@ class MessageInput extends PureComponent { * Defaults to and accepts same props as: [SendButton](https://getstream.github.io/stream-chat-react/#sendbutton) * */ SendButton: PropTypes.oneOfType([PropTypes.node, PropTypes.func]), + /** + * Any additional attrubutes that you may want to add for underlying HTML textarea element. + * e.g. + * + */ + additionalTextareaProps: PropTypes.object, }; static defaultProps = { @@ -139,6 +149,7 @@ class MessageInput extends PureComponent { maxRows: 10, Input: MessageInputLarge, SendButton, + additionalTextareaProps: {}, }; componentDidMount() { diff --git a/src/components/MessageInputFlat.js b/src/components/MessageInputFlat.js index d89d3ebb6..9da091834 100644 --- a/src/components/MessageInputFlat.js +++ b/src/components/MessageInputFlat.js @@ -84,6 +84,10 @@ class MessageInputFlat extends PureComponent { * Defaults to and accepts same props as: [SendButton](https://getstream.github.io/stream-chat-react/#sendbutton) * */ SendButton: PropTypes.oneOfType([PropTypes.node, PropTypes.func]), + /** + * Any additional attrubutes that you may want to add for underlying HTML textarea element. + */ + additionalTextareaProps: PropTypes.object, }; static defaultProps = { @@ -175,6 +179,7 @@ class MessageInputFlat extends PureComponent { grow={this.props.grow} onFocus={this.props.onFocus} disabled={this.props.disabled} + additionalTextareaProps={this.props.additionalTextareaProps} /> ( @@ -203,6 +207,7 @@ class MessageInputLarge extends PureComponent { onPaste={this.props.onPaste} grow={this.props.grow} disabled={this.props.disabled} + additionalTextareaProps={this.props.additionalTextareaProps} /> ( @@ -176,6 +180,7 @@ class MessageInputSmall extends PureComponent { onPaste={this.props.onPaste} grow={this.props.grow} disabled={this.props.disabled} + additionalTextareaProps={this.props.additionalTextareaProps} /> + */ + additionalTextareaProps: object; } export type ImageUpload = { @@ -655,6 +665,7 @@ export interface ChatAutoCompleteProps { commands: Client.CommandResponse[]; onFocus?: React.FocusEventHandler; onPaste?: React.ClipboardEventHandler; + additionalTextareaProps: object; } export interface ChatDownProps extends TranslationContextValue { From a6719bb8dc0b9209c45653c5b6fe6fe0e5e8bf32 Mon Sep 17 00:00:00 2001 From: vishtree Date: Thu, 26 Mar 2020 16:55:17 +0100 Subject: [PATCH 3/3] adding additionalTextareaProps in EditMessageForm --- src/components/EditMessageForm.js | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/components/EditMessageForm.js b/src/components/EditMessageForm.js index 36e76b592..b0dc0c666 100644 --- a/src/components/EditMessageForm.js +++ b/src/components/EditMessageForm.js @@ -78,6 +78,10 @@ class EditMessageForm extends React.Component { maxNumberOfFiles: PropTypes.number, /** @see See [channel context](https://getstream.github.io/stream-chat-react/#channel) doc */ acceptedFiles: PropTypes.object, + /** + * Any additional attrubutes that you may want to add for underlying HTML textarea element. + */ + additionalTextareaProps: PropTypes.object, }; static defaultProps = { @@ -179,6 +183,7 @@ class EditMessageForm extends React.Component { maxRows={this.props.maxRows} onPaste={this.props.onPaste} grow={this.props.grow} + additionalTextareaProps={this.props.additionalTextareaProps} />