2020-01-30 04:37:25 +09:00
|
|
|
<template>
|
2020-10-17 20:12:00 +09:00
|
|
|
<MkContainer :show-header="props.showHeader">
|
2021-04-20 23:22:59 +09:00
|
|
|
<template #header><i class="fas fa-sticky-note"></i>{{ $ts._widgets.memo }}</template>
|
2020-01-30 04:37:25 +09:00
|
|
|
|
2020-07-11 10:13:11 +09:00
|
|
|
<div class="otgbylcu">
|
2020-12-26 10:47:36 +09:00
|
|
|
<textarea v-model="text" :placeholder="$ts.placeholder" @input="onChange"></textarea>
|
|
|
|
<button @click="saveMemo" :disabled="!changed" class="_buttonPrimary">{{ $ts.save }}</button>
|
2020-07-11 10:13:11 +09:00
|
|
|
</div>
|
2020-10-17 20:12:00 +09:00
|
|
|
</MkContainer>
|
2020-01-30 04:37:25 +09:00
|
|
|
</template>
|
|
|
|
|
|
|
|
<script lang="ts">
|
2020-10-17 20:12:00 +09:00
|
|
|
import { defineComponent } from 'vue';
|
2021-03-23 17:30:14 +09:00
|
|
|
import MkContainer from '@client/components/ui/container.vue';
|
2020-01-30 04:37:25 +09:00
|
|
|
import define from './define';
|
2021-03-23 17:30:14 +09:00
|
|
|
import * as os from '@client/os';
|
2020-01-30 04:37:25 +09:00
|
|
|
|
2020-10-17 20:12:00 +09:00
|
|
|
const widget = define({
|
2020-01-30 04:37:25 +09:00
|
|
|
name: 'memo',
|
|
|
|
props: () => ({
|
2020-07-11 10:13:11 +09:00
|
|
|
showHeader: {
|
|
|
|
type: 'boolean',
|
|
|
|
default: true,
|
|
|
|
},
|
2020-01-30 04:37:25 +09:00
|
|
|
})
|
2020-10-17 20:12:00 +09:00
|
|
|
});
|
|
|
|
|
|
|
|
export default defineComponent({
|
|
|
|
extends: widget,
|
2020-01-30 04:37:25 +09:00
|
|
|
components: {
|
|
|
|
MkContainer
|
|
|
|
},
|
|
|
|
|
|
|
|
data() {
|
|
|
|
return {
|
|
|
|
text: null,
|
|
|
|
changed: false,
|
|
|
|
timeoutId: null,
|
|
|
|
};
|
|
|
|
},
|
|
|
|
|
|
|
|
created() {
|
2020-12-19 10:55:52 +09:00
|
|
|
this.text = this.$store.state.memo;
|
2020-01-30 04:37:25 +09:00
|
|
|
|
2020-12-19 10:55:52 +09:00
|
|
|
this.$watch(() => this.$store.reactiveState.memo, text => {
|
2020-01-30 04:37:25 +09:00
|
|
|
this.text = text;
|
|
|
|
});
|
|
|
|
},
|
|
|
|
|
|
|
|
methods: {
|
|
|
|
onChange() {
|
|
|
|
this.changed = true;
|
|
|
|
clearTimeout(this.timeoutId);
|
|
|
|
this.timeoutId = setTimeout(this.saveMemo, 1000);
|
|
|
|
},
|
|
|
|
|
|
|
|
saveMemo() {
|
2020-12-19 10:55:52 +09:00
|
|
|
this.$store.set('memo', this.text);
|
2020-01-30 04:37:25 +09:00
|
|
|
this.changed = false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
});
|
|
|
|
</script>
|
|
|
|
|
|
|
|
<style lang="scss" scoped>
|
|
|
|
.otgbylcu {
|
|
|
|
padding-bottom: 28px + 16px;
|
|
|
|
|
|
|
|
> textarea {
|
|
|
|
display: block;
|
|
|
|
width: 100%;
|
|
|
|
max-width: 100%;
|
|
|
|
min-width: 100%;
|
|
|
|
padding: 16px;
|
2021-02-06 21:36:47 +09:00
|
|
|
color: var(--fg);
|
|
|
|
background: transparent;
|
2020-01-30 04:37:25 +09:00
|
|
|
border: none;
|
2021-04-10 12:40:50 +09:00
|
|
|
border-bottom: solid 0.5px var(--divider);
|
2020-01-30 04:37:25 +09:00
|
|
|
border-radius: 0;
|
2020-03-29 11:06:58 +09:00
|
|
|
box-sizing: border-box;
|
2021-02-06 21:36:47 +09:00
|
|
|
font: inherit;
|
|
|
|
font-size: 0.9em;
|
|
|
|
|
2021-10-03 02:46:58 +09:00
|
|
|
&:focus-visible {
|
2021-02-06 21:36:47 +09:00
|
|
|
outline: none;
|
|
|
|
}
|
2020-01-30 04:37:25 +09:00
|
|
|
}
|
|
|
|
|
|
|
|
> button {
|
|
|
|
display: block;
|
|
|
|
position: absolute;
|
|
|
|
bottom: 8px;
|
|
|
|
right: 8px;
|
|
|
|
margin: 0;
|
|
|
|
padding: 0 10px;
|
|
|
|
height: 28px;
|
|
|
|
outline: none;
|
|
|
|
border-radius: 4px;
|
|
|
|
|
|
|
|
&:disabled {
|
|
|
|
opacity: 0.7;
|
|
|
|
cursor: default;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
</style>
|