antares/src/renderer/components/TheScratchpad.vue

83 lines
2.0 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>
2022-04-30 00:47:37 +02:00
import { storeToRefs } from 'pinia';
2022-04-27 18:23:48 +02:00
import { useApplicationStore } from '@/stores/application';
import ConfirmModal from '@/components/BaseConfirmModal';
import TextEditor from '@/components/BaseTextEditor';
2022-04-30 00:47:37 +02:00
import { useScratchpadStore } from '@/stores/scratchpad';
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();
2022-04-30 00:47:37 +02:00
const scratchpadStore = useScratchpadStore();
2022-04-27 18:23:48 +02:00
2022-04-30 00:47:37 +02:00
const { notes } = storeToRefs(scratchpadStore);
const { changeNotes } = scratchpadStore;
return {
notes,
hideScratchpad: applicationStore.hideScratchpad,
changeNotes
};
2022-04-27 18:23:48 +02:00
},
data () {
return {
localNotes: '',
debounceTimeout: null
};
},
watch: {
localNotes () {
clearTimeout(this.debounceTimeout);
this.debounceTimeout = setTimeout(() => {
this.changeNotes(this.localNotes);
}, 200);
}
},
created () {
this.localNotes = this.notes;
},
methods: {
hideModal () {
this.$emit('hide');
}
}
};
</script>