feat: Keyboard shortcuts improvements (#2790)

This commit is contained in:
Sivin Varghese 2021-08-26 15:55:58 +05:30 committed by GitHub
parent 69b0434bb7
commit d13c4ff8c5
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
7 changed files with 31 additions and 9 deletions

View file

@ -38,6 +38,11 @@ import CannedResponse from '../conversation/CannedResponse';
const TYPING_INDICATOR_IDLE_TIME = 4000;
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 = []) => {
return EditorState.create({
@ -53,6 +58,7 @@ const createState = (content, placeholder, plugins = []) => {
export default {
name: 'WootMessageEditor',
components: { TagAgents, CannedResponse },
mixins: [eventListenerMixins],
props: {
value: { type: String, default: '' },
placeholder: { type: String, default: '' },
@ -177,8 +183,20 @@ export default {
},
},
});
this.focusEditorInputField();
},
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) {
if (!this.view) {
return null;

View file

@ -354,9 +354,6 @@ export default {
if (this.showRichContentEditor) {
return;
}
if (this.$refs.messageInput === undefined) {
return;
}
this.$nextTick(() => this.$refs.messageInput.focus());
},
emojiOnClick(emoji) {

View file

@ -9,7 +9,7 @@
</h2>
<div class="shortcut-key__wrap">
<p class="shortcut-key">
{{ $t('KEYBOARD_SHORTCUTS.KEYS.COMMAND_KEY') }}
{{ $t('KEYBOARD_SHORTCUTS.KEYS.WINDOWS_KEY_AND_COMMAND_KEY') }}
</p>
<p class="shortcut-key key">
{{ $t('KEYBOARD_SHORTCUTS.KEYS.FORWARD_SLASH_KEY') }}
@ -51,7 +51,7 @@
</span>
<div class="shortcut-key__wrap">
<span class="shortcut-key">
{{ $t('KEYBOARD_SHORTCUTS.KEYS.COMMAND_KEY') }}
{{ $t('KEYBOARD_SHORTCUTS.KEYS.WINDOWS_KEY_AND_COMMAND_KEY') }}
</span>
<span class="shortcut-key">
{{ $t('KEYBOARD_SHORTCUTS.KEYS.ALT_OR_OPTION_KEY') }}