feat: Allow users to select Cmd+Enter as a hotkey (#4401)

Co-authored-by: Pranav Raj S <pranav@chatwoot.com>
This commit is contained in:
Sivin Varghese 2022-10-04 03:57:34 +05:30 committed by GitHub
parent 9ea43a2678
commit beedfc47bf
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
14 changed files with 344 additions and 93 deletions

View file

@ -0,0 +1,113 @@
<template>
<div class="preview-card--wrap" :class="{ activecard: active }">
<div class="header--wrap" :class="{ active: active }">
<div class="heading-wrap text-block-title">{{ heading }}</div>
<fluent-icon
v-if="active"
icon="checkmark-circle"
type="solid"
size="24"
class="checkmark"
/>
</div>
<div class="content-wrap">
{{ content }}
</div>
<div class="image-wrap">
<img :src="src" class="image" :class="{ activeimage: active }" />
</div>
</div>
</template>
<script>
export default {
props: {
heading: {
type: String,
default: '',
},
content: {
type: String,
default: '',
},
active: {
type: Boolean,
default: false,
},
buttonText: {
type: String,
default: 'Active',
},
src: {
type: String,
default: '',
},
},
};
</script>
<style lang="scss" scoped>
.preview-card--wrap {
border-radius: var(--border-radius-normal);
border: 1px solid var(--color-border);
display: flex;
flex-direction: column;
max-height: 34rem;
max-width: 38rem;
min-width: 24rem;
.header--wrap {
background: var(--s-50);
border-bottom: 1px solid var(--color-border);
border-top-left-radius: var(--border-radius-normal);
border-top-right-radius: var(--border-radius-normal);
display: flex;
height: 4rem;
justify-content: space-between;
padding: var(--space-small);
width: 100%;
}
.active {
background: var(--w-50);
border-bottom: 1px solid var(--w-75);
}
.heading-wrap {
align-items: center;
display: flex;
font-weight: var(--font-weight-medium);
padding: var(--space-smaller);
}
.checkmark {
color: var(--w-500);
}
.content-wrap {
color: var(--s-700);
font-size: var(--font-size-mini);
line-height: 1.4;
padding: var(--space-slab) var(--space-slab) 0 var(--space-slab);
text-align: start;
}
.image-wrap {
padding: var(--space-slab);
}
.image {
border: 1px solid var(--color-border);
border-radius: var(--border-radius-normal);
}
.activeimage {
border: 1px solid var(--w-75);
}
}
.activecard {
background: var(--w-25);
border: 1px solid var(--w-300);
}
</style>

View file

@ -91,17 +91,6 @@
</transition> </transition>
</div> </div>
<div class="right-wrap"> <div class="right-wrap">
<div v-if="isFormatMode" class="enter-to-send--checkbox">
<input
:checked="enterToSendEnabled"
type="checkbox"
value="enterToSend"
@input="toggleEnterToSend"
/>
<label for="enterToSend">
{{ $t('CONVERSATION.REPLYBOX.ENTER_TO_SEND') }}
</label>
</div>
<woot-button <woot-button
size="small" size="small"
:class-names="buttonClass" :class-names="buttonClass"
@ -201,10 +190,6 @@ export default {
type: Boolean, type: Boolean,
default: false, default: false,
}, },
enterToSendEnabled: {
type: Boolean,
default: true,
},
enableMultipleFileUpload: { enableMultipleFileUpload: {
type: Boolean, type: Boolean,
default: true, default: true,
@ -278,9 +263,6 @@ export default {
this.$refs.upload.$children[1].$el.click(); this.$refs.upload.$children[1].$el.click();
} }
}, },
toggleEnterToSend() {
this.$emit('toggleEnterToSend', !this.enterToSendEnabled);
},
toggleMessageSignature() { toggleMessageSignature() {
this.updateUISettings({ this.updateUISettings({
send_with_signature: !this.sendWithSignature, send_with_signature: !this.sendWithSignature,
@ -312,20 +294,6 @@ export default {
.right-wrap { .right-wrap {
display: flex; display: flex;
.enter-to-send--checkbox {
align-items: center;
display: flex;
input {
margin: 0;
}
label {
color: var(--s-500);
font-size: var(--font-size-mini);
}
}
} }
::v-deep .file-uploads { ::v-deep .file-uploads {

View file

@ -110,10 +110,8 @@
:is-recording-audio="isRecordingAudio" :is-recording-audio="isRecordingAudio"
:is-on-private-note="isOnPrivateNote" :is-on-private-note="isOnPrivateNote"
:is-format-mode="showRichContentEditor" :is-format-mode="showRichContentEditor"
:enter-to-send-enabled="enterToSendEnabled"
:enable-multiple-file-upload="enableMultipleFileUpload" :enable-multiple-file-upload="enableMultipleFileUpload"
:has-whatsapp-templates="hasWhatsappTemplates" :has-whatsapp-templates="hasWhatsappTemplates"
@toggleEnterToSend="toggleEnterToSend"
@selectWhatsappTemplate="openWhatsappTemplateModal" @selectWhatsappTemplate="openWhatsappTemplateModal"
/> />
<whatsapp-templates <whatsapp-templates
@ -150,18 +148,14 @@ import {
} from 'shared/constants/messages'; } from 'shared/constants/messages';
import { BUS_EVENTS } from 'shared/constants/busEvents'; import { BUS_EVENTS } from 'shared/constants/busEvents';
import WhatsappTemplates from './WhatsappTemplates/Modal.vue'; import WhatsappTemplates from './WhatsappTemplates/Modal.vue';
import { import { buildHotKeys } from 'shared/helpers/KeyboardHelpers';
isEscape,
isEnter,
hasPressedShift,
hasPressedCommandPlusKKey,
} from 'shared/helpers/KeyboardHelpers';
import { MESSAGE_MAX_LENGTH } from 'shared/helpers/MessageTypeHelper'; import { MESSAGE_MAX_LENGTH } from 'shared/helpers/MessageTypeHelper';
import inboxMixin from 'shared/mixins/inboxMixin'; import inboxMixin from 'shared/mixins/inboxMixin';
import uiSettingsMixin from 'dashboard/mixins/uiSettings'; import uiSettingsMixin from 'dashboard/mixins/uiSettings';
import { DirectUpload } from 'activestorage'; import { DirectUpload } from 'activestorage';
import { frontendURL } from '../../../helper/URLHelper'; import { frontendURL } from '../../../helper/URLHelper';
import wootConstants from 'dashboard/constants'; import wootConstants from 'dashboard/constants';
import { isEditorHotKeyEnabled } from 'dashboard/mixins/uiSettings';
export default { export default {
components: { components: {
@ -267,9 +261,6 @@ export default {
return !!this.$store.getters['inboxes/getWhatsAppTemplates'](this.inboxId) return !!this.$store.getters['inboxes/getWhatsAppTemplates'](this.inboxId)
.length; .length;
}, },
enterToSendEnabled() {
return !!this.uiSettings.enter_to_send_enabled;
},
isPrivate() { isPrivate() {
if (this.currentChat.can_reply || this.isAWhatsAppChannel) { if (this.currentChat.can_reply || this.isAWhatsAppChannel) {
return this.isOnPrivateNote; return this.isOnPrivateNote;
@ -343,13 +334,16 @@ export default {
); );
}, },
replyButtonLabel() { replyButtonLabel() {
let sendMessageText = this.$t('CONVERSATION.REPLYBOX.SEND');
if (this.isPrivate) { if (this.isPrivate) {
return this.$t('CONVERSATION.REPLYBOX.CREATE'); sendMessageText = this.$t('CONVERSATION.REPLYBOX.CREATE');
} else if (this.conversationType === 'tweet') {
sendMessageText = this.$t('CONVERSATION.REPLYBOX.TWEET');
} }
if (this.conversationType === 'tweet') { const keyLabel = isEditorHotKeyEnabled(this.uiSettings, 'cmd_enter')
return this.$t('CONVERSATION.REPLYBOX.TWEET'); ? '(⌘ + ↵)'
} : '(↵)';
return this.$t('CONVERSATION.REPLYBOX.SEND'); return `${sendMessageText} ${keyLabel}`;
}, },
replyBoxClass() { replyBoxClass() {
return { return {
@ -430,12 +424,18 @@ export default {
profilePath() { profilePath() {
return frontendURL(`accounts/${this.accountId}/profile/settings`); return frontendURL(`accounts/${this.accountId}/profile/settings`);
}, },
conversationId() { editorMessageKey() {
return this.currentChat.id; const { editor_message_key: isEnabled } = this.uiSettings;
return isEnabled;
},
commandPlusEnterToSendEnabled() {
return this.editorMessageKey === 'cmd_enter';
},
enterToSendEnabled() {
return this.editorMessageKey === 'enter';
}, },
editorStateId() { editorStateId() {
const key = `draft-${this.conversationIdByRoute}-${this.replyType}`; return `draft-${this.conversationIdByRoute}-${this.replyType}`;
return key;
}, },
}, },
watch: { watch: {
@ -471,16 +471,41 @@ export default {
mounted() { mounted() {
// Donot use the keyboard listener mixin here as the events here are supposed to be // Donot use the keyboard listener mixin here as the events here are supposed to be
// working even if input/textarea is focussed. // working even if input/textarea is focussed.
document.addEventListener('keydown', this.handleKeyEvents);
document.addEventListener('paste', this.onPaste); document.addEventListener('paste', this.onPaste);
document.addEventListener('keydown', this.handleKeyEvents);
this.setCCEmailFromLastChat(); this.setCCEmailFromLastChat();
}, },
destroyed() { destroyed() {
document.removeEventListener('keydown', this.handleKeyEvents);
document.removeEventListener('paste', this.onPaste); document.removeEventListener('paste', this.onPaste);
document.removeEventListener('keydown', this.handleKeyEvents);
}, },
methods: { methods: {
handleKeyEvents(e) {
const keyCode = buildHotKeys(e);
if (keyCode === 'escape') {
this.hideEmojiPicker();
this.hideMentions();
} else if (keyCode === 'meta+k') {
const ninja = document.querySelector('ninja-keys');
ninja.open();
e.preventDefault();
} else if (keyCode === 'enter' && this.isAValidEvent('enter')) {
this.onSendReply();
} else if (
['meta+enter', 'ctrl+enter'].includes(keyCode) &&
this.isAValidEvent('cmd_enter')
) {
this.onSendReply();
}
},
isAValidEvent(selectedKey) {
return (
!this.hasUserMention &&
!this.showCannedMenu &&
this.isFocused &&
isEditorHotKeyEnabled(this.uiSettings, selectedKey)
);
},
onPaste(e) { onPaste(e) {
const data = e.clipboardData.files; const data = e.clipboardData.files;
if (!this.showRichContentEditor && data.length !== 0) { if (!this.showRichContentEditor && data.length !== 0) {
@ -500,34 +525,6 @@ export default {
toggleCannedMenu(value) { toggleCannedMenu(value) {
this.showCannedMenu = value; this.showCannedMenu = value;
}, },
handleKeyEvents(e) {
if (isEscape(e)) {
this.hideEmojiPicker();
this.hideMentions();
} else if (isEnter(e)) {
const hasSendOnEnterEnabled =
(this.showRichContentEditor &&
this.enterToSendEnabled &&
!this.hasUserMention &&
!this.showCannedMenu) ||
!this.showRichContentEditor;
const shouldSendMessage =
hasSendOnEnterEnabled && !hasPressedShift(e) && this.isFocused;
if (shouldSendMessage) {
e.preventDefault();
this.onSendReply();
}
} else if (hasPressedCommandPlusKKey(e)) {
this.openCommandBar();
}
},
openCommandBar() {
const ninja = document.querySelector('ninja-keys');
ninja.open();
},
toggleEnterToSend(enterToSendEnabled) {
this.updateUISettings({ enter_to_send_enabled: enterToSendEnabled });
},
openWhatsappTemplateModal() { openWhatsappTemplateModal() {
this.showWhatsAppTemplatesModal = true; this.showWhatsAppTemplatesModal = true;
}, },
@ -603,7 +600,6 @@ export default {
}, },
setReplyMode(mode = REPLY_EDITOR_MODES.REPLY) { setReplyMode(mode = REPLY_EDITOR_MODES.REPLY) {
const { can_reply: canReply } = this.currentChat; const { can_reply: canReply } = this.currentChat;
if (canReply || this.isAWhatsAppChannel) this.replyType = mode; if (canReply || this.isAWhatsAppChannel) this.replyType = mode;
if (this.showRichContentEditor) { if (this.showRichContentEditor) {
if (this.isRecordingAudio) { if (this.isRecordingAudio) {

View file

@ -111,7 +111,6 @@
"TIP_AUDIORECORDER_ICON": "Record audio", "TIP_AUDIORECORDER_ICON": "Record audio",
"TIP_AUDIORECORDER_PERMISSION": "Allow access to audio", "TIP_AUDIORECORDER_PERMISSION": "Allow access to audio",
"TIP_AUDIORECORDER_ERROR": "Could not open the audio", "TIP_AUDIORECORDER_ERROR": "Could not open the audio",
"ENTER_TO_SEND": "Enter to send",
"DRAG_DROP": "Drag and drop here to attach", "DRAG_DROP": "Drag and drop here to attach",
"START_AUDIO_RECORDING": "Start audio recording", "START_AUDIO_RECORDING": "Start audio recording",
"STOP_AUDIO_RECORDING": "Stop audio recording", "STOP_AUDIO_RECORDING": "Stop audio recording",

View file

@ -19,6 +19,21 @@
"TITLE": "Profile", "TITLE": "Profile",
"NOTE": "Your email address is your identity and is used to log in." "NOTE": "Your email address is your identity and is used to log in."
}, },
"SEND_MESSAGE": {
"TITLE": "Hotkey to send messages",
"NOTE": "You can select a hotkey (either Enter or Cmd/Ctrl+Enter) based on your preference of writing.",
"UPDATE_SUCCESS": "Your settings have been updated successfully",
"CARD": {
"ENTER_KEY": {
"HEADING": "Enter (↵)",
"CONTENT": "Send messages by pressing Enter key instead of clicking the send button."
},
"CMD_ENTER_KEY": {
"HEADING": "Cmd/Ctrl + Enter (⌘ + ↵)",
"CONTENT": "Send messages by pressing Cmd/Ctrl + enter key instead of clicking the send button."
}
}
},
"MESSAGE_SIGNATURE_SECTION": { "MESSAGE_SIGNATURE_SECTION": {
"TITLE": "Personal message signature", "TITLE": "Personal message signature",
"NOTE": "Create a personal message signature that would be added to all the messages you send from your email inbox. Use the rich content editor to create a highly personalised signature.", "NOTE": "Create a personal message signature that would be added to all the messages you send from your email inbox. Use the rich content editor to create a highly personalised signature.",

View file

@ -2,6 +2,7 @@ import { shallowMount, createLocalVue } from '@vue/test-utils';
import uiSettingsMixin, { import uiSettingsMixin, {
DEFAULT_CONVERSATION_SIDEBAR_ITEMS_ORDER, DEFAULT_CONVERSATION_SIDEBAR_ITEMS_ORDER,
DEFAULT_CONTACT_SIDEBAR_ITEMS_ORDER, DEFAULT_CONTACT_SIDEBAR_ITEMS_ORDER,
isEditorHotKeyEnabled,
} from '../uiSettings'; } from '../uiSettings';
import Vuex from 'vuex'; import Vuex from 'vuex';
const localVue = createLocalVue(); const localVue = createLocalVue();
@ -137,3 +138,26 @@ describe('uiSettingsMixin', () => {
}); });
}); });
}); });
describe('isEditorHotKeyEnabled', () => {
it('returns true if hot key is not configured and enter to send flag is true', () => {
expect(
isEditorHotKeyEnabled({ enter_to_send_enabled: true }, 'enter')
).toEqual(true);
expect(
isEditorHotKeyEnabled({ enter_to_send_enabled: true }, 'cmd_enter')
).toEqual(false);
expect(isEditorHotKeyEnabled({}, 'cmd_enter')).toEqual(true);
expect(isEditorHotKeyEnabled({}, 'enter')).toEqual(false);
});
it('returns correct value if hot key is configured', () => {
expect(
isEditorHotKeyEnabled({ editor_message_key: 'enter' }, 'enter')
).toEqual(true);
expect(
isEditorHotKeyEnabled({ editor_message_key: 'cmd_enter' }, 'enter')
).toEqual(false);
});
});

View file

@ -10,11 +10,24 @@ export const DEFAULT_CONTACT_SIDEBAR_ITEMS_ORDER = [
{ name: 'contact_labels' }, { name: 'contact_labels' },
{ name: 'previous_conversation' }, { name: 'previous_conversation' },
]; ];
export const isEditorHotKeyEnabled = (uiSettings, key) => {
const {
editor_message_key: editorMessageKey,
enter_to_send_enabled: enterToSendEnabled,
} = uiSettings || {};
if (!editorMessageKey) {
if (enterToSendEnabled) {
return key === 'enter';
}
return key === 'cmd_enter';
}
return editorMessageKey === key;
};
export default { export default {
computed: { computed: {
...mapGetters({ ...mapGetters({ uiSettings: 'getUISettings' }),
uiSettings: 'getUISettings',
}),
conversationSidebarItemsOrder() { conversationSidebarItemsOrder() {
const { conversation_sidebar_items_order: itemsOrder } = this.uiSettings; const { conversation_sidebar_items_order: itemsOrder } = this.uiSettings;
return itemsOrder || DEFAULT_CONVERSATION_SIDEBAR_ITEMS_ORDER; return itemsOrder || DEFAULT_CONVERSATION_SIDEBAR_ITEMS_ORDER;

View file

@ -70,6 +70,31 @@
</div> </div>
</form> </form>
<message-signature /> <message-signature />
<div class="profile--settings--row row">
<div class="columns small-3">
<h4 class="block-title">
{{ $t('PROFILE_SETTINGS.FORM.SEND_MESSAGE.TITLE') }}
</h4>
<p>
{{ $t('PROFILE_SETTINGS.FORM.SEND_MESSAGE.NOTE') }}
</p>
</div>
<div class="columns small-9 medium-5 card-preview">
<button
v-for="keyOption in keyOptions"
:key="keyOption.key"
class="preview-button"
@click="toggleEditorMessageKey(keyOption.key)"
>
<preview-card
:heading="keyOption.heading"
:content="keyOption.content"
:src="keyOption.src"
:active="isEditorHotKeyEnabled(uiSettings, keyOption.key)"
/>
</button>
</div>
</div>
<change-password v-if="!globalConfig.disableUserProfileUpdate" /> <change-password v-if="!globalConfig.disableUserProfileUpdate" />
<notification-settings /> <notification-settings />
<div class="profile--settings--row row"> <div class="profile--settings--row row">
@ -102,14 +127,19 @@ import alertMixin from 'shared/mixins/alertMixin';
import ChangePassword from './ChangePassword'; import ChangePassword from './ChangePassword';
import MessageSignature from './MessageSignature'; import MessageSignature from './MessageSignature';
import globalConfigMixin from 'shared/mixins/globalConfigMixin'; import globalConfigMixin from 'shared/mixins/globalConfigMixin';
import uiSettingsMixin, {
isEditorHotKeyEnabled,
} from 'dashboard/mixins/uiSettings';
import PreviewCard from 'dashboard/components/ui/PreviewCard.vue';
export default { export default {
components: { components: {
NotificationSettings, NotificationSettings,
ChangePassword, ChangePassword,
MessageSignature, MessageSignature,
PreviewCard,
}, },
mixins: [alertMixin, globalConfigMixin], mixins: [alertMixin, globalConfigMixin, uiSettingsMixin],
data() { data() {
return { return {
avatarFile: '', avatarFile: '',
@ -119,6 +149,28 @@ export default {
email: '', email: '',
isProfileUpdating: false, isProfileUpdating: false,
errorMessage: '', errorMessage: '',
keyOptions: [
{
key: 'enter',
src: '/assets/images/dashboard/editor/enter-editor.png',
heading: this.$t(
'PROFILE_SETTINGS.FORM.SEND_MESSAGE.CARD.ENTER_KEY.HEADING'
),
content: this.$t(
'PROFILE_SETTINGS.FORM.SEND_MESSAGE.CARD.ENTER_KEY.CONTENT'
),
},
{
key: 'cmd_enter',
src: '/assets/images/dashboard/editor/cmd-editor.png',
heading: this.$t(
'PROFILE_SETTINGS.FORM.SEND_MESSAGE.CARD.CMD_ENTER_KEY.HEADING'
),
content: this.$t(
'PROFILE_SETTINGS.FORM.SEND_MESSAGE.CARD.CMD_ENTER_KEY.CONTENT'
),
},
],
}; };
}, },
validations: { validations: {
@ -158,6 +210,7 @@ export default {
this.avatarUrl = this.currentUser.avatar_url; this.avatarUrl = this.currentUser.avatar_url;
this.displayName = this.currentUser.display_name; this.displayName = this.currentUser.display_name;
}, },
isEditorHotKeyEnabled,
async updateUser() { async updateUser() {
this.$v.$touch(); this.$v.$touch();
if (this.$v.$invalid) { if (this.$v.$invalid) {
@ -207,6 +260,12 @@ export default {
showDeleteButton() { showDeleteButton() {
return this.avatarUrl && !this.avatarUrl.includes('www.gravatar.com'); return this.avatarUrl && !this.avatarUrl.includes('www.gravatar.com');
}, },
toggleEditorMessageKey(key) {
this.updateUISettings({ editor_message_key: key });
this.showAlert(
this.$t('PROFILE_SETTINGS.FORM.SEND_MESSAGE.UPDATE_SUCCESS')
);
},
}, },
}; };
</script> </script>
@ -216,18 +275,32 @@ export default {
@import '~dashboard/assets/scss/mixins.scss'; @import '~dashboard/assets/scss/mixins.scss';
.profile--settings { .profile--settings {
padding: 24px;
overflow: auto; overflow: auto;
padding: 24px;
} }
.profile--settings--row { .profile--settings--row {
@include border-normal-bottom; @include border-normal-bottom;
align-items: center;
display: flex;
padding: $space-normal; padding: $space-normal;
.small-3 { .small-3 {
padding: $space-normal $space-medium $space-normal 0; padding: $space-normal $space-medium $space-normal 0;
} }
.small-9 { .small-9 {
padding: $space-normal; padding: $space-normal;
} }
.card-preview {
display: flex;
flex-direction: row;
.preview-button {
cursor: pointer;
margin-right: var(--space-normal);
}
}
} }
</style> </style>

View file

@ -77,7 +77,7 @@ export default {
methods: { methods: {
initValues() { initValues() {
const { message_signature: messageSignature } = this.currentUser; const { message_signature: messageSignature } = this.currentUser;
this.messageSignature = messageSignature; this.messageSignature = messageSignature || '';
}, },
async updateSignature() { async updateSignature() {
this.$v.$touch(); this.$v.$touch();

View file

@ -154,7 +154,7 @@
) )
}} }}
</p> </p>
<div v-else> <div v-else class="push-notification--button">
<woot-submit-button <woot-submit-button
:button-text=" :button-text="
$t( $t(
@ -368,4 +368,8 @@ export default {
.notification--checkbox { .notification--checkbox {
font-size: $font-size-large; font-size: $font-size-large;
} }
.push-notification--button {
margin-bottom: var(--space-one);
}
</style> </style>

View file

@ -10,6 +10,10 @@ export const hasPressedShift = e => {
return e.shiftKey; return e.shiftKey;
}; };
export const hasPressedCommand = e => {
return e.metaKey;
};
export const hasPressedCommandAndEnter = e => { export const hasPressedCommandAndEnter = e => {
return e.metaKey && e.keyCode === 13; return e.metaKey && e.keyCode === 13;
}; };
@ -89,3 +93,25 @@ export const hasPressedArrowDownKey = e => {
export const hasPressedCommandPlusKKey = e => { export const hasPressedCommandPlusKKey = e => {
return e.metaKey && e.keyCode === 75; return e.metaKey && e.keyCode === 75;
}; };
export const buildHotKeys = e => {
const key = e.key.toLowerCase();
if (['shift', 'meta', 'alt', 'control'].includes(key)) {
return key;
}
let hotKeyPattern = '';
if (e.altKey) {
hotKeyPattern += 'alt+';
}
if (e.ctrlKey) {
hotKeyPattern += 'ctrl+';
}
if (e.metaKey && !e.ctrlKey) {
hotKeyPattern += 'meta+';
}
if (e.shiftKey) {
hotKeyPattern += 'shift+';
}
hotKeyPattern += key;
return hotKeyPattern;
};

View file

@ -1,4 +1,10 @@
import { isEnter, isEscape, hasPressedShift } from '../KeyboardHelpers'; import {
isEnter,
isEscape,
hasPressedShift,
hasPressedCommand,
buildHotKeys,
} from '../KeyboardHelpers';
describe('#KeyboardHelpers', () => { describe('#KeyboardHelpers', () => {
describe('#isEnter', () => { describe('#isEnter', () => {
@ -18,4 +24,18 @@ describe('#KeyboardHelpers', () => {
expect(hasPressedShift({ shiftKey: true })).toEqual(true); expect(hasPressedShift({ shiftKey: true })).toEqual(true);
}); });
}); });
describe('#hasPressedCommand', () => {
it('return correct values', () => {
expect(hasPressedCommand({ metaKey: true })).toEqual(true);
});
});
describe('#buildHotKeys', () => {
it('returns hot keys', () => {
expect(buildHotKeys({ altKey: true, key: 'alt' })).toEqual('alt');
expect(buildHotKeys({ ctrlKey: true, key: 'a' })).toEqual('ctrl+a');
expect(buildHotKeys({ metaKey: true, key: 'b' })).toEqual('meta+b');
});
});
}); });

Binary file not shown.

After

Width:  |  Height:  |  Size: 146 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 144 KiB