feat: Keyboard shortcuts improvements (#2790)
This commit is contained in:
parent
69b0434bb7
commit
d13c4ff8c5
7 changed files with 31 additions and 9 deletions
|
@ -54,7 +54,7 @@ export default {
|
||||||
},
|
},
|
||||||
mounted() {
|
mounted() {
|
||||||
document.addEventListener('keydown', e => {
|
document.addEventListener('keydown', e => {
|
||||||
if (this.show && e.keyCode === 27) {
|
if (this.show && e.code === 'Escape') {
|
||||||
this.onClose();
|
this.onClose();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
|
@ -198,6 +198,7 @@ export default {
|
||||||
allConversations[0].click();
|
allConversations[0].click();
|
||||||
document.querySelector('.conversations-list').scrollTop = 0;
|
document.querySelector('.conversations-list').scrollTop = 0;
|
||||||
}
|
}
|
||||||
|
e.preventDefault();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
|
@ -94,7 +94,10 @@ import AccountSelector from './sidebarComponents/AccountSelector.vue';
|
||||||
import AddAccountModal from './sidebarComponents/AddAccountModal.vue';
|
import AddAccountModal from './sidebarComponents/AddAccountModal.vue';
|
||||||
import AddLabelModal from '../../routes/dashboard/settings/labels/AddLabel';
|
import AddLabelModal from '../../routes/dashboard/settings/labels/AddLabel';
|
||||||
import WootKeyShortcutModal from 'components/widgets/modal/WootKeyShortcutModal';
|
import WootKeyShortcutModal from 'components/widgets/modal/WootKeyShortcutModal';
|
||||||
import { hasPressedCommandAndForwardSlash } from 'shared/helpers/KeyboardHelpers';
|
import {
|
||||||
|
hasPressedCommandAndForwardSlash,
|
||||||
|
isEscape,
|
||||||
|
} from 'shared/helpers/KeyboardHelpers';
|
||||||
import eventListenerMixins from 'shared/mixins/eventListenerMixins';
|
import eventListenerMixins from 'shared/mixins/eventListenerMixins';
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
|
@ -278,6 +281,9 @@ export default {
|
||||||
if (hasPressedCommandAndForwardSlash(e)) {
|
if (hasPressedCommandAndForwardSlash(e)) {
|
||||||
this.toggleKeyShortcutModal();
|
this.toggleKeyShortcutModal();
|
||||||
}
|
}
|
||||||
|
if (isEscape(e)) {
|
||||||
|
this.closeKeyShortcutModal();
|
||||||
|
}
|
||||||
},
|
},
|
||||||
toggleSupportChatWindow() {
|
toggleSupportChatWindow() {
|
||||||
window.$chatwoot.toggle();
|
window.$chatwoot.toggle();
|
||||||
|
|
|
@ -38,6 +38,11 @@ import CannedResponse from '../conversation/CannedResponse';
|
||||||
const TYPING_INDICATOR_IDLE_TIME = 4000;
|
const TYPING_INDICATOR_IDLE_TIME = 4000;
|
||||||
|
|
||||||
import '@chatwoot/prosemirror-schema/src/woot-editor.css';
|
import '@chatwoot/prosemirror-schema/src/woot-editor.css';
|
||||||
|
import {
|
||||||
|
hasPressedAltAndPKey,
|
||||||
|
hasPressedAltAndLKey,
|
||||||
|
} from 'shared/helpers/KeyboardHelpers';
|
||||||
|
import eventListenerMixins from 'shared/mixins/eventListenerMixins';
|
||||||
|
|
||||||
const createState = (content, placeholder, plugins = []) => {
|
const createState = (content, placeholder, plugins = []) => {
|
||||||
return EditorState.create({
|
return EditorState.create({
|
||||||
|
@ -53,6 +58,7 @@ const createState = (content, placeholder, plugins = []) => {
|
||||||
export default {
|
export default {
|
||||||
name: 'WootMessageEditor',
|
name: 'WootMessageEditor',
|
||||||
components: { TagAgents, CannedResponse },
|
components: { TagAgents, CannedResponse },
|
||||||
|
mixins: [eventListenerMixins],
|
||||||
props: {
|
props: {
|
||||||
value: { type: String, default: '' },
|
value: { type: String, default: '' },
|
||||||
placeholder: { type: String, default: '' },
|
placeholder: { type: String, default: '' },
|
||||||
|
@ -177,8 +183,20 @@ export default {
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
this.focusEditorInputField();
|
||||||
},
|
},
|
||||||
methods: {
|
methods: {
|
||||||
|
handleKeyEvents(e) {
|
||||||
|
if (hasPressedAltAndPKey(e)) {
|
||||||
|
this.focusEditorInputField();
|
||||||
|
}
|
||||||
|
if (hasPressedAltAndLKey(e)) {
|
||||||
|
this.focusEditorInputField();
|
||||||
|
}
|
||||||
|
},
|
||||||
|
focusEditorInputField() {
|
||||||
|
this.$refs.editor.querySelector('div.ProseMirror-woot-style').focus();
|
||||||
|
},
|
||||||
insertMentionNode(mentionItem) {
|
insertMentionNode(mentionItem) {
|
||||||
if (!this.view) {
|
if (!this.view) {
|
||||||
return null;
|
return null;
|
||||||
|
|
|
@ -354,9 +354,6 @@ export default {
|
||||||
if (this.showRichContentEditor) {
|
if (this.showRichContentEditor) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (this.$refs.messageInput === undefined) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
this.$nextTick(() => this.$refs.messageInput.focus());
|
this.$nextTick(() => this.$refs.messageInput.focus());
|
||||||
},
|
},
|
||||||
emojiOnClick(emoji) {
|
emojiOnClick(emoji) {
|
||||||
|
|
|
@ -9,7 +9,7 @@
|
||||||
</h2>
|
</h2>
|
||||||
<div class="shortcut-key__wrap">
|
<div class="shortcut-key__wrap">
|
||||||
<p class="shortcut-key">
|
<p class="shortcut-key">
|
||||||
{{ $t('KEYBOARD_SHORTCUTS.KEYS.COMMAND_KEY') }}
|
{{ $t('KEYBOARD_SHORTCUTS.KEYS.WINDOWS_KEY_AND_COMMAND_KEY') }}
|
||||||
</p>
|
</p>
|
||||||
<p class="shortcut-key key">
|
<p class="shortcut-key key">
|
||||||
{{ $t('KEYBOARD_SHORTCUTS.KEYS.FORWARD_SLASH_KEY') }}
|
{{ $t('KEYBOARD_SHORTCUTS.KEYS.FORWARD_SLASH_KEY') }}
|
||||||
|
@ -51,7 +51,7 @@
|
||||||
</span>
|
</span>
|
||||||
<div class="shortcut-key__wrap">
|
<div class="shortcut-key__wrap">
|
||||||
<span class="shortcut-key">
|
<span class="shortcut-key">
|
||||||
{{ $t('KEYBOARD_SHORTCUTS.KEYS.COMMAND_KEY') }}
|
{{ $t('KEYBOARD_SHORTCUTS.KEYS.WINDOWS_KEY_AND_COMMAND_KEY') }}
|
||||||
</span>
|
</span>
|
||||||
<span class="shortcut-key">
|
<span class="shortcut-key">
|
||||||
{{ $t('KEYBOARD_SHORTCUTS.KEYS.ALT_OR_OPTION_KEY') }}
|
{{ $t('KEYBOARD_SHORTCUTS.KEYS.ALT_OR_OPTION_KEY') }}
|
||||||
|
|
|
@ -178,14 +178,14 @@
|
||||||
"GO_TO_REPORTS_SIDEBAR": "Go to Reports sidebar",
|
"GO_TO_REPORTS_SIDEBAR": "Go to Reports sidebar",
|
||||||
"MOVE_TO_NEXT_TAB": "Move to next tab in conversation list",
|
"MOVE_TO_NEXT_TAB": "Move to next tab in conversation list",
|
||||||
"GO_TO_SETTINGS": "Go to Settings",
|
"GO_TO_SETTINGS": "Go to Settings",
|
||||||
"SWITCH_CONVERSATION_STATUS": "Switch Conversation status",
|
"SWITCH_CONVERSATION_STATUS": "Switch to the next conversation status",
|
||||||
"SWITCH_TO_PRIVATE_NOTE": "Switch to Private Note",
|
"SWITCH_TO_PRIVATE_NOTE": "Switch to Private Note",
|
||||||
"TOGGLE_RICH_CONTENT_EDITOR": "Toggle Rich Content editor",
|
"TOGGLE_RICH_CONTENT_EDITOR": "Toggle Rich Content editor",
|
||||||
"SWITCH_TO_REPLY": "Switch to Reply",
|
"SWITCH_TO_REPLY": "Switch to Reply",
|
||||||
"TOGGLE_SNOOZE_DROPDOWN": "Toggle snooze dropdown"
|
"TOGGLE_SNOOZE_DROPDOWN": "Toggle snooze dropdown"
|
||||||
},
|
},
|
||||||
"KEYS": {
|
"KEYS": {
|
||||||
"COMMAND_KEY": "⌘",
|
"WINDOWS_KEY_AND_COMMAND_KEY": "Win / ⌘",
|
||||||
"ALT_OR_OPTION_KEY": "Alt / ⌥",
|
"ALT_OR_OPTION_KEY": "Alt / ⌥",
|
||||||
"FORWARD_SLASH_KEY": "/"
|
"FORWARD_SLASH_KEY": "/"
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue