antares/src/renderer/components/TheScratchpad.vue

82 lines
1.9 KiB
Vue
Raw Normal View History

<template>
<ConfirmModal
:confirm-text="$t('word.update')"
:cancel-text="$t('word.close')"
size="large"
:hide-footer="true"
@hide="hideScratchpad"
>
2021-12-10 17:34:44 +01:00
<template #header>
<div class="d-flex">
<i class="mdi mdi-24px mdi-notebook-edit-outline mr-1" /> {{ $t('word.scratchpad') }}
</div>
</template>
2021-12-10 17:34:44 +01:00
<template #body>
<div>
<div>
<TextEditor
2022-04-21 14:39:24 +02:00
v-model="localNotes"
editor-class="textarea-editor"
mode="markdown"
:auto-focus="true"
:show-line-numbers="false"
/>
</div>
<small class="text-gray">{{ $t('message.markdownSupported') }}</small>
</div>
2021-12-10 17:34:44 +01:00
</template>
</ConfirmModal>
</template>
<script>
import { mapActions, mapGetters } from 'vuex';
2022-04-27 18:23:48 +02:00
import { useApplicationStore } from '@/stores/application';
import ConfirmModal from '@/components/BaseConfirmModal';
import TextEditor from '@/components/BaseTextEditor';
export default {
name: 'TheScratchpad',
components: {
ConfirmModal,
TextEditor
},
2022-04-22 12:16:02 +02:00
emits: ['hide'],
2022-04-27 18:23:48 +02:00
setup () {
const applicationStore = useApplicationStore();
return { hideScratchpad: applicationStore.hideScratchpad };
},
data () {
return {
localNotes: '',
debounceTimeout: null
};
},
computed: {
...mapGetters({
notes: 'scratchpad/getNotes'
})
},
watch: {
localNotes () {
clearTimeout(this.debounceTimeout);
this.debounceTimeout = setTimeout(() => {
this.changeNotes(this.localNotes);
}, 200);
}
},
created () {
this.localNotes = this.notes;
},
methods: {
...mapActions({
changeNotes: 'scratchpad/changeNotes'
}),
hideModal () {
this.$emit('hide');
}
}
};
</script>