-
-
Notifications
You must be signed in to change notification settings - Fork 131
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: scratchpad to save persistent notes
- Loading branch information
Showing
9 changed files
with
130 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,75 @@ | ||
<template> | ||
<ConfirmModal | ||
:confirm-text="$t('word.update')" | ||
:cancel-text="$t('word.close')" | ||
size="large" | ||
:hide-footer="true" | ||
@hide="hideScratchpad" | ||
> | ||
<template :slot="'header'"> | ||
<div class="d-flex"> | ||
<i class="mdi mdi-24px mdi-notebook-edit-outline mr-1" /> {{ $t('word.scratchpad') }} | ||
</div> | ||
</template> | ||
<div :slot="'body'"> | ||
<div> | ||
<div> | ||
<TextEditor | ||
:value.sync="localNotes" | ||
editor-class="textarea-editor" | ||
mode="markdown" | ||
:auto-focus="true" | ||
:show-line-numbers="false" | ||
/> | ||
</div> | ||
<small class="text-gray">{{ $t('message.markdownSupported') }}</small> | ||
</div> | ||
</div> | ||
</ConfirmModal> | ||
</template> | ||
|
||
<script> | ||
import { mapActions, mapGetters } from 'vuex'; | ||
import ConfirmModal from '@/components/BaseConfirmModal'; | ||
import TextEditor from '@/components/BaseTextEditor'; | ||
export default { | ||
name: 'TheScratchpad', | ||
components: { | ||
ConfirmModal, | ||
TextEditor | ||
}, | ||
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({ | ||
hideScratchpad: 'application/hideScratchpad', | ||
changeNotes: 'scratchpad/changeNotes' | ||
}), | ||
hideModal () { | ||
this.$emit('hide'); | ||
} | ||
} | ||
}; | ||
</script> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
'use strict'; | ||
import Store from 'electron-store'; | ||
const persistentStore = new Store({ name: 'notes' }); | ||
|
||
export default { | ||
namespaced: true, | ||
strict: true, | ||
state: { | ||
notes: persistentStore.get('notes', '# HOW TO SUPPORT ANTARES\n\n- [ ] Leave a star to Antares [GitHub repo](https://github.com/Fabio286/antares)\n- [ ] Send feedbacks and advices\n- [ ] Report for bugs\n- [ ] If you enjoy, share Antares with friends\n\n# ABOUT SCRATCHPAD\n\nThis is a scratchpad where you can save your **personal notes**. It supports `markdown` format, but you are free to use plain text.\nThis content is just a placeholder, feel free to clear it to make space for your notes.\n') | ||
}, | ||
getters: { | ||
getNotes: state => state.notes | ||
}, | ||
mutations: { | ||
SET_NOTES (state, notes) { | ||
state.notes = notes; | ||
persistentStore.set('notes', state.notes); | ||
} | ||
}, | ||
actions: { | ||
changeNotes ({ commit }, notes) { | ||
commit('SET_NOTES', notes); | ||
} | ||
} | ||
}; |