2020-10-17 20:12:00 +09:00
|
|
|
<template>
|
2023-01-06 13:40:17 +09:00
|
|
|
<div class="_gaps_m">
|
2023-01-05 21:04:56 +09:00
|
|
|
<FromSlot>
|
2022-07-20 22:24:26 +09:00
|
|
|
<template #label>{{ i18n.ts.reactionSettingDescription }}</template>
|
2021-11-28 20:07:37 +09:00
|
|
|
<div v-panel style="border-radius: 6px;">
|
2023-05-19 20:52:15 +09:00
|
|
|
<Sortable v-model="reactions" :class="$style.reactions" :itemKey="item => item" :animation="150" :delay="100" :delayOnTouchOnly="true">
|
2020-12-05 12:50:09 +09:00
|
|
|
<template #item="{element}">
|
2023-05-14 10:21:56 +09:00
|
|
|
<button class="_button" :class="$style.reactionsItem" @click="remove(element, $event)">
|
2023-01-26 15:48:12 +09:00
|
|
|
<MkCustomEmoji v-if="element[0] === ':'" :name="element" :normal="true"/>
|
|
|
|
<MkEmoji v-else :emoji="element" :normal="true"/>
|
2020-12-05 12:50:09 +09:00
|
|
|
</button>
|
|
|
|
</template>
|
2020-11-14 14:32:01 +09:00
|
|
|
<template #footer>
|
2023-05-14 10:21:56 +09:00
|
|
|
<button class="_button" :class="$style.reactionsAdd" @click="chooseEmoji"><i class="ti ti-plus"></i></button>
|
2020-11-14 14:32:01 +09:00
|
|
|
</template>
|
2022-12-21 11:04:49 +09:00
|
|
|
</Sortable>
|
2020-10-17 20:12:00 +09:00
|
|
|
</div>
|
2022-07-20 22:24:26 +09:00
|
|
|
<template #caption>{{ i18n.ts.reactionSettingDescription2 }} <button class="_textButton" @click="preview">{{ i18n.ts.preview }}</button></template>
|
2021-11-28 20:07:37 +09:00
|
|
|
</FromSlot>
|
2020-11-25 21:31:34 +09:00
|
|
|
|
2023-01-07 15:09:46 +09:00
|
|
|
<MkRadios v-model="reactionPickerSize">
|
2022-07-20 22:24:26 +09:00
|
|
|
<template #label>{{ i18n.ts.size }}</template>
|
|
|
|
<option :value="1">{{ i18n.ts.small }}</option>
|
|
|
|
<option :value="2">{{ i18n.ts.medium }}</option>
|
|
|
|
<option :value="3">{{ i18n.ts.large }}</option>
|
2023-01-07 15:09:46 +09:00
|
|
|
</MkRadios>
|
|
|
|
<MkRadios v-model="reactionPickerWidth">
|
2022-07-20 22:24:26 +09:00
|
|
|
<template #label>{{ i18n.ts.numberOfColumn }}</template>
|
2022-02-11 13:38:47 +09:00
|
|
|
<option :value="1">5</option>
|
|
|
|
<option :value="2">6</option>
|
|
|
|
<option :value="3">7</option>
|
2022-02-11 13:53:02 +09:00
|
|
|
<option :value="4">8</option>
|
|
|
|
<option :value="5">9</option>
|
2023-01-07 15:09:46 +09:00
|
|
|
</MkRadios>
|
|
|
|
<MkRadios v-model="reactionPickerHeight">
|
2022-07-20 22:24:26 +09:00
|
|
|
<template #label>{{ i18n.ts.height }}</template>
|
|
|
|
<option :value="1">{{ i18n.ts.small }}</option>
|
|
|
|
<option :value="2">{{ i18n.ts.medium }}</option>
|
|
|
|
<option :value="3">{{ i18n.ts.large }}</option>
|
|
|
|
<option :value="4">{{ i18n.ts.large }}+</option>
|
2023-01-07 15:09:46 +09:00
|
|
|
</MkRadios>
|
2021-12-17 16:14:31 +09:00
|
|
|
|
2023-01-07 14:59:54 +09:00
|
|
|
<MkSwitch v-model="reactionPickerUseDrawerForMobile">
|
2022-07-20 22:24:26 +09:00
|
|
|
{{ i18n.ts.useDrawerReactionPickerForMobile }}
|
|
|
|
<template #caption>{{ i18n.ts.needReloadToApply }}</template>
|
2023-01-07 14:59:54 +09:00
|
|
|
</MkSwitch>
|
2021-12-17 16:14:31 +09:00
|
|
|
|
2021-11-28 20:07:37 +09:00
|
|
|
<FormSection>
|
2023-01-06 09:41:14 +09:00
|
|
|
<div class="_buttons">
|
|
|
|
<MkButton inline @click="preview"><i class="ti ti-eye"></i> {{ i18n.ts.preview }}</MkButton>
|
|
|
|
<MkButton inline danger @click="setDefault"><i class="ti ti-reload"></i> {{ i18n.ts.default }}</MkButton>
|
2021-12-17 16:14:31 +09:00
|
|
|
</div>
|
2021-11-28 20:07:37 +09:00
|
|
|
</FormSection>
|
|
|
|
</div>
|
2020-10-17 20:12:00 +09:00
|
|
|
</template>
|
|
|
|
|
2022-01-28 12:30:59 +09:00
|
|
|
<script lang="ts" setup>
|
2022-05-01 22:51:07 +09:00
|
|
|
import { defineAsyncComponent, watch } from 'vue';
|
2022-12-21 15:10:21 +09:00
|
|
|
import Sortable from 'vuedraggable';
|
2023-01-07 15:09:46 +09:00
|
|
|
import MkRadios from '@/components/MkRadios.vue';
|
2021-11-28 20:07:37 +09:00
|
|
|
import FromSlot from '@/components/form/slot.vue';
|
2023-01-06 09:41:14 +09:00
|
|
|
import MkButton from '@/components/MkButton.vue';
|
2021-11-28 20:07:37 +09:00
|
|
|
import FormSection from '@/components/form/section.vue';
|
2023-01-07 14:59:54 +09:00
|
|
|
import MkSwitch from '@/components/MkSwitch.vue';
|
2021-11-12 02:02:25 +09:00
|
|
|
import * as os from '@/os';
|
|
|
|
import { defaultStore } from '@/store';
|
2022-01-28 12:30:59 +09:00
|
|
|
import { i18n } from '@/i18n';
|
2022-06-20 17:38:49 +09:00
|
|
|
import { definePageMetadata } from '@/scripts/page-metadata';
|
2022-11-17 09:31:07 +09:00
|
|
|
import { deepClone } from '@/scripts/clone';
|
2020-10-17 20:12:00 +09:00
|
|
|
|
2022-11-17 09:31:07 +09:00
|
|
|
let reactions = $ref(deepClone(defaultStore.state.reactions));
|
2020-10-17 20:12:00 +09:00
|
|
|
|
2022-02-11 13:38:47 +09:00
|
|
|
const reactionPickerSize = $computed(defaultStore.makeGetterSetter('reactionPickerSize'));
|
2022-01-28 12:30:59 +09:00
|
|
|
const reactionPickerWidth = $computed(defaultStore.makeGetterSetter('reactionPickerWidth'));
|
|
|
|
const reactionPickerHeight = $computed(defaultStore.makeGetterSetter('reactionPickerHeight'));
|
|
|
|
const reactionPickerUseDrawerForMobile = $computed(defaultStore.makeGetterSetter('reactionPickerUseDrawerForMobile'));
|
2020-10-17 20:12:00 +09:00
|
|
|
|
2022-01-28 12:30:59 +09:00
|
|
|
function save() {
|
|
|
|
defaultStore.set('reactions', reactions);
|
|
|
|
}
|
2020-10-17 20:12:00 +09:00
|
|
|
|
2022-01-28 12:30:59 +09:00
|
|
|
function remove(reaction, ev: MouseEvent) {
|
|
|
|
os.popupMenu([{
|
|
|
|
text: i18n.ts.remove,
|
|
|
|
action: () => {
|
|
|
|
reactions = reactions.filter(x => x !== reaction);
|
2022-06-20 17:38:49 +09:00
|
|
|
},
|
2022-01-28 12:30:59 +09:00
|
|
|
}], ev.currentTarget ?? ev.target);
|
|
|
|
}
|
2020-10-17 20:12:00 +09:00
|
|
|
|
2022-01-28 12:30:59 +09:00
|
|
|
function preview(ev: MouseEvent) {
|
2022-08-31 00:24:33 +09:00
|
|
|
os.popup(defineAsyncComponent(() => import('@/components/MkEmojiPickerDialog.vue')), {
|
2022-01-28 12:30:59 +09:00
|
|
|
asReactionPicker: true,
|
|
|
|
src: ev.currentTarget ?? ev.target,
|
|
|
|
}, {}, 'closed');
|
|
|
|
}
|
2020-11-14 14:32:01 +09:00
|
|
|
|
2022-01-28 12:30:59 +09:00
|
|
|
async function setDefault() {
|
|
|
|
const { canceled } = await os.confirm({
|
|
|
|
type: 'warning',
|
|
|
|
text: i18n.ts.resetAreYouSure,
|
|
|
|
});
|
|
|
|
if (canceled) return;
|
2020-10-17 20:12:00 +09:00
|
|
|
|
2022-11-17 09:31:07 +09:00
|
|
|
reactions = deepClone(defaultStore.def.reactions.default);
|
2022-01-28 12:30:59 +09:00
|
|
|
}
|
2020-10-17 20:12:00 +09:00
|
|
|
|
2022-01-28 12:30:59 +09:00
|
|
|
function chooseEmoji(ev: MouseEvent) {
|
|
|
|
os.pickEmoji(ev.currentTarget ?? ev.target, {
|
2022-06-20 17:38:49 +09:00
|
|
|
showPinned: false,
|
2022-01-28 12:30:59 +09:00
|
|
|
}).then(emoji => {
|
|
|
|
if (!reactions.includes(emoji)) {
|
|
|
|
reactions.push(emoji);
|
|
|
|
}
|
|
|
|
});
|
|
|
|
}
|
2020-11-14 14:32:01 +09:00
|
|
|
|
2022-01-28 12:30:59 +09:00
|
|
|
watch($$(reactions), () => {
|
|
|
|
save();
|
|
|
|
}, {
|
|
|
|
deep: true,
|
|
|
|
});
|
2020-10-17 20:12:00 +09:00
|
|
|
|
2022-06-20 17:38:49 +09:00
|
|
|
const headerActions = $computed(() => []);
|
|
|
|
|
|
|
|
const headerTabs = $computed(() => []);
|
|
|
|
|
|
|
|
definePageMetadata({
|
|
|
|
title: i18n.ts.reaction,
|
2022-12-19 19:01:30 +09:00
|
|
|
icon: 'ti ti-mood-happy',
|
2022-06-20 17:38:49 +09:00
|
|
|
action: {
|
2022-12-19 19:01:30 +09:00
|
|
|
icon: 'ti ti-eye',
|
2022-06-20 17:38:49 +09:00
|
|
|
handler: preview,
|
2022-01-28 12:30:59 +09:00
|
|
|
},
|
2020-10-17 20:12:00 +09:00
|
|
|
});
|
|
|
|
</script>
|
2020-11-14 14:32:01 +09:00
|
|
|
|
2023-05-14 10:21:56 +09:00
|
|
|
<style lang="scss" module>
|
|
|
|
.reactions {
|
2021-11-28 20:07:37 +09:00
|
|
|
padding: 12px;
|
|
|
|
font-size: 1.1em;
|
2023-05-14 10:21:56 +09:00
|
|
|
}
|
2020-11-14 14:32:01 +09:00
|
|
|
|
2023-05-14 10:21:56 +09:00
|
|
|
.reactionsItem {
|
|
|
|
display: inline-block;
|
|
|
|
padding: 8px;
|
|
|
|
cursor: move;
|
|
|
|
}
|
2020-12-05 12:50:09 +09:00
|
|
|
|
2023-05-14 10:21:56 +09:00
|
|
|
.reactionsAdd {
|
|
|
|
display: inline-block;
|
|
|
|
padding: 8px;
|
2020-11-14 14:32:01 +09:00
|
|
|
}
|
|
|
|
</style>
|