2021-05-01 13:56:17 +00:00
|
|
|
<template>
|
2021-05-20 17:38:05 +00:00
|
|
|
<div class="card">
|
2021-10-25 13:05:58 +00:00
|
|
|
<woot-message-editor
|
|
|
|
v-model="noteContent"
|
2021-05-20 17:38:05 +00:00
|
|
|
class="input--note"
|
2021-10-25 13:05:58 +00:00
|
|
|
:placeholder="$t('NOTES.ADD.PLACEHOLDER')"
|
|
|
|
:enable-suggestions="false"
|
2021-05-20 17:38:05 +00:00
|
|
|
/>
|
2021-05-01 13:56:17 +00:00
|
|
|
<div class="footer">
|
|
|
|
<woot-button
|
|
|
|
color-scheme="warning"
|
|
|
|
:title="$t('NOTES.ADD.TITLE')"
|
|
|
|
:is-disabled="buttonDisabled"
|
|
|
|
@click="onAdd"
|
|
|
|
>
|
2021-10-25 13:05:58 +00:00
|
|
|
{{ $t('NOTES.ADD.BUTTON') }} (⌘⏎)
|
2021-05-01 13:56:17 +00:00
|
|
|
</woot-button>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</template>
|
|
|
|
|
|
|
|
<script>
|
2021-10-25 13:05:58 +00:00
|
|
|
import WootMessageEditor from 'dashboard/components/widgets/WootWriter/Editor';
|
|
|
|
import { hasPressedCommandAndEnter } from 'shared/helpers/KeyboardHelpers';
|
2021-05-01 13:56:17 +00:00
|
|
|
export default {
|
2021-10-25 13:05:58 +00:00
|
|
|
components: {
|
|
|
|
WootMessageEditor,
|
|
|
|
},
|
|
|
|
|
2021-05-01 13:56:17 +00:00
|
|
|
data() {
|
|
|
|
return {
|
2021-10-25 13:05:58 +00:00
|
|
|
noteContent: '',
|
2021-05-01 13:56:17 +00:00
|
|
|
};
|
|
|
|
},
|
|
|
|
|
|
|
|
computed: {
|
|
|
|
buttonDisabled() {
|
2021-10-25 13:05:58 +00:00
|
|
|
return this.noteContent === '';
|
2021-05-01 13:56:17 +00:00
|
|
|
},
|
|
|
|
},
|
|
|
|
|
2021-10-25 13:05:58 +00:00
|
|
|
mounted() {
|
|
|
|
document.addEventListener('keydown', this.onMetaEnter);
|
|
|
|
},
|
|
|
|
|
|
|
|
beforeDestroy() {
|
|
|
|
document.removeEventListener('keydown', this.onMetaEnter);
|
|
|
|
},
|
|
|
|
|
2021-05-01 13:56:17 +00:00
|
|
|
methods: {
|
2021-10-25 13:05:58 +00:00
|
|
|
onMetaEnter(e) {
|
|
|
|
if (hasPressedCommandAndEnter(e)) {
|
|
|
|
e.preventDefault();
|
|
|
|
this.onAdd();
|
|
|
|
}
|
|
|
|
},
|
2021-05-01 13:56:17 +00:00
|
|
|
onAdd() {
|
2021-10-25 13:05:58 +00:00
|
|
|
if (this.noteContent !== '') {
|
|
|
|
this.$emit('add', this.noteContent);
|
2021-05-01 13:56:17 +00:00
|
|
|
}
|
2021-10-25 13:05:58 +00:00
|
|
|
this.noteContent = '';
|
2021-05-01 13:56:17 +00:00
|
|
|
},
|
|
|
|
},
|
|
|
|
};
|
|
|
|
</script>
|
|
|
|
|
|
|
|
<style lang="scss" scoped>
|
2021-05-20 18:11:15 +00:00
|
|
|
.input--note {
|
2021-10-25 13:05:58 +00:00
|
|
|
&::v-deep .ProseMirror-menubar {
|
|
|
|
padding: 0;
|
|
|
|
margin-top: var(--space-minus-small);
|
|
|
|
}
|
|
|
|
|
|
|
|
&::v-deep .ProseMirror-woot-style {
|
|
|
|
max-height: 36rem;
|
|
|
|
}
|
2021-05-20 18:11:15 +00:00
|
|
|
}
|
2021-05-01 13:56:17 +00:00
|
|
|
|
2021-05-20 18:11:15 +00:00
|
|
|
.footer {
|
|
|
|
display: flex;
|
|
|
|
justify-content: flex-end;
|
|
|
|
width: 100%;
|
2021-05-01 13:56:17 +00:00
|
|
|
}
|
|
|
|
</style>
|