2021-04-03 12:17:40 +02:00
|
|
|
<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>
|
2021-04-03 12:17:40 +02:00
|
|
|
<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>
|
2021-04-03 12:17:40 +02:00
|
|
|
<div>
|
|
|
|
<div>
|
|
|
|
<TextEditor
|
2022-04-21 14:39:24 +02:00
|
|
|
v-model="localNotes"
|
2021-04-03 12:17:40 +02:00
|
|
|
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>
|
2021-04-03 12:17:40 +02:00
|
|
|
</ConfirmModal>
|
|
|
|
</template>
|
|
|
|
|
2022-05-14 11:15:42 +02:00
|
|
|
<script setup lang="ts">
|
|
|
|
import { ref, Ref, watch } from 'vue';
|
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';
|
2022-04-30 00:47:37 +02:00
|
|
|
import { useScratchpadStore } from '@/stores/scratchpad';
|
2022-05-14 11:15:42 +02:00
|
|
|
import ConfirmModal from '@/components/BaseConfirmModal.vue';
|
|
|
|
import TextEditor from '@/components/BaseTextEditor.vue';
|
2021-04-03 12:17:40 +02:00
|
|
|
|
2022-05-14 11:15:42 +02:00
|
|
|
const applicationStore = useApplicationStore();
|
|
|
|
const scratchpadStore = useScratchpadStore();
|
2022-04-27 18:23:48 +02:00
|
|
|
|
2022-05-14 11:15:42 +02:00
|
|
|
const { notes } = storeToRefs(scratchpadStore);
|
|
|
|
const { changeNotes } = scratchpadStore;
|
|
|
|
const { hideScratchpad } = applicationStore;
|
2022-04-30 00:47:37 +02:00
|
|
|
|
2022-06-04 18:37:16 +02:00
|
|
|
const localNotes = ref(notes.value);
|
2022-05-14 11:15:42 +02:00
|
|
|
const debounceTimeout: Ref<NodeJS.Timeout> = ref(null);
|
|
|
|
|
|
|
|
watch(localNotes, () => {
|
|
|
|
clearTimeout(debounceTimeout.value);
|
|
|
|
|
|
|
|
debounceTimeout.value = setTimeout(() => {
|
|
|
|
changeNotes(localNotes.value);
|
|
|
|
}, 200);
|
|
|
|
});
|
2021-04-03 12:17:40 +02:00
|
|
|
|
|
|
|
</script>
|