mirror of
https://github.com/element-hq/element-web
synced 2024-11-25 02:35:48 +03:00
Merge pull request #2677 from jryans/composer-input
Add `onClick` to Markdown buttons
This commit is contained in:
commit
c45ca58689
2 changed files with 10 additions and 4 deletions
|
@ -257,6 +257,8 @@ export default class MessageComposer extends React.Component {
|
||||||
}
|
}
|
||||||
|
|
||||||
onInputStateChanged(inputState) {
|
onInputStateChanged(inputState) {
|
||||||
|
// Merge the new input state with old to support partial updates
|
||||||
|
inputState = Object.assign({}, this.state.inputState, inputState);
|
||||||
this.setState({inputState});
|
this.setState({inputState});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -501,7 +503,7 @@ export default class MessageComposer extends React.Component {
|
||||||
{ formatButtons }
|
{ formatButtons }
|
||||||
<div style={{ flex: 1 }}></div>
|
<div style={{ flex: 1 }}></div>
|
||||||
<AccessibleButton className="mx_MessageComposer_formatbar_markdown mx_MessageComposer_markdownDisabled"
|
<AccessibleButton className="mx_MessageComposer_formatbar_markdown mx_MessageComposer_markdownDisabled"
|
||||||
onMouseDown={this.onToggleMarkdownClicked}
|
onClick={this.onToggleMarkdownClicked}
|
||||||
title={_t("Markdown is disabled")}
|
title={_t("Markdown is disabled")}
|
||||||
/>
|
/>
|
||||||
<AccessibleButton element="img" title={_t("Hide Text Formatting Toolbar")}
|
<AccessibleButton element="img" title={_t("Hide Text Formatting Toolbar")}
|
||||||
|
|
|
@ -628,7 +628,6 @@ export default class MessageComposerInput extends React.Component {
|
||||||
}
|
}
|
||||||
const inputState = {
|
const inputState = {
|
||||||
marks: editorState.activeMarks,
|
marks: editorState.activeMarks,
|
||||||
isRichTextEnabled: this.state.isRichTextEnabled,
|
|
||||||
blockType,
|
blockType,
|
||||||
};
|
};
|
||||||
this.props.onInputStateChanged(inputState);
|
this.props.onInputStateChanged(inputState);
|
||||||
|
@ -698,8 +697,13 @@ export default class MessageComposerInput extends React.Component {
|
||||||
this.setState({
|
this.setState({
|
||||||
editorState: this.createEditorState(enabled, editorState),
|
editorState: this.createEditorState(enabled, editorState),
|
||||||
isRichTextEnabled: enabled,
|
isRichTextEnabled: enabled,
|
||||||
}, ()=>{
|
}, () => {
|
||||||
this._editor.focus();
|
this._editor.focus();
|
||||||
|
if (this.props.onInputStateChanged) {
|
||||||
|
this.props.onInputStateChanged({
|
||||||
|
isRichTextEnabled: enabled,
|
||||||
|
});
|
||||||
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
SettingsStore.setValue("MessageComposerInput.isRichTextEnabled", null, SettingLevel.ACCOUNT, enabled);
|
SettingsStore.setValue("MessageComposerInput.isRichTextEnabled", null, SettingLevel.ACCOUNT, enabled);
|
||||||
|
@ -1603,7 +1607,7 @@ export default class MessageComposerInput extends React.Component {
|
||||||
</div>
|
</div>
|
||||||
<div className={className}>
|
<div className={className}>
|
||||||
<AccessibleButton className={markdownClasses}
|
<AccessibleButton className={markdownClasses}
|
||||||
onMouseDown={this.onMarkdownToggleClicked}
|
onClick={this.onMarkdownToggleClicked}
|
||||||
title={this.state.isRichTextEnabled ? _t("Markdown is disabled") : _t("Markdown is enabled")}
|
title={this.state.isRichTextEnabled ? _t("Markdown is disabled") : _t("Markdown is enabled")}
|
||||||
/>
|
/>
|
||||||
<Editor ref={this._collectEditor}
|
<Editor ref={this._collectEditor}
|
||||||
|
|
Loading…
Reference in a new issue