1
0
mirror of https://github.com/misskey-dev/misskey synced 2024-12-05 10:18:42 +09:00

Emoji support in profile (#3514)

* Emoji in profile

* Add emojis to fields
This commit is contained in:
MeiMei 2018-12-06 10:02:04 +09:00 committed by syuilo
parent fe891da886
commit 4522568749
41 changed files with 261 additions and 70 deletions

View File

@ -3,7 +3,9 @@
<ol class="users" ref="suggests" v-if="users.length > 0"> <ol class="users" ref="suggests" v-if="users.length > 0">
<li v-for="user in users" @click="complete(type, user)" @keydown="onKeydown" tabindex="-1"> <li v-for="user in users" @click="complete(type, user)" @keydown="onKeydown" tabindex="-1">
<img class="avatar" :src="user.avatarUrl" alt=""/> <img class="avatar" :src="user.avatarUrl" alt=""/>
<span class="name">{{ user | userName }}</span> <span class="name">
<misskey-flavored-markdown :text="user.name || user.username" :shouldBreak="false" :plainText="true" :custom-emojis="user.emojis"/>
</span>
<span class="username">@{{ user | acct }}</span> <span class="username">@{{ user | acct }}</span>
</li> </li>
</ol> </ol>

View File

@ -1,5 +1,5 @@
<template> <template>
<img v-if="customEmoji" class="fvgwvorwhxigeolkkrcderjzcawqrscl custom" :src="url" :alt="alt" :title="alt"/> <img v-if="customEmoji" class="fvgwvorwhxigeolkkrcderjzcawqrscl custom" :class="{ normal: normal }" :src="url" :alt="alt" :title="alt"/>
<img v-else-if="char && !useOsDefaultEmojis" class="fvgwvorwhxigeolkkrcderjzcawqrscl" :src="url" :alt="alt" :title="alt"/> <img v-else-if="char && !useOsDefaultEmojis" class="fvgwvorwhxigeolkkrcderjzcawqrscl" :src="url" :alt="alt" :title="alt"/>
<span v-else-if="char && useOsDefaultEmojis">{{ char }}</span> <span v-else-if="char && useOsDefaultEmojis">{{ char }}</span>
<span v-else>:{{ name }}:</span> <span v-else>:{{ name }}:</span>
@ -20,6 +20,11 @@ export default Vue.extend({
type: String, type: String,
required: false required: false
}, },
normal: {
type: Boolean,
required: false,
default: false
},
customEmojis: { customEmojis: {
required: false, required: false,
default: () => [] default: () => []
@ -83,4 +88,11 @@ export default Vue.extend({
&:hover &:hover
transform scale(1.2) transform scale(1.2)
&.normal
height 1.25em
vertical-align -0.25em
&:hover
transform none
</style> </style>

View File

@ -49,6 +49,10 @@ export default Vue.component('misskey-flavored-markdown', {
type: Boolean, type: Boolean,
default: true default: true
}, },
plainText: {
type: Boolean,
default: false
},
author: { author: {
type: Object, type: Object,
default: null default: null
@ -69,7 +73,7 @@ export default Vue.component('misskey-flavored-markdown', {
if (this.ast == null) { if (this.ast == null) {
// Parse text to ast // Parse text to ast
ast = parse(this.text); ast = parse(this.text, this.plainText);
} else { } else {
ast = this.ast as Node[]; ast = this.ast as Node[];
} }
@ -254,7 +258,8 @@ export default Vue.component('misskey-flavored-markdown', {
name: token.props.name name: token.props.name
}, },
props: { props: {
customEmojis: this.customEmojis || customEmojis customEmojis: this.customEmojis || customEmojis,
normal: this.plainText
} }
})]; })];
} }

View File

@ -1,7 +1,9 @@
<template> <template>
<header class="bvonvjxbwzaiskogyhbwgyxvcgserpmu"> <header class="bvonvjxbwzaiskogyhbwgyxvcgserpmu">
<mk-avatar class="avatar" :user="note.user" v-if="$store.state.device.postStyle == 'smart'"/> <mk-avatar class="avatar" :user="note.user" v-if="$store.state.device.postStyle == 'smart'"/>
<router-link class="name" :to="note.user | userPage" v-user-preview="note.user.id">{{ note.user | userName }}</router-link> <router-link class="name" :to="note.user | userPage" v-user-preview="note.user.id">
<misskey-flavored-markdown :text="note.user.name || note.user.username" :shouldBreak="false" :plainText="true" :custom-emojis="note.user.emojis"/>
</router-link>
<span class="is-admin" v-if="note.user.isAdmin">admin</span> <span class="is-admin" v-if="note.user.isAdmin">admin</span>
<span class="is-bot" v-if="note.user.isBot">bot</span> <span class="is-bot" v-if="note.user.isBot">bot</span>
<span class="is-cat" v-if="note.user.isCat">cat</span> <span class="is-cat" v-if="note.user.isCat">cat</span>

View File

@ -3,7 +3,9 @@
<mk-avatar class="avatar" :user="note.user"/> <mk-avatar class="avatar" :user="note.user"/>
<fa icon="retweet"/> <fa icon="retweet"/>
<i18n path="@.renoted-by" tag="span"> <i18n path="@.renoted-by" tag="span">
<router-link class="name" :to="note.user | userPage" v-user-preview="note.userId" place="user">{{ note.user | userName }}</router-link> <router-link class="name" :to="note.user | userPage" v-user-preview="note.userId" place="user">
<misskey-flavored-markdown :text="note.user.name || note.user.username" :shouldBreak="false" :plainText="true" :custom-emojis="note.user.emojis"/>
</router-link>
</i18n> </i18n>
<div class="info"> <div class="info">
<span class="mobile" v-if="note.viaMobile"><fa icon="mobile-alt"/></span> <span class="mobile" v-if="note.viaMobile"><fa icon="mobile-alt"/></span>

View File

@ -5,7 +5,9 @@
<mk-avatar class="avatar" :user="note.user" target="_blank"/> <mk-avatar class="avatar" :user="note.user" target="_blank"/>
<div class="body"> <div class="body">
<header> <header>
<router-link class="name" :to="note.user | userPage" v-user-preview="note.user.id">{{ note.user | userName }}</router-link> <router-link class="name" :to="note.user | userPage" v-user-preview="note.user.id">
<misskey-flavored-markdown :text="note.user.name || note.user.username" :shouldBreak="false" :plainText="true" :custom-emojis="note.user.emojis"/>
</router-link>
<span class="username">@{{ note.user | acct }}</span> <span class="username">@{{ note.user | acct }}</span>
<div class="info"> <div class="info">
<router-link class="created-at" :to="note | notePage"> <router-link class="created-at" :to="note | notePage">

View File

@ -6,10 +6,12 @@
<div class="banner" :style="bannerStyle"></div> <div class="banner" :style="bannerStyle"></div>
<mk-avatar class="avatar" :user="user" :disable-preview="true"/> <mk-avatar class="avatar" :user="user" :disable-preview="true"/>
<div class="body"> <div class="body">
<router-link :to="user | userPage" class="name">{{ user | userName }}</router-link> <router-link :to="user | userPage" class="name">
<misskey-flavored-markdown :text="user.name || user.username" :shouldBreak="false" :plainText="true" :custom-emojis="user.emojis"/>
</router-link>
<span class="username">@{{ user | acct }}</span> <span class="username">@{{ user | acct }}</span>
<div class="description"> <div class="description">
<misskey-flavored-markdown v-if="user.description" :text="user.description" :author="user" :i="$store.state.i"/> <misskey-flavored-markdown v-if="user.description" :text="user.description" :author="user" :i="$store.state.i" :custom-emojis="user.emojis"/>
</div> </div>
</div> </div>
</main> </main>

View File

@ -5,7 +5,9 @@
<div class="user" v-for="user in users" :key="user.id"> <div class="user" v-for="user in users" :key="user.id">
<mk-avatar class="avatar" :user="user" target="_blank"/> <mk-avatar class="avatar" :user="user" target="_blank"/>
<div class="body"> <div class="body">
<router-link class="name" :to="user | userPage" v-user-preview="user.id">{{ user | userName }}</router-link> <router-link class="name" :to="user | userPage" v-user-preview="user.id">
<misskey-flavored-markdown :text="user.name || user.username" :shouldBreak="false" :plainText="true" :custom-emojis="user.emojis"/>
</router-link>
<p class="username">@{{ user | acct }}</p> <p class="username">@{{ user | acct }}</p>
</div> </div>
</div> </div>

View File

@ -20,7 +20,9 @@
<article> <article>
<mk-avatar class="avatar" :user="appearNote.user"/> <mk-avatar class="avatar" :user="appearNote.user"/>
<header> <header>
<router-link class="name" :to="appearNote.user | userPage" v-user-preview="appearNote.user.id">{{ appearNote.user | userName }}</router-link> <router-link class="name" :to="appearNote.user | userPage" v-user-preview="appearNote.user.id">
<misskey-flavored-markdown :text="appearNote.user.name || appearNote.user.username" :shouldBreak="false" :plainText="true" :custom-emojis="appearNote.user.emojis"/>
</router-link>
<span class="username"><mk-acct :user="appearNote.user"/></span> <span class="username"><mk-acct :user="appearNote.user"/></span>
<div class="info"> <div class="info">
<router-link class="time" :to="appearNote | notePage"> <router-link class="time" :to="appearNote | notePage">

View File

@ -18,7 +18,9 @@
<div class="text"> <div class="text">
<p> <p>
<mk-reaction-icon :reaction="notification.reaction"/> <mk-reaction-icon :reaction="notification.reaction"/>
<router-link :to="notification.user | userPage" v-user-preview="notification.user.id">{{ notification.user | userName }}</router-link> <router-link :to="notification.user | userPage" v-user-preview="notification.user.id">
<misskey-flavored-markdown :text="notification.user.name || notification.user.username" :shouldBreak="false" :plainText="true" :custom-emojis="notification.user.emojis"/>
</router-link>
</p> </p>
<router-link class="note-ref" :to="notification.note | notePage" :title="getNoteSummary(notification.note)"> <router-link class="note-ref" :to="notification.note | notePage" :title="getNoteSummary(notification.note)">
<fa icon="quote-left"/>{{ getNoteSummary(notification.note) }}<fa icon="quote-right"/> <fa icon="quote-left"/>{{ getNoteSummary(notification.note) }}<fa icon="quote-right"/>
@ -30,7 +32,9 @@
<mk-avatar class="avatar" :user="notification.note.user"/> <mk-avatar class="avatar" :user="notification.note.user"/>
<div class="text"> <div class="text">
<p><fa icon="retweet"/> <p><fa icon="retweet"/>
<router-link :to="notification.note.user | userPage" v-user-preview="notification.note.userId">{{ notification.note.user | userName }}</router-link> <router-link :to="notification.note.user | userPage" v-user-preview="notification.note.userId">
<misskey-flavored-markdown :text="notification.note.user.name || notification.note.user.username" :shouldBreak="false" :plainText="true" :custom-emojis="notification.note.user.emojis"/>
</router-link>
</p> </p>
<router-link class="note-ref" :to="notification.note | notePage" :title="getNoteSummary(notification.note.renote)"> <router-link class="note-ref" :to="notification.note | notePage" :title="getNoteSummary(notification.note.renote)">
<fa icon="quote-left"/>{{ getNoteSummary(notification.note.renote) }}<fa icon="quote-right"/> <fa icon="quote-left"/>{{ getNoteSummary(notification.note.renote) }}<fa icon="quote-right"/>
@ -42,7 +46,9 @@
<mk-avatar class="avatar" :user="notification.note.user"/> <mk-avatar class="avatar" :user="notification.note.user"/>
<div class="text"> <div class="text">
<p><fa icon="quote-left"/> <p><fa icon="quote-left"/>
<router-link :to="notification.note.user | userPage" v-user-preview="notification.note.userId">{{ notification.note.user | userName }}</router-link> <router-link :to="notification.note.user | userPage" v-user-preview="notification.note.userId">
<misskey-flavored-markdown :text="notification.note.user.name || notification.note.user.username" :shouldBreak="false" :plainText="true" :custom-emojis="notification.note.user.emojis"/>
</router-link>
</p> </p>
<router-link class="note-preview" :to="notification.note | notePage" :title="getNoteSummary(notification.note)">{{ getNoteSummary(notification.note) }}</router-link> <router-link class="note-preview" :to="notification.note | notePage" :title="getNoteSummary(notification.note)">{{ getNoteSummary(notification.note) }}</router-link>
</div> </div>
@ -52,7 +58,9 @@
<mk-avatar class="avatar" :user="notification.user"/> <mk-avatar class="avatar" :user="notification.user"/>
<div class="text"> <div class="text">
<p><fa icon="user-plus"/> <p><fa icon="user-plus"/>
<router-link :to="notification.user | userPage" v-user-preview="notification.user.id">{{ notification.user | userName }}</router-link> <router-link :to="notification.user | userPage" v-user-preview="notification.user.id">
<misskey-flavored-markdown :text="notification.user.name || notification.user.username" :shouldBreak="false" :plainText="true" :custom-emojis="notification.user.emojis"/>
</router-link>
</p> </p>
</div> </div>
</template> </template>
@ -61,7 +69,9 @@
<mk-avatar class="avatar" :user="notification.user"/> <mk-avatar class="avatar" :user="notification.user"/>
<div class="text"> <div class="text">
<p><fa icon="user-clock"/> <p><fa icon="user-clock"/>
<router-link :to="notification.user | userPage" v-user-preview="notification.user.id">{{ notification.user | userName }}</router-link> <router-link :to="notification.user | userPage" v-user-preview="notification.user.id">
<misskey-flavored-markdown :text="notification.user.name || notification.user.username" :shouldBreak="false" :plainText="true" :custom-emojis="notification.user.emojis"/>
</router-link>
</p> </p>
</div> </div>
</template> </template>
@ -70,7 +80,9 @@
<mk-avatar class="avatar" :user="notification.note.user"/> <mk-avatar class="avatar" :user="notification.note.user"/>
<div class="text"> <div class="text">
<p><fa icon="reply"/> <p><fa icon="reply"/>
<router-link :to="notification.note.user | userPage" v-user-preview="notification.note.userId">{{ notification.note.user | userName }}</router-link> <router-link :to="notification.note.user | userPage" v-user-preview="notification.note.userId">
<misskey-flavored-markdown :text="notification.note.user.name || notification.note.user.username" :shouldBreak="false" :plainText="true" :custom-emojis="notification.note.user.emojis"/>
</router-link>
</p> </p>
<router-link class="note-preview" :to="notification.note | notePage" :title="getNoteSummary(notification.note)">{{ getNoteSummary(notification.note) }}</router-link> <router-link class="note-preview" :to="notification.note | notePage" :title="getNoteSummary(notification.note)">{{ getNoteSummary(notification.note) }}</router-link>
</div> </div>
@ -80,7 +92,9 @@
<mk-avatar class="avatar" :user="notification.note.user"/> <mk-avatar class="avatar" :user="notification.note.user"/>
<div class="text"> <div class="text">
<p><fa icon="at"/> <p><fa icon="at"/>
<router-link :to="notification.note.user | userPage" v-user-preview="notification.note.userId">{{ notification.note.user | userName }}</router-link> <router-link :to="notification.note.user | userPage" v-user-preview="notification.note.userId">
<misskey-flavored-markdown :text="notification.note.user.name || notification.note.user.username" :shouldBreak="false" :plainText="true" :custom-emojis="notification.note.user.emojis"/>
</router-link>
</p> </p>
<a class="note-preview" :href="notification.note | notePage" :title="getNoteSummary(notification.note)">{{ getNoteSummary(notification.note) }}</a> <a class="note-preview" :href="notification.note | notePage" :title="getNoteSummary(notification.note)">{{ getNoteSummary(notification.note) }}</a>
</div> </div>
@ -89,7 +103,9 @@
<template v-if="notification.type == 'poll_vote'"> <template v-if="notification.type == 'poll_vote'">
<mk-avatar class="avatar" :user="notification.user"/> <mk-avatar class="avatar" :user="notification.user"/>
<div class="text"> <div class="text">
<p><fa icon="chart-pie"/><a :href="notification.user | userPage" v-user-preview="notification.user.id">{{ notification.user | userName }}</a></p> <p><fa icon="chart-pie"/><a :href="notification.user | userPage" v-user-preview="notification.user.id">
<misskey-flavored-markdown :text="notification.user.name || notification.user.username" :shouldBreak="false" :plainText="true" :custom-emojis="notification.user.emojis"/>
</a></p>
<router-link class="note-ref" :to="notification.note | notePage" :title="getNoteSummary(notification.note)"> <router-link class="note-ref" :to="notification.note | notePage" :title="getNoteSummary(notification.note)">
<fa icon="quote-left"/>{{ getNoteSummary(notification.note) }}<fa icon="quote-right"/> <fa icon="quote-left"/>{{ getNoteSummary(notification.note) }}<fa icon="quote-right"/>
</router-link> </router-link>

View File

@ -7,7 +7,9 @@
> >
<div class="content"> <div class="content">
<div v-if="visibility == 'specified'" class="visibleUsers"> <div v-if="visibility == 'specified'" class="visibleUsers">
<span v-for="u in visibleUsers">{{ u | userName }}<a @click="removeVisibleUser(u)">[x]</a></span> <span v-for="u in visibleUsers">
<misskey-flavored-markdown :text="u.name || u.username" :shouldBreak="false" :plainText="true" :custom-emojis="u.emojis"/>
<a @click="removeVisibleUser(u)">[x]</a></span>
<a @click="addVisibleUser">{{ $t('add-visible-user') }}</a> <a @click="addVisibleUser">{{ $t('add-visible-user') }}</a>
</div> </div>
<div class="hashtags" v-if="recentHashtags.length > 0 && $store.state.settings.suggestRecentHashtags"> <div class="hashtags" v-if="recentHashtags.length > 0 && $store.state.settings.suggestRecentHashtags">

View File

@ -4,7 +4,9 @@
<div class="slpqaxdoxhvglersgjukmvizkqbmbokc"> <div class="slpqaxdoxhvglersgjukmvizkqbmbokc">
<div v-for="req in requests"> <div v-for="req in requests">
<router-link :key="req.id" :to="req.follower | userPage">{{ req.follower | userName }}</router-link> <router-link :key="req.id" :to="req.follower | userPage">
<misskey-flavored-markdown :text="req.follower.name || req.follower.username" :shouldBreak="false" :plainText="true" :custom-emojis="req.follower.emojis"/>
</router-link>
<span> <span>
<a @click="accept(req.follower)">{{ $t('accept') }}</a>|<a @click="reject(req.follower)">{{ $t('reject') }}</a> <a @click="accept(req.follower)">{{ $t('accept') }}</a>|<a @click="reject(req.follower)">{{ $t('reject') }}</a>
</span> </span>

View File

@ -4,10 +4,12 @@
<mk-avatar class="avatar" :user="user" :disable-preview="true"/> <mk-avatar class="avatar" :user="user" :disable-preview="true"/>
<mk-follow-button :user="user" class="follow" mini/> <mk-follow-button :user="user" class="follow" mini/>
<div class="body"> <div class="body">
<router-link :to="user | userPage" class="name">{{ user | userName }}</router-link> <router-link :to="user | userPage" class="name">
<misskey-flavored-markdown :text="user.name || user.username" :shouldBreak="false" :plainText="true" :custom-emojis="user.emojis"/>
</router-link>
<span class="username">@{{ user | acct }}</span> <span class="username">@{{ user | acct }}</span>
<div class="description"> <div class="description">
<misskey-flavored-markdown v-if="user.description" :text="user.description" :author="user" :i="$store.state.i"/> <misskey-flavored-markdown v-if="user.description" :text="user.description" :author="user" :i="$store.state.i" :custom-emojis="user.emojis"/>
</div> </div>
</div> </div>
</div> </div>

View File

@ -4,10 +4,14 @@
<div class="banner" :style="u.bannerUrl ? `background-image: url(${u.bannerUrl})` : ''"></div> <div class="banner" :style="u.bannerUrl ? `background-image: url(${u.bannerUrl})` : ''"></div>
<mk-avatar class="avatar" :user="u" :disable-preview="true"/> <mk-avatar class="avatar" :user="u" :disable-preview="true"/>
<div class="title"> <div class="title">
<router-link class="name" :to="u | userPage">{{ u | userName }}</router-link> <router-link class="name" :to="u | userPage">
<misskey-flavored-markdown :text="u.name || u.username" :shouldBreak="false" :plainText="true" :custom-emojis="u.emojis"/>
</router-link>
<p class="username"><mk-acct :user="u"/></p> <p class="username"><mk-acct :user="u"/></p>
</div> </div>
<div class="description">{{ u.description }}</div> <div class="description">
<misskey-flavored-markdown v-if="u.description" :text="u.description" :author="u" :i="$store.state.i" :custom-emojis="u.emojis"/>
</div>
<div class="status"> <div class="status">
<div> <div>
<p>{{ $t('notes') }}</p><span>{{ u.notesCount }}</span> <p>{{ $t('notes') }}</p><span>{{ u.notesCount }}</span>

View File

@ -5,7 +5,9 @@
<div> <div>
<header> <header>
<mk-reaction-icon :reaction="notification.reaction"/> <mk-reaction-icon :reaction="notification.reaction"/>
<router-link :to="notification.user | userPage">{{ notification.user | userName }}</router-link> <router-link :to="notification.user | userPage">
<misskey-flavored-markdown :text="notification.user.name || notification.user.username" :shouldBreak="false" :plainText="true" :custom-emojis="notification.user.emojis"/>
</router-link>
<mk-time :time="notification.createdAt"/> <mk-time :time="notification.createdAt"/>
</header> </header>
<router-link class="note-ref" :to="notification.note | notePage" :title="getNoteSummary(notification.note)"> <router-link class="note-ref" :to="notification.note | notePage" :title="getNoteSummary(notification.note)">
@ -20,7 +22,9 @@
<div> <div>
<header> <header>
<fa icon="retweet"/> <fa icon="retweet"/>
<router-link :to="notification.user | userPage">{{ notification.user | userName }}</router-link> <router-link :to="notification.user | userPage">
<misskey-flavored-markdown :text="notification.user.name || notification.user.username" :shouldBreak="false" :plainText="true" :custom-emojis="notification.user.emojis"/>
</router-link>
<mk-time :time="notification.createdAt"/> <mk-time :time="notification.createdAt"/>
</header> </header>
<router-link class="note-ref" :to="notification.note | notePage" :title="getNoteSummary(notification.note.renote)"> <router-link class="note-ref" :to="notification.note | notePage" :title="getNoteSummary(notification.note.renote)">
@ -34,7 +38,9 @@
<div> <div>
<header> <header>
<fa icon="user-plus"/> <fa icon="user-plus"/>
<router-link :to="notification.user | userPage">{{ notification.user | userName }}</router-link> <router-link :to="notification.user | userPage">
<misskey-flavored-markdown :text="notification.user.name || notification.user.username" :shouldBreak="false" :plainText="true" :custom-emojis="notification.user.emojis"/>
</router-link>
<mk-time :time="notification.createdAt"/> <mk-time :time="notification.createdAt"/>
</header> </header>
</div> </div>
@ -45,7 +51,9 @@
<div> <div>
<header> <header>
<fa icon="user-clock"/> <fa icon="user-clock"/>
<router-link :to="notification.user | userPage">{{ notification.user | userName }}</router-link> <router-link :to="notification.user | userPage">
<misskey-flavored-markdown :text="notification.user.name || notification.user.username" :shouldBreak="false" :plainText="true" :custom-emojis="notification.user.emojis"/>
</router-link>
<mk-time :time="notification.createdAt"/> <mk-time :time="notification.createdAt"/>
</header> </header>
</div> </div>
@ -56,7 +64,9 @@
<div> <div>
<header> <header>
<fa icon="chart-pie"/> <fa icon="chart-pie"/>
<router-link :to="notification.user | userPage">{{ notification.user | userName }}</router-link> <router-link :to="notification.user | userPage">
<misskey-flavored-markdown :text="notification.user.name || notification.user.username" :shouldBreak="false" :plainText="true" :custom-emojis="notification.user.emojis"/>
</router-link>
<mk-time :time="notification.createdAt"/> <mk-time :time="notification.createdAt"/>
</header> </header>
<router-link class="note-ref" :to="notification.note | notePage" :title="getNoteSummary(notification.note)"> <router-link class="note-ref" :to="notification.note | notePage" :title="getNoteSummary(notification.note)">

View File

@ -16,13 +16,15 @@
<button class="menu" @click="menu" ref="menu"><fa icon="ellipsis-h"/></button> <button class="menu" @click="menu" ref="menu"><fa icon="ellipsis-h"/></button>
<mk-follow-button v-if="$store.getters.isSignedIn && user.id != $store.state.i.id" :user="user" class="follow" mini/> <mk-follow-button v-if="$store.getters.isSignedIn && user.id != $store.state.i.id" :user="user" class="follow" mini/>
<mk-avatar class="avatar" :user="user" :disable-preview="true"/> <mk-avatar class="avatar" :user="user" :disable-preview="true"/>
<span class="name">{{ user | userName }}</span> <span class="name">
<misskey-flavored-markdown :text="user.name || user.username" :shouldBreak="false" :plainText="true" :custom-emojis="user.emojis"/>
</span>
<span class="acct">@{{ user | acct }}</span> <span class="acct">@{{ user | acct }}</span>
</div> </div>
</header> </header>
<div class="info"> <div class="info">
<div class="description"> <div class="description">
<misskey-flavored-markdown v-if="user.description" :text="user.description" :author="user" :i="$store.state.i"/> <misskey-flavored-markdown v-if="user.description" :text="user.description" :author="user" :i="$store.state.i" :custom-emojis="user.emojis"/>
</div> </div>
<div class="counts"> <div class="counts">
<div> <div>

View File

@ -4,7 +4,9 @@
<header> <header>
<mk-avatar class="avatar" :user="user"/> <mk-avatar class="avatar" :user="user"/>
<i18n :path="isFollowing ? 'following' : 'followers'" tag="p"> <i18n :path="isFollowing ? 'following' : 'followers'" tag="p">
<router-link :to="user | userPage" place="user">{{ user | userName }}</router-link> <router-link :to="user | userPage" place="user">
<misskey-flavored-markdown :text="user.name || user.username" :shouldBreak="false" :plainText="true" :custom-emojis="user.emojis"/>
</router-link>
</i18n> </i18n>
</header> </header>
<div class="users"> <div class="users">

View File

@ -4,7 +4,9 @@
<div class="banner" ref="banner" :style="style" @click="onBannerClick"></div> <div class="banner" ref="banner" :style="style" @click="onBannerClick"></div>
<div class="fade"></div> <div class="fade"></div>
<div class="title"> <div class="title">
<p class="name">{{ user | userName }}</p> <p class="name">
<misskey-flavored-markdown :text="user.name || user.username" :shouldBreak="false" :plainText="true" :custom-emojis="user.emojis"/>
</p>
<div> <div>
<span class="username"><mk-acct :user="user" :detail="true" /></span> <span class="username"><mk-acct :user="user" :detail="true" /></span>
<span v-if="user.isBot" :title="$t('title')"><fa icon="robot"/></span> <span v-if="user.isBot" :title="$t('title')"><fa icon="robot"/></span>
@ -14,7 +16,7 @@
<mk-avatar class="avatar" :user="user" :disable-preview="true"/> <mk-avatar class="avatar" :user="user" :disable-preview="true"/>
<div class="body"> <div class="body">
<div class="description"> <div class="description">
<misskey-flavored-markdown v-if="user.description" :text="user.description" :author="user" :i="$store.state.i"/> <misskey-flavored-markdown v-if="user.description" :text="user.description" :author="user" :i="$store.state.i" :custom-emojis="user.emojis"/>
</div> </div>
<div class="info"> <div class="info">
<span class="location" v-if="user.host === null && user.profile.location"><fa icon="map-marker"/> {{ user.profile.location }}</span> <span class="location" v-if="user.host === null && user.profile.location"><fa icon="map-marker"/> {{ user.profile.location }}</span>

View File

@ -15,7 +15,9 @@
@click="() => os.apis.updateAvatar()" @click="() => os.apis.updateAvatar()"
:title="$t('update-avatar')" :title="$t('update-avatar')"
/> />
<router-link class="name" :to="$store.state.i | userPage">{{ $store.state.i | userName }}</router-link> <router-link class="name" :to="$store.state.i | userPage">
<misskey-flavored-markdown :text="$store.state.i.name || $store.state.i.username" :shouldBreak="false" :plainText="true" :custom-emojis="$store.state.i.emojis"/>
</router-link>
<p class="username">@{{ $store.state.i | acct }}</p> <p class="username">@{{ $store.state.i | acct }}</p>
</div> </div>
</mk-widget-container> </mk-widget-container>

View File

@ -13,7 +13,9 @@
<div class="user" v-for="_user in users"> <div class="user" v-for="_user in users">
<mk-avatar class="avatar" :user="_user"/> <mk-avatar class="avatar" :user="_user"/>
<div class="body"> <div class="body">
<router-link class="name" :to="_user | userPage" v-user-preview="_user.id">{{ _user | userName }}</router-link> <router-link class="name" :to="_user | userPage" v-user-preview="_user.id">
<misskey-flavored-markdown :text="_user.name || _user.username" :shouldBreak="false" :plainText="true" :custom-emojis="_user.emojis"/>
</router-link>
<p class="username">@{{ _user | acct }}</p> <p class="username">@{{ _user | acct }}</p>
</div> </div>
</div> </div>

View File

@ -2,7 +2,9 @@
<div class="mk-note-card"> <div class="mk-note-card">
<a :href="note | notePage"> <a :href="note | notePage">
<header> <header>
<img :src="note.user.avatarUrl" alt="avatar"/><h3>{{ note.user | userName }}</h3> <img :src="note.user.avatarUrl" alt="avatar"/><h3>
<misskey-flavored-markdown :text="note.user.name || note.user.username" :shouldBreak="false" :plainText="true" :custom-emojis="note.user.emojis"/>
</h3>
</header> </header>
<div> <div>
{{ text }} {{ text }}

View File

@ -20,7 +20,9 @@
<header> <header>
<mk-avatar class="avatar" :user="appearNote.user"/> <mk-avatar class="avatar" :user="appearNote.user"/>
<div> <div>
<router-link class="name" :to="appearNote.user | userPage">{{ appearNote.user | userName }}</router-link> <router-link class="name" :to="appearNote.user | userPage">
<misskey-flavored-markdown :text="appearNote.user.name || appearNote.user.username" :shouldBreak="false" :plainText="true" :custom-emojis="appearNote.user.emojis"/>
</router-link>
<span class="username"><mk-acct :user="appearNote.user"/></span> <span class="username"><mk-acct :user="appearNote.user"/></span>
</div> </div>
</header> </header>

View File

@ -3,7 +3,7 @@
<template v-if="notification.type == 'reaction'"> <template v-if="notification.type == 'reaction'">
<mk-avatar class="avatar" :user="notification.user"/> <mk-avatar class="avatar" :user="notification.user"/>
<div class="text"> <div class="text">
<p><mk-reaction-icon :reaction="notification.reaction"/>{{ notification.user | userName }}</p> <p><mk-reaction-icon :reaction="notification.reaction"/><misskey-flavored-markdown :text="notification.user.name || notification.user.username" :shouldBreak="false" :plainText="true" :custom-emojis="notification.user.emojis"/></p>
<p class="note-ref"><fa icon="quote-left"/>{{ getNoteSummary(notification.note) }}<fa icon="quote-right"/></p> <p class="note-ref"><fa icon="quote-left"/>{{ getNoteSummary(notification.note) }}<fa icon="quote-right"/></p>
</div> </div>
</template> </template>
@ -11,7 +11,7 @@
<template v-if="notification.type == 'renote'"> <template v-if="notification.type == 'renote'">
<mk-avatar class="avatar" :user="notification.note.user"/> <mk-avatar class="avatar" :user="notification.note.user"/>
<div class="text"> <div class="text">
<p><fa icon="retweet"/>{{ notification.note.user | userName }}</p> <p><fa icon="retweet"/><misskey-flavored-markdown :text="notification.note.user.name || notification.note.user.username" :shouldBreak="false" :plainText="true" :custom-emojis="notification.note.user.emojis"/></p>
<p class="note-ref"><fa icon="quote-left"/>{{ getNoteSummary(notification.note.renote) }}<fa icon="quote-right"/></p> <p class="note-ref"><fa icon="quote-left"/>{{ getNoteSummary(notification.note.renote) }}<fa icon="quote-right"/></p>
</div> </div>
</template> </template>
@ -19,7 +19,7 @@
<template v-if="notification.type == 'quote'"> <template v-if="notification.type == 'quote'">
<mk-avatar class="avatar" :user="notification.note.user"/> <mk-avatar class="avatar" :user="notification.note.user"/>
<div class="text"> <div class="text">
<p><fa icon="quote-left"/>{{ notification.note.user | userName }}</p> <p><fa icon="quote-left"/><misskey-flavored-markdown :text="notification.note.user.name || notification.note.user.username" :shouldBreak="false" :plainText="true" :custom-emojis="notification.note.user.emojis"/></p>
<p class="note-preview">{{ getNoteSummary(notification.note) }}</p> <p class="note-preview">{{ getNoteSummary(notification.note) }}</p>
</div> </div>
</template> </template>
@ -27,21 +27,21 @@
<template v-if="notification.type == 'follow'"> <template v-if="notification.type == 'follow'">
<mk-avatar class="avatar" :user="notification.user"/> <mk-avatar class="avatar" :user="notification.user"/>
<div class="text"> <div class="text">
<p><fa icon="user-plus"/>{{ notification.user | userName }}</p> <p><fa icon="user-plus"/><misskey-flavored-markdown :text="notification.user.name || notification.user.username" :shouldBreak="false" :plainText="true" :custom-emojis="notification.user.emojis"/></p>
</div> </div>
</template> </template>
<template v-if="notification.type == 'receiveFollowRequest'"> <template v-if="notification.type == 'receiveFollowRequest'">
<mk-avatar class="avatar" :user="notification.user"/> <mk-avatar class="avatar" :user="notification.user"/>
<div class="text"> <div class="text">
<p><fa icon="user-clock"/>{{ notification.user | userName }}</p> <p><fa icon="user-clock"/><misskey-flavored-markdown :text="notification.user.name || notification.user.username" :shouldBreak="false" :plainText="true" :custom-emojis="notification.user.emojis"/></p>
</div> </div>
</template> </template>
<template v-if="notification.type == 'reply'"> <template v-if="notification.type == 'reply'">
<mk-avatar class="avatar" :user="notification.note.user"/> <mk-avatar class="avatar" :user="notification.note.user"/>
<div class="text"> <div class="text">
<p><fa icon="reply"/>{{ notification.note.user | userName }}</p> <p><fa icon="reply"/><misskey-flavored-markdown :text="notification.note.user.name || notification.note.user.username" :shouldBreak="false" :plainText="true" :custom-emojis="notification.note.user.emojis"/></p>
<p class="note-preview">{{ getNoteSummary(notification.note) }}</p> <p class="note-preview">{{ getNoteSummary(notification.note) }}</p>
</div> </div>
</template> </template>
@ -49,7 +49,7 @@
<template v-if="notification.type == 'mention'"> <template v-if="notification.type == 'mention'">
<mk-avatar class="avatar" :user="notification.note.user"/> <mk-avatar class="avatar" :user="notification.note.user"/>
<div class="text"> <div class="text">
<p><fa icon="at"/>{{ notification.note.user | userName }}</p> <p><fa icon="at"/><misskey-flavored-markdown :text="notification.note.user.name || notification.note.user.username" :shouldBreak="false" :plainText="true" :custom-emojis="notification.note.user.emojis"/></p>
<p class="note-preview">{{ getNoteSummary(notification.note) }}</p> <p class="note-preview">{{ getNoteSummary(notification.note) }}</p>
</div> </div>
</template> </template>
@ -57,7 +57,7 @@
<template v-if="notification.type == 'poll_vote'"> <template v-if="notification.type == 'poll_vote'">
<mk-avatar class="avatar" :user="notification.user"/> <mk-avatar class="avatar" :user="notification.user"/>
<div class="text"> <div class="text">
<p><fa icon="chart-pie"/>{{ notification.user | userName }}</p> <p><fa icon="chart-pie"/><misskey-flavored-markdown :text="notification.user.name || notification.user.username" :shouldBreak="false" :plainText="true" :custom-emojis="notification.user.emojis"/></p>
<p class="note-ref"><fa icon="quote-left"/>{{ getNoteSummary(notification.note) }}<fa icon="quote-right"/></p> <p class="note-ref"><fa icon="quote-left"/>{{ getNoteSummary(notification.note) }}<fa icon="quote-right"/></p>
</div> </div>
</template> </template>

View File

@ -5,7 +5,7 @@
<div> <div>
<header> <header>
<mk-reaction-icon :reaction="notification.reaction"/> <mk-reaction-icon :reaction="notification.reaction"/>
<router-link :to="notification.user | userPage">{{ notification.user | userName }}</router-link> <router-link :to="notification.user | userPage"><misskey-flavored-markdown :text="notification.user.name || notification.user.username" :shouldBreak="false" :plainText="true" :custom-emojis="notification.user.emojis"/></router-link>
<mk-time :time="notification.createdAt"/> <mk-time :time="notification.createdAt"/>
</header> </header>
<router-link class="note-ref" :to="notification.note | notePage" :title="getNoteSummary(notification.note)"> <router-link class="note-ref" :to="notification.note | notePage" :title="getNoteSummary(notification.note)">
@ -20,7 +20,7 @@
<div> <div>
<header> <header>
<fa icon="retweet"/> <fa icon="retweet"/>
<router-link :to="notification.user | userPage">{{ notification.user | userName }}</router-link> <router-link :to="notification.user | userPage"><misskey-flavored-markdown :text="notification.user.name || notification.user.username" :shouldBreak="false" :plainText="true" :custom-emojis="notification.user.emojis"/></router-link>
<mk-time :time="notification.createdAt"/> <mk-time :time="notification.createdAt"/>
</header> </header>
<router-link class="note-ref" :to="notification.note | notePage" :title="getNoteSummary(notification.note.renote)"> <router-link class="note-ref" :to="notification.note | notePage" :title="getNoteSummary(notification.note.renote)">
@ -34,7 +34,7 @@
<div> <div>
<header> <header>
<fa icon="user-plus"/> <fa icon="user-plus"/>
<router-link :to="notification.user | userPage">{{ notification.user | userName }}</router-link> <router-link :to="notification.user | userPage"><misskey-flavored-markdown :text="notification.user.name || notification.user.username" :shouldBreak="false" :plainText="true" :custom-emojis="notification.user.emojis"/></router-link>
<mk-time :time="notification.createdAt"/> <mk-time :time="notification.createdAt"/>
</header> </header>
</div> </div>
@ -45,7 +45,7 @@
<div> <div>
<header> <header>
<fa icon="user-clock"/> <fa icon="user-clock"/>
<router-link :to="notification.user | userPage">{{ notification.user | userName }}</router-link> <router-link :to="notification.user | userPage"><misskey-flavored-markdown :text="notification.user.name || notification.user.username" :shouldBreak="false" :plainText="true" :custom-emojis="notification.user.emojis"/></router-link>
<mk-time :time="notification.createdAt"/> <mk-time :time="notification.createdAt"/>
</header> </header>
</div> </div>
@ -56,7 +56,7 @@
<div> <div>
<header> <header>
<fa icon="chart-pie"/> <fa icon="chart-pie"/>
<router-link :to="notification.user | userPage">{{ notification.user | userName }}</router-link> <router-link :to="notification.user | userPage"><misskey-flavored-markdown :text="notification.user.name || notification.user.username" :shouldBreak="false" :plainText="true" :custom-emojis="notification.user.emojis"/></router-link>
<mk-time :time="notification.createdAt"/> <mk-time :time="notification.createdAt"/>
</header> </header>
<router-link class="note-ref" :to="notification.note | notePage" :title="getNoteSummary(notification.note)"> <router-link class="note-ref" :to="notification.note | notePage" :title="getNoteSummary(notification.note)">

View File

@ -13,7 +13,10 @@
<mk-note-preview class="preview" v-if="reply" :note="reply"/> <mk-note-preview class="preview" v-if="reply" :note="reply"/>
<mk-note-preview class="preview" v-if="renote" :note="renote"/> <mk-note-preview class="preview" v-if="renote" :note="renote"/>
<div v-if="visibility == 'specified'" class="visibleUsers"> <div v-if="visibility == 'specified'" class="visibleUsers">
<span v-for="u in visibleUsers">{{ u | userName }}<a @click="removeVisibleUser(u)">[x]</a></span> <span v-for="u in visibleUsers">
<misskey-flavored-markdown :text="u.name || u.username" :shouldBreak="false" :plainText="true" :custom-emojis="u.emojis"/>
<a @click="removeVisibleUser(u)">[x]</a>
</span>
<a @click="addVisibleUser">+{{ $t('add-visible-user') }}</a> <a @click="addVisibleUser">+{{ $t('add-visible-user') }}</a>
</div> </div>
<input v-show="useCw" ref="cw" v-model="cw" :placeholder="$t('annotations')" v-autocomplete="'cw'"> <input v-show="useCw" ref="cw" v-model="cw" :placeholder="$t('annotations')" v-autocomplete="'cw'">

View File

@ -11,7 +11,9 @@
<div class="body" v-if="isOpen"> <div class="body" v-if="isOpen">
<router-link class="me" v-if="$store.getters.isSignedIn" :to="`/@${$store.state.i.username}`"> <router-link class="me" v-if="$store.getters.isSignedIn" :to="`/@${$store.state.i.username}`">
<img class="avatar" :src="$store.state.i.avatarUrl" alt="avatar"/> <img class="avatar" :src="$store.state.i.avatarUrl" alt="avatar"/>
<p class="name">{{ $store.state.i | userName }}</p> <p class="name">
<misskey-flavored-markdown :text="$store.state.i.name || $store.state.i.username" :shouldBreak="false" :plainText="true" :custom-emojis="$store.state.i.emojis"/>
</p>
</router-link> </router-link>
<div class="links"> <div class="links">
<ul> <ul>

View File

@ -3,7 +3,9 @@
<header :style="user.bannerUrl ? `background-image: url(${user.bannerUrl})` : ''"> <header :style="user.bannerUrl ? `background-image: url(${user.bannerUrl})` : ''">
<mk-avatar class="avatar" :user="user"/> <mk-avatar class="avatar" :user="user"/>
</header> </header>
<a class="name" :href="user | userPage" target="_blank">{{ user | userName }}</a> <a class="name" :href="user | userPage" target="_blank">
<misskey-flavored-markdown :text="user.name || user.username" :shouldBreak="false" :plainText="true" :custom-emojis="user.emojis"/>
</a>
<p class="username"><mk-acct :user="user"/></p> <p class="username"><mk-acct :user="user"/></p>
<mk-follow-button class="follow-button" :user="user"/> <mk-follow-button class="follow-button" :user="user"/>
</div> </div>

View File

@ -3,11 +3,15 @@
<mk-avatar class="avatar" :user="user"/> <mk-avatar class="avatar" :user="user"/>
<div class="main"> <div class="main">
<header> <header>
<router-link class="name" :to="user | userPage">{{ user | userName }}</router-link> <router-link class="name" :to="user | userPage">
<misskey-flavored-markdown :text="user.name || user.username" :shouldBreak="false" :plainText="true" :custom-emojis="user.emojis"/>
</router-link>
<span class="username"><mk-acct :user="user"/></span> <span class="username"><mk-acct :user="user"/></span>
</header> </header>
<div class="body"> <div class="body">
<div class="description">{{ user.description }}</div> <div class="description">
<misskey-flavored-markdown v-if="u.description" :text="u.description" :author="u" :i="$store.state.i" :custom-emojis="u.emojis"/>
</div>
</div> </div>
</div> </div>
</div> </div>

View File

@ -4,7 +4,9 @@
<main> <main>
<div v-for="req in requests"> <div v-for="req in requests">
<router-link :key="req.id" :to="req.follower | userPage">{{ req.follower | userName }}</router-link> <router-link :key="req.id" :to="req.follower | userPage">
<misskey-flavored-markdown :text="req.follower.name || req.follower.username" :shouldBreak="false" :plainText="true" :custom-emojis="req.follower.emojis"/>
</router-link>
<span> <span>
<a @click="accept(req.follower)">{{ $t('accept') }}</a>|<a @click="reject(req.follower)">{{ $t('reject') }}</a> <a @click="accept(req.follower)">{{ $t('accept') }}</a>|<a @click="reject(req.follower)">{{ $t('reject') }}</a>
</span> </span>

View File

@ -4,7 +4,9 @@
<main v-if="!fetching"> <main v-if="!fetching">
<ul> <ul>
<li v-for="user in users" :key="user.id"><router-link :to="user | userPage">{{ user | userName }}</router-link></li> <li v-for="user in users" :key="user.id"><router-link :to="user | userPage">
<misskey-flavored-markdown :text="user.name || user.username" :shouldBreak="false" :plainText="true" :custom-emojis="user.emojis"/>
</router-link></li>
</ul> </ul>
</main> </main>
</mk-ui> </mk-ui>

View File

@ -1,6 +1,8 @@
<template> <template>
<mk-ui> <mk-ui>
<template slot="header" v-if="!fetching"><img :src="user.avatarUrl" alt="">{{ user | userName }}</template> <template slot="header" v-if="!fetching"><img :src="user.avatarUrl" alt="">
<misskey-flavored-markdown :text="user.name || user.username" :shouldBreak="false" :plainText="true" :custom-emojis="user.emojis"/>
</template>
<main v-if="!fetching"> <main v-if="!fetching">
<div class="is-suspended" v-if="user.isSuspended"><p><fa icon="exclamation-triangle"/> {{ $t('is-suspended') }}</p></div> <div class="is-suspended" v-if="user.isSuspended"><p><fa icon="exclamation-triangle"/> {{ $t('is-suspended') }}</p></div>
<div class="is-remote" v-if="user.host != null"><p><fa icon="exclamation-triangle"/> {{ $t('@.is-remote-user') }}<a :href="user.url || user.uri" target="_blank">{{ $t('@.view-on-remote') }}</a></p></div> <div class="is-remote" v-if="user.host != null"><p><fa icon="exclamation-triangle"/> {{ $t('@.is-remote-user') }}<a :href="user.url || user.uri" target="_blank">{{ $t('@.view-on-remote') }}</a></p></div>
@ -15,12 +17,12 @@
<mk-follow-button v-if="$store.getters.isSignedIn && $store.state.i.id != user.id" :user="user"/> <mk-follow-button v-if="$store.getters.isSignedIn && $store.state.i.id != user.id" :user="user"/>
</div> </div>
<div class="title"> <div class="title">
<h1>{{ user | userName }}</h1> <h1><misskey-flavored-markdown :text="user.name || user.username" :shouldBreak="false" :plainText="true" :custom-emojis="user.emojis"/></h1>
<span class="username"><mk-acct :user="user" :detail="true" /></span> <span class="username"><mk-acct :user="user" :detail="true" /></span>
<span class="followed" v-if="user.isFollowed">{{ $t('follows-you') }}</span> <span class="followed" v-if="user.isFollowed">{{ $t('follows-you') }}</span>
</div> </div>
<div class="description"> <div class="description">
<misskey-flavored-markdown v-if="user.description" :text="user.description" :author="user" :i="$store.state.i"/> <misskey-flavored-markdown v-if="user.description" :text="user.description" :author="user" :i="$store.state.i" :custom-emojis="user.emojis"/>
</div> </div>
<div class="info"> <div class="info">
<p class="location" v-if="user.host === null && user.profile.location"> <p class="location" v-if="user.host === null && user.profile.location">

View File

@ -8,7 +8,9 @@
:src="$store.state.i.avatarUrl" :src="$store.state.i.avatarUrl"
alt="avatar" alt="avatar"
/> />
<router-link :class="$style.name" :to="$store.state.i | userPage">{{ $store.state.i | userName }}</router-link> <router-link :class="$style.name" :to="$store.state.i | userPage">
<misskey-flavored-markdown :text="$store.state.i.name || $store.state.i.username" :shouldBreak="false" :plainText="true" :custom-emojis="$store.state.i.emojis"/>
</router-link>
</mk-widget-container> </mk-widget-container>
</div> </div>
</template> </template>

View File

@ -1,13 +1,13 @@
import parser, { Node } from './parser'; import parser, { Node, plainParser } from './parser';
import * as A from '../prelude/array'; import * as A from '../prelude/array';
import * as S from '../prelude/string'; import * as S from '../prelude/string';
export default (source: string): Node[] => { export default (source: string, plainText = false): Node[] => {
if (source == null || source == '') { if (source == null || source == '') {
return null; return null;
} }
let nodes: Node[] = parser.root.tryParse(source); let nodes: Node[] = plainText ? plainParser.root.tryParse(source) : parser.root.tryParse(source);
const combineText = (es: Node[]): Node => const combineText = (es: Node[]): Node =>
({ name: 'text', props: { text: S.concat(es.map(e => e.props.text)) } }); ({ name: 'text', props: { text: S.concat(es.map(e => e.props.text)) } });

View File

@ -64,6 +64,29 @@ const newline = P((input, i) => {
} }
}); });
export const plainParser = P.createLanguage({
root: r => P.alt(
r.emoji,
r.text
).atLeast(1),
text: () => P.any.map(x => makeNode('text', { text: x })),
//#region Emoji
emoji: r =>
P.alt(
P.regexp(/:([a-z0-9_+-]+):/i, 1)
.map(x => makeNode('emoji', {
name: x
})),
P.regexp(emojiRegex)
.map(x => makeNode('emoji', {
emoji: x
})),
),
//#endregion
});
const mfm = P.createLanguage({ const mfm = P.createLanguage({
root: r => P.alt( root: r => P.alt(
r.big, r.big,

View File

@ -11,6 +11,7 @@ import { getFriendIds } from '../server/api/common/get-friends';
import config from '../config'; import config from '../config';
import FollowRequest from './follow-request'; import FollowRequest from './follow-request';
import fetchMeta from '../misc/fetch-meta'; import fetchMeta from '../misc/fetch-meta';
import Emoji from './emoji';
const User = db.get<IUser>('users'); const User = db.get<IUser>('users');
@ -46,6 +47,7 @@ type IUserBase = {
description: string; description: string;
lang?: string; lang?: string;
pinnedNoteIds: mongo.ObjectID[]; pinnedNoteIds: mongo.ObjectID[];
emojis?: string[];
/** /**
* *
@ -247,6 +249,7 @@ export const pack = (
host: true, host: true,
avatarColor: true, avatarColor: true,
avatarUrl: true, avatarUrl: true,
emojis: true,
isCat: true, isCat: true,
isBot: true, isBot: true,
isAdmin: true, isAdmin: true,
@ -377,6 +380,16 @@ export const pack = (
delete _user.hasUnreadMentions; delete _user.hasUnreadMentions;
} }
// カスタム絵文字添付
if (_user.emojis) {
_user.emojis = Emoji.find({
name: { $in: _user.emojis },
host: _user.host
}, {
fields: { _id: false }
});
}
// resolve promises in _user object // resolve promises in _user object
_user = await rap(_user); _user = await rap(_user);

View File

@ -164,7 +164,7 @@ export async function resolveNote(value: string | IObject, resolver?: Resolver):
return await createNote(uri, resolver); return await createNote(uri, resolver);
} }
async function extractEmojis(tags: ITag[], host_: string) { export async function extractEmojis(tags: ITag[], host_: string) {
const host = toUnicode(host_.toLowerCase()); const host = toUnicode(host_.toLowerCase());
if (!tags) return []; if (!tags) return [];

View File

@ -12,10 +12,11 @@ import Meta from '../../../models/meta';
import htmlToMFM from '../../../mfm/html-to-mfm'; import htmlToMFM from '../../../mfm/html-to-mfm';
import usersChart from '../../../chart/users'; import usersChart from '../../../chart/users';
import { URL } from 'url'; import { URL } from 'url';
import { resolveNote } from './note'; import { resolveNote, extractEmojis } from './note';
import registerInstance from '../../../services/register-instance'; import registerInstance from '../../../services/register-instance';
import Instance from '../../../models/instance'; import Instance from '../../../models/instance';
import getDriveFileUrl from '../../../misc/get-drive-file-url'; import getDriveFileUrl from '../../../misc/get-drive-file-url';
import { IEmoji } from '../../../models/emoji';
const log = debug('misskey:activitypub'); const log = debug('misskey:activitypub');
@ -234,6 +235,21 @@ export async function createPerson(uri: string, resolver?: Resolver): Promise<IU
user.bannerColor = bannerColor; user.bannerColor = bannerColor;
//#endregion //#endregion
//#region カスタム絵文字取得
const emojis = await extractEmojis(person.tag, host).catch(e => {
console.log(`extractEmojis: ${e}`);
return [] as IEmoji[];
});
const emojiNames = emojis.map(emoji => emoji.name);
await User.update({ _id: user._id }, {
$set: {
emojis: emojiNames
}
});
//#endregion
await updateFeatured(user._id).catch(err => console.log(err)); await updateFeatured(user._id).catch(err => console.log(err));
return user; return user;
@ -301,6 +317,14 @@ export async function updatePerson(uri: string, resolver?: Resolver, hint?: obje
: resolveImage(exist, img).catch(() => null) : resolveImage(exist, img).catch(() => null)
))); )));
// カスタム絵文字取得
const emojis = await extractEmojis(person.tag, exist.host).catch(e => {
console.log(`extractEmojis: ${e}`);
return [] as IEmoji[];
});
const emojiNames = emojis.map(emoji => emoji.name);
// Update user // Update user
await User.update({ _id: exist._id }, { await User.update({ _id: exist._id }, {
$set: { $set: {
@ -314,6 +338,7 @@ export async function updatePerson(uri: string, resolver?: Resolver, hint?: obje
bannerUrl: getDriveFileUrl(banner, false), bannerUrl: getDriveFileUrl(banner, false),
avatarColor: avatar && avatar.metadata.properties.avgColor ? avatar.metadata.properties.avgColor : null, avatarColor: avatar && avatar.metadata.properties.avgColor ? avatar.metadata.properties.avgColor : null,
bannerColor: banner && banner.metadata.properties.avgColor ? banner.metadata.properties.avgColor : null, bannerColor: banner && banner.metadata.properties.avgColor ? banner.metadata.properties.avgColor : null,
emojis: emojiNames,
description: htmlToMFM(person.summary), description: htmlToMFM(person.summary),
followersCount, followersCount,
followingCount, followingCount,

View File

@ -137,7 +137,7 @@ export default async function renderNote(note: INote, dive = true): Promise<any>
}; };
} }
async function getEmojis(names: string[]): Promise<IEmoji[]> { export async function getEmojis(names: string[]): Promise<IEmoji[]> {
if (names == null || names.length < 1) return []; if (names == null || names.length < 1) return [];
const emojis = await Promise.all( const emojis = await Promise.all(

View File

@ -5,6 +5,8 @@ import { ILocalUser } from '../../../models/user';
import toHtml from '../../../mfm/html'; import toHtml from '../../../mfm/html';
import parse from '../../../mfm/parse'; import parse from '../../../mfm/parse';
import DriveFile from '../../../models/drive-file'; import DriveFile from '../../../models/drive-file';
import { getEmojis } from './note';
import renderEmoji from './emoji';
export default async (user: ILocalUser) => { export default async (user: ILocalUser) => {
const id = `${config.url}/users/${user._id}`; const id = `${config.url}/users/${user._id}`;
@ -36,6 +38,13 @@ export default async (user: ILocalUser) => {
value: `<a href="https://discordapp.com/users/${user.discord.id}" rel="me nofollow noopener" target="_blank"><span>@${user.discord.username}#${user.discord.discriminator}</span></a>` value: `<a href="https://discordapp.com/users/${user.discord.id}" rel="me nofollow noopener" target="_blank"><span>@${user.discord.username}#${user.discord.discriminator}</span></a>`
}); });
const emojis = await getEmojis(user.emojis);
const apemojis = emojis.map(emoji => renderEmoji(emoji));
const tag = [
...apemojis,
];
return { return {
type: user.isBot ? 'Service' : 'Person', type: user.isBot ? 'Service' : 'Person',
id, id,
@ -51,6 +60,7 @@ export default async (user: ILocalUser) => {
summary: toHtml(parse(user.description)), summary: toHtml(parse(user.description)),
icon: user.avatarId && renderImage(avatar), icon: user.avatarId && renderImage(avatar),
image: user.bannerId && renderImage(banner), image: user.bannerId && renderImage(banner),
tag,
manuallyApprovesFollowers: user.isLocked, manuallyApprovesFollowers: user.isLocked,
publicKey: renderKey(user), publicKey: renderKey(user),
isCat: user.isCat, isCat: user.isCat,

View File

@ -6,6 +6,8 @@ import acceptAllFollowRequests from '../../../../services/following/requests/acc
import { publishToFollowers } from '../../../../services/i/update'; import { publishToFollowers } from '../../../../services/i/update';
import define from '../../define'; import define from '../../define';
import getDriveFileUrl from '../../../../misc/get-drive-file-url'; import getDriveFileUrl from '../../../../misc/get-drive-file-url';
import parse from '../../../../mfm/parse';
import { extractEmojis } from '../../../../services/note/create';
const langmap = require('langmap'); const langmap = require('langmap');
export const meta = { export const meta = {
@ -191,6 +193,24 @@ export default define(meta, (ps, user, app) => new Promise(async (res, rej) => {
} }
} }
//#region emojis
if (updates.name != null || updates.description != null) {
let emojis = [] as string[];
if (updates.name != null) {
const match = updates.name.match(/:\w{1,100}:/g) as string[];
if (match) emojis = emojis.concat(match.map(m => m.replace(/:(\w+):/, '$1')));
}
if (updates.description != null) {
const tokens = parse(updates.description);
emojis = emojis.concat(extractEmojis(tokens));
}
updates.emojis = emojis;
}
//#endregion
await User.update(user._id, { await User.update(user._id, {
$set: updates $set: updates
}); });

View File

@ -482,7 +482,7 @@ function extractHashtags(tokens: ReturnType<typeof parse>): string[] {
return unique(hashtags); return unique(hashtags);
} }
function extractEmojis(tokens: ReturnType<typeof parse>): string[] { export function extractEmojis(tokens: ReturnType<typeof parse>): string[] {
const emojis: string[] = []; const emojis: string[] = [];
const extract = (tokens: Node[]) => { const extract = (tokens: Node[]) => {