絵文字デッキの作成
This commit is contained in:
parent
b72f9186b5
commit
90c735f234
|
@ -124,7 +124,14 @@ export interface Locale {
|
||||||
"add": string;
|
"add": string;
|
||||||
"reaction": string;
|
"reaction": string;
|
||||||
"reactions": string;
|
"reactions": string;
|
||||||
"reactionSetting": string;
|
"reactionDeckSettingTitle": string;
|
||||||
|
"reactionDeckSettingDescription": string;
|
||||||
|
"emojiDeckSettingTitle": string;
|
||||||
|
"emojiDeckSettingDescription": string;
|
||||||
|
"diversionReactionDeckEmojisTitle": string;
|
||||||
|
"diversionReactionDeckEmojisDescription": string;
|
||||||
|
"diversionReactionDeckSettingCaption": string;
|
||||||
|
"diversionReactionDeckSettingDescription": string;
|
||||||
"reactionSettingDescription2": string;
|
"reactionSettingDescription2": string;
|
||||||
"rememberNoteVisibility": string;
|
"rememberNoteVisibility": string;
|
||||||
"attachCancel": string;
|
"attachCancel": string;
|
||||||
|
|
|
@ -121,7 +121,14 @@ sensitive: "センシティブ"
|
||||||
add: "追加"
|
add: "追加"
|
||||||
reaction: "リアクション"
|
reaction: "リアクション"
|
||||||
reactions: "リアクション"
|
reactions: "リアクション"
|
||||||
reactionSetting: "ピッカーに表示するリアクション"
|
reactionDeckSettingTitle: "リアクションデッキ"
|
||||||
|
reactionDeckSettingDescription: "ノートの+ボタンから使用するリアクションデッキの設定です。"
|
||||||
|
emojiDeckSettingTitle: "絵文字デッキ"
|
||||||
|
emojiDeckSettingDescription: "投稿時に使用する絵文字デッキの設定です。"
|
||||||
|
diversionReactionDeckEmojisTitle: "ピッカーの表示設定"
|
||||||
|
diversionReactionDeckEmojisDescription: "ピッカーの表示についての設定を行います。この設定はリアクションピッカーと絵文字ピッカーで共通です。"
|
||||||
|
diversionReactionDeckSettingCaption: "リアクションデッキと同じ設定を使う"
|
||||||
|
diversionReactionDeckSettingDescription: "絵文字デッキの設定をリアクションデッキと同じにします。絵文字デッキの設定内容そのものは消えません。"
|
||||||
reactionSettingDescription2: "ドラッグして並び替え、クリックして削除、+を押して追加します。"
|
reactionSettingDescription2: "ドラッグして並び替え、クリックして削除、+を押して追加します。"
|
||||||
rememberNoteVisibility: "公開範囲を記憶する"
|
rememberNoteVisibility: "公開範囲を記憶する"
|
||||||
attachCancel: "添付取り消し"
|
attachCancel: "添付取り消し"
|
||||||
|
|
|
@ -77,8 +77,8 @@ SPDX-License-Identifier: AGPL-3.0-only
|
||||||
:key="`custom:${child.value}`"
|
:key="`custom:${child.value}`"
|
||||||
:initialShown="false"
|
:initialShown="false"
|
||||||
:emojis="computed(() => customEmojis.filter(e => child.value === '' ? (e.category === 'null' || !e.category) : e.category === child.value).filter(filterAvailable).map(e => `:${e.name}:`))"
|
:emojis="computed(() => customEmojis.filter(e => child.value === '' ? (e.category === 'null' || !e.category) : e.category === child.value).filter(filterAvailable).map(e => `:${e.name}:`))"
|
||||||
:hasChildSection="child.children.length !== 0"
|
:hasChildSection="child.children.length !== 0"
|
||||||
:customEmojiTree="child.children"
|
:customEmojiTree="child.children"
|
||||||
@chosen="chosen"
|
@chosen="chosen"
|
||||||
>
|
>
|
||||||
{{ child.value || i18n.ts.other }}
|
{{ child.value || i18n.ts.other }}
|
||||||
|
@ -103,12 +103,12 @@ import { ref, shallowRef, computed, watch, onMounted } from 'vue';
|
||||||
import * as Misskey from 'misskey-js';
|
import * as Misskey from 'misskey-js';
|
||||||
import XSection from '@/components/MkEmojiPicker.section.vue';
|
import XSection from '@/components/MkEmojiPicker.section.vue';
|
||||||
import {
|
import {
|
||||||
emojilist,
|
emojilist,
|
||||||
emojiCharByCategory,
|
emojiCharByCategory,
|
||||||
UnicodeEmojiDef,
|
UnicodeEmojiDef,
|
||||||
unicodeEmojiCategories as categories,
|
unicodeEmojiCategories as categories,
|
||||||
getEmojiName,
|
getEmojiName,
|
||||||
CustomEmojiFolderTree
|
CustomEmojiFolderTree,
|
||||||
} from '@/scripts/emojilist.js';
|
} from '@/scripts/emojilist.js';
|
||||||
import MkRippleEffect from '@/components/MkRippleEffect.vue';
|
import MkRippleEffect from '@/components/MkRippleEffect.vue';
|
||||||
import * as os from '@/os.js';
|
import * as os from '@/os.js';
|
||||||
|
@ -121,6 +121,7 @@ import { $i } from '@/account.js';
|
||||||
|
|
||||||
const props = withDefaults(defineProps<{
|
const props = withDefaults(defineProps<{
|
||||||
showPinned?: boolean;
|
showPinned?: boolean;
|
||||||
|
pinnedEmojis?: string[];
|
||||||
asReactionPicker?: boolean;
|
asReactionPicker?: boolean;
|
||||||
maxHeight?: number;
|
maxHeight?: number;
|
||||||
asDrawer?: boolean;
|
asDrawer?: boolean;
|
||||||
|
@ -137,15 +138,13 @@ const searchEl = shallowRef<HTMLInputElement>();
|
||||||
const emojisEl = shallowRef<HTMLDivElement>();
|
const emojisEl = shallowRef<HTMLDivElement>();
|
||||||
|
|
||||||
const {
|
const {
|
||||||
reactions: pinnedReactions,
|
|
||||||
reactionPickerSize,
|
reactionPickerSize,
|
||||||
reactionPickerWidth,
|
reactionPickerWidth,
|
||||||
reactionPickerHeight,
|
reactionPickerHeight,
|
||||||
disableShowingAnimatedImages,
|
|
||||||
recentlyUsedEmojis,
|
recentlyUsedEmojis,
|
||||||
} = defaultStore.reactiveState;
|
} = defaultStore.reactiveState;
|
||||||
|
|
||||||
const pinned = computed(() => props.asReactionPicker ? pinnedReactions.value : []); // TODO: 非リアクションの絵文字ピッカー用のpinned絵文字を設定可能にする?
|
const pinned = computed(() => props.pinnedEmojis);
|
||||||
const size = computed(() => props.asReactionPicker ? reactionPickerSize.value : 1);
|
const size = computed(() => props.asReactionPicker ? reactionPickerSize.value : 1);
|
||||||
const width = computed(() => props.asReactionPicker ? reactionPickerWidth.value : 3);
|
const width = computed(() => props.asReactionPicker ? reactionPickerWidth.value : 3);
|
||||||
const height = computed(() => props.asReactionPicker ? reactionPickerHeight.value : 2);
|
const height = computed(() => props.asReactionPicker ? reactionPickerHeight.value : 2);
|
||||||
|
@ -154,7 +153,7 @@ const searchResultCustom = ref<Misskey.entities.EmojiSimple[]>([]);
|
||||||
const searchResultUnicode = ref<UnicodeEmojiDef[]>([]);
|
const searchResultUnicode = ref<UnicodeEmojiDef[]>([]);
|
||||||
const tab = ref<'index' | 'custom' | 'unicode' | 'tags'>('index');
|
const tab = ref<'index' | 'custom' | 'unicode' | 'tags'>('index');
|
||||||
|
|
||||||
const customEmojiFolderRoot: CustomEmojiFolderTree = { value: "", category: "", children: [] };
|
const customEmojiFolderRoot: CustomEmojiFolderTree = { value: '', category: '', children: [] };
|
||||||
|
|
||||||
function parseAndMergeCategories(input: string, root: CustomEmojiFolderTree): CustomEmojiFolderTree {
|
function parseAndMergeCategories(input: string, root: CustomEmojiFolderTree): CustomEmojiFolderTree {
|
||||||
const parts = input.split('/').map(p => p.trim());
|
const parts = input.split('/').map(p => p.trim());
|
||||||
|
@ -176,9 +175,9 @@ function parseAndMergeCategories(input: string, root: CustomEmojiFolderTree): Cu
|
||||||
}
|
}
|
||||||
|
|
||||||
customEmojiCategories.value.forEach(ec => {
|
customEmojiCategories.value.forEach(ec => {
|
||||||
if (ec !== null) {
|
if (ec !== null) {
|
||||||
parseAndMergeCategories(ec, customEmojiFolderRoot);
|
parseAndMergeCategories(ec, customEmojiFolderRoot);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
parseAndMergeCategories('', customEmojiFolderRoot);
|
parseAndMergeCategories('', customEmojiFolderRoot);
|
||||||
|
|
|
@ -22,6 +22,7 @@ SPDX-License-Identifier: AGPL-3.0-only
|
||||||
class="_popup _shadow"
|
class="_popup _shadow"
|
||||||
:class="{ [$style.drawer]: type === 'drawer' }"
|
:class="{ [$style.drawer]: type === 'drawer' }"
|
||||||
:showPinned="showPinned"
|
:showPinned="showPinned"
|
||||||
|
:pinnedEmojis="pinnedEmojis"
|
||||||
:asReactionPicker="asReactionPicker"
|
:asReactionPicker="asReactionPicker"
|
||||||
:asDrawer="type === 'drawer'"
|
:asDrawer="type === 'drawer'"
|
||||||
:max-height="maxHeight"
|
:max-height="maxHeight"
|
||||||
|
@ -40,11 +41,13 @@ const props = withDefaults(defineProps<{
|
||||||
manualShowing?: boolean | null;
|
manualShowing?: boolean | null;
|
||||||
src?: HTMLElement;
|
src?: HTMLElement;
|
||||||
showPinned?: boolean;
|
showPinned?: boolean;
|
||||||
|
pinnedEmojis?: string[],
|
||||||
asReactionPicker?: boolean;
|
asReactionPicker?: boolean;
|
||||||
choseAndClose?: boolean;
|
choseAndClose?: boolean;
|
||||||
}>(), {
|
}>(), {
|
||||||
manualShowing: null,
|
manualShowing: null,
|
||||||
showPinned: true,
|
showPinned: true,
|
||||||
|
pinnedEmojis: undefined,
|
||||||
asReactionPicker: false,
|
asReactionPicker: false,
|
||||||
choseAndClose: true,
|
choseAndClose: true,
|
||||||
});
|
});
|
||||||
|
|
|
@ -6,6 +6,7 @@ SPDX-License-Identifier: AGPL-3.0-only
|
||||||
<template>
|
<template>
|
||||||
<div :class="[$style.root, { [$style.rootFirst]: first }]">
|
<div :class="[$style.root, { [$style.rootFirst]: first }]">
|
||||||
<div :class="[$style.label, { [$style.labelFirst]: first }]"><slot name="label"></slot></div>
|
<div :class="[$style.label, { [$style.labelFirst]: first }]"><slot name="label"></slot></div>
|
||||||
|
<div :class="[$style.description]"><slot name="description"></slot></div>
|
||||||
<div :class="$style.main">
|
<div :class="$style.main">
|
||||||
<slot></slot>
|
<slot></slot>
|
||||||
</div>
|
</div>
|
||||||
|
@ -31,7 +32,7 @@ defineProps<{
|
||||||
.label {
|
.label {
|
||||||
font-weight: bold;
|
font-weight: bold;
|
||||||
padding: 1.5em 0 0 0;
|
padding: 1.5em 0 0 0;
|
||||||
margin: 0 0 16px 0;
|
margin: 0 0 8px 0;
|
||||||
|
|
||||||
&:empty {
|
&:empty {
|
||||||
display: none;
|
display: none;
|
||||||
|
@ -45,4 +46,10 @@ defineProps<{
|
||||||
.main {
|
.main {
|
||||||
margin: 1.5em 0 0 0;
|
margin: 1.5em 0 0 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.description {
|
||||||
|
font-size: 0.85em;
|
||||||
|
color: var(--fgTransparentWeak);
|
||||||
|
margin: 0 0 8px 0;
|
||||||
|
}
|
||||||
</style>
|
</style>
|
||||||
|
|
|
@ -95,6 +95,7 @@ const defaultStoreSaveKeys: (keyof typeof defaultStore['state'])[] = [
|
||||||
'numberOfPageCache',
|
'numberOfPageCache',
|
||||||
'showNoteActionsOnlyHover',
|
'showNoteActionsOnlyHover',
|
||||||
'showClipButtonInNoteFooter',
|
'showClipButtonInNoteFooter',
|
||||||
|
'useReactionDeckItems',
|
||||||
'reactionsDisplaySize',
|
'reactionsDisplaySize',
|
||||||
'forceShowAds',
|
'forceShowAds',
|
||||||
'aiChanMode',
|
'aiChanMode',
|
||||||
|
|
|
@ -5,65 +5,129 @@ SPDX-License-Identifier: AGPL-3.0-only
|
||||||
|
|
||||||
<template>
|
<template>
|
||||||
<div class="_gaps_m">
|
<div class="_gaps_m">
|
||||||
<FromSlot>
|
<FormSection first="true">
|
||||||
<template #label>{{ i18n.ts.reactionSettingDescription }}</template>
|
<template #label>{{ i18n.ts.reactionDeckSettingTitle }}</template>
|
||||||
<div v-panel style="border-radius: 6px;">
|
<template #description>{{ i18n.ts.reactionDeckSettingDescription }}</template>
|
||||||
<Sortable v-model="reactions" :class="$style.reactions" :itemKey="item => item" :animation="150" :delay="100" :delayOnTouchOnly="true">
|
|
||||||
<template #item="{element}">
|
<div class="_gaps_m">
|
||||||
<button class="_button" :class="$style.reactionsItem" @click="remove(element, $event)">
|
<div>
|
||||||
<MkCustomEmoji v-if="element[0] === ':'" :name="element" :normal="true"/>
|
<div v-panel style="border-radius: 6px;">
|
||||||
<MkEmoji v-else :emoji="element" :normal="true"/>
|
<Sortable
|
||||||
</button>
|
v-model="reactionDeckItems"
|
||||||
</template>
|
:class="$style.reactions"
|
||||||
<template #footer>
|
:itemKey="item => item"
|
||||||
<button class="_button" :class="$style.reactionsAdd" @click="chooseEmoji"><i class="ti ti-plus"></i></button>
|
:animation="150"
|
||||||
</template>
|
:delay="100"
|
||||||
</Sortable>
|
:delayOnTouchOnly="true"
|
||||||
|
>
|
||||||
|
<template #item="{element}">
|
||||||
|
<button class="_button" :class="$style.reactionsItem" @click="removeReaction(element, $event)">
|
||||||
|
<MkCustomEmoji v-if="element[0] === ':'" :name="element" :normal="true"/>
|
||||||
|
<MkEmoji v-else :emoji="element" :normal="true"/>
|
||||||
|
</button>
|
||||||
|
</template>
|
||||||
|
<template #footer>
|
||||||
|
<button class="_button" :class="$style.reactionsAdd" @click="chooseReaction">
|
||||||
|
<i class="ti ti-plus"></i>
|
||||||
|
</button>
|
||||||
|
</template>
|
||||||
|
</Sortable>
|
||||||
|
</div>
|
||||||
|
<span class="description">{{ i18n.ts.reactionSettingDescription2 }}</span>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="_buttons">
|
||||||
|
<MkButton inline @click="previewReaction"><i class="ti ti-eye"></i> {{ i18n.ts.preview }}</MkButton>
|
||||||
|
<MkButton inline danger @click="setDefaultReaction"><i class="ti ti-reload"></i> {{ i18n.ts.default }}</MkButton>
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<template #caption>{{ i18n.ts.reactionSettingDescription2 }} <button class="_textButton" @click="preview">{{ i18n.ts.preview }}</button></template>
|
</FormSection>
|
||||||
</FromSlot>
|
|
||||||
|
|
||||||
<MkRadios v-model="reactionPickerSize">
|
|
||||||
<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>
|
|
||||||
</MkRadios>
|
|
||||||
<MkRadios v-model="reactionPickerWidth">
|
|
||||||
<template #label>{{ i18n.ts.numberOfColumn }}</template>
|
|
||||||
<option :value="1">5</option>
|
|
||||||
<option :value="2">6</option>
|
|
||||||
<option :value="3">7</option>
|
|
||||||
<option :value="4">8</option>
|
|
||||||
<option :value="5">9</option>
|
|
||||||
</MkRadios>
|
|
||||||
<MkRadios v-model="reactionPickerHeight">
|
|
||||||
<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>
|
|
||||||
</MkRadios>
|
|
||||||
|
|
||||||
<MkSwitch v-model="reactionPickerUseDrawerForMobile">
|
|
||||||
{{ i18n.ts.useDrawerReactionPickerForMobile }}
|
|
||||||
<template #caption>{{ i18n.ts.needReloadToApply }}</template>
|
|
||||||
</MkSwitch>
|
|
||||||
|
|
||||||
<FormSection>
|
<FormSection>
|
||||||
<div class="_buttons">
|
<template #label>{{ i18n.ts.emojiDeckSettingTitle }}</template>
|
||||||
<MkButton inline @click="preview"><i class="ti ti-eye"></i> {{ i18n.ts.preview }}</MkButton>
|
<template #description>{{ i18n.ts.emojiDeckSettingDescription }}</template>
|
||||||
<MkButton inline danger @click="setDefault"><i class="ti ti-reload"></i> {{ i18n.ts.default }}</MkButton>
|
|
||||||
|
<div class="_gaps_m">
|
||||||
|
<MkSwitch v-model="useReactionDeckItems">
|
||||||
|
{{ i18n.ts.diversionReactionDeckSettingCaption }}
|
||||||
|
<template #caption>{{ i18n.ts.diversionReactionDeckSettingDescription }}</template>
|
||||||
|
</MkSwitch>
|
||||||
|
|
||||||
|
<div v-if="!useReactionDeckItems">
|
||||||
|
<div v-panel style="border-radius: 6px;">
|
||||||
|
<Sortable
|
||||||
|
v-model="emojiDeckItems"
|
||||||
|
:class="$style.reactions"
|
||||||
|
:itemKey="item => item"
|
||||||
|
:animation="150"
|
||||||
|
:delay="100"
|
||||||
|
:delayOnTouchOnly="true"
|
||||||
|
>
|
||||||
|
<template #item="{element}">
|
||||||
|
<button class="_button" :class="$style.reactionsItem" @click="removeEmoji(element, $event)">
|
||||||
|
<MkCustomEmoji v-if="element[0] === ':'" :name="element" :normal="true"/>
|
||||||
|
<MkEmoji v-else :emoji="element" :normal="true"/>
|
||||||
|
</button>
|
||||||
|
</template>
|
||||||
|
<template #footer>
|
||||||
|
<button class="_button" :class="$style.reactionsAdd" @click="chooseEmoji">
|
||||||
|
<i class="ti ti-plus"></i>
|
||||||
|
</button>
|
||||||
|
</template>
|
||||||
|
</Sortable>
|
||||||
|
</div>
|
||||||
|
<span class="description">{{ i18n.ts.reactionSettingDescription2 }}</span>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div v-if="!useReactionDeckItems" class="_buttons">
|
||||||
|
<MkButton inline @click="previewEmoji"><i class="ti ti-eye"></i> {{ i18n.ts.preview }}</MkButton>
|
||||||
|
<MkButton inline danger @click="setDefaultEmoji"><i class="ti ti-reload"></i> {{ i18n.ts.default }}</MkButton>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</FormSection>
|
||||||
|
|
||||||
|
<FormSection>
|
||||||
|
<template #label>{{ i18n.ts.diversionReactionDeckEmojisTitle }}</template>
|
||||||
|
<template #description>{{ i18n.ts.diversionReactionDeckEmojisDescription }}</template>
|
||||||
|
|
||||||
|
<div class="_gaps_m">
|
||||||
|
<MkRadios v-model="reactionPickerSize">
|
||||||
|
<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>
|
||||||
|
</MkRadios>
|
||||||
|
|
||||||
|
<MkRadios v-model="reactionPickerWidth">
|
||||||
|
<template #label>{{ i18n.ts.numberOfColumn }}</template>
|
||||||
|
<option :value="1">5</option>
|
||||||
|
<option :value="2">6</option>
|
||||||
|
<option :value="3">7</option>
|
||||||
|
<option :value="4">8</option>
|
||||||
|
<option :value="5">9</option>
|
||||||
|
</MkRadios>
|
||||||
|
|
||||||
|
<MkRadios v-model="reactionPickerHeight">
|
||||||
|
<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>
|
||||||
|
</MkRadios>
|
||||||
|
|
||||||
|
<MkSwitch v-model="reactionPickerUseDrawerForMobile">
|
||||||
|
{{ i18n.ts.useDrawerReactionPickerForMobile }}
|
||||||
|
<template #caption>{{ i18n.ts.needReloadToApply }}</template>
|
||||||
|
</MkSwitch>
|
||||||
</div>
|
</div>
|
||||||
</FormSection>
|
</FormSection>
|
||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script lang="ts" setup>
|
<script lang="ts" setup>
|
||||||
import { defineAsyncComponent, watch, ref, computed } from 'vue';
|
import { computed, ref, Ref, watch } from 'vue';
|
||||||
import Sortable from 'vuedraggable';
|
import Sortable from 'vuedraggable';
|
||||||
import MkRadios from '@/components/MkRadios.vue';
|
import MkRadios from '@/components/MkRadios.vue';
|
||||||
import FromSlot from '@/components/form/slot.vue';
|
|
||||||
import MkButton from '@/components/MkButton.vue';
|
import MkButton from '@/components/MkButton.vue';
|
||||||
import FormSection from '@/components/form/section.vue';
|
import FormSection from '@/components/form/section.vue';
|
||||||
import MkSwitch from '@/components/MkSwitch.vue';
|
import MkSwitch from '@/components/MkSwitch.vue';
|
||||||
|
@ -72,88 +136,110 @@ import { defaultStore } from '@/store.js';
|
||||||
import { i18n } from '@/i18n.js';
|
import { i18n } from '@/i18n.js';
|
||||||
import { definePageMetadata } from '@/scripts/page-metadata.js';
|
import { definePageMetadata } from '@/scripts/page-metadata.js';
|
||||||
import { deepClone } from '@/scripts/clone.js';
|
import { deepClone } from '@/scripts/clone.js';
|
||||||
|
import { reactionPicker } from '@/scripts/reaction-picker.js';
|
||||||
|
import { emojiPicker } from '@/scripts/emoji-picker.js';
|
||||||
|
import MkCustomEmoji from '@/components/global/MkCustomEmoji.vue';
|
||||||
|
import MkEmoji from '@/components/global/MkEmoji.vue';
|
||||||
|
|
||||||
const reactions = ref(deepClone(defaultStore.state.reactions));
|
const reactionDeckItems: Ref<string[]> = ref(deepClone(defaultStore.state.reactions));
|
||||||
|
const emojiDeckItems: Ref<string[]> = ref(deepClone(defaultStore.state.emojiDeckItems));
|
||||||
|
|
||||||
|
const useReactionDeckItems = computed(defaultStore.makeGetterSetter('useReactionDeckItems'));
|
||||||
const reactionPickerSize = computed(defaultStore.makeGetterSetter('reactionPickerSize'));
|
const reactionPickerSize = computed(defaultStore.makeGetterSetter('reactionPickerSize'));
|
||||||
const reactionPickerWidth = computed(defaultStore.makeGetterSetter('reactionPickerWidth'));
|
const reactionPickerWidth = computed(defaultStore.makeGetterSetter('reactionPickerWidth'));
|
||||||
const reactionPickerHeight = computed(defaultStore.makeGetterSetter('reactionPickerHeight'));
|
const reactionPickerHeight = computed(defaultStore.makeGetterSetter('reactionPickerHeight'));
|
||||||
const reactionPickerUseDrawerForMobile = computed(defaultStore.makeGetterSetter('reactionPickerUseDrawerForMobile'));
|
const reactionPickerUseDrawerForMobile = computed(defaultStore.makeGetterSetter('reactionPickerUseDrawerForMobile'));
|
||||||
|
|
||||||
function save() {
|
const removeReaction = (reaction: string, ev: MouseEvent) => remove(reactionDeckItems, reaction, ev);
|
||||||
defaultStore.set('reactions', reactions.value);
|
const chooseReaction = (ev: MouseEvent) => pickEmoji(reactionDeckItems, ev);
|
||||||
|
const setDefaultReaction = () => setDefault(reactionDeckItems);
|
||||||
|
|
||||||
|
const removeEmoji = (reaction: string, ev: MouseEvent) => remove(emojiDeckItems, reaction, ev);
|
||||||
|
const chooseEmoji = (ev: MouseEvent) => pickEmoji(emojiDeckItems, ev);
|
||||||
|
const setDefaultEmoji = () => setDefault(emojiDeckItems);
|
||||||
|
|
||||||
|
function previewReaction(ev: MouseEvent) {
|
||||||
|
reactionPicker.show(getHTMLElement(ev));
|
||||||
}
|
}
|
||||||
|
|
||||||
function remove(reaction, ev: MouseEvent) {
|
function previewEmoji(ev: MouseEvent) {
|
||||||
|
emojiPicker.show(getHTMLElement(ev), undefined, undefined, 'emojis');
|
||||||
|
}
|
||||||
|
|
||||||
|
function remove(itemsRef: Ref<string[]>, reaction: string, ev: MouseEvent) {
|
||||||
os.popupMenu([{
|
os.popupMenu([{
|
||||||
text: i18n.ts.remove,
|
text: i18n.ts.remove,
|
||||||
action: () => {
|
action: () => {
|
||||||
reactions.value = reactions.value.filter(x => x !== reaction);
|
itemsRef.value = itemsRef.value.filter(x => x !== reaction);
|
||||||
},
|
},
|
||||||
}], ev.currentTarget ?? ev.target);
|
}], getHTMLElement(ev));
|
||||||
}
|
}
|
||||||
|
|
||||||
function preview(ev: MouseEvent) {
|
async function setDefault(itemsRef: Ref<string[]>) {
|
||||||
os.popup(defineAsyncComponent(() => import('@/components/MkEmojiPickerDialog.vue')), {
|
|
||||||
asReactionPicker: true,
|
|
||||||
src: ev.currentTarget ?? ev.target,
|
|
||||||
}, {}, 'closed');
|
|
||||||
}
|
|
||||||
|
|
||||||
async function setDefault() {
|
|
||||||
const { canceled } = await os.confirm({
|
const { canceled } = await os.confirm({
|
||||||
type: 'warning',
|
type: 'warning',
|
||||||
text: i18n.ts.resetAreYouSure,
|
text: i18n.ts.resetAreYouSure,
|
||||||
});
|
});
|
||||||
if (canceled) return;
|
if (canceled) return;
|
||||||
|
|
||||||
reactions.value = deepClone(defaultStore.def.reactions.default);
|
itemsRef.value = deepClone(defaultStore.def.reactions.default);
|
||||||
}
|
}
|
||||||
|
|
||||||
function chooseEmoji(ev: MouseEvent) {
|
async function pickEmoji(itemsRef: Ref<string[]>, ev: MouseEvent) {
|
||||||
os.pickEmoji(ev.currentTarget ?? ev.target, {
|
os.pickEmoji(getHTMLElement(ev), {
|
||||||
showPinned: false,
|
showPinned: false,
|
||||||
}).then(emoji => {
|
}).then(it => {
|
||||||
if (!reactions.value.includes(emoji)) {
|
const emoji = it as string;
|
||||||
reactions.value.push(emoji);
|
if (!itemsRef.value.includes(emoji)) {
|
||||||
|
itemsRef.value.push(emoji);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
watch(reactions, () => {
|
function getHTMLElement(ev: MouseEvent): HTMLElement {
|
||||||
save();
|
const target = ev.currentTarget ?? ev.target;
|
||||||
|
return target as HTMLElement;
|
||||||
|
}
|
||||||
|
|
||||||
|
watch(reactionDeckItems, () => {
|
||||||
|
defaultStore.set('reactions', reactionDeckItems.value);
|
||||||
}, {
|
}, {
|
||||||
deep: true,
|
deep: true,
|
||||||
});
|
});
|
||||||
|
|
||||||
const headerActions = computed(() => []);
|
watch(emojiDeckItems, () => {
|
||||||
|
defaultStore.set('emojiDeckItems', emojiDeckItems.value);
|
||||||
const headerTabs = computed(() => []);
|
}, {
|
||||||
|
deep: true,
|
||||||
|
});
|
||||||
|
|
||||||
definePageMetadata({
|
definePageMetadata({
|
||||||
title: i18n.ts.reaction,
|
title: i18n.ts.reaction,
|
||||||
icon: 'ti ti-mood-happy',
|
icon: 'ti ti-mood-happy',
|
||||||
action: {
|
|
||||||
icon: 'ti ti-eye',
|
|
||||||
handler: preview,
|
|
||||||
},
|
|
||||||
});
|
});
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
|
<style lang="scss">
|
||||||
|
.description {
|
||||||
|
font-size: 0.85em;
|
||||||
|
color: var(--fgTransparentWeak);
|
||||||
|
}
|
||||||
|
</style>
|
||||||
|
|
||||||
<style lang="scss" module>
|
<style lang="scss" module>
|
||||||
.reactions {
|
.reactions {
|
||||||
padding: 12px;
|
padding: 12px;
|
||||||
font-size: 1.1em;
|
font-size: 1.1em;
|
||||||
}
|
}
|
||||||
|
|
||||||
.reactionsItem {
|
.reactionsItem {
|
||||||
display: inline-block;
|
display: inline-block;
|
||||||
padding: 8px;
|
padding: 8px;
|
||||||
cursor: move;
|
cursor: move;
|
||||||
}
|
}
|
||||||
|
|
||||||
.reactionsAdd {
|
.reactionsAdd {
|
||||||
display: inline-block;
|
display: inline-block;
|
||||||
padding: 8px;
|
padding: 8px;
|
||||||
}
|
}
|
||||||
</style>
|
</style>
|
||||||
|
|
|
@ -3,8 +3,9 @@
|
||||||
* SPDX-License-Identifier: AGPL-3.0-only
|
* SPDX-License-Identifier: AGPL-3.0-only
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import { defineAsyncComponent, Ref, ref } from 'vue';
|
import { defineAsyncComponent, Ref, ref, computed, ComputedRef } from 'vue';
|
||||||
import { popup } from '@/os.js';
|
import { popup } from '@/os.js';
|
||||||
|
import { defaultStore } from '@/store.js';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 絵文字ピッカーを表示する。
|
* 絵文字ピッカーを表示する。
|
||||||
|
@ -15,6 +16,7 @@ import { popup } from '@/os.js';
|
||||||
class EmojiPicker {
|
class EmojiPicker {
|
||||||
private src: Ref<HTMLElement | null> = ref(null);
|
private src: Ref<HTMLElement | null> = ref(null);
|
||||||
private manualShowing = ref(false);
|
private manualShowing = ref(false);
|
||||||
|
private itemPresetType = ref<DeckItemPresetType>('auto');
|
||||||
private onChosen?: (emoji: string) => void;
|
private onChosen?: (emoji: string) => void;
|
||||||
private onClosed?: () => void;
|
private onClosed?: () => void;
|
||||||
|
|
||||||
|
@ -22,10 +24,30 @@ class EmojiPicker {
|
||||||
// nop
|
// nop
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private createDeckItemCompute(): ComputedRef<string[]> {
|
||||||
|
const itemPresetType = this.itemPresetType;
|
||||||
|
const useReactionDeckItems = defaultStore.reactiveState.useReactionDeckItems;
|
||||||
|
const reactionsRef = defaultStore.reactiveState.reactions;
|
||||||
|
const emojisRef = defaultStore.reactiveState.emojiDeckItems;
|
||||||
|
|
||||||
|
return computed(() => {
|
||||||
|
switch (itemPresetType.value) {
|
||||||
|
case 'reactions':
|
||||||
|
return reactionsRef.value;
|
||||||
|
case 'emojis':
|
||||||
|
return emojisRef.value;
|
||||||
|
default:
|
||||||
|
return useReactionDeckItems.value ? reactionsRef.value : emojisRef.value;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
public async init() {
|
public async init() {
|
||||||
|
const emojisComputed = this.createDeckItemCompute();
|
||||||
await popup(defineAsyncComponent(() => import('@/components/MkEmojiPickerDialog.vue')), {
|
await popup(defineAsyncComponent(() => import('@/components/MkEmojiPickerDialog.vue')), {
|
||||||
src: this.src,
|
src: this.src,
|
||||||
asReactionPicker: false,
|
pinnedEmojis: emojisComputed,
|
||||||
|
asReactionPicker: true,
|
||||||
manualShowing: this.manualShowing,
|
manualShowing: this.manualShowing,
|
||||||
choseAndClose: false,
|
choseAndClose: false,
|
||||||
}, {
|
}, {
|
||||||
|
@ -44,14 +66,18 @@ class EmojiPicker {
|
||||||
|
|
||||||
public show(
|
public show(
|
||||||
src: HTMLElement,
|
src: HTMLElement,
|
||||||
onChosen: EmojiPicker['onChosen'],
|
onChosen?: EmojiPicker['onChosen'],
|
||||||
onClosed: EmojiPicker['onClosed'],
|
onClosed?: EmojiPicker['onClosed'],
|
||||||
|
itemPresetType: DeckItemPresetType = 'auto',
|
||||||
) {
|
) {
|
||||||
this.src.value = src;
|
this.src.value = src;
|
||||||
|
this.itemPresetType.value = itemPresetType;
|
||||||
this.manualShowing.value = true;
|
this.manualShowing.value = true;
|
||||||
this.onChosen = onChosen;
|
this.onChosen = onChosen;
|
||||||
this.onClosed = onClosed;
|
this.onClosed = onClosed;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export type DeckItemPresetType = 'reactions' | 'emojis' | 'auto';
|
||||||
|
|
||||||
export const emojiPicker = new EmojiPicker();
|
export const emojiPicker = new EmojiPicker();
|
||||||
|
|
|
@ -5,6 +5,7 @@
|
||||||
|
|
||||||
import { defineAsyncComponent, Ref, ref } from 'vue';
|
import { defineAsyncComponent, Ref, ref } from 'vue';
|
||||||
import { popup } from '@/os.js';
|
import { popup } from '@/os.js';
|
||||||
|
import { defaultStore } from '@/store.js';
|
||||||
|
|
||||||
class ReactionPicker {
|
class ReactionPicker {
|
||||||
private src: Ref<HTMLElement | null> = ref(null);
|
private src: Ref<HTMLElement | null> = ref(null);
|
||||||
|
@ -17,8 +18,10 @@ class ReactionPicker {
|
||||||
}
|
}
|
||||||
|
|
||||||
public async init() {
|
public async init() {
|
||||||
|
const reactionsRef = defaultStore.reactiveState.reactions;
|
||||||
await popup(defineAsyncComponent(() => import('@/components/MkEmojiPickerDialog.vue')), {
|
await popup(defineAsyncComponent(() => import('@/components/MkEmojiPickerDialog.vue')), {
|
||||||
src: this.src,
|
src: this.src,
|
||||||
|
pinnedEmojis: reactionsRef,
|
||||||
asReactionPicker: true,
|
asReactionPicker: true,
|
||||||
manualShowing: this.manualShowing,
|
manualShowing: this.manualShowing,
|
||||||
}, {
|
}, {
|
||||||
|
@ -35,7 +38,7 @@ class ReactionPicker {
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
public show(src: HTMLElement, onChosen: ReactionPicker['onChosen'], onClosed: ReactionPicker['onClosed']) {
|
public show(src: HTMLElement, onChosen?: ReactionPicker['onChosen'], onClosed?: ReactionPicker['onClosed']) {
|
||||||
this.src.value = src;
|
this.src.value = src;
|
||||||
this.manualShowing.value = true;
|
this.manualShowing.value = true;
|
||||||
this.onChosen = onChosen;
|
this.onChosen = onChosen;
|
||||||
|
|
|
@ -119,6 +119,10 @@ export const defaultStore = markRaw(new Storage('base', {
|
||||||
where: 'account',
|
where: 'account',
|
||||||
default: ['👍', '❤️', '😆', '🤔', '😮', '🎉', '💢', '😥', '😇', '🍮'],
|
default: ['👍', '❤️', '😆', '🤔', '😮', '🎉', '💢', '😥', '😇', '🍮'],
|
||||||
},
|
},
|
||||||
|
emojiDeckItems: {
|
||||||
|
where: 'account',
|
||||||
|
default: ['👍', '❤️', '😆', '🤔', '😮', '🎉', '💢', '😥', '😇', '🍮'],
|
||||||
|
},
|
||||||
reactionAcceptance: {
|
reactionAcceptance: {
|
||||||
where: 'account',
|
where: 'account',
|
||||||
default: 'nonSensitiveOnly' as 'likeOnly' | 'likeOnlyForRemote' | 'nonSensitiveOnly' | 'nonSensitiveOnlyForLocalLikeOnlyForRemote' | null,
|
default: 'nonSensitiveOnly' as 'likeOnly' | 'likeOnlyForRemote' | 'nonSensitiveOnly' | 'nonSensitiveOnlyForLocalLikeOnlyForRemote' | null,
|
||||||
|
@ -339,6 +343,10 @@ export const defaultStore = markRaw(new Storage('base', {
|
||||||
where: 'device',
|
where: 'device',
|
||||||
default: false,
|
default: false,
|
||||||
},
|
},
|
||||||
|
useReactionDeckItems: {
|
||||||
|
where: 'device',
|
||||||
|
default: true,
|
||||||
|
},
|
||||||
reactionsDisplaySize: {
|
reactionsDisplaySize: {
|
||||||
where: 'device',
|
where: 'device',
|
||||||
default: 'medium' as 'small' | 'medium' | 'large',
|
default: 'medium' as 'small' | 'medium' | 'large',
|
||||||
|
|
Loading…
Reference in New Issue