mirror of
https://github.com/element-hq/element-web.git
synced 2024-12-15 16:41:31 +03:00
Hide surround with behind a setting
Signed-off-by: Šimon Brandner <simon.bra.ag@gmail.com>
This commit is contained in:
parent
e90f5ddf5b
commit
b330dd55a0
3 changed files with 8 additions and 1 deletions
|
@ -418,6 +418,7 @@ export default class BasicMessageEditor extends React.Component<IProps, IState>
|
||||||
};
|
};
|
||||||
|
|
||||||
private onKeyDown = (event: React.KeyboardEvent) => {
|
private onKeyDown = (event: React.KeyboardEvent) => {
|
||||||
|
const surroundWith = SettingsStore.getValue("MessageComposerInput.surroundWith");
|
||||||
const selectionRange = getRangeForSelection(this.editorRef.current, this.props.model, document.getSelection());
|
const selectionRange = getRangeForSelection(this.editorRef.current, this.props.model, document.getSelection());
|
||||||
// trim the range as we want it to exclude leading/trailing spaces
|
// trim the range as we want it to exclude leading/trailing spaces
|
||||||
selectionRange.trim();
|
selectionRange.trim();
|
||||||
|
@ -475,7 +476,7 @@ export default class BasicMessageEditor extends React.Component<IProps, IState>
|
||||||
});
|
});
|
||||||
handled = true;
|
handled = true;
|
||||||
// autocomplete or enter to send below shouldn't have any modifier keys pressed.
|
// autocomplete or enter to send below shouldn't have any modifier keys pressed.
|
||||||
} else if (document.getSelection().type != "Caret") {
|
} else if (surroundWith && document.getSelection().type != "Caret") {
|
||||||
if (event.key === '(') {
|
if (event.key === '(') {
|
||||||
this.historyManager.ensureLastChangesPushed(this.props.model);
|
this.historyManager.ensureLastChangesPushed(this.props.model);
|
||||||
this.modifiedFlag = true;
|
this.modifiedFlag = true;
|
||||||
|
|
|
@ -34,6 +34,7 @@ export default class PreferencesUserSettingsTab extends React.Component {
|
||||||
'MessageComposerInput.suggestEmoji',
|
'MessageComposerInput.suggestEmoji',
|
||||||
'sendTypingNotifications',
|
'sendTypingNotifications',
|
||||||
'MessageComposerInput.ctrlEnterToSend',
|
'MessageComposerInput.ctrlEnterToSend',
|
||||||
|
'MessageComposerInput.surroundWith',
|
||||||
];
|
];
|
||||||
|
|
||||||
static TIMELINE_SETTINGS = [
|
static TIMELINE_SETTINGS = [
|
||||||
|
|
|
@ -336,6 +336,11 @@ export const SETTINGS: {[setting: string]: ISetting} = {
|
||||||
displayName: isMac ? _td("Use Command + Enter to send a message") : _td("Use Ctrl + Enter to send a message"),
|
displayName: isMac ? _td("Use Command + Enter to send a message") : _td("Use Ctrl + Enter to send a message"),
|
||||||
default: false,
|
default: false,
|
||||||
},
|
},
|
||||||
|
"MessageComposerInput.surroundWith": {
|
||||||
|
supportedLevels: LEVELS_ACCOUNT_SETTINGS,
|
||||||
|
displayName: _td("Use surround with"),
|
||||||
|
default: false,
|
||||||
|
},
|
||||||
"MessageComposerInput.autoReplaceEmoji": {
|
"MessageComposerInput.autoReplaceEmoji": {
|
||||||
supportedLevels: LEVELS_ACCOUNT_SETTINGS,
|
supportedLevels: LEVELS_ACCOUNT_SETTINGS,
|
||||||
displayName: _td('Automatically replace plain text Emoji'),
|
displayName: _td('Automatically replace plain text Emoji'),
|
||||||
|
|
Loading…
Reference in a new issue