Move FormattingButton to separate component
Signed-off-by: YaoiFangirl420 <48789208+YaoiFangirl420@users.noreply.github.com>
This commit is contained in:
parent
817f1d482f
commit
3dae9f3d58
1 changed files with 23 additions and 17 deletions
|
@ -117,6 +117,24 @@ HangupButton.propTypes = {
|
||||||
roomId: PropTypes.string.isRequired,
|
roomId: PropTypes.string.isRequired,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function FormattingButton(props) {
|
||||||
|
const AccessibleButton = sdk.getComponent('elements.AccessibleButton');
|
||||||
|
return <AccessibleButton
|
||||||
|
element="img"
|
||||||
|
className="mx_MessageComposer_formatting"
|
||||||
|
alt={_t("Show Text Formatting Toolbar")}
|
||||||
|
title={_t("Show Text Formatting Toolbar")}
|
||||||
|
src={require("../../../../res/img/button-text-formatting.svg")}
|
||||||
|
style={{visibility: props.showFormatting ? 'hidden' : 'visible'}}
|
||||||
|
onClick={props.onClickHandler}
|
||||||
|
/>;
|
||||||
|
}
|
||||||
|
|
||||||
|
FormattingButton.propTypes = {
|
||||||
|
showFormatting: PropTypes.bool.isRequired,
|
||||||
|
onClickHandler: PropTypes.func.isRequired,
|
||||||
|
}
|
||||||
|
|
||||||
class UploadButton extends React.Component {
|
class UploadButton extends React.Component {
|
||||||
static propTypes = {
|
static propTypes = {
|
||||||
roomId: PropTypes.string.isRequired,
|
roomId: PropTypes.string.isRequired,
|
||||||
|
@ -374,32 +392,19 @@ export default class MessageComposer extends React.Component {
|
||||||
}
|
}
|
||||||
|
|
||||||
render() {
|
render() {
|
||||||
const MessageComposerInput = sdk.getComponent("rooms.MessageComposerInput");
|
|
||||||
|
|
||||||
const callInProgress = this.props.callState && this.props.callState !== 'ended';
|
|
||||||
|
|
||||||
const controls = [
|
const controls = [
|
||||||
this.state.me ? <Avatar key="controls_avatar" me={this.state.me} /> : null,
|
this.state.me ? <Avatar key="controls_avatar" me={this.state.me} /> : null,
|
||||||
this.props.e2eStatus ? <E2EIcon key="e2eIcon" status={this.props.e2eStatus} className="mx_MessageComposer_e2eIcon" /> : null,
|
this.props.e2eStatus ? <E2EIcon key="e2eIcon" status={this.props.e2eStatus} className="mx_MessageComposer_e2eIcon" /> : null,
|
||||||
];
|
];
|
||||||
|
|
||||||
const AccessibleButton = sdk.getComponent('elements.AccessibleButton');
|
|
||||||
|
|
||||||
if (!this.state.tombstone && this.state.canSendMessages) {
|
if (!this.state.tombstone && this.state.canSendMessages) {
|
||||||
// This also currently includes the call buttons. Really we should
|
// This also currently includes the call buttons. Really we should
|
||||||
// check separately for whether we can call, but this is slightly
|
// check separately for whether we can call, but this is slightly
|
||||||
// complex because of conference calls.
|
// complex because of conference calls.
|
||||||
|
|
||||||
const formattingButton = this.state.inputState.isRichTextEnabled ? (
|
const MessageComposerInput = sdk.getComponent("rooms.MessageComposerInput");
|
||||||
<AccessibleButton element="img" className="mx_MessageComposer_formatting"
|
const showFormattingButton = this.state.inputState.isRichTextEnabled;
|
||||||
alt={_t("Show Text Formatting Toolbar")}
|
const callInProgress = this.props.callState && this.props.callState !== 'ended';
|
||||||
title={_t("Show Text Formatting Toolbar")}
|
|
||||||
src={require("../../../../res/img/button-text-formatting.svg")}
|
|
||||||
onClick={this.onToggleFormattingClicked}
|
|
||||||
style={{visibility: this.state.showFormatting ? 'hidden' : 'visible'}}
|
|
||||||
key="controls_formatting" />
|
|
||||||
) : null;
|
|
||||||
|
|
||||||
|
|
||||||
controls.push(
|
controls.push(
|
||||||
<MessageComposerInput
|
<MessageComposerInput
|
||||||
|
@ -409,7 +414,8 @@ export default class MessageComposer extends React.Component {
|
||||||
placeholder={this.renderPlaceholderText()}
|
placeholder={this.renderPlaceholderText()}
|
||||||
onInputStateChanged={this.onInputStateChanged}
|
onInputStateChanged={this.onInputStateChanged}
|
||||||
permalinkCreator={this.props.permalinkCreator} />,
|
permalinkCreator={this.props.permalinkCreator} />,
|
||||||
formattingButton,
|
showFormattingButton ? <FormattingButton key="controls_formatting"
|
||||||
|
showFormatting={this.state.showFormatting} onClickHandler={this.onToggleFormattingClicked} /> : null,
|
||||||
<Stickerpicker key='stickerpicker_controls_button' room={this.props.room} />,
|
<Stickerpicker key='stickerpicker_controls_button' room={this.props.room} />,
|
||||||
<UploadButton key="controls_upload" roomId={this.props.room.roomId} />,
|
<UploadButton key="controls_upload" roomId={this.props.room.roomId} />,
|
||||||
callInProgress ? <HangupButton key="controls_hangup" roomId={this.props.room.roomId} /> : null,
|
callInProgress ? <HangupButton key="controls_hangup" roomId={this.props.room.roomId} /> : null,
|
||||||
|
|
Loading…
Reference in a new issue