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