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

Commit

Permalink
Merge pull request #2677 from jryans/composer-input
Browse files Browse the repository at this point in the history
Add `onClick` to Markdown buttons
  • Loading branch information
jryans committed Feb 22, 2019
2 parents a025080 + ccd4dee commit c45ca58
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 4 deletions.
4 changes: 3 additions & 1 deletion src/components/views/rooms/MessageComposer.js
Original file line number Diff line number Diff line change
Expand Up @@ -257,6 +257,8 @@ export default class MessageComposer extends React.Component {
}

onInputStateChanged(inputState) {
// Merge the new input state with old to support partial updates
inputState = Object.assign({}, this.state.inputState, inputState);
this.setState({inputState});
}

Expand Down Expand Up @@ -501,7 +503,7 @@ export default class MessageComposer extends React.Component {
{ formatButtons }
<div style={{ flex: 1 }}></div>
<AccessibleButton className="mx_MessageComposer_formatbar_markdown mx_MessageComposer_markdownDisabled"
onMouseDown={this.onToggleMarkdownClicked}
onClick={this.onToggleMarkdownClicked}
title={_t("Markdown is disabled")}
/>
<AccessibleButton element="img" title={_t("Hide Text Formatting Toolbar")}
Expand Down
10 changes: 7 additions & 3 deletions src/components/views/rooms/MessageComposerInput.js
Original file line number Diff line number Diff line change
Expand Up @@ -628,7 +628,6 @@ export default class MessageComposerInput extends React.Component {
}
const inputState = {
marks: editorState.activeMarks,
isRichTextEnabled: this.state.isRichTextEnabled,
blockType,
};
this.props.onInputStateChanged(inputState);
Expand Down Expand Up @@ -698,8 +697,13 @@ export default class MessageComposerInput extends React.Component {
this.setState({
editorState: this.createEditorState(enabled, editorState),
isRichTextEnabled: enabled,
}, ()=>{
}, () => {
this._editor.focus();
if (this.props.onInputStateChanged) {
this.props.onInputStateChanged({
isRichTextEnabled: enabled,
});
}
});

SettingsStore.setValue("MessageComposerInput.isRichTextEnabled", null, SettingLevel.ACCOUNT, enabled);
Expand Down Expand Up @@ -1603,7 +1607,7 @@ export default class MessageComposerInput extends React.Component {
</div>
<div className={className}>
<AccessibleButton className={markdownClasses}
onMouseDown={this.onMarkdownToggleClicked}
onClick={this.onMarkdownToggleClicked}
title={this.state.isRichTextEnabled ? _t("Markdown is disabled") : _t("Markdown is enabled")}
/>
<Editor ref={this._collectEditor}
Expand Down

0 comments on commit c45ca58

Please sign in to comment.