diff options
| author | MeiMei <30769358+mei23@users.noreply.github.com> | 2019-03-18 00:03:57 +0900 |
|---|---|---|
| committer | syuilo <Syuilotan@yahoo.co.jp> | 2019-03-18 00:03:57 +0900 |
| commit | 26845416932ecf0ce035240ce934d2afb77bf550 (patch) | |
| tree | 41992508c56c9ac05c481f76af524f5a3f14ca31 /src/client | |
| parent | Change default dark theme (diff) | |
| download | sharkey-26845416932ecf0ce035240ce934d2afb77bf550.tar.gz sharkey-26845416932ecf0ce035240ce934d2afb77bf550.tar.bz2 sharkey-26845416932ecf0ce035240ce934d2afb77bf550.zip | |
Custom reaction (#4517)
* Custom reaction
* increase limit of reactions/delete
* リアクションの場合は OS標準の絵文字を使用 を迂回する
* カスタムリアクションを無効にする設定
* fix
* disableCustomReaction --> enableEmojiReaction
* Avoid MFM rendering
* :art:
* :art:
* Auto accept
* custom emoji reaction
* Improve usability
* Extract emojiRegex
* Fix
* Clean up
* :art:
* :art:
* toDbReaction で reaction は必須に
あとフォールバックは like に
* Clean up
* Make required
* https://github.com/syuilo/misskey/pull/4517/commits/3eb08748feeaab9ee5c5b505c870f97d7edbeb0d#r266241728
* Refactor
* Allow null
Diffstat (limited to 'src/client')
5 files changed, 91 insertions, 25 deletions
diff --git a/src/client/app/admin/views/instance.vue b/src/client/app/admin/views/instance.vue index 8b3ec0cb26..ab337f1871 100644 --- a/src/client/app/admin/views/instance.vue +++ b/src/client/app/admin/views/instance.vue @@ -25,6 +25,7 @@ <ui-switch v-model="disableLocalTimeline">{{ $t('disable-local-timeline') }}</ui-switch> <ui-switch v-model="disableGlobalTimeline">{{ $t('disable-global-timeline') }}</ui-switch> <ui-info>{{ $t('disabling-timelines-info') }}</ui-info> + <ui-switch v-model="enableEmojiReaction">{{ $t('enable-emoji-reaction') }}</ui-switch> </section> <section class="fit-bottom"> <header><fa icon="cloud"/> {{ $t('drive-config') }}</header> @@ -155,6 +156,7 @@ export default Vue.extend({ disableRegistration: false, disableLocalTimeline: false, disableGlobalTimeline: false, + enableEmojiReaction: true, mascotImageUrl: null, bannerUrl: null, errorImageUrl: null, @@ -206,6 +208,7 @@ export default Vue.extend({ this.disableRegistration = meta.disableRegistration; this.disableLocalTimeline = meta.disableLocalTimeline; this.disableGlobalTimeline = meta.disableGlobalTimeline; + this.enableEmojiReaction = meta.enableEmojiReaction; this.mascotImageUrl = meta.mascotImageUrl; this.bannerUrl = meta.bannerUrl; this.errorImageUrl = meta.errorImageUrl; @@ -267,6 +270,7 @@ export default Vue.extend({ disableRegistration: this.disableRegistration, disableLocalTimeline: this.disableLocalTimeline, disableGlobalTimeline: this.disableGlobalTimeline, + enableEmojiReaction: this.enableEmojiReaction, mascotImageUrl: this.mascotImageUrl, bannerUrl: this.bannerUrl, errorImageUrl: this.errorImageUrl, diff --git a/src/client/app/common/views/components/emoji.vue b/src/client/app/common/views/components/emoji.vue index b4618a8d85..65b5683c2f 100644 --- a/src/client/app/common/views/components/emoji.vue +++ b/src/client/app/common/views/components/emoji.vue @@ -29,7 +29,11 @@ export default Vue.extend({ customEmojis: { required: false, default: () => [] - } + }, + isReaction: { + type: Boolean, + default: false + }, }, data() { @@ -46,7 +50,7 @@ export default Vue.extend({ }, useOsDefaultEmojis(): boolean { - return this.$store.state.device.useOsDefaultEmojis; + return this.$store.state.device.useOsDefaultEmojis && !this.isReaction; } }, diff --git a/src/client/app/common/views/components/reaction-icon.vue b/src/client/app/common/views/components/reaction-icon.vue index d413bece6b..1991669507 100644 --- a/src/client/app/common/views/components/reaction-icon.vue +++ b/src/client/app/common/views/components/reaction-icon.vue @@ -1,19 +1,5 @@ <template> -<span class="mk-reaction-icon"> - <img v-if="reaction == 'like'" src="https://twemoji.maxcdn.com/2/svg/1f44d.svg" :alt="$t('@.reactions.like')"> - <img v-if="reaction == 'love'" src="https://twemoji.maxcdn.com/2/svg/2764.svg" :alt="$t('@.reactions.love')"> - <img v-if="reaction == 'laugh'" src="https://twemoji.maxcdn.com/2/svg/1f606.svg" :alt="$t('@.reactions.laugh')"> - <img v-if="reaction == 'hmm'" src="https://twemoji.maxcdn.com/2/svg/1f914.svg" :alt="$t('@.reactions.hmm')"> - <img v-if="reaction == 'surprise'" src="https://twemoji.maxcdn.com/2/svg/1f62e.svg" :alt="$t('@.reactions.surprise')"> - <img v-if="reaction == 'congrats'" src="https://twemoji.maxcdn.com/2/svg/1f389.svg" :alt="$t('@.reactions.congrats')"> - <img v-if="reaction == 'angry'" src="https://twemoji.maxcdn.com/2/svg/1f4a2.svg" :alt="$t('@.reactions.angry')"> - <img v-if="reaction == 'confused'" src="https://twemoji.maxcdn.com/2/svg/1f625.svg" :alt="$t('@.reactions.confused')"> - <img v-if="reaction == 'rip'" src="https://twemoji.maxcdn.com/2/svg/1f607.svg" :alt="$t('@.reactions.rip')"> - <template v-if="reaction == 'pudding'"> - <img v-if="$store.getters.isSignedIn && $store.state.settings.iLikeSushi" src="https://twemoji.maxcdn.com/2/svg/1f363.svg" :alt="$t('@.reactions.pudding')"> - <img v-else src="https://twemoji.maxcdn.com/2/svg/1f36e.svg" :alt="$t('@.reactions.pudding')"> - </template> -</span> +<mk-emoji :emoji="str.startsWith(':') ? null : str" :name="str.startsWith(':') ? str.substr(1, str.length - 2) : null" :is-reaction="true" :custom-emojis="customEmojis" :normal="true"/> </template> <script lang="ts"> @@ -21,7 +7,34 @@ import Vue from 'vue'; import i18n from '../../../i18n'; export default Vue.extend({ i18n: i18n(), - props: ['reaction'] + props: { + reaction: { + type: String, + required: true + }, + }, + data() { + return { + customEmojis: (this.$root.getMetaSync() || { emojis: [] }).emojis || [] + }; + }, + computed: { + str(): any { + switch (this.reaction) { + case 'like': return '👍'; + case 'love': return '❤'; + case 'laugh': return '😆'; + case 'hmm': return '🤔'; + case 'surprise': return '😮'; + case 'congrats': return '🎉'; + case 'angry': return '💢'; + case 'confused': return '😥'; + case 'rip': return '😇'; + case 'pudding': return (this.$store.getters.isSignedIn && this.$store.state.settings.iLikeSushi) ? '🍣' : '🍮'; + default: return this.reaction; + } + }, + }, }); </script> diff --git a/src/client/app/common/views/components/reaction-picker.vue b/src/client/app/common/views/components/reaction-picker.vue index 54c8e2a68f..af340dcf7a 100644 --- a/src/client/app/common/views/components/reaction-picker.vue +++ b/src/client/app/common/views/components/reaction-picker.vue @@ -3,7 +3,7 @@ <div class="backdrop" ref="backdrop" @click="close"></div> <div class="popover" :class="{ isMobile: $root.isMobile }" ref="popover"> <p v-if="!$root.isMobile">{{ title }}</p> - <div ref="buttons" :class="{ showFocus }"> + <div class="buttons" ref="buttons" :class="{ showFocus }"> <button @click="react('like')" @mouseover="onMouseover" @mouseout="onMouseout" tabindex="1" :title="$t('@.reactions.like')" v-particle><mk-reaction-icon reaction="like"/></button> <button @click="react('love')" @mouseover="onMouseover" @mouseout="onMouseout" tabindex="2" :title="$t('@.reactions.love')" v-particle><mk-reaction-icon reaction="love"/></button> <button @click="react('laugh')" @mouseover="onMouseover" @mouseout="onMouseout" tabindex="3" :title="$t('@.reactions.laugh')" v-particle><mk-reaction-icon reaction="laugh"/></button> @@ -15,6 +15,9 @@ <button @click="react('rip')" @mouseover="onMouseover" @mouseout="onMouseout" tabindex="9" :title="$t('@.reactions.rip')" v-particle><mk-reaction-icon reaction="rip"/></button> <button @click="react('pudding')" @mouseover="onMouseover" @mouseout="onMouseout" tabindex="10" :title="$t('@.reactions.pudding')" v-particle><mk-reaction-icon reaction="pudding"/></button> </div> + <div v-if="enableEmojiReaction" class="text"> + <input v-model="text" placeholder="または絵文字を入力" @keyup.enter="reactText" @input="tryReactText" v-autocomplete="{ model: 'text' }"> + </div> </div> </div> </template> @@ -23,6 +26,7 @@ import Vue from 'vue'; import i18n from '../../../i18n'; import anime from 'animejs'; +import { emojiRegex } from '../../../../../misc/emoji-regex'; export default Vue.extend({ i18n: i18n('common/views/components/reaction-picker.vue'), @@ -56,6 +60,8 @@ export default Vue.extend({ data() { return { title: this.$t('choose-reaction'), + text: null, + enableEmojiReaction: false, focus: null }; }, @@ -94,6 +100,10 @@ export default Vue.extend({ }, mounted() { + this.$root.getMeta().then(meta => { + this.enableEmojiReaction = meta.enableEmojiReaction; + }); + this.$nextTick(() => { this.focus = 0; @@ -143,6 +153,17 @@ export default Vue.extend({ }); }, + reactText() { + if (!this.text) return; + this.react(this.text); + }, + + tryReactText() { + if (!this.text) return; + if (!this.text.match(emojiRegex)) return; + this.reactText(); + }, + onMouseover(e) { this.title = e.target.title; }, @@ -256,9 +277,9 @@ export default Vue.extend({ color var(--popupFg) border-bottom solid var(--lineWidth) var(--faceDivider) - > div + > .buttons padding 4px - width 240px + width 216px text-align center &.showFocus @@ -283,6 +304,9 @@ export default Vue.extend({ font-size 24px border-radius 2px + > * + height 1em + &:hover background var(--reactionPickerButtonHoverBg) @@ -290,4 +314,29 @@ export default Vue.extend({ background var(--primary) box-shadow inset 0 0.15em 0.3em rgba(27, 31, 35, 0.15) + > .text + width 216px + padding 4px 8px 8px 8px + + > input + width 100% + padding 10px + margin 0 + text-align center + font-size 16px + color var(--desktopPostFormTextareaFg) + background var(--desktopPostFormTextareaBg) + outline none + border solid 1px var(--primaryAlpha01) + border-radius 4px + transition border-color .2s ease + + &:hover + border-color var(--primaryAlpha02) + transition border-color .1s ease + + &:focus + border-color var(--primaryAlpha05) + transition border-color 0s ease + </style> diff --git a/src/client/app/common/views/components/reactions-viewer.reaction.vue b/src/client/app/common/views/components/reactions-viewer.reaction.vue index b7c321fc9f..ecd22d3f57 100644 --- a/src/client/app/common/views/components/reactions-viewer.reaction.vue +++ b/src/client/app/common/views/components/reactions-viewer.reaction.vue @@ -136,12 +136,8 @@ export default Vue.extend({ &:hover background var(--reactionViewerButtonHoverBg) - > .mk-reaction-icon - font-size 1.4em - > span font-size 1.1em line-height 32px - vertical-align middle color var(--text) </style> |