tweak shortcuts

This commit is contained in:
Nitwel
2020-09-23 16:55:54 +02:00
parent 033b0caca5
commit ace6893741
4 changed files with 12 additions and 2 deletions

View File

@@ -35,6 +35,7 @@
:batch-active="batchActive"
:disabled="isDisabled"
:primary-key="primaryKey"
data-disable-mousetrap
@input="$emit('input', $event)"
/>

View File

@@ -37,6 +37,7 @@
<script lang="ts">
import { defineComponent, ref, computed, provide } from '@vue/composition-api';
import useShortcut from '@/composables/use-shortcut';
export default defineComponent({
model: {
@@ -72,6 +73,11 @@ export default defineComponent({
},
},
setup(props, { emit }) {
useShortcut('esc', () => {
console.log('A');
_active.value = false;
});
const sidebarActive = ref(false);
const localActive = ref(false);

View File

@@ -4,7 +4,7 @@ import Mousetrap from 'mousetrap';
const mousetrap = new Mousetrap();
mousetrap.stopCallback = function (e: Event, element: Element) {
// if the element has the class "mousetrap" then no need to stop
if (element.hasAttribute('data-disable-mousetrap')) {
if (element.hasAttribute('data-disable-mousetrap') || element.closest('*[data-disable-mousetrap]') !== null) {
return true;
}

View File

@@ -22,6 +22,7 @@ import { defineComponent, ref, PropType } from '@vue/composition-api';
import notify from '@/utils/notify';
import api from '@/api';
import i18n from '@/lang';
import useShortcut from '@/composables/use-shortcut';
export default defineComponent({
props: {
@@ -39,12 +40,14 @@ export default defineComponent({
},
},
setup(props) {
const newCommentContent = ref(null);
useShortcut('mod+enter', postComment);
const newCommentContent = ref<string | null>(null);
const saving = ref(false);
return { newCommentContent, postComment, saving };
async function postComment() {
if (newCommentContent.value === null || newCommentContent.value.length === 0) return;
saving.value = true;
try {