Hide surround with behind a setting

Signed-off-by: Šimon Brandner <simon.bra.ag@gmail.com>
This commit is contained in:
Šimon Brandner 2021-02-12 07:53:09 +01:00
parent e90f5ddf5b
commit b330dd55a0
No known key found for this signature in database
GPG key ID: 9760693FDD98A790
3 changed files with 8 additions and 1 deletions

View file

@ -418,6 +418,7 @@ export default class BasicMessageEditor extends React.Component<IProps, IState>
};
private onKeyDown = (event: React.KeyboardEvent) => {
const surroundWith = SettingsStore.getValue("MessageComposerInput.surroundWith");
const selectionRange = getRangeForSelection(this.editorRef.current, this.props.model, document.getSelection());
// trim the range as we want it to exclude leading/trailing spaces
selectionRange.trim();
@ -475,7 +476,7 @@ export default class BasicMessageEditor extends React.Component<IProps, IState>
});
handled = true;
// 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 === '(') {
this.historyManager.ensureLastChangesPushed(this.props.model);
this.modifiedFlag = true;

View file

@ -34,6 +34,7 @@ export default class PreferencesUserSettingsTab extends React.Component {
'MessageComposerInput.suggestEmoji',
'sendTypingNotifications',
'MessageComposerInput.ctrlEnterToSend',
'MessageComposerInput.surroundWith',
];
static TIMELINE_SETTINGS = [

View file

@ -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"),
default: false,
},
"MessageComposerInput.surroundWith": {
supportedLevels: LEVELS_ACCOUNT_SETTINGS,
displayName: _td("Use surround with"),
default: false,
},
"MessageComposerInput.autoReplaceEmoji": {
supportedLevels: LEVELS_ACCOUNT_SETTINGS,
displayName: _td('Automatically replace plain text Emoji'),