summaryrefslogtreecommitdiff
path: root/packages/frontend-embed/src/components
diff options
context:
space:
mode:
authorかっこかり <67428053+kakkokari-gtyih@users.noreply.github.com>2024-09-09 20:57:36 +0900
committerGitHub <noreply@github.com>2024-09-09 20:57:36 +0900
commit2cbe1d1210a5745787f37069ecb59b8f6c03c224 (patch)
tree9acb1e675d2ae85f7f1f0f34f6acdc4965bff3f9 /packages/frontend-embed/src/components
parentrefactor(misskey-js): warnを除去 (#14520) (diff)
downloadsharkey-2cbe1d1210a5745787f37069ecb59b8f6c03c224.tar.gz
sharkey-2cbe1d1210a5745787f37069ecb59b8f6c03c224.tar.bz2
sharkey-2cbe1d1210a5745787f37069ecb59b8f6c03c224.zip
feat(frontend): ノート・ユーザータイムライン埋め込み (#13929)
* fix * navhookをbootに移動 * サーバーサイドのbootも分けるように * 埋め込みページかどうかの判定は最初の一回だけに * tooltipは出せるように * fix design * 埋め込み独自のtooltipを削除 * ロジックの分岐が多かったMkNoteDetailedを分離 * fix indent * プレビュー用iframeにフォーカスが当たるのを修正 * popupの制御を出す側で行うように * パラメータが逆になっていたのを修正 * Update MkEmbedCodeGenDialog.vue * fix * eliminate misskey-js lint warns * fix * add appropriate attributes to embed html * enhance: サーバーサイドのembed系をさらに分離 * enhance: embed routerを分離(route定義をboot時に変更できるようにする改修を含む) * type * lint * fix indent * server-side styleを完全に分離 * Revert "refactor: 画面サイズのしきい値をconstにまとめる" This reverts commit 05ca36f400889456981e89489ae0ae242fa09b67. * fix * revert all changes in base.pug * embedドメインをまとめた * embedドメインをまとめた * prevent calling contextmenu in embed page by stopping at the caller * fix import * fix import * improve directory structure * fix import * register timeline ui as a container * wa- * rename * wa- * Update EmMediaList.vue * Update EmMediaList.vue * Update EmMediaList.vue * Update EmMediaImage.vue * Update EmNote.vue * revert mkmedialist changes * 戻し漏れ * wip * tweak embed media ui * revert original media components * Update boot.embed.js * rename * wip * Update MkNote.vue * wip * Update MkSubNoteContent.vue * Update EmNote.vue * Update packages/frontend/src/router/definition.ts * Revert "Update packages/frontend/src/router/definition.ts" This reverts commit 937ae44521cdb0f250796943b20142b65f8ed944. * refactor EmMediaImage * fix import * remove unused imports * Update router.ts * wip * Update boot.ts * wip * wip * wip * wip * Update EmNote.vue * Update EmNote.vue * Create EmA.vue * Create EmAvatar.vue * Update EmAvatar.vue * wip * wip * wip * Create EmImgWithBlurhash.vue * Update EmImgWithBlurhash.vue * Create EmPagination.vue * wip * Update boot.ts * wip * wip * wi@p * wip * wip * wiop * wip * wip * wip * wip * wip * wip * wip * wip * wip * wip * Update boot.ts * wip * Update MkMisskeyFlavoredMarkdown.ts * wip * wip * wip * wip * wip * Update post-message.ts * wip * Update EmNoteDetailed.vue * Update EmNoteDetailed.vue * Create instance.ts * Update EmNoteDetailed.vue * wip * Update EmNoteDetailed.vue * wip * wip * wip * Update pnpm-lock.yaml * wip * wip * wp * wip * Update ClientServerService.ts * wip * Update boot.ts * Update vite.config.local-dev.ts * Update vite.config.ts * Create index.html * wa- * wip * Update boot.ts * wip * wip * wip * wip * wip * wip * wip * wip * wip * Create EmLink.vue * Create EmMention.vue * Update EmMfm.ts * wip * wip * wip * wip * Update vite.config.ts * Update boot.ts * Update EmA.vue * うぃp * wip * wip * Create EmError.vue * wip * Update MkEmbedCodeGenDialog.vue * Update EmNote.vue * wip * wip * Update user-timeline.vue * Update check-spdx-license-id.yml * wip * wip * style(frontend-shared): lint fixes on build.js * fix(frontend-shared): include `*.{js,json}` files in js-built * wip * use alias * refactor * refactor * Update scroll.ts * refactor * refactor * refactor * wip * wip * wip * wip * Update roles.vue * Update branding.vue * wip * wip * wip * Update page.vue * wip * fix import * add missing css variables * 絵文字をtwemojiに変更 クライアントデフォルトにあわせるため * force empoll readonly * fix compiler error * fix broken imports * tweak button style * run api extractor * fix storybook theme preloads * fix storybook instance imports * Update preview.ts * Update preview.ts * Update preview.ts * Revert "Update preview.ts" This reverts commit 12bab1c6fbd3baf753515df760ff19d027b85155. * Revert "Update preview.ts" This reverts commit 5c0ce01dbdf2194ffe94aba950f747a9968f29c4. * Revert "Update preview.ts" This reverts commit f4863524d7e5ca0f25470808849c24a72bea000a. * Revert "fix storybook instance imports" This reverts commit ed8eabb246edf731d31adffbe3c77c539e53ae9e. * Revert "wip" This reverts commit d3c1926519878155193a1654f49141e515d49683. * Revert "Update page.vue" This reverts commit 27c7900b0c1ae296b56075e8a9c22585d9cd744b. * Revert "Update branding.vue" This reverts commit c08ccb65ba66774c3e2b3dcfc6153004b5c0aa16. * Revert "Update roles.vue" This reverts commit 1488b670660cb1803d17d8f5c78f2d79e59fa52d. * Revert "wip" This reverts commit aab1c769814b08c257cad3025422a0eea3bfba4f. * refactor: use common media proxy * fix imports * fix * fix: MediaProxyの初期化を保証する(storybook対策?) * enhance(frontend-embed): improve embedParams provide * fix(backend): MK_DEV_PREFER=backendのときにembed viteが読み込めないのを修正 * fix * embed-pageを共通化 * fix import * fix import * fix import * const.jsを共通化 (たぶんrevertしすぎた) * fix type error * fix duplicated import * fix lint * fix * コメントとして残す * sharedとembedをlint対象にする * lint * attempt to fix eslint (frontend-shared) * lint fixes --------- Co-authored-by: syuilo <4439005+syuilo@users.noreply.github.com> Co-authored-by: zyoshoka <107108195+zyoshoka@users.noreply.github.com>
Diffstat (limited to 'packages/frontend-embed/src/components')
-rw-r--r--packages/frontend-embed/src/components/EmA.vue21
-rw-r--r--packages/frontend-embed/src/components/EmAcct.vue24
-rw-r--r--packages/frontend-embed/src/components/EmAvatar.vue250
-rw-r--r--packages/frontend-embed/src/components/EmCustomEmoji.vue101
-rw-r--r--packages/frontend-embed/src/components/EmEmoji.vue26
-rw-r--r--packages/frontend-embed/src/components/EmError.vue43
-rw-r--r--packages/frontend-embed/src/components/EmImgWithBlurhash.vue240
-rw-r--r--packages/frontend-embed/src/components/EmInstanceTicker.vue87
-rw-r--r--packages/frontend-embed/src/components/EmLink.vue40
-rw-r--r--packages/frontend-embed/src/components/EmLoading.vue112
-rw-r--r--packages/frontend-embed/src/components/EmMediaBanner.vue55
-rw-r--r--packages/frontend-embed/src/components/EmMediaImage.vue154
-rw-r--r--packages/frontend-embed/src/components/EmMediaList.vue146
-rw-r--r--packages/frontend-embed/src/components/EmMediaVideo.vue64
-rw-r--r--packages/frontend-embed/src/components/EmMention.vue46
-rw-r--r--packages/frontend-embed/src/components/EmMfm.ts461
-rw-r--r--packages/frontend-embed/src/components/EmNote.vue609
-rw-r--r--packages/frontend-embed/src/components/EmNoteDetailed.vue486
-rw-r--r--packages/frontend-embed/src/components/EmNoteHeader.vue104
-rw-r--r--packages/frontend-embed/src/components/EmNoteSimple.vue105
-rw-r--r--packages/frontend-embed/src/components/EmNoteSub.vue149
-rw-r--r--packages/frontend-embed/src/components/EmNotes.vue48
-rw-r--r--packages/frontend-embed/src/components/EmPagination.vue504
-rw-r--r--packages/frontend-embed/src/components/EmPoll.vue82
-rw-r--r--packages/frontend-embed/src/components/EmReactionIcon.vue23
-rw-r--r--packages/frontend-embed/src/components/EmReactionsViewer.reaction.vue99
-rw-r--r--packages/frontend-embed/src/components/EmReactionsViewer.vue104
-rw-r--r--packages/frontend-embed/src/components/EmSubNoteContent.vue113
-rw-r--r--packages/frontend-embed/src/components/EmTime.vue107
-rw-r--r--packages/frontend-embed/src/components/EmTimelineContainer.vue39
-rw-r--r--packages/frontend-embed/src/components/EmUrl.vue96
-rw-r--r--packages/frontend-embed/src/components/EmUserName.vue21
-rw-r--r--packages/frontend-embed/src/components/I18n.vue51
33 files changed, 4610 insertions, 0 deletions
diff --git a/packages/frontend-embed/src/components/EmA.vue b/packages/frontend-embed/src/components/EmA.vue
new file mode 100644
index 0000000000..1c236b9a35
--- /dev/null
+++ b/packages/frontend-embed/src/components/EmA.vue
@@ -0,0 +1,21 @@
+<!--
+SPDX-FileCopyrightText: syuilo and misskey-project
+SPDX-License-Identifier: AGPL-3.0-only
+-->
+
+<template>
+<a :href="to" target="_blank" rel="noopener">
+ <slot></slot>
+</a>
+</template>
+
+<script lang="ts" setup>
+import { } from 'vue';
+
+const props = withDefaults(defineProps<{
+ to: string;
+ activeClass?: null | string;
+}>(), {
+ activeClass: null,
+});
+</script>
diff --git a/packages/frontend-embed/src/components/EmAcct.vue b/packages/frontend-embed/src/components/EmAcct.vue
new file mode 100644
index 0000000000..07315e6a8b
--- /dev/null
+++ b/packages/frontend-embed/src/components/EmAcct.vue
@@ -0,0 +1,24 @@
+<!--
+SPDX-FileCopyrightText: syuilo and misskey-project
+SPDX-License-Identifier: AGPL-3.0-only
+-->
+
+<template>
+<span>
+ <span>@{{ user.username }}</span>
+ <span v-if="user.host || detail" style="opacity: 0.5;">@{{ user.host || host }}</span>
+</span>
+</template>
+
+<script lang="ts" setup>
+import * as Misskey from 'misskey-js';
+import { toUnicode } from 'punycode/';
+import { host as hostRaw } from '@/config.js';
+
+defineProps<{
+ user: Misskey.entities.UserLite;
+ detail?: boolean;
+}>();
+
+const host = toUnicode(hostRaw);
+</script>
diff --git a/packages/frontend-embed/src/components/EmAvatar.vue b/packages/frontend-embed/src/components/EmAvatar.vue
new file mode 100644
index 0000000000..58c35c8ef0
--- /dev/null
+++ b/packages/frontend-embed/src/components/EmAvatar.vue
@@ -0,0 +1,250 @@
+<!--
+SPDX-FileCopyrightText: syuilo and misskey-project
+SPDX-License-Identifier: AGPL-3.0-only
+-->
+
+<template>
+<component :is="link ? EmA : 'span'" v-bind="bound" class="_noSelect" :class="[$style.root, { [$style.cat]: user.isCat }]">
+ <EmImgWithBlurhash :class="$style.inner" :src="url" :hash="user.avatarBlurhash" :cover="true" :onlyAvgColor="true"/>
+ <div v-if="user.isCat" :class="[$style.ears]">
+ <div :class="$style.earLeft">
+ <div v-if="false" :class="$style.layer">
+ <div :class="$style.plot" :style="{ backgroundImage: `url(${JSON.stringify(url)})` }"/>
+ <div :class="$style.plot" :style="{ backgroundImage: `url(${JSON.stringify(url)})` }"/>
+ <div :class="$style.plot" :style="{ backgroundImage: `url(${JSON.stringify(url)})` }"/>
+ </div>
+ </div>
+ <div :class="$style.earRight">
+ <div v-if="false" :class="$style.layer">
+ <div :class="$style.plot" :style="{ backgroundImage: `url(${JSON.stringify(url)})` }"/>
+ <div :class="$style.plot" :style="{ backgroundImage: `url(${JSON.stringify(url)})` }"/>
+ <div :class="$style.plot" :style="{ backgroundImage: `url(${JSON.stringify(url)})` }"/>
+ </div>
+ </div>
+ </div>
+ <img
+ v-for="decoration in user.avatarDecorations"
+ :class="[$style.decoration]"
+ :src="getDecorationUrl(decoration)"
+ :style="{
+ rotate: getDecorationAngle(decoration),
+ scale: getDecorationScale(decoration),
+ translate: getDecorationOffset(decoration),
+ }"
+ alt=""
+ >
+</component>
+</template>
+
+<script lang="ts" setup>
+import { computed } from 'vue';
+import * as Misskey from 'misskey-js';
+import EmImgWithBlurhash from './EmImgWithBlurhash.vue';
+import EmA from './EmA.vue';
+import { userPage } from '@/utils.js';
+
+const props = withDefaults(defineProps<{
+ user: Misskey.entities.User;
+ link?: boolean;
+ preview?: boolean;
+ indicator?: boolean;
+}>(), {
+ link: false,
+ preview: false,
+ indicator: false,
+});
+
+const emit = defineEmits<{
+ (ev: 'click', v: MouseEvent): void;
+}>();
+
+const bound = computed(() => props.link
+ ? { to: userPage(props.user) }
+ : {});
+
+const url = computed(() => {
+ if (props.user.avatarUrl == null) return null;
+ return props.user.avatarUrl;
+});
+
+function getDecorationUrl(decoration: Omit<Misskey.entities.UserDetailed['avatarDecorations'][number], 'id'>) {
+ return decoration.url;
+}
+
+function getDecorationAngle(decoration: Omit<Misskey.entities.UserDetailed['avatarDecorations'][number], 'id'>) {
+ const angle = decoration.angle ?? 0;
+ return angle === 0 ? undefined : `${angle * 360}deg`;
+}
+
+function getDecorationScale(decoration: Omit<Misskey.entities.UserDetailed['avatarDecorations'][number], 'id'>) {
+ const scaleX = decoration.flipH ? -1 : 1;
+ return scaleX === 1 ? undefined : `${scaleX} 1`;
+}
+
+function getDecorationOffset(decoration: Omit<Misskey.entities.UserDetailed['avatarDecorations'][number], 'id'>) {
+ const offsetX = decoration.offsetX ?? 0;
+ const offsetY = decoration.offsetY ?? 0;
+ return offsetX === 0 && offsetY === 0 ? undefined : `${offsetX * 100}% ${offsetY * 100}%`;
+}
+</script>
+
+<style lang="scss" module>
+.root {
+ position: relative;
+ display: inline-block;
+ vertical-align: bottom;
+ flex-shrink: 0;
+ border-radius: 100%;
+ line-height: 16px;
+}
+
+.inner {
+ position: absolute;
+ bottom: 0;
+ left: 0;
+ right: 0;
+ top: 0;
+ border-radius: 100%;
+ z-index: 1;
+ overflow: clip;
+ object-fit: cover;
+ width: 100%;
+ height: 100%;
+}
+
+.indicator {
+ position: absolute;
+ z-index: 2;
+ bottom: 0;
+ left: 0;
+ width: 20%;
+ height: 20%;
+}
+
+.cat {
+ > .ears {
+ contain: strict;
+ position: absolute;
+ top: -50%;
+ left: -50%;
+ width: 100%;
+ height: 100%;
+ padding: 50%;
+ pointer-events: none;
+
+ > .earLeft,
+ > .earRight {
+ contain: strict;
+ display: inline-block;
+ height: 50%;
+ width: 50%;
+ background: currentColor;
+
+ &::after {
+ contain: strict;
+ content: '';
+ display: block;
+ width: 60%;
+ height: 60%;
+ margin: 20%;
+ background: #df548f;
+ }
+
+ > .layer {
+ contain: strict;
+ position: absolute;
+ top: 0;
+ width: 280%;
+ height: 280%;
+
+ > .plot {
+ contain: strict;
+ position: absolute;
+ width: 100%;
+ height: 100%;
+ clip-path: path('M0 0H1V1H0z');
+ transform: scale(32767);
+ transform-origin: 0 0;
+ opacity: 0.5;
+
+ &:first-child {
+ opacity: 1;
+ }
+
+ &:last-child {
+ opacity: calc(1 / 3);
+ }
+ }
+ }
+ }
+
+ > .earLeft {
+ transform: rotate(37.5deg) skew(30deg);
+
+ &, &::after {
+ border-radius: 25% 75% 75%;
+ }
+
+ > .layer {
+ left: 0;
+ transform:
+ skew(-30deg)
+ rotate(-37.5deg)
+ translate(-2.82842712475%, /* -2 * sqrt(2) */
+ -38.5857864376%); /* 40 - 2 * sqrt(2) */
+
+ > .plot {
+ background-position: 20% 10%; /* ~= 37.5deg */
+
+ &:first-child {
+ background-position-x: 21%;
+ }
+
+ &:last-child {
+ background-position-y: 11%;
+ }
+ }
+ }
+ }
+
+ > .earRight {
+ transform: rotate(-37.5deg) skew(-30deg);
+
+ &, &::after {
+ border-radius: 75% 25% 75% 75%;
+ }
+
+ > .layer {
+ right: 0;
+ transform:
+ skew(30deg)
+ rotate(37.5deg)
+ translate(2.82842712475%, /* 2 * sqrt(2) */
+ -38.5857864376%); /* 40 - 2 * sqrt(2) */
+
+ > .plot {
+ position: absolute;
+ background-position: 80% 10%; /* ~= 37.5deg */
+
+ &:first-child {
+ background-position-x: 79%;
+ }
+
+ &:last-child {
+ background-position-y: 11%;
+ }
+ }
+ }
+ }
+ }
+}
+
+.decoration {
+ position: absolute;
+ z-index: 1;
+ top: -50%;
+ left: -50%;
+ width: 200%;
+ pointer-events: none;
+}
+</style>
diff --git a/packages/frontend-embed/src/components/EmCustomEmoji.vue b/packages/frontend-embed/src/components/EmCustomEmoji.vue
new file mode 100644
index 0000000000..e4149cf363
--- /dev/null
+++ b/packages/frontend-embed/src/components/EmCustomEmoji.vue
@@ -0,0 +1,101 @@
+<!--
+SPDX-FileCopyrightText: syuilo and misskey-project
+SPDX-License-Identifier: AGPL-3.0-only
+-->
+
+<template>
+<img
+ v-if="errored && fallbackToImage"
+ :class="[$style.root, { [$style.normal]: normal, [$style.noStyle]: noStyle }]"
+ src="/client-assets/dummy.png"
+ :title="alt"
+/>
+<span v-else-if="errored">:{{ customEmojiName }}:</span>
+<img
+ v-else
+ :class="[$style.root, { [$style.normal]: normal, [$style.noStyle]: noStyle }]"
+ :src="url"
+ :alt="alt"
+ :title="alt"
+ decoding="async"
+ @error="errored = true"
+ @load="errored = false"
+/>
+</template>
+
+<script lang="ts" setup>
+import { computed, inject, ref } from 'vue';
+import { customEmojisMap } from '@/custom-emojis.js';
+
+import { DI } from '@/di.js';
+
+const mediaProxy = inject(DI.mediaProxy)!;
+
+const props = defineProps<{
+ name: string;
+ normal?: boolean;
+ noStyle?: boolean;
+ host?: string | null;
+ url?: string;
+ useOriginalSize?: boolean;
+ menu?: boolean;
+ menuReaction?: boolean;
+ fallbackToImage?: boolean;
+}>();
+
+const customEmojiName = computed(() => (props.name[0] === ':' ? props.name.substring(1, props.name.length - 1) : props.name).replace('@.', ''));
+const isLocal = computed(() => !props.host && (customEmojiName.value.endsWith('@.') || !customEmojiName.value.includes('@')));
+
+const rawUrl = computed(() => {
+ if (props.url) {
+ return props.url;
+ }
+ if (isLocal.value) {
+ return customEmojisMap.get(customEmojiName.value)?.url ?? null;
+ }
+ return props.host ? `/emoji/${customEmojiName.value}@${props.host}.webp` : `/emoji/${customEmojiName.value}.webp`;
+});
+
+const url = computed(() => {
+ if (rawUrl.value == null) return undefined;
+
+ const proxied =
+ (rawUrl.value.startsWith('/emoji/') || (props.useOriginalSize && isLocal.value))
+ ? rawUrl.value
+ : mediaProxy.getProxiedImageUrl(
+ rawUrl.value,
+ props.useOriginalSize ? undefined : 'emoji',
+ false,
+ true,
+ );
+ return proxied;
+});
+
+const alt = computed(() => `:${customEmojiName.value}:`);
+const errored = ref(url.value == null);
+</script>
+
+<style lang="scss" module>
+.root {
+ height: 2em;
+ vertical-align: middle;
+ transition: transform 0.2s ease;
+
+ &:hover {
+ transform: scale(1.2);
+ }
+}
+
+.normal {
+ height: 1.25em;
+ vertical-align: -0.25em;
+
+ &:hover {
+ transform: none;
+ }
+}
+
+.noStyle {
+ height: auto !important;
+}
+</style>
diff --git a/packages/frontend-embed/src/components/EmEmoji.vue b/packages/frontend-embed/src/components/EmEmoji.vue
new file mode 100644
index 0000000000..224979707b
--- /dev/null
+++ b/packages/frontend-embed/src/components/EmEmoji.vue
@@ -0,0 +1,26 @@
+<!--
+SPDX-FileCopyrightText: syuilo and misskey-project
+SPDX-License-Identifier: AGPL-3.0-only
+-->
+
+<template>
+<img :class="$style.root" :src="url" :alt="props.emoji" decoding="async"/>
+</template>
+
+<script lang="ts" setup>
+import { computed } from 'vue';
+import { char2twemojiFilePath } from '@@/js/emoji-base.js';
+
+const props = defineProps<{
+ emoji: string;
+}>();
+
+const url = computed(() => char2twemojiFilePath(props.emoji));
+</script>
+
+<style lang="scss" module>
+.root {
+ height: 1.25em;
+ vertical-align: -0.25em;
+}
+</style>
diff --git a/packages/frontend-embed/src/components/EmError.vue b/packages/frontend-embed/src/components/EmError.vue
new file mode 100644
index 0000000000..d376b29a7f
--- /dev/null
+++ b/packages/frontend-embed/src/components/EmError.vue
@@ -0,0 +1,43 @@
+<!--
+SPDX-FileCopyrightText: syuilo and misskey-project
+SPDX-License-Identifier: AGPL-3.0-only
+-->
+
+<template>
+<div :class="$style.root">
+ <p :class="$style.text"><i class="ti ti-alert-triangle"></i> {{ i18n.ts.somethingHappened }}</p>
+ <button class="_buttonGray _buttonRounded" :class="$style.button" @click="() => emit('retry')">{{ i18n.ts.retry }}</button>
+</div>
+</template>
+
+<script lang="ts" setup>
+import { i18n } from '@/i18n.js';
+
+const emit = defineEmits<{
+ (ev: 'retry'): void;
+}>();
+</script>
+
+<style lang="scss" module>
+.root {
+ padding: 32px;
+ text-align: center;
+ align-items: center;
+}
+
+.text {
+ margin: 0 0 8px 0;
+}
+
+.button {
+ margin: 0 auto;
+}
+
+.img {
+ vertical-align: bottom;
+ width: 128px;
+ height: 128px;
+ margin-bottom: 16px;
+ border-radius: 16px;
+}
+</style>
diff --git a/packages/frontend-embed/src/components/EmImgWithBlurhash.vue b/packages/frontend-embed/src/components/EmImgWithBlurhash.vue
new file mode 100644
index 0000000000..d19cd08d0a
--- /dev/null
+++ b/packages/frontend-embed/src/components/EmImgWithBlurhash.vue
@@ -0,0 +1,240 @@
+<!--
+SPDX-FileCopyrightText: syuilo and misskey-project
+SPDX-License-Identifier: AGPL-3.0-only
+-->
+
+<template>
+<div ref="root" :class="['chromatic-ignore', $style.root, { [$style.cover]: cover }]" :title="title ?? ''">
+ <canvas v-show="hide" key="canvas" ref="canvas" :class="$style.canvas" :width="canvasWidth" :height="canvasHeight" :title="title ?? undefined" tabindex="-1"/>
+ <img v-show="!hide" key="img" ref="img" :height="imgHeight ?? undefined" :width="imgWidth ?? undefined" :class="$style.img" :src="src ?? undefined" :title="title ?? undefined" :alt="alt ?? undefined" loading="eager" decoding="async" tabindex="-1"/>
+</div>
+</template>
+
+<script lang="ts">
+import DrawBlurhash from '@/workers/draw-blurhash?worker';
+import TestWebGL2 from '@/workers/test-webgl2?worker';
+import { WorkerMultiDispatch } from '@/to-be-shared/worker-multi-dispatch.js';
+import { extractAvgColorFromBlurhash } from '@@/js/extract-avg-color-from-blurhash.js';
+
+const canvasPromise = new Promise<WorkerMultiDispatch | HTMLCanvasElement>(resolve => {
+ // テスト環境で Web Worker インスタンスは作成できない
+ if (import.meta.env.MODE === 'test') {
+ const canvas = document.createElement('canvas');
+ canvas.width = 64;
+ canvas.height = 64;
+ resolve(canvas);
+ return;
+ }
+ const testWorker = new TestWebGL2();
+ testWorker.addEventListener('message', event => {
+ if (event.data.result) {
+ const workers = new WorkerMultiDispatch(
+ () => new DrawBlurhash(),
+ Math.min(navigator.hardwareConcurrency - 1, 4),
+ );
+ resolve(workers);
+ if (_DEV_) console.log('WebGL2 in worker is supported!');
+ } else {
+ const canvas = document.createElement('canvas');
+ canvas.width = 64;
+ canvas.height = 64;
+ resolve(canvas);
+ if (_DEV_) console.log('WebGL2 in worker is not supported...');
+ }
+ testWorker.terminate();
+ });
+});
+</script>
+
+<script lang="ts" setup>
+import { computed, nextTick, onMounted, onUnmounted, shallowRef, watch, ref } from 'vue';
+import { v4 as uuid } from 'uuid';
+import { render } from 'buraha';
+
+const props = withDefaults(defineProps<{
+ src?: string | null;
+ hash?: string | null;
+ alt?: string | null;
+ title?: string | null;
+ height?: number;
+ width?: number;
+ cover?: boolean;
+ forceBlurhash?: boolean;
+ onlyAvgColor?: boolean; // 軽量化のためにBlurhashを使わずに平均色だけを描画
+}>(), {
+ src: null,
+ alt: '',
+ title: null,
+ height: 64,
+ width: 64,
+ cover: true,
+ forceBlurhash: false,
+ onlyAvgColor: false,
+});
+
+const viewId = uuid();
+const canvas = shallowRef<HTMLCanvasElement>();
+const root = shallowRef<HTMLDivElement>();
+const img = shallowRef<HTMLImageElement>();
+const loaded = ref(false);
+const canvasWidth = ref(64);
+const canvasHeight = ref(64);
+const imgWidth = ref(props.width);
+const imgHeight = ref(props.height);
+const bitmapTmp = ref<CanvasImageSource | undefined>();
+const hide = computed(() => !loaded.value || props.forceBlurhash);
+
+function waitForDecode() {
+ if (props.src != null && props.src !== '') {
+ nextTick()
+ .then(() => img.value?.decode())
+ .then(() => {
+ loaded.value = true;
+ }, error => {
+ console.log('Error occurred during decoding image', img.value, error);
+ });
+ } else {
+ loaded.value = false;
+ }
+}
+
+watch([() => props.width, () => props.height, root], () => {
+ const ratio = props.width / props.height;
+ if (ratio > 1) {
+ canvasWidth.value = Math.round(64 * ratio);
+ canvasHeight.value = 64;
+ } else {
+ canvasWidth.value = 64;
+ canvasHeight.value = Math.round(64 / ratio);
+ }
+
+ const clientWidth = root.value?.clientWidth ?? 300;
+ imgWidth.value = clientWidth;
+ imgHeight.value = Math.round(clientWidth / ratio);
+}, {
+ immediate: true,
+});
+
+function drawImage(bitmap: CanvasImageSource) {
+ // canvasがない(mountedされていない)場合はTmpに保存しておく
+ if (!canvas.value) {
+ bitmapTmp.value = bitmap;
+ return;
+ }
+
+ // canvasがあれば描画する
+ bitmapTmp.value = undefined;
+ const ctx = canvas.value.getContext('2d');
+ if (!ctx) return;
+ ctx.drawImage(bitmap, 0, 0, canvasWidth.value, canvasHeight.value);
+}
+
+function drawAvg() {
+ if (!canvas.value) return;
+
+ const color = (props.hash != null && extractAvgColorFromBlurhash(props.hash)) || '#888';
+
+ const ctx = canvas.value.getContext('2d');
+ if (!ctx) return;
+
+ // avgColorでお茶をにごす
+ ctx.beginPath();
+ ctx.fillStyle = color;
+ ctx.fillRect(0, 0, canvasWidth.value, canvasHeight.value);
+}
+
+async function draw() {
+ if (import.meta.env.MODE === 'test' && props.hash == null) return;
+
+ drawAvg();
+
+ if (props.hash == null) return;
+
+ if (props.onlyAvgColor) return;
+
+ const work = await canvasPromise;
+ if (work instanceof WorkerMultiDispatch) {
+ work.postMessage(
+ {
+ id: viewId,
+ hash: props.hash,
+ },
+ undefined,
+ );
+ } else {
+ try {
+ render(props.hash, work);
+ drawImage(work);
+ } catch (error) {
+ console.error('Error occurred during drawing blurhash', error);
+ }
+ }
+}
+
+function workerOnMessage(event: MessageEvent) {
+ if (event.data.id !== viewId) return;
+ drawImage(event.data.bitmap as ImageBitmap);
+}
+
+canvasPromise.then(work => {
+ if (work instanceof WorkerMultiDispatch) {
+ work.addListener(workerOnMessage);
+ }
+
+ draw();
+});
+
+watch(() => props.src, () => {
+ waitForDecode();
+});
+
+watch(() => props.hash, () => {
+ draw();
+});
+
+onMounted(() => {
+ // drawImageがmountedより先に呼ばれている場合はここで描画する
+ if (bitmapTmp.value) {
+ drawImage(bitmapTmp.value);
+ }
+ waitForDecode();
+});
+
+onUnmounted(() => {
+ canvasPromise.then(work => {
+ if (work instanceof WorkerMultiDispatch) {
+ work.removeListener(workerOnMessage);
+ }
+ });
+});
+</script>
+
+<style lang="scss" module>
+.root {
+ position: relative;
+ width: 100%;
+ height: 100%;
+
+ &.cover {
+ > .canvas,
+ > .img {
+ object-fit: cover;
+ }
+ }
+}
+
+.canvas,
+.img {
+ display: block;
+ width: 100%;
+ height: 100%;
+}
+
+.canvas {
+ object-fit: contain;
+}
+
+.img {
+ object-fit: contain;
+}
+</style>
diff --git a/packages/frontend-embed/src/components/EmInstanceTicker.vue b/packages/frontend-embed/src/components/EmInstanceTicker.vue
new file mode 100644
index 0000000000..eeeaee528e
--- /dev/null
+++ b/packages/frontend-embed/src/components/EmInstanceTicker.vue
@@ -0,0 +1,87 @@
+<!--
+SPDX-FileCopyrightText: syuilo and misskey-project
+SPDX-License-Identifier: AGPL-3.0-only
+-->
+
+<template>
+<div :class="$style.root" :style="bg">
+ <img v-if="faviconUrl" :class="$style.icon" :src="faviconUrl"/>
+ <div :class="$style.name">{{ instance.name }}</div>
+</div>
+</template>
+
+<script lang="ts" setup>
+import { computed, inject } from 'vue';
+
+import { DI } from '@/di.js';
+
+const serverMetadata = inject(DI.serverMetadata)!;
+const mediaProxy = inject(DI.mediaProxy)!;
+
+const props = defineProps<{
+ instance?: {
+ faviconUrl?: string | null
+ name?: string | null
+ themeColor?: string | null
+ }
+}>();
+
+// if no instance data is given, this is for the local instance
+const instance = props.instance ?? {
+ name: serverMetadata.name,
+ themeColor: (document.querySelector('meta[name="theme-color-orig"]') as HTMLMetaElement).content,
+};
+
+const faviconUrl = computed(() => props.instance ? mediaProxy.getProxiedImageUrlNullable(props.instance.faviconUrl, 'preview') : mediaProxy.getProxiedImageUrlNullable(serverMetadata.iconUrl, 'preview') ?? '/favicon.ico');
+
+const themeColor = serverMetadata.themeColor ?? '#777777';
+
+const bg = {
+ background: `linear-gradient(90deg, ${themeColor}, ${themeColor}00)`,
+};
+</script>
+
+<style lang="scss" module>
+$height: 2ex;
+
+.root {
+ display: flex;
+ align-items: center;
+ height: $height;
+ border-radius: 4px 0 0 4px;
+ overflow: clip;
+ color: #fff;
+ text-shadow: /* .866 ≈ sin(60deg) */
+ 1px 0 1px #000,
+ .866px .5px 1px #000,
+ .5px .866px 1px #000,
+ 0 1px 1px #000,
+ -.5px .866px 1px #000,
+ -.866px .5px 1px #000,
+ -1px 0 1px #000,
+ -.866px -.5px 1px #000,
+ -.5px -.866px 1px #000,
+ 0 -1px 1px #000,
+ .5px -.866px 1px #000,
+ .866px -.5px 1px #000;
+ mask-image: linear-gradient(90deg,
+ rgb(0,0,0),
+ rgb(0,0,0) calc(100% - 16px),
+ rgba(0,0,0,0) 100%
+ );
+}
+
+.icon {
+ height: $height;
+ flex-shrink: 0;
+}
+
+.name {
+ margin-left: 4px;
+ line-height: 1;
+ font-size: 0.9em;
+ font-weight: bold;
+ white-space: nowrap;
+ overflow: visible;
+}
+</style>
diff --git a/packages/frontend-embed/src/components/EmLink.vue b/packages/frontend-embed/src/components/EmLink.vue
new file mode 100644
index 0000000000..319ad72399
--- /dev/null
+++ b/packages/frontend-embed/src/components/EmLink.vue
@@ -0,0 +1,40 @@
+<!--
+SPDX-FileCopyrightText: syuilo and misskey-project
+SPDX-License-Identifier: AGPL-3.0-only
+-->
+
+<template>
+<component
+ :is="self ? EmA : 'a'" ref="el" style="word-break: break-all;" class="_link" :[attr]="self ? url.substring(local.length) : url" :rel="rel ?? 'nofollow noopener'" :target="target"
+ :title="url"
+>
+ <slot></slot>
+ <i v-if="target === '_blank'" class="ti ti-external-link" :class="$style.icon"></i>
+</component>
+</template>
+
+<script lang="ts" setup>
+import { ref } from 'vue';
+import EmA from './EmA.vue';
+import { url as local } from '@/config.js';
+
+const props = withDefaults(defineProps<{
+ url: string;
+ rel?: null | string;
+}>(), {
+});
+
+const self = props.url.startsWith(local);
+const attr = self ? 'to' : 'href';
+const target = self ? null : '_blank';
+
+const el = ref<HTMLElement | { $el: HTMLElement }>();
+
+</script>
+
+<style lang="scss" module>
+.icon {
+ padding-left: 2px;
+ font-size: .9em;
+}
+</style>
diff --git a/packages/frontend-embed/src/components/EmLoading.vue b/packages/frontend-embed/src/components/EmLoading.vue
new file mode 100644
index 0000000000..49d8ace37b
--- /dev/null
+++ b/packages/frontend-embed/src/components/EmLoading.vue
@@ -0,0 +1,112 @@
+<!--
+SPDX-FileCopyrightText: syuilo and misskey-project
+SPDX-License-Identifier: AGPL-3.0-only
+-->
+
+<template>
+<div :class="[$style.root, { [$style.inline]: inline, [$style.colored]: colored, [$style.mini]: mini, [$style.em]: em }]">
+ <div :class="$style.container">
+ <svg :class="[$style.spinner, $style.bg]" viewBox="0 0 168 168" xmlns="http://www.w3.org/2000/svg">
+ <g transform="matrix(1.125,0,0,1.125,12,12)">
+ <circle cx="64" cy="64" r="64" style="fill:none;stroke:currentColor;stroke-width:21.33px;"/>
+ </g>
+ </svg>
+ <svg :class="[$style.spinner, $style.fg, { [$style.static]: static }]" viewBox="0 0 168 168" xmlns="http://www.w3.org/2000/svg">
+ <g transform="matrix(1.125,0,0,1.125,12,12)">
+ <path d="M128,64C128,28.654 99.346,0 64,0C99.346,0 128,28.654 128,64Z" style="fill:none;stroke:currentColor;stroke-width:21.33px;"/>
+ </g>
+ </svg>
+ </div>
+</div>
+</template>
+
+<script lang="ts" setup>
+import { } from 'vue';
+
+const props = withDefaults(defineProps<{
+ static?: boolean;
+ inline?: boolean;
+ colored?: boolean;
+ mini?: boolean;
+ em?: boolean;
+}>(), {
+ static: false,
+ inline: false,
+ colored: true,
+ mini: false,
+ em: false,
+});
+</script>
+
+<style lang="scss" module>
+@keyframes spinner {
+ 0% {
+ transform: rotate(0deg);
+ }
+ 100% {
+ transform: rotate(360deg);
+ }
+}
+
+.root {
+ padding: 32px;
+ text-align: center;
+ cursor: wait;
+
+ --size: 38px;
+
+ &.colored {
+ color: var(--accent);
+ }
+
+ &.inline {
+ display: inline;
+ padding: 0;
+ --size: 32px;
+ }
+
+ &.mini {
+ padding: 16px;
+ --size: 32px;
+ }
+
+ &.em {
+ display: inline-block;
+ vertical-align: middle;
+ padding: 0;
+ --size: 1em;
+ }
+}
+
+.container {
+ position: relative;
+ width: var(--size);
+ height: var(--size);
+ margin: 0 auto;
+}
+
+.spinner {
+ position: absolute;
+ top: 0;
+ left: 0;
+ width: var(--size);
+ height: var(--size);
+ fill-rule: evenodd;
+ clip-rule: evenodd;
+ stroke-linecap: round;
+ stroke-linejoin: round;
+ stroke-miterlimit: 1.5;
+}
+
+.bg {
+ opacity: 0.275;
+}
+
+.fg {
+ animation: spinner 0.5s linear infinite;
+
+ &.static {
+ animation-play-state: paused;
+ }
+}
+</style>
diff --git a/packages/frontend-embed/src/components/EmMediaBanner.vue b/packages/frontend-embed/src/components/EmMediaBanner.vue
new file mode 100644
index 0000000000..435da238a4
--- /dev/null
+++ b/packages/frontend-embed/src/components/EmMediaBanner.vue
@@ -0,0 +1,55 @@
+<!--
+SPDX-FileCopyrightText: syuilo and misskey-project
+SPDX-License-Identifier: AGPL-3.0-only
+-->
+
+<template>
+<a :href="href" target="_blank" :class="$style.root">
+ <div :class="$style.label">
+ <template v-if="media.type.startsWith('audio')"><i class="ti ti-music"></i> {{ i18n.ts.audio }}</template>
+ <template v-else><i class="ti ti-file"></i> {{ i18n.ts.file }}</template>
+ </div>
+ <div :class="$style.go">
+ <i class="ti ti-chevron-right"></i>
+ </div>
+</a>
+</template>
+
+<script setup lang="ts">
+import * as Misskey from 'misskey-js';
+import { i18n } from '@/i18n.js';
+
+defineProps<{
+ media: Misskey.entities.DriveFile;
+ href: string;
+}>();
+</script>
+
+<style lang="scss" module>
+.root {
+ box-sizing: border-box;
+ display: flex;
+ align-items: center;
+ width: 100%;
+ padding: var(--margin);
+ margin-top: 4px;
+ border: 1px solid var(--inputBorder);
+ border-radius: var(--radius);
+ background-color: var(--panel);
+ transition: background-color .1s, border-color .1s;
+
+ &:hover {
+ text-decoration: none;
+ border-color: var(--inputBorderHover);
+ background-color: var(--buttonHoverBg);
+ }
+}
+
+.label {
+ font-size: .9em;
+}
+
+.go {
+ margin-left: auto;
+}
+</style>
diff --git a/packages/frontend-embed/src/components/EmMediaImage.vue b/packages/frontend-embed/src/components/EmMediaImage.vue
new file mode 100644
index 0000000000..fe1aa5a877
--- /dev/null
+++ b/packages/frontend-embed/src/components/EmMediaImage.vue
@@ -0,0 +1,154 @@
+<!--
+SPDX-FileCopyrightText: syuilo and misskey-project
+SPDX-License-Identifier: AGPL-3.0-only
+-->
+
+<template>
+<div :class="[hide ? $style.hidden : $style.visible]" :style="darkMode ? '--c: rgb(255 255 255 / 2%);' : '--c: rgb(0 0 0 / 2%);'" @click="onclick">
+ <a
+ :title="image.name"
+ :class="$style.imageContainer"
+ :href="href ?? image.url"
+ target="_blank"
+ rel="noopener"
+ >
+ <ImgWithBlurhash
+ :hash="image.blurhash"
+ :src="hide ? null : url"
+ :forceBlurhash="hide"
+ :cover="hide || cover"
+ :alt="image.comment || image.name"
+ :title="image.comment || image.name"
+ :width="image.properties.width"
+ :height="image.properties.height"
+ :style="hide ? 'filter: brightness(0.7);' : null"
+ />
+ </a>
+ <template v-if="hide">
+ <div :class="$style.hiddenText">
+ <div :class="$style.hiddenTextWrapper">
+ <b v-if="image.isSensitive" style="display: block;"><i class="ti ti-eye-exclamation"></i> {{ i18n.ts.sensitive }}</b>
+ <b v-else style="display: block;"><i class="ti ti-photo"></i> {{ i18n.ts.image }}</b>
+ <span style="display: block;">{{ i18n.ts.clickToShow }}</span>
+ </div>
+ </div>
+ </template>
+ <div :class="$style.indicators">
+ <div v-if="['image/gif', 'image/apng'].includes(image.type)" :class="$style.indicator">GIF</div>
+ <div v-if="image.comment" :class="$style.indicator">ALT</div>
+ <div v-if="image.isSensitive" :class="$style.indicator" style="color: var(--warn);" :title="i18n.ts.sensitive"><i class="ti ti-eye-exclamation"></i></div>
+ </div>
+ <i v-if="!hide" class="ti ti-eye-off" :class="$style.hide" @click.stop="hide = true"></i>
+</div>
+</template>
+
+<script lang="ts" setup>
+import { ref, computed } from 'vue';
+import * as Misskey from 'misskey-js';
+import ImgWithBlurhash from '@/components/EmImgWithBlurhash.vue';
+import { i18n } from '@/i18n.js';
+
+const props = withDefaults(defineProps<{
+ image: Misskey.entities.DriveFile;
+ href?: string;
+ raw?: boolean;
+ cover?: boolean;
+}>(), {
+ cover: false,
+});
+
+const hide = ref(props.image.isSensitive);
+const darkMode = ref<boolean>(false); // TODO
+
+const url = computed(() => (props.raw)
+ ? props.image.url
+ : props.image.thumbnailUrl,
+);
+
+async function onclick(ev: MouseEvent) {
+ if (hide.value) {
+ ev.stopPropagation();
+ hide.value = false;
+ }
+}
+</script>
+
+<style lang="scss" module>
+.hidden {
+ position: relative;
+}
+
+.hiddenText {
+ position: absolute;
+ left: 0;
+ top: 0;
+ width: 100%;
+ height: 100%;
+ z-index: 1;
+ display: flex;
+ justify-content: center;
+ align-items: center;
+ cursor: pointer;
+}
+
+.hide {
+ display: block;
+ position: absolute;
+ border-radius: 6px;
+ background-color: var(--fg);
+ color: var(--accentLighten);
+ font-size: 12px;
+ opacity: .5;
+ padding: 5px 8px;
+ text-align: center;
+ cursor: pointer;
+ top: 12px;
+ right: 12px;
+}
+
+.hiddenTextWrapper {
+ display: table-cell;
+ text-align: center;
+ font-size: 0.8em;
+ color: #fff;
+}
+
+.visible {
+ position: relative;
+ //box-shadow: 0 0 0 1px var(--divider) inset;
+ background: var(--bg);
+ background-image: linear-gradient(45deg, var(--c) 16.67%, var(--bg) 16.67%, var(--bg) 50%, var(--c) 50%, var(--c) 66.67%, var(--bg) 66.67%, var(--bg) 100%);
+ background-size: 16px 16px;
+}
+
+.imageContainer {
+ display: block;
+ overflow: hidden;
+ width: 100%;
+ height: 100%;
+ background-position: center;
+ background-size: contain;
+ background-repeat: no-repeat;
+}
+
+.indicators {
+ display: inline-flex;
+ position: absolute;
+ top: 10px;
+ left: 10px;
+ pointer-events: none;
+ opacity: .5;
+ gap: 6px;
+}
+
+.indicator {
+ /* Hardcode to black because either --bg or --fg makes it hard to read in dark/light mode */
+ background-color: black;
+ border-radius: 6px;
+ color: var(--accentLighten);
+ display: inline-block;
+ font-weight: bold;
+ font-size: 0.8em;
+ padding: 2px 5px;
+}
+</style>
diff --git a/packages/frontend-embed/src/components/EmMediaList.vue b/packages/frontend-embed/src/components/EmMediaList.vue
new file mode 100644
index 0000000000..0b2d835abe
--- /dev/null
+++ b/packages/frontend-embed/src/components/EmMediaList.vue
@@ -0,0 +1,146 @@
+<!--
+SPDX-FileCopyrightText: syuilo and misskey-project
+SPDX-License-Identifier: AGPL-3.0-only
+-->
+
+<template>
+<div>
+ <div v-for="media in mediaList.filter(media => !previewable(media))" :key="media.id" :class="$style.banner">
+ <XBanner :media="media" :href="originalEntityUrl"/>
+ </div>
+ <div v-if="mediaList.filter(media => previewable(media)).length > 0" :class="$style.container">
+ <div
+ :class="[
+ $style.medias,
+ count === 1 ? [$style.n1] : count === 2 ? $style.n2 : count === 3 ? $style.n3 : count === 4 ? $style.n4 : $style.nMany,
+ ]"
+ >
+ <div v-for="media in mediaList.filter(media => previewable(media))" :class="$style.media">
+ <XVideo v-if="media.type.startsWith('video')" :key="`video:${media.id}`" :class="$style.mediaInner" :video="media" :href="originalEntityUrl"/>
+ <XImage v-else-if="media.type.startsWith('image')" :key="`image:${media.id}`" :class="$style.mediaInner" class="image" :image="media" :raw="raw" :href="originalEntityUrl"/>
+ </div>
+ </div>
+ </div>
+</div>
+</template>
+
+<script lang="ts" setup>
+import { computed } from 'vue';
+import * as Misskey from 'misskey-js';
+import XBanner from './EmMediaBanner.vue';
+import XImage from './EmMediaImage.vue';
+import XVideo from './EmMediaVideo.vue';
+import { FILE_TYPE_BROWSERSAFE } from '@@/js/const.js';
+
+const props = defineProps<{
+ mediaList: Misskey.entities.DriveFile[];
+ raw?: boolean;
+
+ /** 埋め込みページ用 親要素の正規URL */
+ originalEntityUrl: string;
+}>();
+
+const count = computed(() => props.mediaList.filter(media => previewable(media)).length);
+
+const previewable = (file: Misskey.entities.DriveFile): boolean => {
+ if (file.type === 'image/svg+xml') return true; // svgのwebpublic/thumbnailはpngなのでtrue
+ // FILE_TYPE_BROWSERSAFEに適合しないものはブラウザで表示するのに不適切
+ return (file.type.startsWith('video') || file.type.startsWith('image')) && FILE_TYPE_BROWSERSAFE.includes(file.type);
+};
+</script>
+
+<style lang="scss" module>
+.container {
+ position: relative;
+ width: 100%;
+ margin-top: 4px;
+}
+
+.medias {
+ display: grid;
+ grid-gap: 8px;
+
+ height: 100%;
+ width: 100%;
+
+ &.n1 {
+ grid-template-rows: 1fr;
+
+ // default but fallback (expand)
+ min-height: 64px;
+ max-height: clamp(
+ 64px,
+ 50cqh,
+ min(360px, 50vh)
+ );
+
+ &.n116_9 {
+ min-height: initial;
+ max-height: initial;
+ aspect-ratio: 16 / 9; // fallback
+ }
+
+ &.n11_1{
+ min-height: initial;
+ max-height: initial;
+ aspect-ratio: 1 / 1; // fallback
+ }
+
+ &.n12_3 {
+ min-height: initial;
+ max-height: initial;
+ aspect-ratio: 2 / 3; // fallback
+ }
+ }
+
+ &.n2 {
+ aspect-ratio: 16/9;
+ grid-template-columns: 1fr 1fr;
+ grid-template-rows: 1fr;
+ }
+
+ &.n3 {
+ aspect-ratio: 16/9;
+ grid-template-columns: 1fr 0.5fr;
+ grid-template-rows: 1fr 1fr;
+
+ > .media:nth-child(1) {
+ grid-row: 1 / 3;
+ }
+
+ > .media:nth-child(3) {
+ grid-column: 2 / 3;
+ grid-row: 2 / 3;
+ }
+ }
+
+ &.n4 {
+ aspect-ratio: 16/9;
+ grid-template-columns: 1fr 1fr;
+ grid-template-rows: 1fr 1fr;
+ }
+
+ &.nMany {
+ grid-template-columns: 1fr 1fr;
+
+ > .media {
+ aspect-ratio: 16/9;
+ }
+ }
+}
+
+.media {
+ overflow: hidden; // clipにするとバグる
+ border-radius: 8px;
+ position: relative;
+
+ >.mediaInner {
+ width: 100%;
+ height: 100%;
+ }
+}
+
+.banner {
+ position: relative;
+}
+</style>
diff --git a/packages/frontend-embed/src/components/EmMediaVideo.vue b/packages/frontend-embed/src/components/EmMediaVideo.vue
new file mode 100644
index 0000000000..ce751f9acd
--- /dev/null
+++ b/packages/frontend-embed/src/components/EmMediaVideo.vue
@@ -0,0 +1,64 @@
+<!--
+SPDX-FileCopyrightText: syuilo and misskey-project
+SPDX-License-Identifier: AGPL-3.0-only
+-->
+
+<template>
+<a :href="href" target="_blank" :class="$style.root">
+ <img v-if="!video.isSensitive && video.thumbnailUrl" :class="$style.thumbnail" :src="video.thumbnailUrl">
+ <div :class="$style.videoOverlayPlayButton"><i class="ti ti-player-play-filled"></i></div>
+</a>
+</template>
+
+<script setup lang="ts">
+import * as Misskey from 'misskey-js';
+
+defineProps<{
+ video: Misskey.entities.DriveFile;
+ href: string;
+}>();
+</script>
+
+<style lang="scss" module>
+.root {
+ position: relative;
+ box-sizing: border-box;
+ display: flex;
+ align-items: center;
+ justify-content: center;
+ width: 100%;
+ height: auto;
+ aspect-ratio: 16 / 9;
+ padding: var(--margin);
+ border: 1px solid var(--divider);
+ border-radius: var(--radius);
+ background-color: #000;
+
+ &:hover {
+ text-decoration: none;
+ }
+}
+
+.thumbnail {
+ position: absolute;
+ top: 0;
+ left: 0;
+ width: 100%;
+ height: 100%;
+ object-fit: cover;
+}
+
+.videoOverlayPlayButton {
+ background: var(--accent);
+ color: #fff;
+ padding: 1rem;
+ border-radius: 99rem;
+
+ font-size: 1rem;
+ line-height: 1rem;
+
+ &:focus-visible {
+ outline: none;
+ }
+}
+</style>
diff --git a/packages/frontend-embed/src/components/EmMention.vue b/packages/frontend-embed/src/components/EmMention.vue
new file mode 100644
index 0000000000..5eadf828c7
--- /dev/null
+++ b/packages/frontend-embed/src/components/EmMention.vue
@@ -0,0 +1,46 @@
+<!--
+SPDX-FileCopyrightText: syuilo and misskey-project
+SPDX-License-Identifier: AGPL-3.0-only
+-->
+
+<template>
+<MkA v-user-preview="canonical" :class="[$style.root]" :to="url" :style="{ background: bgCss }">
+ <span>
+ <span>@{{ username }}</span>
+ <span v-if="(host != localHost)" :class="$style.host">@{{ toUnicode(host) }}</span>
+ </span>
+</MkA>
+</template>
+
+<script lang="ts" setup>
+import { toUnicode } from 'punycode';
+import { } from 'vue';
+import tinycolor from 'tinycolor2';
+import { host as localHost } from '@/config.js';
+
+const props = defineProps<{
+ username: string;
+ host: string;
+}>();
+
+const canonical = props.host === localHost ? `@${props.username}` : `@${props.username}@${toUnicode(props.host)}`;
+
+const url = `/${canonical}`;
+
+const bg = tinycolor(getComputedStyle(document.documentElement).getPropertyValue('--mention'));
+bg.setAlpha(0.1);
+const bgCss = bg.toRgbString();
+</script>
+
+<style lang="scss" module>
+.root {
+ display: inline-block;
+ padding: 4px 8px 4px 4px;
+ border-radius: 999px;
+ color: var(--mention);
+}
+
+.host {
+ opacity: 0.5;
+}
+</style>
diff --git a/packages/frontend-embed/src/components/EmMfm.ts b/packages/frontend-embed/src/components/EmMfm.ts
new file mode 100644
index 0000000000..7543d3cd54
--- /dev/null
+++ b/packages/frontend-embed/src/components/EmMfm.ts
@@ -0,0 +1,461 @@
+/*
+ * SPDX-FileCopyrightText: syuilo and misskey-project
+ * SPDX-License-Identifier: AGPL-3.0-only
+ */
+
+import { VNode, h, SetupContext, provide } from 'vue';
+import * as mfm from 'mfm-js';
+import * as Misskey from 'misskey-js';
+import EmUrl from '@/components/EmUrl.vue';
+import EmTime from '@/components/EmTime.vue';
+import EmLink from '@/components/EmLink.vue';
+import EmMention from '@/components/EmMention.vue';
+import EmEmoji from '@/components/EmEmoji.vue';
+import EmCustomEmoji from '@/components/EmCustomEmoji.vue';
+import EmA from '@/components/EmA.vue';
+import { host } from '@/config.js';
+
+function safeParseFloat(str: unknown): number | null {
+ if (typeof str !== 'string' || str === '') return null;
+ const num = parseFloat(str);
+ if (isNaN(num)) return null;
+ return num;
+}
+
+const QUOTE_STYLE = `
+display: block;
+margin: 8px;
+padding: 6px 0 6px 12px;
+color: var(--fg);
+border-left: solid 3px var(--fg);
+opacity: 0.7;
+`.split('\n').join(' ');
+
+type MfmProps = {
+ text: string;
+ plain?: boolean;
+ nowrap?: boolean;
+ author?: Misskey.entities.UserLite;
+ isNote?: boolean;
+ emojiUrls?: Record<string, string>;
+ rootScale?: number;
+ nyaize?: boolean | 'respect';
+ parsedNodes?: mfm.MfmNode[] | null;
+ enableEmojiMenu?: boolean;
+ enableEmojiMenuReaction?: boolean;
+ linkNavigationBehavior?: string;
+};
+
+type MfmEvents = {
+ clickEv(id: string): void;
+};
+
+// eslint-disable-next-line import/no-default-export
+export default function (props: MfmProps, { emit }: { emit: SetupContext<MfmEvents>['emit'] }) {
+ provide('linkNavigationBehavior', props.linkNavigationBehavior);
+
+ const isNote = props.isNote ?? true;
+ const shouldNyaize = props.nyaize ? props.nyaize === 'respect' ? props.author?.isCat : false : false;
+
+ // eslint-disable-next-line @typescript-eslint/no-unnecessary-condition
+ if (props.text == null || props.text === '') return;
+
+ const rootAst = props.parsedNodes ?? (props.plain ? mfm.parseSimple : mfm.parse)(props.text);
+
+ const validTime = (t: string | boolean | null | undefined) => {
+ if (t == null) return null;
+ if (typeof t === 'boolean') return null;
+ return t.match(/^\-?[0-9.]+s$/) ? t : null;
+ };
+
+ const validColor = (c: unknown): string | null => {
+ if (typeof c !== 'string') return null;
+ return c.match(/^[0-9a-f]{3,6}$/i) ? c : null;
+ };
+
+ const useAnim = true;
+
+ /**
+ * Gen Vue Elements from MFM AST
+ * @param ast MFM AST
+ * @param scale How times large the text is
+ * @param disableNyaize Whether nyaize is disabled or not
+ */
+ const genEl = (ast: mfm.MfmNode[], scale: number, disableNyaize = false) => ast.map((token): VNode | string | (VNode | string)[] => {
+ switch (token.type) {
+ case 'text': {
+ let text = token.props.text.replace(/(\r\n|\n|\r)/g, '\n');
+ if (!disableNyaize && shouldNyaize) {
+ text = Misskey.nyaize(text);
+ }
+
+ if (!props.plain) {
+ const res: (VNode | string)[] = [];
+ for (const t of text.split('\n')) {
+ res.push(h('br'));
+ res.push(t);
+ }
+ res.shift();
+ return res;
+ } else {
+ return [text.replace(/\n/g, ' ')];
+ }
+ }
+
+ case 'bold': {
+ return [h('b', genEl(token.children, scale))];
+ }
+
+ case 'strike': {
+ return [h('del', genEl(token.children, scale))];
+ }
+
+ case 'italic': {
+ return h('i', {
+ style: 'font-style: oblique;',
+ }, genEl(token.children, scale));
+ }
+
+ case 'fn': {
+ // TODO: CSSを文字列で組み立てていくと token.props.args.~~~ 経由でCSSインジェクションできるのでよしなにやる
+ let style: string | undefined;
+ switch (token.props.name) {
+ case 'tada': {
+ const speed = validTime(token.props.args.speed) ?? '1s';
+ const delay = validTime(token.props.args.delay) ?? '0s';
+ style = 'font-size: 150%;' + (useAnim ? `animation: global-tada ${speed} linear infinite both; animation-delay: ${delay};` : '');
+ break;
+ }
+ case 'jelly': {
+ const speed = validTime(token.props.args.speed) ?? '1s';
+ const delay = validTime(token.props.args.delay) ?? '0s';
+ style = (useAnim ? `animation: mfm-rubberBand ${speed} linear infinite both; animation-delay: ${delay};` : '');
+ break;
+ }
+ case 'twitch': {
+ const speed = validTime(token.props.args.speed) ?? '0.5s';
+ const delay = validTime(token.props.args.delay) ?? '0s';
+ style = useAnim ? `animation: mfm-twitch ${speed} ease infinite; animation-delay: ${delay};` : '';
+ break;
+ }
+ case 'shake': {
+ const speed = validTime(token.props.args.speed) ?? '0.5s';
+ const delay = validTime(token.props.args.delay) ?? '0s';
+ style = useAnim ? `animation: mfm-shake ${speed} ease infinite; animation-delay: ${delay};` : '';
+ break;
+ }
+ case 'spin': {
+ const direction =
+ token.props.args.left ? 'reverse' :
+ token.props.args.alternate ? 'alternate' :
+ 'normal';
+ const anime =
+ token.props.args.x ? 'mfm-spinX' :
+ token.props.args.y ? 'mfm-spinY' :
+ 'mfm-spin';
+ const speed = validTime(token.props.args.speed) ?? '1.5s';
+ const delay = validTime(token.props.args.delay) ?? '0s';
+ style = useAnim ? `animation: ${anime} ${speed} linear infinite; animation-direction: ${direction}; animation-delay: ${delay};` : '';
+ break;
+ }
+ case 'jump': {
+ const speed = validTime(token.props.args.speed) ?? '0.75s';
+ const delay = validTime(token.props.args.delay) ?? '0s';
+ style = useAnim ? `animation: mfm-jump ${speed} linear infinite; animation-delay: ${delay};` : '';
+ break;
+ }
+ case 'bounce': {
+ const speed = validTime(token.props.args.speed) ?? '0.75s';
+ const delay = validTime(token.props.args.delay) ?? '0s';
+ style = useAnim ? `animation: mfm-bounce ${speed} linear infinite; transform-origin: center bottom; animation-delay: ${delay};` : '';
+ break;
+ }
+ case 'flip': {
+ const transform =
+ (token.props.args.h && token.props.args.v) ? 'scale(-1, -1)' :
+ token.props.args.v ? 'scaleY(-1)' :
+ 'scaleX(-1)';
+ style = `transform: ${transform};`;
+ break;
+ }
+ case 'x2': {
+ return h('span', {
+ class: 'mfm-x2',
+ }, genEl(token.children, scale * 2));
+ }
+ case 'x3': {
+ return h('span', {
+ class: 'mfm-x3',
+ }, genEl(token.children, scale * 3));
+ }
+ case 'x4': {
+ return h('span', {
+ class: 'mfm-x4',
+ }, genEl(token.children, scale * 4));
+ }
+ case 'font': {
+ const family =
+ token.props.args.serif ? 'serif' :
+ token.props.args.monospace ? 'monospace' :
+ token.props.args.cursive ? 'cursive' :
+ token.props.args.fantasy ? 'fantasy' :
+ token.props.args.emoji ? 'emoji' :
+ token.props.args.math ? 'math' :
+ null;
+ if (family) style = `font-family: ${family};`;
+ break;
+ }
+ case 'blur': {
+ return h('span', {
+ class: '_mfm_blur_',
+ }, genEl(token.children, scale));
+ }
+ case 'rainbow': {
+ if (!useAnim) {
+ return h('span', {
+ class: '_mfm_rainbow_fallback_',
+ }, genEl(token.children, scale));
+ }
+ const speed = validTime(token.props.args.speed) ?? '1s';
+ const delay = validTime(token.props.args.delay) ?? '0s';
+ style = `animation: mfm-rainbow ${speed} linear infinite; animation-delay: ${delay};`;
+ break;
+ }
+ case 'sparkle': {
+ return genEl(token.children, scale);
+ }
+ case 'rotate': {
+ const degrees = safeParseFloat(token.props.args.deg) ?? 90;
+ style = `transform: rotate(${degrees}deg); transform-origin: center center;`;
+ break;
+ }
+ case 'position': {
+ const x = safeParseFloat(token.props.args.x) ?? 0;
+ const y = safeParseFloat(token.props.args.y) ?? 0;
+ style = `transform: translateX(${x}em) translateY(${y}em);`;
+ break;
+ }
+ case 'scale': {
+ const x = Math.min(safeParseFloat(token.props.args.x) ?? 1, 5);
+ const y = Math.min(safeParseFloat(token.props.args.y) ?? 1, 5);
+ style = `transform: scale(${x}, ${y});`;
+ scale = scale * Math.max(x, y);
+ break;
+ }
+ case 'fg': {
+ let color = validColor(token.props.args.color);
+ color = color ?? 'f00';
+ style = `color: #${color}; overflow-wrap: anywhere;`;
+ break;
+ }
+ case 'bg': {
+ let color = validColor(token.props.args.color);
+ color = color ?? 'f00';
+ style = `background-color: #${color}; overflow-wrap: anywhere;`;
+ break;
+ }
+ case 'border': {
+ let color = validColor(token.props.args.color);
+ color = color ? `#${color}` : 'var(--accent)';
+ let b_style = token.props.args.style;
+ if (
+ typeof b_style !== 'string' ||
+ !['hidden', 'dotted', 'dashed', 'solid', 'double', 'groove', 'ridge', 'inset', 'outset']
+ .includes(b_style)
+ ) b_style = 'solid';
+ const width = safeParseFloat(token.props.args.width) ?? 1;
+ const radius = safeParseFloat(token.props.args.radius) ?? 0;
+ style = `border: ${width}px ${b_style} ${color}; border-radius: ${radius}px;${token.props.args.noclip ? '' : ' overflow: clip;'}`;
+ break;
+ }
+ case 'ruby': {
+ if (token.children.length === 1) {
+ const child = token.children[0];
+ let text = child.type === 'text' ? child.props.text : '';
+ if (!disableNyaize && shouldNyaize) {
+ text = Misskey.nyaize(text);
+ }
+ return h('ruby', {}, [text.split(' ')[0], h('rt', text.split(' ')[1])]);
+ } else {
+ const rt = token.children.at(-1)!;
+ let text = rt.type === 'text' ? rt.props.text : '';
+ if (!disableNyaize && shouldNyaize) {
+ text = Misskey.nyaize(text);
+ }
+ return h('ruby', {}, [...genEl(token.children.slice(0, token.children.length - 1), scale), h('rt', text.trim())]);
+ }
+ }
+ case 'unixtime': {
+ const child = token.children[0];
+ const unixtime = parseInt(child.type === 'text' ? child.props.text : '');
+ return h('span', {
+ style: 'display: inline-block; font-size: 90%; border: solid 1px var(--divider); border-radius: 999px; padding: 4px 10px 4px 6px;',
+ }, [
+ h('i', {
+ class: 'ti ti-clock',
+ style: 'margin-right: 0.25em;',
+ }),
+ h(EmTime, {
+ key: Math.random(),
+ time: unixtime * 1000,
+ mode: 'detail',
+ }),
+ ]);
+ }
+ case 'clickable': {
+ return h('span', { onClick(ev: MouseEvent): void {
+ ev.stopPropagation();
+ ev.preventDefault();
+ const clickEv = typeof token.props.args.ev === 'string' ? token.props.args.ev : '';
+ emit('clickEv', clickEv);
+ } }, genEl(token.children, scale));
+ }
+ }
+ if (style === undefined) {
+ return h('span', {}, ['$[', token.props.name, ' ', ...genEl(token.children, scale), ']']);
+ } else {
+ return h('span', {
+ style: 'display: inline-block; ' + style,
+ }, genEl(token.children, scale));
+ }
+ }
+
+ case 'small': {
+ return [h('small', {
+ style: 'opacity: 0.7;',
+ }, genEl(token.children, scale))];
+ }
+
+ case 'center': {
+ return [h('div', {
+ style: 'text-align:center;',
+ }, genEl(token.children, scale))];
+ }
+
+ case 'url': {
+ return [h(EmUrl, {
+ key: Math.random(),
+ url: token.props.url,
+ rel: 'nofollow noopener',
+ })];
+ }
+
+ case 'link': {
+ return [h(EmLink, {
+ key: Math.random(),
+ url: token.props.url,
+ rel: 'nofollow noopener',
+ }, genEl(token.children, scale, true))];
+ }
+
+ case 'mention': {
+ return [h(EmMention, {
+ key: Math.random(),
+ host: (token.props.host == null && props.author && props.author.host != null ? props.author.host : token.props.host) ?? host,
+ username: token.props.username,
+ })];
+ }
+
+ case 'hashtag': {
+ return [h(EmA, {
+ key: Math.random(),
+ to: isNote ? `/tags/${encodeURIComponent(token.props.hashtag)}` : `/user-tags/${encodeURIComponent(token.props.hashtag)}`,
+ style: 'color:var(--hashtag);',
+ }, `#${token.props.hashtag}`)];
+ }
+
+ case 'blockCode': {
+ return [h('code', {
+ key: Math.random(),
+ lang: token.props.lang ?? undefined,
+ }, token.props.code)];
+ }
+
+ case 'inlineCode': {
+ return [h('code', {
+ key: Math.random(),
+ }, token.props.code)];
+ }
+
+ case 'quote': {
+ if (!props.nowrap) {
+ return [h('div', {
+ style: QUOTE_STYLE,
+ }, genEl(token.children, scale, true))];
+ } else {
+ return [h('span', {
+ style: QUOTE_STYLE,
+ }, genEl(token.children, scale, true))];
+ }
+ }
+
+ case 'emojiCode': {
+ if (props.author?.host == null) {
+ return [h(EmCustomEmoji, {
+ key: Math.random(),
+ name: token.props.name,
+ normal: props.plain,
+ host: null,
+ useOriginalSize: scale >= 2.5,
+ menu: props.enableEmojiMenu,
+ menuReaction: props.enableEmojiMenuReaction,
+ fallbackToImage: false,
+ })];
+ } else {
+ // eslint-disable-next-line @typescript-eslint/no-unnecessary-condition
+ if (props.emojiUrls && (props.emojiUrls[token.props.name] == null)) {
+ return [h('span', `:${token.props.name}:`)];
+ } else {
+ return [h(EmCustomEmoji, {
+ key: Math.random(),
+ name: token.props.name,
+ url: props.emojiUrls && props.emojiUrls[token.props.name],
+ normal: props.plain,
+ host: props.author.host,
+ useOriginalSize: scale >= 2.5,
+ })];
+ }
+ }
+ }
+
+ case 'unicodeEmoji': {
+ return [h(EmEmoji, {
+ key: Math.random(),
+ emoji: token.props.emoji,
+ menu: props.enableEmojiMenu,
+ menuReaction: props.enableEmojiMenuReaction,
+ })];
+ }
+
+ case 'mathInline': {
+ return [h('code', token.props.formula)];
+ }
+
+ case 'mathBlock': {
+ return [h('code', token.props.formula)];
+ }
+
+ case 'search': {
+ return [h('div', {
+ key: Math.random(),
+ }, token.props.query)];
+ }
+
+ case 'plain': {
+ return [h('span', genEl(token.children, scale, true))];
+ }
+
+ default: {
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
+ console.error('unrecognized ast type:', (token as any).type);
+
+ return [];
+ }
+ }
+ }).flat(Infinity) as (VNode | string)[];
+
+ return h('span', {
+ // https://codeday.me/jp/qa/20190424/690106.html
+ style: props.nowrap ? 'white-space: pre; word-wrap: normal; overflow: hidden; text-overflow: ellipsis;' : 'white-space: pre-wrap;',
+ }, genEl(rootAst, props.rootScale ?? 1));
+}
diff --git a/packages/frontend-embed/src/components/EmNote.vue b/packages/frontend-embed/src/components/EmNote.vue
new file mode 100644
index 0000000000..7c4d591066
--- /dev/null
+++ b/packages/frontend-embed/src/components/EmNote.vue
@@ -0,0 +1,609 @@
+<!--
+SPDX-FileCopyrightText: syuilo and misskey-project
+SPDX-License-Identifier: AGPL-3.0-only
+-->
+
+<template>
+<div
+ v-show="!isDeleted"
+ ref="rootEl"
+ :class="[$style.root]"
+ :tabindex="isDeleted ? '-1' : '0'"
+>
+ <EmNoteSub v-if="appearNote.reply" :note="appearNote.reply" :class="$style.replyTo"/>
+ <div v-if="pinned" :class="$style.tip"><i class="ti ti-pin"></i> {{ i18n.ts.pinnedNote }}</div>
+ <!--<div v-if="appearNote._prId_" class="tip"><i class="ti ti-speakerphone"></i> {{ i18n.ts.promotion }}<button class="_textButton hide" @click="readPromo()">{{ i18n.ts.hideThisNote }} <i class="ti ti-x"></i></button></div>-->
+ <!--<div v-if="appearNote._featuredId_" class="tip"><i class="ti ti-bolt"></i> {{ i18n.ts.featured }}</div>-->
+ <div v-if="isRenote" :class="$style.renote">
+ <div v-if="note.channel" :class="$style.colorBar" :style="{ background: note.channel.color }"></div>
+ <EmAvatar :class="$style.renoteAvatar" :user="note.user" link/>
+ <i class="ti ti-repeat" style="margin-right: 4px;"></i>
+ <I18n :src="i18n.ts.renotedBy" tag="span" :class="$style.renoteText">
+ <template #user>
+ <EmA v-user-preview="true ? undefined : note.userId" :class="$style.renoteUserName" :to="userPage(note.user)">
+ <EmUserName :user="note.user"/>
+ </EmA>
+ </template>
+ </I18n>
+ <div :class="$style.renoteInfo">
+ <button ref="renoteTime" :class="$style.renoteTime" class="_button">
+ <i class="ti ti-dots" :class="$style.renoteMenu"></i>
+ <EmTime :time="note.createdAt"/>
+ </button>
+ <span v-if="note.visibility !== 'public'" style="margin-left: 0.5em;" :title="i18n.ts._visibility[note.visibility]">
+ <i v-if="note.visibility === 'home'" class="ti ti-home"></i>
+ <i v-else-if="note.visibility === 'followers'" class="ti ti-lock"></i>
+ <i v-else-if="note.visibility === 'specified'" ref="specified" class="ti ti-mail"></i>
+ </span>
+ <span v-if="note.localOnly" style="margin-left: 0.5em;" :title="i18n.ts._visibility['disableFederation']"><i class="ti ti-rocket-off"></i></span>
+ <span v-if="note.channel" style="margin-left: 0.5em;" :title="note.channel.name"><i class="ti ti-device-tv"></i></span>
+ </div>
+ </div>
+ <article :class="$style.article">
+ <div v-if="appearNote.channel" :class="$style.colorBar" :style="{ background: appearNote.channel.color }"></div>
+ <EmAvatar :class="$style.avatar" :user="appearNote.user" link/>
+ <div :class="$style.main">
+ <EmNoteHeader :note="appearNote" :mini="true"/>
+ <div style="container-type: inline-size;">
+ <p v-if="appearNote.cw != null" :class="$style.cw">
+ <EmMfm v-if="appearNote.cw != ''" style="margin-right: 8px;" :text="appearNote.cw" :author="appearNote.user" :nyaize="'respect'"/>
+ <button style="display: block; width: 100%; margin: 4px 0;" class="_buttonGray _buttonRounded" @click="showContent = !showContent">{{ showContent ? i18n.ts._cw.hide : i18n.ts._cw.show }}</button>
+ </p>
+ <div v-show="appearNote.cw == null || showContent" :class="[{ [$style.contentCollapsed]: collapsed }]">
+ <div :class="$style.text">
+ <span v-if="appearNote.isHidden" style="opacity: 0.5">({{ i18n.ts.private }})</span>
+ <EmA v-if="appearNote.replyId" :class="$style.replyIcon" :to="`/notes/${appearNote.replyId}`"><i class="ti ti-arrow-back-up"></i></EmA>
+ <EmMfm
+ v-if="appearNote.text"
+ :parsedNodes="parsed"
+ :text="appearNote.text"
+ :author="appearNote.user"
+ :nyaize="'respect'"
+ :emojiUrls="appearNote.emojis"
+ :enableEmojiMenu="!true"
+ :enableEmojiMenuReaction="true"
+ />
+ </div>
+ <div v-if="appearNote.files && appearNote.files.length > 0">
+ <EmMediaList :mediaList="appearNote.files" :originalEntityUrl="`${url}/notes/${appearNote.id}`"/>
+ </div>
+ <EmPoll v-if="appearNote.poll" :noteId="appearNote.id" :poll="appearNote.poll" :readOnly="true" :class="$style.poll"/>
+ <div v-if="appearNote.renote" :class="$style.quote"><EmNoteSimple :note="appearNote.renote" :class="$style.quoteNote"/></div>
+ <button v-if="isLong && collapsed" :class="$style.collapsed" class="_button" @click="collapsed = false">
+ <span :class="$style.collapsedLabel">{{ i18n.ts.showMore }}</span>
+ </button>
+ <button v-else-if="isLong && !collapsed" :class="$style.showLess" class="_button" @click="collapsed = true">
+ <span :class="$style.showLessLabel">{{ i18n.ts.showLess }}</span>
+ </button>
+ </div>
+ <EmA v-if="appearNote.channel && !inChannel" :class="$style.channel" :to="`/channels/${appearNote.channel.id}`"><i class="ti ti-device-tv"></i> {{ appearNote.channel.name }}</EmA>
+ </div>
+ <EmReactionsViewer v-if="appearNote.reactionAcceptance !== 'likeOnly'" :note="appearNote" :maxNumber="16">
+ <template #more>
+ <EmA :to="`/notes/${appearNote.id}/reactions`" :class="[$style.reactionOmitted]">{{ i18n.ts.more }}</EmA>
+ </template>
+ </EmReactionsViewer>
+ <footer :class="$style.footer">
+ <a :href="`/notes/${appearNote.id}`" target="_blank" rel="noopener" :class="[$style.footerButton, $style.footerButtonLink]" class="_button">
+ <i class="ti ti-arrow-back-up"></i>
+ </a>
+ <a :href="`/notes/${appearNote.id}`" target="_blank" rel="noopener" :class="[$style.footerButton, $style.footerButtonLink]" class="_button">
+ <i class="ti ti-repeat"></i>
+ </a>
+ <a :href="`/notes/${appearNote.id}`" target="_blank" rel="noopener" :class="[$style.footerButton, $style.footerButtonLink]" class="_button">
+ <i v-if="appearNote.reactionAcceptance === 'likeOnly'" class="ti ti-heart"></i>
+ <i v-else class="ti ti-plus"></i>
+ </a>
+ <a :href="`/notes/${appearNote.id}`" target="_blank" rel="noopener" :class="[$style.footerButton, $style.footerButtonLink]" class="_button">
+ <i class="ti ti-dots"></i>
+ </a>
+ </footer>
+ </div>
+ </article>
+</div>
+</template>
+
+<script lang="ts" setup>
+import { computed, inject, onMounted, ref, shallowRef, Ref, watch, provide } from 'vue';
+import * as mfm from 'mfm-js';
+import * as Misskey from 'misskey-js';
+import I18n from '@/components/I18n.vue';
+import EmNoteSub from '@/components/EmNoteSub.vue';
+import EmNoteHeader from '@/components/EmNoteHeader.vue';
+import EmNoteSimple from '@/components/EmNoteSimple.vue';
+import EmReactionsViewer from '@/components/EmReactionsViewer.vue';
+import EmMediaList from '@/components/EmMediaList.vue';
+import EmPoll from '@/components/EmPoll.vue';
+import EmMfm from '@/components/EmMfm.js';
+import EmA from '@/components/EmA.vue';
+import EmAvatar from '@/components/EmAvatar.vue';
+import EmUserName from '@/components/EmUserName.vue';
+import EmTime from '@/components/EmTime.vue';
+import { userPage } from '@/utils.js';
+import { i18n } from '@/i18n.js';
+import { shouldCollapsed } from '@/to-be-shared/collapsed.js';
+import { url } from '@/config.js';
+
+function getAppearNote(note: Misskey.entities.Note) {
+ return Misskey.note.isPureRenote(note) ? note.renote : note;
+}
+
+const props = withDefaults(defineProps<{
+ note: Misskey.entities.Note;
+ pinned?: boolean;
+}>(), {
+});
+
+const emit = defineEmits<{
+ (ev: 'reaction', emoji: string): void;
+ (ev: 'removeReaction', emoji: string): void;
+}>();
+
+const inChannel = inject('inChannel', null);
+
+const note = ref((props.note));
+
+const isRenote = Misskey.note.isPureRenote(note.value);
+
+const rootEl = shallowRef<HTMLElement>();
+const renoteTime = shallowRef<HTMLElement>();
+const appearNote = computed(() => getAppearNote(note.value));
+const showContent = ref(false);
+const parsed = computed(() => appearNote.value.text ? mfm.parse(appearNote.value.text) : null);
+const isLong = shouldCollapsed(appearNote.value, []);
+const collapsed = ref(appearNote.value.cw == null && isLong);
+const isDeleted = ref(false);
+</script>
+
+<style lang="scss" module>
+.root {
+ position: relative;
+ transition: box-shadow 0.1s ease;
+ font-size: 1.05em;
+ overflow: clip;
+ contain: content;
+
+ // これらの指定はパフォーマンス向上には有効だが、ノートの高さは一定でないため、
+ // 下の方までスクロールすると上のノートの高さがここで決め打ちされたものに変化し、表示しているノートの位置が変わってしまう
+ // ノートがマウントされたときに自身の高さを取得し contain-intrinsic-size を設定しなおせばほぼ解決できそうだが、
+ // 今度はその処理自体がパフォーマンス低下の原因にならないか懸念される。また、被リアクションでも高さは変化するため、やはり多少のズレは生じる
+ // 一度レンダリングされた要素はブラウザがよしなにサイズを覚えておいてくれるような実装になるまで待った方が良さそう(なるのか?)
+ //content-visibility: auto;
+ //contain-intrinsic-size: 0 128px;
+
+ &:focus-visible {
+ outline: none;
+
+ &::after {
+ content: "";
+ pointer-events: none;
+ display: block;
+ position: absolute;
+ z-index: 10;
+ top: 0;
+ left: 0;
+ right: 0;
+ bottom: 0;
+ margin: auto;
+ width: calc(100% - 8px);
+ height: calc(100% - 8px);
+ border: dashed 2px var(--focus);
+ border-radius: var(--radius);
+ box-sizing: border-box;
+ }
+ }
+
+ .footer {
+ position: relative;
+ z-index: 1;
+ }
+
+ &:hover > .article > .main > .footer > .footerButton {
+ opacity: 1;
+ }
+
+ &.showActionsOnlyHover {
+ .footer {
+ visibility: hidden;
+ position: absolute;
+ top: 12px;
+ right: 12px;
+ padding: 0 4px;
+ margin-bottom: 0 !important;
+ background: var(--popup);
+ border-radius: 8px;
+ box-shadow: 0px 4px 32px var(--shadow);
+ }
+
+ .footerButton {
+ font-size: 90%;
+
+ &:not(:last-child) {
+ margin-right: 0;
+ }
+ }
+ }
+
+ &.showActionsOnlyHover:hover {
+ .footer {
+ visibility: visible;
+ }
+ }
+}
+
+.tip {
+ display: flex;
+ align-items: center;
+ padding: 16px 32px 8px 32px;
+ line-height: 24px;
+ font-size: 90%;
+ white-space: pre;
+ color: #d28a3f;
+}
+
+.tip + .article {
+ padding-top: 8px;
+}
+
+.replyTo {
+ opacity: 0.7;
+ padding-bottom: 0;
+}
+
+.renote {
+ position: relative;
+ display: flex;
+ align-items: center;
+ padding: 16px 32px 8px 32px;
+ line-height: 28px;
+ white-space: pre;
+ color: var(--renote);
+
+ & + .article {
+ padding-top: 8px;
+ }
+
+ > .colorBar {
+ height: calc(100% - 6px);
+ }
+}
+
+.renoteAvatar {
+ flex-shrink: 0;
+ display: inline-block;
+ width: 28px;
+ height: 28px;
+ margin: 0 8px 0 0;
+}
+
+.renoteText {
+ overflow: hidden;
+ flex-shrink: 1;
+ text-overflow: ellipsis;
+ white-space: nowrap;
+}
+
+.renoteUserName {
+ font-weight: bold;
+}
+
+.renoteInfo {
+ margin-left: auto;
+ font-size: 0.9em;
+}
+
+.renoteTime {
+ flex-shrink: 0;
+ color: inherit;
+}
+
+.renoteMenu {
+ margin-right: 4px;
+}
+
+.collapsedRenoteTarget {
+ display: flex;
+ align-items: center;
+ line-height: 28px;
+ white-space: pre;
+ padding: 0 32px 18px;
+}
+
+.collapsedRenoteTargetAvatar {
+ flex-shrink: 0;
+ display: inline-block;
+ width: 28px;
+ height: 28px;
+ margin: 0 8px 0 0;
+}
+
+.collapsedRenoteTargetText {
+ overflow: hidden;
+ flex-shrink: 1;
+ text-overflow: ellipsis;
+ white-space: nowrap;
+ font-size: 90%;
+ opacity: 0.7;
+ cursor: pointer;
+
+ &:hover {
+ text-decoration: underline;
+ }
+}
+
+.article {
+ position: relative;
+ display: flex;
+ padding: 28px 32px;
+}
+
+.colorBar {
+ position: absolute;
+ top: 8px;
+ left: 8px;
+ width: 5px;
+ height: calc(100% - 16px);
+ border-radius: 999px;
+ pointer-events: none;
+}
+
+.avatar {
+ flex-shrink: 0;
+ display: block !important;
+ margin: 0 14px 0 0;
+ width: 58px;
+ height: 58px;
+ position: sticky !important;
+ top: calc(22px + var(--stickyTop, 0px));
+ left: 0;
+}
+
+.main {
+ flex: 1;
+ min-width: 0;
+}
+
+.cw {
+ cursor: default;
+ display: block;
+ margin: 0;
+ padding: 0;
+ overflow-wrap: break-word;
+}
+
+.showLess {
+ width: 100%;
+ margin-top: 14px;
+ position: sticky;
+ bottom: calc(var(--stickyBottom, 0px) + 14px);
+}
+
+.showLessLabel {
+ display: inline-block;
+ background: var(--popup);
+ padding: 6px 10px;
+ font-size: 0.8em;
+ border-radius: 999px;
+ box-shadow: 0 2px 6px rgb(0 0 0 / 20%);
+}
+
+.contentCollapsed {
+ position: relative;
+ max-height: 9em;
+ overflow: clip;
+}
+
+.collapsed {
+ display: block;
+ position: absolute;
+ bottom: 0;
+ left: 0;
+ z-index: 2;
+ width: 100%;
+ height: 64px;
+ background: linear-gradient(0deg, var(--panel), color(from var(--panel) srgb r g b / 0));
+
+ &:hover > .collapsedLabel {
+ background: var(--panelHighlight);
+ }
+}
+
+.collapsedLabel {
+ display: inline-block;
+ background: var(--panel);
+ padding: 6px 10px;
+ font-size: 0.8em;
+ border-radius: 999px;
+ box-shadow: 0 2px 6px rgb(0 0 0 / 20%);
+}
+
+.text {
+ overflow-wrap: break-word;
+}
+
+.replyIcon {
+ color: var(--accent);
+ margin-right: 0.5em;
+}
+
+.translation {
+ border: solid 0.5px var(--divider);
+ border-radius: var(--radius);
+ padding: 12px;
+ margin-top: 8px;
+}
+
+.urlPreview {
+ margin-top: 8px;
+}
+
+.poll {
+ font-size: 80%;
+}
+
+.quote {
+ padding: 8px 0;
+}
+
+.quoteNote {
+ padding: 16px;
+ border: dashed 1px var(--renote);
+ border-radius: 8px;
+ overflow: clip;
+}
+
+.channel {
+ opacity: 0.7;
+ font-size: 80%;
+}
+
+.footer {
+ margin-bottom: -14px;
+}
+
+.footerButton {
+ margin: 0;
+ padding: 8px;
+ opacity: 0.7;
+
+ &:not(:last-child) {
+ margin-right: 28px;
+ }
+
+ &:hover {
+ color: var(--fgHighlighted);
+ }
+}
+
+.footerButtonLink:hover,
+.footerButtonLink:focus,
+.footerButtonLink:active {
+ text-decoration: none;
+}
+
+.footerButtonCount {
+ display: inline;
+ margin: 0 0 0 8px;
+ opacity: 0.7;
+}
+
+@container (max-width: 580px) {
+ .root {
+ font-size: 0.95em;
+ }
+
+ .renote {
+ padding: 12px 26px 0 26px;
+ }
+
+ .article {
+ padding: 24px 26px;
+ }
+
+ .avatar {
+ width: 50px;
+ height: 50px;
+ }
+}
+
+@container (max-width: 500px) {
+ .root {
+ font-size: 0.9em;
+ }
+
+ .renote {
+ padding: 10px 22px 0 22px;
+ }
+
+ .article {
+ padding: 20px 22px;
+ }
+
+ .footer {
+ margin-bottom: -8px;
+ }
+}
+
+@container (max-width: 480px) {
+ .renote {
+ padding: 8px 16px 0 16px;
+ }
+
+ .tip {
+ padding: 8px 16px 0 16px;
+ }
+
+ .collapsedRenoteTarget {
+ padding: 0 16px 9px;
+ margin-top: 4px;
+ }
+
+ .article {
+ padding: 14px 16px;
+ }
+}
+
+@container (max-width: 450px) {
+ .avatar {
+ margin: 0 10px 0 0;
+ width: 46px;
+ height: 46px;
+ top: calc(14px + var(--stickyTop, 0px));
+ }
+}
+
+@container (max-width: 400px) {
+ .root:not(.showActionsOnlyHover) {
+ .footerButton {
+ &:not(:last-child) {
+ margin-right: 18px;
+ }
+ }
+ }
+}
+
+@container (max-width: 350px) {
+ .root:not(.showActionsOnlyHover) {
+ .footerButton {
+ &:not(:last-child) {
+ margin-right: 12px;
+ }
+ }
+ }
+
+ .colorBar {
+ top: 6px;
+ left: 6px;
+ width: 4px;
+ height: calc(100% - 12px);
+ }
+}
+
+@container (max-width: 300px) {
+ .avatar {
+ width: 44px;
+ height: 44px;
+ }
+
+ .root:not(.showActionsOnlyHover) {
+ .footerButton {
+ &:not(:last-child) {
+ margin-right: 8px;
+ }
+ }
+ }
+}
+
+@container (max-width: 250px) {
+ .quoteNote {
+ padding: 12px;
+ }
+}
+
+.reactionOmitted {
+ display: inline-block;
+ margin-left: 8px;
+ opacity: .8;
+ font-size: 95%;
+}
+</style>
diff --git a/packages/frontend-embed/src/components/EmNoteDetailed.vue b/packages/frontend-embed/src/components/EmNoteDetailed.vue
new file mode 100644
index 0000000000..74a26856c8
--- /dev/null
+++ b/packages/frontend-embed/src/components/EmNoteDetailed.vue
@@ -0,0 +1,486 @@
+<!--
+SPDX-FileCopyrightText: syuilo and misskey-project
+SPDX-License-Identifier: AGPL-3.0-only
+-->
+
+<template>
+<div
+ v-show="!isDeleted"
+ ref="rootEl"
+ :class="$style.root"
+>
+ <EmNoteSub v-if="appearNote.reply" :note="appearNote.reply" :class="$style.replyTo"/>
+ <div v-if="isRenote" :class="$style.renote">
+ <EmAvatar :class="$style.renoteAvatar" :user="note.user" link/>
+ <i class="ti ti-repeat" style="margin-right: 4px;"></i>
+ <span :class="$style.renoteText">
+ <I18n :src="i18n.ts.renotedBy" tag="span">
+ <template #user>
+ <EmA :class="$style.renoteName" :to="userPage(note.user)">
+ <EmUserName :user="note.user"/>
+ </EmA>
+ </template>
+ </I18n>
+ </span>
+ <div :class="$style.renoteInfo">
+ <div class="$style.renoteTime">
+ <EmTime :time="note.createdAt"/>
+ </div>
+ <span v-if="note.visibility !== 'public'" style="margin-left: 0.5em;" :title="i18n.ts._visibility[note.visibility]">
+ <i v-if="note.visibility === 'home'" class="ti ti-home"></i>
+ <i v-else-if="note.visibility === 'followers'" class="ti ti-lock"></i>
+ <i v-else-if="note.visibility === 'specified'" ref="specified" class="ti ti-mail"></i>
+ </span>
+ <span v-if="note.localOnly" style="margin-left: 0.5em;" :title="i18n.ts._visibility['disableFederation']"><i class="ti ti-rocket-off"></i></span>
+ </div>
+ </div>
+ <article :class="$style.note">
+ <header :class="$style.noteHeader">
+ <EmAvatar :class="$style.noteHeaderAvatar" :user="appearNote.user" indicator link/>
+ <div :class="$style.noteHeaderBody">
+ <div :class="$style.noteHeaderBodyUpper">
+ <div style="min-width: 0;">
+ <div class="_nowrap">
+ <EmA :class="$style.noteHeaderName" :to="userPage(appearNote.user)">
+ <EmUserName :nowrap="true" :user="appearNote.user"/>
+ </EmA>
+ <span v-if="appearNote.user.isBot" :class="$style.isBot">bot</span>
+ </div>
+ <div :class="$style.noteHeaderUsername"><EmAcct :user="appearNote.user"/></div>
+ </div>
+ <div :class="$style.noteHeaderInfo">
+ <a :href="url" :class="$style.noteHeaderInstanceIconLink" target="_blank" rel="noopener noreferrer">
+ <img :src="serverMetadata.iconUrl || '/favicon.ico'" alt="" :class="$style.noteHeaderInstanceIcon"/>
+ </a>
+ </div>
+ </div>
+ </div>
+ </header>
+ <div :class="[$style.noteContent, { [$style.contentCollapsed]: collapsed }]">
+ <p v-if="appearNote.cw != null" :class="$style.cw">
+ <EmMfm v-if="appearNote.cw != ''" style="margin-right: 8px;" :text="appearNote.cw" :author="appearNote.user" :nyaize="'respect'"/>
+ <button style="display: block; width: 100%; margin: 4px 0;" class="_buttonGray _buttonRounded" @click="showContent = !showContent">{{ showContent ? i18n.ts._cw.hide : i18n.ts._cw.show }}</button>
+ </p>
+ <div v-show="appearNote.cw == null || showContent">
+ <span v-if="appearNote.isHidden" style="opacity: 0.5">({{ i18n.ts.private }})</span>
+ <EmA v-if="appearNote.replyId" :class="$style.noteReplyTarget" :to="`/notes/${appearNote.replyId}`"><i class="ti ti-arrow-back-up"></i></EmA>
+ <EmMfm
+ v-if="appearNote.text"
+ :parsedNodes="parsed"
+ :text="appearNote.text"
+ :author="appearNote.user"
+ :nyaize="'respect'"
+ :emojiUrls="appearNote.emojis"
+ />
+ <a v-if="appearNote.renote != null" :class="$style.rn">RN:</a>
+ <div v-if="appearNote.files && appearNote.files.length > 0">
+ <EmMediaList :mediaList="appearNote.files" :originalEntityUrl="`${url}/notes/${appearNote.id}`"/>
+ </div>
+ <EmPoll v-if="appearNote.poll" ref="pollViewer" :noteId="appearNote.id" :poll="appearNote.poll" :readOnly="true" :class="$style.poll"/>
+ <div v-if="appearNote.renote" :class="$style.quote"><EmNoteSimple :note="appearNote.renote" :class="$style.quoteNote"/></div>
+ <button v-if="isLong && collapsed" :class="$style.collapsed" class="_button" @click="collapsed = false">
+ <span :class="$style.collapsedLabel">{{ i18n.ts.showMore }}</span>
+ </button>
+ <button v-else-if="isLong && !collapsed" :class="$style.showLess" class="_button" @click="collapsed = true">
+ <span :class="$style.showLessLabel">{{ i18n.ts.showLess }}</span>
+ </button>
+ </div>
+ <EmA v-if="appearNote.channel && !inChannel" :class="$style.channel" :to="`/channels/${appearNote.channel.id}`"><i class="ti ti-device-tv"></i> {{ appearNote.channel.name }}</EmA>
+ </div>
+ <footer>
+ <div :class="$style.noteFooterInfo">
+ <span v-if="appearNote.visibility !== 'public'" style="display: inline-block; margin-right: 0.5em;" :title="i18n.ts._visibility[appearNote.visibility]">
+ <i v-if="appearNote.visibility === 'home'" class="ti ti-home"></i>
+ <i v-else-if="appearNote.visibility === 'followers'" class="ti ti-lock"></i>
+ <i v-else-if="appearNote.visibility === 'specified'" ref="specified" class="ti ti-mail"></i>
+ </span>
+ <span v-if="appearNote.localOnly" style="display: inline-block; margin-right: 0.5em;" :title="i18n.ts._visibility['disableFederation']"><i class="ti ti-rocket-off"></i></span>
+ <EmA :to="notePage(appearNote)">
+ <EmTime :time="appearNote.createdAt" mode="detail" colored/>
+ </EmA>
+ </div>
+ <EmReactionsViewer v-if="appearNote.reactionAcceptance !== 'likeOnly'" ref="reactionsViewer" :maxNumber="16" :note="appearNote">
+ <template #more>
+ <EmA :to="`/notes/${appearNote.id}`" :class="[$style.reactionOmitted]">{{ i18n.ts.more }}</EmA>
+ </template>
+ </EmReactionsViewer>
+ <a :href="`/notes/${appearNote.id}`" target="_blank" rel="noopener" :class="[$style.noteFooterButton, $style.footerButtonLink]" class="_button">
+ <i class="ti ti-arrow-back-up"></i>
+ </a>
+ <a :href="`/notes/${appearNote.id}`" target="_blank" rel="noopener" :class="[$style.noteFooterButton, $style.footerButtonLink]" class="_button">
+ <i class="ti ti-repeat"></i>
+ <p v-if="appearNote.renoteCount > 0" :class="$style.noteFooterButtonCount">{{ (appearNote.renoteCount) }}</p>
+ </a>
+ <a :href="`/notes/${appearNote.id}`" target="_blank" rel="noopener" :class="[$style.noteFooterButton, $style.footerButtonLink]" class="_button">
+ <i v-if="appearNote.reactionAcceptance === 'likeOnly'" class="ti ti-heart"></i>
+ <i v-else class="ti ti-plus"></i>
+ <p v-if="(appearNote.reactionAcceptance === 'likeOnly') && appearNote.reactionCount > 0" :class="$style.noteFooterButtonCount">{{ (appearNote.reactionCount) }}</p>
+ </a>
+ <a :href="`/notes/${appearNote.id}`" target="_blank" rel="noopener" :class="[$style.noteFooterButton, $style.footerButtonLink]" class="_button">
+ <i class="ti ti-dots"></i>
+ </a>
+ </footer>
+ </article>
+</div>
+</template>
+
+<script lang="ts" setup>
+import { computed, inject, ref } from 'vue';
+import * as mfm from 'mfm-js';
+import * as Misskey from 'misskey-js';
+import I18n from '@/components/I18n.vue';
+import EmMediaList from '@/components/EmMediaList.vue';
+import EmNoteSub from '@/components/EmNoteSub.vue';
+import EmNoteSimple from '@/components/EmNoteSimple.vue';
+import EmReactionsViewer from '@/components/EmReactionsViewer.vue';
+import EmPoll from '@/components/EmPoll.vue';
+import EmA from '@/components/EmA.vue';
+import EmAvatar from '@/components/EmAvatar.vue';
+import EmTime from '@/components/EmTime.vue';
+import EmUserName from '@/components/EmUserName.vue';
+import EmAcct from '@/components/EmAcct.vue';
+import { userPage } from '@/utils.js';
+import { notePage } from '@/utils.js';
+import { i18n } from '@/i18n.js';
+import { shouldCollapsed } from '@/to-be-shared/collapsed.js';
+import { serverMetadata } from '@/server-metadata.js';
+import { url } from '@/config.js';
+import EmMfm from '@/components/EmMfm.js';
+
+const props = defineProps<{
+ note: Misskey.entities.Note;
+}>();
+
+const inChannel = inject('inChannel', null);
+
+const note = ref(props.note);
+
+const isRenote = (
+ note.value.renote != null &&
+ note.value.reply == null &&
+ note.value.text == null &&
+ note.value.cw == null &&
+ note.value.fileIds && note.value.fileIds.length === 0 &&
+ note.value.poll == null
+);
+
+const appearNote = computed(() => isRenote ? note.value.renote as Misskey.entities.Note : note.value);
+const showContent = ref(false);
+const isDeleted = ref(false);
+const parsed = appearNote.value.text ? mfm.parse(appearNote.value.text) : null;
+const isLong = shouldCollapsed(appearNote.value, []);
+const collapsed = ref(appearNote.value.cw == null && isLong);
+</script>
+
+<style lang="scss" module>
+.root {
+ position: relative;
+ transition: box-shadow 0.1s ease;
+ overflow: clip;
+ contain: content;
+}
+
+.replyTo {
+ opacity: 0.7;
+ padding-bottom: 0;
+}
+
+.renote {
+ display: flex;
+ align-items: center;
+ padding: 16px 32px 8px 32px;
+ line-height: 28px;
+ white-space: pre;
+ color: var(--renote);
+}
+
+.renoteAvatar {
+ flex-shrink: 0;
+ display: inline-block;
+ width: 28px;
+ height: 28px;
+ margin: 0 8px 0 0;
+ border-radius: 6px;
+}
+
+.renoteText {
+ overflow: hidden;
+ flex-shrink: 1;
+ text-overflow: ellipsis;
+ white-space: nowrap;
+}
+
+.renoteName {
+ font-weight: bold;
+}
+
+.renoteInfo {
+ margin-left: auto;
+ font-size: 0.9em;
+}
+
+.renoteTime {
+ flex-shrink: 0;
+ color: inherit;
+}
+
+.renote + .note {
+ padding-top: 8px;
+}
+
+.note {
+ padding: 24px 32px 16px;
+ font-size: 1.2em;
+
+ &:hover > .main > .footer > .button {
+ opacity: 1;
+ }
+}
+
+.noteHeader {
+ display: flex;
+ position: relative;
+ margin-bottom: 16px;
+ align-items: center;
+}
+
+.noteHeaderAvatar {
+ display: block;
+ flex-shrink: 0;
+ width: 50px;
+ height: 50px;
+}
+
+.noteHeaderBody {
+ flex: 1;
+ display: flex;
+ min-width: 0;
+ flex-direction: column;
+ justify-content: center;
+ padding-left: 16px;
+ font-size: 0.95em;
+}
+
+.noteHeaderBodyUpper {
+ display: flex;
+ min-width: 0;
+}
+
+.noteHeaderName {
+ font-weight: bold;
+ line-height: 1.3;
+}
+
+.isBot {
+ display: inline-block;
+ margin: 0 0.5em;
+ padding: 4px 6px;
+ font-size: 80%;
+ line-height: 1;
+ border: solid 0.5px var(--divider);
+ border-radius: 4px;
+}
+
+.noteHeaderInfo {
+ margin-left: auto;
+ display: flex;
+ gap: 0.5em;
+ align-items: center;
+}
+
+.noteHeaderInstanceIconLink {
+ display: inline-block;
+ margin-left: 4px;
+}
+
+.noteHeaderInstanceIcon {
+ width: 32px;
+ height: 32px;
+ border-radius: 4px;
+}
+
+.noteHeaderUsername {
+ margin-bottom: 2px;
+ line-height: 1.3;
+ word-wrap: anywhere;
+}
+
+.noteContent {
+ container-type: inline-size;
+ overflow-wrap: break-word;
+}
+
+.cw {
+ cursor: default;
+ display: block;
+ margin: 0;
+ padding: 0;
+ overflow-wrap: break-word;
+}
+
+.noteReplyTarget {
+ color: var(--accent);
+ margin-right: 0.5em;
+}
+
+.rn {
+ margin-left: 4px;
+ font-style: oblique;
+ color: var(--renote);
+}
+
+.reactionOmitted {
+ display: inline-block;
+ margin-left: 8px;
+ opacity: .8;
+ font-size: 95%;
+}
+
+.poll {
+ font-size: 80%;
+}
+
+.quote {
+ padding: 8px 0;
+}
+
+.quoteNote {
+ padding: 16px;
+ border: dashed 1px var(--renote);
+ border-radius: 8px;
+ overflow: clip;
+}
+
+.channel {
+ opacity: 0.7;
+ font-size: 80%;
+}
+
+.showLess {
+ width: 100%;
+ margin-top: 14px;
+ position: sticky;
+ bottom: calc(var(--stickyBottom, 0px) + 14px);
+}
+
+.showLessLabel {
+ display: inline-block;
+ background: var(--popup);
+ padding: 6px 10px;
+ font-size: 0.8em;
+ border-radius: 999px;
+ box-shadow: 0 2px 6px rgb(0 0 0 / 20%);
+}
+
+.contentCollapsed {
+ position: relative;
+ max-height: 9em;
+ overflow: clip;
+}
+
+.collapsed {
+ display: block;
+ position: absolute;
+ bottom: 0;
+ left: 0;
+ z-index: 2;
+ width: 100%;
+ height: 64px;
+ background: linear-gradient(0deg, var(--panel), var(--X15));
+
+ &:hover > .collapsedLabel {
+ background: var(--panelHighlight);
+ }
+}
+
+.collapsedLabel {
+ display: inline-block;
+ background: var(--panel);
+ padding: 6px 10px;
+ font-size: 0.8em;
+ border-radius: 999px;
+ box-shadow: 0 2px 6px rgb(0 0 0 / 20%);
+}
+
+.noteFooterInfo {
+ margin: 16px 0;
+ opacity: 0.7;
+ font-size: 0.9em;
+}
+
+.noteFooterButton {
+ margin: 0;
+ padding: 8px;
+ opacity: 0.7;
+
+ &:not(:last-child) {
+ margin-right: 28px;
+ }
+
+ &:hover {
+ color: var(--fgHighlighted);
+ }
+}
+
+.footerButtonLink:hover,
+.footerButtonLink:focus,
+.footerButtonLink:active {
+ text-decoration: none;
+}
+
+.noteFooterButtonCount {
+ display: inline;
+ margin: 0 0 0 8px;
+ opacity: 0.7;
+
+ &.reacted {
+ color: var(--accent);
+ }
+}
+
+@container (max-width: 500px) {
+ .root {
+ font-size: 0.9em;
+ }
+}
+
+@container (max-width: 450px) {
+ .renote {
+ padding: 8px 16px 0 16px;
+ }
+
+ .note {
+ padding: 16px;
+ }
+
+ .noteHeaderAvatar {
+ width: 50px;
+ height: 50px;
+ }
+}
+
+@container (max-width: 350px) {
+ .noteFooterButton {
+ &:not(:last-child) {
+ margin-right: 18px;
+ }
+ }
+}
+
+@container (max-width: 300px) {
+ .root {
+ font-size: 0.825em;
+ }
+
+ .noteHeaderAvatar {
+ width: 50px;
+ height: 50px;
+ }
+
+ .noteFooterButton {
+ &:not(:last-child) {
+ margin-right: 12px;
+ }
+ }
+}
+</style>
diff --git a/packages/frontend-embed/src/components/EmNoteHeader.vue b/packages/frontend-embed/src/components/EmNoteHeader.vue
new file mode 100644
index 0000000000..e4add9501f
--- /dev/null
+++ b/packages/frontend-embed/src/components/EmNoteHeader.vue
@@ -0,0 +1,104 @@
+<!--
+SPDX-FileCopyrightText: syuilo and misskey-project
+SPDX-License-Identifier: AGPL-3.0-only
+-->
+
+<template>
+<header :class="$style.root">
+ <EmA :class="$style.name" :to="userPage(note.user)">
+ <EmUserName :user="note.user"/>
+ </EmA>
+ <div v-if="note.user.isBot" :class="$style.isBot">bot</div>
+ <div :class="$style.username"><EmAcct :user="note.user"/></div>
+ <div v-if="note.user.badgeRoles" :class="$style.badgeRoles">
+ <img v-for="(role, i) in note.user.badgeRoles" :key="i" v-tooltip="role.name" :class="$style.badgeRole" :src="role.iconUrl!"/>
+ </div>
+ <div :class="$style.info">
+ <EmA :to="notePage(note)">
+ <EmTime :time="note.createdAt" colored/>
+ </EmA>
+ <span v-if="note.visibility !== 'public'" style="margin-left: 0.5em;">
+ <i v-if="note.visibility === 'home'" class="ti ti-home"></i>
+ <i v-else-if="note.visibility === 'followers'" class="ti ti-lock"></i>
+ <i v-else-if="note.visibility === 'specified'" ref="specified" class="ti ti-mail"></i>
+ </span>
+ <span v-if="note.localOnly" style="margin-left: 0.5em;"><i class="ti ti-rocket-off"></i></span>
+ <span v-if="note.channel" style="margin-left: 0.5em;" :title="note.channel.name"><i class="ti ti-device-tv"></i></span>
+ </div>
+</header>
+</template>
+
+<script lang="ts" setup>
+import { } from 'vue';
+import * as Misskey from 'misskey-js';
+import { notePage } from '@/utils.js';
+import { userPage } from '@/utils.js';
+import EmA from '@/components/EmA.vue';
+import EmUserName from '@/components/EmUserName.vue';
+import EmAcct from '@/components/EmAcct.vue';
+import EmTime from '@/components/EmTime.vue';
+
+defineProps<{
+ note: Misskey.entities.Note;
+}>();
+</script>
+
+<style lang="scss" module>
+.root {
+ display: flex;
+ align-items: baseline;
+ white-space: nowrap;
+}
+
+.name {
+ flex-shrink: 1;
+ display: block;
+ margin: 0 .5em 0 0;
+ padding: 0;
+ overflow: hidden;
+ font-size: 1em;
+ font-weight: bold;
+ text-decoration: none;
+ text-overflow: ellipsis;
+
+ &:hover {
+ text-decoration: underline;
+ }
+}
+
+.isBot {
+ flex-shrink: 0;
+ align-self: center;
+ margin: 0 .5em 0 0;
+ padding: 1px 6px;
+ font-size: 80%;
+ border: solid 0.5px var(--divider);
+ border-radius: 3px;
+}
+
+.username {
+ flex-shrink: 9999999;
+ margin: 0 .5em 0 0;
+ overflow: hidden;
+ text-overflow: ellipsis;
+}
+
+.info {
+ flex-shrink: 0;
+ margin-left: auto;
+ font-size: 0.9em;
+}
+
+.badgeRoles {
+ margin: 0 .5em 0 0;
+}
+
+.badgeRole {
+ height: 1.3em;
+ vertical-align: -20%;
+
+ & + .badgeRole {
+ margin-left: 0.2em;
+ }
+}
+</style>
diff --git a/packages/frontend-embed/src/components/EmNoteSimple.vue b/packages/frontend-embed/src/components/EmNoteSimple.vue
new file mode 100644
index 0000000000..828b6cd2e2
--- /dev/null
+++ b/packages/frontend-embed/src/components/EmNoteSimple.vue
@@ -0,0 +1,105 @@
+<!--
+SPDX-FileCopyrightText: syuilo and misskey-project
+SPDX-License-Identifier: AGPL-3.0-only
+-->
+
+<template>
+<div :class="$style.root">
+ <EmAvatar :class="$style.avatar" :user="note.user" link preview/>
+ <div :class="$style.main">
+ <EmNoteHeader :class="$style.header" :note="note" :mini="true"/>
+ <div>
+ <p v-if="note.cw != null" :class="$style.cw">
+ <EmMfm v-if="note.cw != ''" style="margin-right: 8px;" :text="note.cw" :author="note.user" :nyaize="'respect'" :emojiUrls="note.emojis"/>
+ <button style="display: block; width: 100%;" class="_buttonGray _buttonRounded" @click="showContent = !showContent">{{ showContent ? i18n.ts._cw.hide : i18n.ts._cw.show }}</button>
+ </p>
+ <div v-show="note.cw == null || showContent">
+ <EmSubNoteContent :class="$style.text" :note="note"/>
+ </div>
+ </div>
+ </div>
+</div>
+</template>
+
+<script lang="ts" setup>
+import { ref } from 'vue';
+import * as Misskey from 'misskey-js';
+import { i18n } from '@/i18n.js';
+import EmNoteHeader from '@/components/EmNoteHeader.vue';
+import EmSubNoteContent from '@/components/EmSubNoteContent.vue';
+import EmMfm from '@/components/EmMfm.js';
+
+const props = defineProps<{
+ note: Misskey.entities.Note;
+}>();
+
+const showContent = ref(false);
+</script>
+
+<style lang="scss" module>
+.root {
+ display: flex;
+ margin: 0;
+ padding: 0;
+ font-size: 0.95em;
+}
+
+.avatar {
+ flex-shrink: 0;
+ display: block;
+ margin: 0 10px 0 0;
+ width: 34px;
+ height: 34px;
+ border-radius: 8px;
+ position: sticky !important;
+ top: calc(16px + var(--stickyTop, 0px));
+ left: 0;
+}
+
+.main {
+ flex: 1;
+ min-width: 0;
+}
+
+.header {
+ margin-bottom: 2px;
+}
+
+.cw {
+ cursor: default;
+ display: block;
+ margin: 0;
+ padding: 0;
+ overflow-wrap: break-word;
+}
+
+.text {
+ cursor: default;
+ margin: 0;
+ padding: 0;
+}
+
+@container (min-width: 250px) {
+ .avatar {
+ margin: 0 10px 0 0;
+ width: 40px;
+ height: 40px;
+ }
+}
+
+@container (min-width: 350px) {
+ .avatar {
+ margin: 0 10px 0 0;
+ width: 44px;
+ height: 44px;
+ }
+}
+
+@container (min-width: 500px) {
+ .avatar {
+ margin: 0 12px 0 0;
+ width: 48px;
+ height: 48px;
+ }
+}
+</style>
diff --git a/packages/frontend-embed/src/components/EmNoteSub.vue b/packages/frontend-embed/src/components/EmNoteSub.vue
new file mode 100644
index 0000000000..c98b956805
--- /dev/null
+++ b/packages/frontend-embed/src/components/EmNoteSub.vue
@@ -0,0 +1,149 @@
+<!--
+SPDX-FileCopyrightText: syuilo and misskey-project
+SPDX-License-Identifier: AGPL-3.0-only
+-->
+
+<template>
+<div :class="[$style.root, { [$style.children]: depth > 1 }]">
+ <div :class="$style.main">
+ <div v-if="note.channel" :class="$style.colorBar" :style="{ background: note.channel.color }"></div>
+ <EmAvatar :class="$style.avatar" :user="note.user" link preview/>
+ <div :class="$style.body">
+ <EmNoteHeader :class="$style.header" :note="note" :mini="true"/>
+ <div>
+ <p v-if="note.cw != null" :class="$style.cw">
+ <EmMfm v-if="note.cw != ''" style="margin-right: 8px;" :text="note.cw" :author="note.user" :nyaize="'respect'"/>
+ <button style="display: block; width: 100%;" class="_buttonGray _buttonRounded" @click="showContent = !showContent">{{ showContent ? i18n.ts._cw.hide : i18n.ts._cw.show }}</button>
+ </p>
+ <div v-show="note.cw == null || showContent">
+ <EmSubNoteContent :class="$style.text" :note="note"/>
+ </div>
+ </div>
+ </div>
+ </div>
+ <template v-if="depth < 5">
+ <EmNoteSub v-for="reply in replies" :key="reply.id" :note="reply" :class="$style.reply" :detail="true" :depth="depth + 1"/>
+ </template>
+ <div v-else :class="$style.more">
+ <EmA class="_link" :to="notePage(note)">{{ i18n.ts.continueThread }} <i class="ti ti-chevron-double-right"></i></EmA>
+ </div>
+</div>
+</template>
+
+<script lang="ts" setup>
+import { ref } from 'vue';
+import * as Misskey from 'misskey-js';
+import EmNoteHeader from '@/components/EmNoteHeader.vue';
+import EmSubNoteContent from '@/components/EmSubNoteContent.vue';
+import { notePage } from '@/utils.js';
+import { misskeyApi } from '@/misskey-api.js';
+import { i18n } from '@/i18n.js';
+import EmMfm from '@/components/EmMfm.js';
+
+const props = withDefaults(defineProps<{
+ note: Misskey.entities.Note;
+ detail?: boolean;
+
+ // how many notes are in between this one and the note being viewed in detail
+ depth?: number;
+}>(), {
+ depth: 1,
+});
+
+const showContent = ref(false);
+const replies = ref<Misskey.entities.Note[]>([]);
+
+if (props.detail) {
+ misskeyApi('notes/children', {
+ noteId: props.note.id,
+ limit: 5,
+ }).then(res => {
+ replies.value = res;
+ });
+}
+</script>
+
+<style lang="scss" module>
+.root {
+ padding: 16px 32px;
+ font-size: 0.9em;
+ position: relative;
+
+ &.children {
+ padding: 10px 0 0 16px;
+ font-size: 1em;
+ }
+}
+
+.main {
+ display: flex;
+}
+
+.colorBar {
+ position: absolute;
+ top: 8px;
+ left: 8px;
+ width: 5px;
+ height: calc(100% - 8px);
+ border-radius: 999px;
+ pointer-events: none;
+}
+
+.avatar {
+ flex-shrink: 0;
+ display: block;
+ margin: 0 8px 0 0;
+ width: 38px;
+ height: 38px;
+ border-radius: 8px;
+}
+
+.body {
+ flex: 1;
+ min-width: 0;
+}
+
+.header {
+ margin-bottom: 2px;
+}
+
+.cw {
+ cursor: default;
+ display: block;
+ margin: 0;
+ padding: 0;
+ overflow-wrap: break-word;
+}
+
+.text {
+ margin: 0;
+ padding: 0;
+}
+
+.reply, .more {
+ border-left: solid 0.5px var(--divider);
+ margin-top: 10px;
+}
+
+.more {
+ padding: 10px 0 0 16px;
+}
+
+@container (max-width: 450px) {
+ .root {
+ padding: 14px 16px;
+
+ &.children {
+ padding: 10px 0 0 8px;
+ }
+ }
+}
+
+.muted {
+ text-align: center;
+ padding: 8px !important;
+ border: 1px solid var(--divider);
+ margin: 8px 8px 0 8px;
+ border-radius: 8px;
+}
+</style>
diff --git a/packages/frontend-embed/src/components/EmNotes.vue b/packages/frontend-embed/src/components/EmNotes.vue
new file mode 100644
index 0000000000..3970d05098
--- /dev/null
+++ b/packages/frontend-embed/src/components/EmNotes.vue
@@ -0,0 +1,48 @@
+<!--
+SPDX-FileCopyrightText: syuilo and misskey-project
+SPDX-License-Identifier: AGPL-3.0-only
+-->
+
+<template>
+<EmPagination ref="pagingComponent" :pagination="pagination" :disableAutoLoad="disableAutoLoad">
+ <template #empty>
+ <div class="_fullinfo">
+ <div>{{ i18n.ts.noNotes }}</div>
+ </div>
+ </template>
+
+ <template #default="{ items: notes }">
+ <div :class="[$style.root]">
+ <EmNote v-for="note in notes" :key="note._featuredId_ || note._prId_ || note.id" :class="$style.note" :note="note"/>
+ </div>
+ </template>
+</EmPagination>
+</template>
+
+<script lang="ts" setup>
+import { shallowRef } from 'vue';
+import EmNote from '@/components/EmNote.vue';
+import EmPagination, { Paging } from '@/components/EmPagination.vue';
+import { i18n } from '@/i18n.js';
+
+const props = withDefaults(defineProps<{
+ pagination: Paging;
+ noGap?: boolean;
+ disableAutoLoad?: boolean;
+ ad?: boolean;
+}>(), {
+ ad: true,
+});
+
+const pagingComponent = shallowRef<InstanceType<typeof EmPagination>>();
+
+defineExpose({
+ pagingComponent,
+});
+</script>
+
+<style lang="scss" module>
+.root {
+ background: var(--panel);
+}
+</style>
diff --git a/packages/frontend-embed/src/components/EmPagination.vue b/packages/frontend-embed/src/components/EmPagination.vue
new file mode 100644
index 0000000000..5d5317a912
--- /dev/null
+++ b/packages/frontend-embed/src/components/EmPagination.vue
@@ -0,0 +1,504 @@
+<!--
+SPDX-FileCopyrightText: syuilo and misskey-project
+SPDX-License-Identifier: AGPL-3.0-only
+-->
+
+<template>
+<EmLoading v-if="fetching"/>
+
+<EmError v-else-if="error" @retry="init()"/>
+
+<div v-else-if="empty" key="_empty_" class="empty">
+ <slot name="empty">
+ <div class="_fullinfo">
+ <div>{{ i18n.ts.nothing }}</div>
+ </div>
+ </slot>
+</div>
+
+<div v-else ref="rootEl">
+ <div v-show="pagination.reversed && more" key="_more_" class="_margin">
+ <button v-if="!moreFetching" class="_buttonPrimary" :class="$style.more" :disabled="moreFetching" :style="{ cursor: moreFetching ? 'wait' : 'pointer' }" @click="fetchMoreAhead">
+ {{ i18n.ts.loadMore }}
+ </button>
+ <EmLoading v-else class="loading"/>
+ </div>
+ <slot :items="Array.from(items.values())" :fetching="fetching || moreFetching"></slot>
+ <div v-show="!pagination.reversed && more" key="_more_" class="_margin">
+ <button v-if="!moreFetching" class="_buttonRounded _buttonPrimary" :class="$style.more" :disabled="moreFetching" :style="{ cursor: moreFetching ? 'wait' : 'pointer' }" @click="fetchMore">
+ {{ i18n.ts.loadMore }}
+ </button>
+ <EmLoading v-else class="loading"/>
+ </div>
+</div>
+</template>
+
+<script lang="ts">
+import { computed, ComputedRef, isRef, nextTick, onActivated, onBeforeMount, onBeforeUnmount, onDeactivated, ref, shallowRef, watch } from 'vue';
+import * as Misskey from 'misskey-js';
+import { useDocumentVisibility } from '@@/js/use-document-visibility.js';
+import { onScrollTop, isTopVisible, getBodyScrollHeight, getScrollContainer, onScrollBottom, scrollToBottom, scroll, isBottomVisible } from '@@/js/scroll.js';
+import { misskeyApi } from '@/misskey-api.js';
+import { i18n } from '@/i18n.js';
+
+const SECOND_FETCH_LIMIT = 30;
+const TOLERANCE = 16;
+const APPEAR_MINIMUM_INTERVAL = 600;
+
+export type Paging<E extends keyof Misskey.Endpoints = keyof Misskey.Endpoints> = {
+ endpoint: E;
+ limit: number;
+ params?: Misskey.Endpoints[E]['req'] | ComputedRef<Misskey.Endpoints[E]['req']>;
+
+ /**
+ * 検索APIのような、ページング不可なエンドポイントを利用する場合
+ * (そのようなAPIをこの関数で使うのは若干矛盾してるけど)
+ */
+ noPaging?: boolean;
+
+ /**
+ * items 配列の中身を逆順にする(新しい方が最後)
+ */
+ reversed?: boolean;
+
+ offsetMode?: boolean;
+
+ pageEl?: HTMLElement;
+};
+
+type MisskeyEntity = {
+ id: string;
+ createdAt: string;
+ _shouldInsertAd_?: boolean;
+ [x: string]: any;
+};
+
+type MisskeyEntityMap = Map<string, MisskeyEntity>;
+
+function arrayToEntries(entities: MisskeyEntity[]): [string, MisskeyEntity][] {
+ return entities.map(en => [en.id, en]);
+}
+
+function concatMapWithArray(map: MisskeyEntityMap, entities: MisskeyEntity[]): MisskeyEntityMap {
+ return new Map([...map, ...arrayToEntries(entities)]);
+}
+
+</script>
+<script lang="ts" setup>
+import EmError from '@/components/EmError.vue';
+import EmLoading from '@/components/EmLoading.vue';
+
+const props = withDefaults(defineProps<{
+ pagination: Paging;
+ disableAutoLoad?: boolean;
+ displayLimit?: number;
+}>(), {
+ displayLimit: 20,
+});
+
+const emit = defineEmits<{
+ (ev: 'queue', count: number): void;
+ (ev: 'status', error: boolean): void;
+}>();
+
+const rootEl = shallowRef<HTMLElement>();
+
+// 遡り中かどうか
+const backed = ref(false);
+
+const scrollRemove = ref<(() => void) | null>(null);
+
+/**
+ * 表示するアイテムのソース
+ * 最新が0番目
+ */
+const items = ref<MisskeyEntityMap>(new Map());
+
+/**
+ * タブが非アクティブなどの場合に更新を貯めておく
+ * 最新が0番目
+ */
+const queue = ref<MisskeyEntityMap>(new Map());
+
+const offset = ref(0);
+
+/**
+ * 初期化中かどうか(trueならEmLoadingで全て隠す)
+ */
+const fetching = ref(true);
+
+const moreFetching = ref(false);
+const more = ref(false);
+const preventAppearFetchMore = ref(false);
+const preventAppearFetchMoreTimer = ref<number | null>(null);
+const isBackTop = ref(false);
+const empty = computed(() => items.value.size === 0);
+const error = ref(false);
+
+const contentEl = computed(() => props.pagination.pageEl ?? rootEl.value);
+const scrollableElement = computed(() => contentEl.value ? getScrollContainer(contentEl.value) : document.body);
+
+const visibility = useDocumentVisibility();
+
+let isPausingUpdate = false;
+let timerForSetPause: number | null = null;
+const BACKGROUND_PAUSE_WAIT_SEC = 10;
+
+// 先頭が表示されているかどうかを検出
+// https://qiita.com/mkataigi/items/0154aefd2223ce23398e
+const scrollObserver = ref<IntersectionObserver>();
+
+watch([() => props.pagination.reversed, scrollableElement], () => {
+ if (scrollObserver.value) scrollObserver.value.disconnect();
+
+ scrollObserver.value = new IntersectionObserver(entries => {
+ backed.value = entries[0].isIntersecting;
+ }, {
+ root: scrollableElement.value,
+ rootMargin: props.pagination.reversed ? '-100% 0px 100% 0px' : '100% 0px -100% 0px',
+ threshold: 0.01,
+ });
+}, { immediate: true });
+
+watch(rootEl, () => {
+ scrollObserver.value?.disconnect();
+ nextTick(() => {
+ if (rootEl.value) scrollObserver.value?.observe(rootEl.value);
+ });
+});
+
+watch([backed, contentEl], () => {
+ if (!backed.value) {
+ if (!contentEl.value) return;
+
+ scrollRemove.value = (props.pagination.reversed ? onScrollBottom : onScrollTop)(contentEl.value, executeQueue, TOLERANCE);
+ } else {
+ if (scrollRemove.value) scrollRemove.value();
+ scrollRemove.value = null;
+ }
+});
+
+// パラメータに何らかの変更があった際、再読込したい(チャンネル等のIDが変わったなど)
+watch(() => [props.pagination.endpoint, props.pagination.params], init, { deep: true });
+
+watch(queue, (a, b) => {
+ if (a.size === 0 && b.size === 0) return;
+ emit('queue', queue.value.size);
+}, { deep: true });
+
+watch(error, (n, o) => {
+ if (n === o) return;
+ emit('status', n);
+});
+
+async function init(): Promise<void> {
+ items.value = new Map();
+ queue.value = new Map();
+ fetching.value = true;
+ const params = props.pagination.params ? isRef(props.pagination.params) ? props.pagination.params.value : props.pagination.params : {};
+ await misskeyApi<MisskeyEntity[]>(props.pagination.endpoint, {
+ ...params,
+ limit: props.pagination.limit ?? 10,
+ allowPartial: true,
+ }).then(res => {
+ for (let i = 0; i < res.length; i++) {
+ const item = res[i];
+ if (i === 3) item._shouldInsertAd_ = true;
+ }
+
+ if (res.length === 0 || props.pagination.noPaging) {
+ concatItems(res);
+ more.value = false;
+ } else {
+ if (props.pagination.reversed) moreFetching.value = true;
+ concatItems(res);
+ more.value = true;
+ }
+
+ offset.value = res.length;
+ error.value = false;
+ fetching.value = false;
+ }, err => {
+ error.value = true;
+ fetching.value = false;
+ });
+}
+
+const reload = (): Promise<void> => {
+ return init();
+};
+
+const fetchMore = async (): Promise<void> => {
+ if (!more.value || fetching.value || moreFetching.value || items.value.size === 0) return;
+ moreFetching.value = true;
+ const params = props.pagination.params ? isRef(props.pagination.params) ? props.pagination.params.value : props.pagination.params : {};
+ await misskeyApi<MisskeyEntity[]>(props.pagination.endpoint, {
+ ...params,
+ limit: SECOND_FETCH_LIMIT,
+ ...(props.pagination.offsetMode ? {
+ offset: offset.value,
+ } : {
+ untilId: Array.from(items.value.keys()).at(-1),
+ }),
+ }).then(res => {
+ for (let i = 0; i < res.length; i++) {
+ const item = res[i];
+ if (i === 10) item._shouldInsertAd_ = true;
+ }
+
+ const reverseConcat = _res => {
+ const oldHeight = scrollableElement.value ? scrollableElement.value.scrollHeight : getBodyScrollHeight();
+ const oldScroll = scrollableElement.value ? scrollableElement.value.scrollTop : window.scrollY;
+
+ items.value = concatMapWithArray(items.value, _res);
+
+ return nextTick(() => {
+ if (scrollableElement.value) {
+ scroll(scrollableElement.value, { top: oldScroll + (scrollableElement.value.scrollHeight - oldHeight), behavior: 'instant' });
+ } else {
+ window.scroll({ top: oldScroll + (getBodyScrollHeight() - oldHeight), behavior: 'instant' });
+ }
+
+ return nextTick();
+ });
+ };
+
+ if (res.length === 0) {
+ if (props.pagination.reversed) {
+ reverseConcat(res).then(() => {
+ more.value = false;
+ moreFetching.value = false;
+ });
+ } else {
+ items.value = concatMapWithArray(items.value, res);
+ more.value = false;
+ moreFetching.value = false;
+ }
+ } else {
+ if (props.pagination.reversed) {
+ reverseConcat(res).then(() => {
+ more.value = true;
+ moreFetching.value = false;
+ });
+ } else {
+ items.value = concatMapWithArray(items.value, res);
+ more.value = true;
+ moreFetching.value = false;
+ }
+ }
+ offset.value += res.length;
+ }, err => {
+ moreFetching.value = false;
+ });
+};
+
+const fetchMoreAhead = async (): Promise<void> => {
+ if (!more.value || fetching.value || moreFetching.value || items.value.size === 0) return;
+ moreFetching.value = true;
+ const params = props.pagination.params ? isRef(props.pagination.params) ? props.pagination.params.value : props.pagination.params : {};
+ await misskeyApi<MisskeyEntity[]>(props.pagination.endpoint, {
+ ...params,
+ limit: SECOND_FETCH_LIMIT,
+ ...(props.pagination.offsetMode ? {
+ offset: offset.value,
+ } : {
+ sinceId: Array.from(items.value.keys()).at(-1),
+ }),
+ }).then(res => {
+ if (res.length === 0) {
+ items.value = concatMapWithArray(items.value, res);
+ more.value = false;
+ } else {
+ items.value = concatMapWithArray(items.value, res);
+ more.value = true;
+ }
+ offset.value += res.length;
+ moreFetching.value = false;
+ }, err => {
+ moreFetching.value = false;
+ });
+};
+
+/**
+ * Appear(IntersectionObserver)によってfetchMoreが呼ばれる場合、
+ * APPEAR_MINIMUM_INTERVALミリ秒以内に2回fetchMoreが呼ばれるのを防ぐ
+ */
+const fetchMoreApperTimeoutFn = (): void => {
+ preventAppearFetchMore.value = false;
+ preventAppearFetchMoreTimer.value = null;
+};
+const fetchMoreAppearTimeout = (): void => {
+ preventAppearFetchMore.value = true;
+ preventAppearFetchMoreTimer.value = window.setTimeout(fetchMoreApperTimeoutFn, APPEAR_MINIMUM_INTERVAL);
+};
+
+const appearFetchMore = async (): Promise<void> => {
+ if (preventAppearFetchMore.value) return;
+ await fetchMore();
+ fetchMoreAppearTimeout();
+};
+
+const appearFetchMoreAhead = async (): Promise<void> => {
+ if (preventAppearFetchMore.value) return;
+ await fetchMoreAhead();
+ fetchMoreAppearTimeout();
+};
+
+const isTop = (): boolean => isBackTop.value || (props.pagination.reversed ? isBottomVisible : isTopVisible)(contentEl.value!, TOLERANCE);
+
+watch(visibility, () => {
+ if (visibility.value === 'hidden') {
+ timerForSetPause = window.setTimeout(() => {
+ isPausingUpdate = true;
+ timerForSetPause = null;
+ },
+ BACKGROUND_PAUSE_WAIT_SEC * 1000);
+ } else { // 'visible'
+ if (timerForSetPause) {
+ clearTimeout(timerForSetPause);
+ timerForSetPause = null;
+ } else {
+ isPausingUpdate = false;
+ if (isTop()) {
+ executeQueue();
+ }
+ }
+ }
+});
+
+/**
+ * 最新のものとして1つだけアイテムを追加する
+ * ストリーミングから降ってきたアイテムはこれで追加する
+ * @param item アイテム
+ */
+const prepend = (item: MisskeyEntity): void => {
+ if (items.value.size === 0) {
+ items.value.set(item.id, item);
+ fetching.value = false;
+ return;
+ }
+
+ if (isTop() && !isPausingUpdate) unshiftItems([item]);
+ else prependQueue(item);
+};
+
+/**
+ * 新着アイテムをitemsの先頭に追加し、displayLimitを適用する
+ * @param newItems 新しいアイテムの配列
+ */
+function unshiftItems(newItems: MisskeyEntity[]) {
+ const length = newItems.length + items.value.size;
+ items.value = new Map([...arrayToEntries(newItems), ...items.value].slice(0, props.displayLimit));
+
+ if (length >= props.displayLimit) more.value = true;
+}
+
+/**
+ * 古いアイテムをitemsの末尾に追加し、displayLimitを適用する
+ * @param oldItems 古いアイテムの配列
+ */
+function concatItems(oldItems: MisskeyEntity[]) {
+ const length = oldItems.length + items.value.size;
+ items.value = new Map([...items.value, ...arrayToEntries(oldItems)].slice(0, props.displayLimit));
+
+ if (length >= props.displayLimit) more.value = true;
+}
+
+function executeQueue() {
+ unshiftItems(Array.from(queue.value.values()));
+ queue.value = new Map();
+}
+
+function prependQueue(newItem: MisskeyEntity) {
+ queue.value = new Map([[newItem.id, newItem], ...queue.value].slice(0, props.displayLimit) as [string, MisskeyEntity][]);
+}
+
+/*
+ * アイテムを末尾に追加する(使うの?)
+ */
+const appendItem = (item: MisskeyEntity): void => {
+ items.value.set(item.id, item);
+};
+
+const removeItem = (id: string) => {
+ items.value.delete(id);
+ queue.value.delete(id);
+};
+
+const updateItem = (id: MisskeyEntity['id'], replacer: (old: MisskeyEntity) => MisskeyEntity): void => {
+ const item = items.value.get(id);
+ if (item) items.value.set(id, replacer(item));
+
+ const queueItem = queue.value.get(id);
+ if (queueItem) queue.value.set(id, replacer(queueItem));
+};
+
+onActivated(() => {
+ isBackTop.value = false;
+});
+
+onDeactivated(() => {
+ isBackTop.value = props.pagination.reversed ? window.scrollY >= (rootEl.value ? rootEl.value.scrollHeight - window.innerHeight : 0) : window.scrollY === 0;
+});
+
+function toBottom() {
+ scrollToBottom(contentEl.value!);
+}
+
+onBeforeMount(() => {
+ init().then(() => {
+ if (props.pagination.reversed) {
+ nextTick(() => {
+ setTimeout(toBottom, 800);
+
+ // scrollToBottomでmoreFetchingボタンが画面外まで出るまで
+ // more = trueを遅らせる
+ setTimeout(() => {
+ moreFetching.value = false;
+ }, 2000);
+ });
+ }
+ });
+});
+
+onBeforeUnmount(() => {
+ if (timerForSetPause) {
+ clearTimeout(timerForSetPause);
+ timerForSetPause = null;
+ }
+ if (preventAppearFetchMoreTimer.value) {
+ clearTimeout(preventAppearFetchMoreTimer.value);
+ preventAppearFetchMoreTimer.value = null;
+ }
+ scrollObserver.value?.disconnect();
+});
+
+defineExpose({
+ items,
+ queue,
+ backed: backed.value,
+ more,
+ reload,
+ prepend,
+ append: appendItem,
+ removeItem,
+ updateItem,
+});
+</script>
+
+<style lang="scss" module>
+.transition_fade_enterActive,
+.transition_fade_leaveActive {
+ transition: opacity 0.125s ease;
+}
+.transition_fade_enterFrom,
+.transition_fade_leaveTo {
+ opacity: 0;
+}
+
+.more {
+ display: block;
+ margin-left: auto;
+ margin-right: auto;
+}
+</style>
diff --git a/packages/frontend-embed/src/components/EmPoll.vue b/packages/frontend-embed/src/components/EmPoll.vue
new file mode 100644
index 0000000000..a2b1203449
--- /dev/null
+++ b/packages/frontend-embed/src/components/EmPoll.vue
@@ -0,0 +1,82 @@
+<!--
+SPDX-FileCopyrightText: syuilo and misskey-project
+SPDX-License-Identifier: AGPL-3.0-only
+-->
+
+<template>
+<div>
+ <ul :class="$style.choices">
+ <li v-for="(choice, i) in poll.choices" :key="i" :class="$style.choice">
+ <div :class="$style.bg" :style="{ 'width': `${choice.votes / total * 100}%` }"></div>
+ <span :class="$style.fg">
+ <template v-if="choice.isVoted"><i class="ti ti-check" style="margin-right: 4px; color: var(--accent);"></i></template>
+ <EmMfm :text="choice.text" :plain="true"/>
+ <span style="margin-left: 4px; opacity: 0.7;">({{ i18n.tsx._poll.votesCount({ n: choice.votes }) }})</span>
+ </span>
+ </li>
+ </ul>
+ <p :class="$style.info">
+ <span>{{ i18n.tsx._poll.totalVotes({ n: total }) }}</span>
+ </p>
+</div>
+</template>
+
+<script lang="ts" setup>
+import { computed } from 'vue';
+import * as Misskey from 'misskey-js';
+import { i18n } from '@/i18n.js';
+import EmMfm from '@/components/EmMfm.js';
+
+function sum(xs: number[]): number {
+ return xs.reduce((a, b) => a + b, 0);
+}
+
+const props = defineProps<{
+ noteId: string;
+ poll: NonNullable<Misskey.entities.Note['poll']>;
+}>();
+
+const total = computed(() => sum(props.poll.choices.map(x => x.votes)));
+</script>
+
+<style lang="scss" module>
+.choices {
+ display: block;
+ margin: 0;
+ padding: 0;
+ list-style: none;
+}
+
+.choice {
+ display: block;
+ position: relative;
+ margin: 4px 0;
+ padding: 4px;
+ //border: solid 0.5px var(--divider);
+ background: var(--accentedBg);
+ border-radius: 4px;
+ overflow: clip;
+}
+
+.bg {
+ position: absolute;
+ top: 0;
+ left: 0;
+ height: 100%;
+ background: var(--accent);
+ background: linear-gradient(90deg,var(--buttonGradateA),var(--buttonGradateB));
+ transition: width 1s ease;
+}
+
+.fg {
+ position: relative;
+ display: inline-block;
+ padding: 3px 5px;
+ background: var(--panel);
+ border-radius: 3px;
+}
+
+.info {
+ color: var(--fg);
+}
+</style>
diff --git a/packages/frontend-embed/src/components/EmReactionIcon.vue b/packages/frontend-embed/src/components/EmReactionIcon.vue
new file mode 100644
index 0000000000..5c38ecb0ed
--- /dev/null
+++ b/packages/frontend-embed/src/components/EmReactionIcon.vue
@@ -0,0 +1,23 @@
+<!--
+SPDX-FileCopyrightText: syuilo and misskey-project
+SPDX-License-Identifier: AGPL-3.0-only
+-->
+
+<template>
+<EmCustomEmoji v-if="reaction[0] === ':'" ref="elRef" :name="reaction" :normal="true" :noStyle="noStyle" :url="emojiUrl" :fallbackToImage="true"/>
+<EmEmoji v-else ref="elRef" :emoji="reaction" :normal="true" :noStyle="noStyle"/>
+</template>
+
+<script lang="ts" setup>
+import { } from 'vue';
+import EmCustomEmoji from './EmCustomEmoji.vue';
+import EmEmoji from './EmEmoji.vue';
+
+const props = defineProps<{
+ reaction: string;
+ noStyle?: boolean;
+ emojiUrl?: string;
+ withTooltip?: boolean;
+}>();
+
+</script>
diff --git a/packages/frontend-embed/src/components/EmReactionsViewer.reaction.vue b/packages/frontend-embed/src/components/EmReactionsViewer.reaction.vue
new file mode 100644
index 0000000000..2e43eb8d17
--- /dev/null
+++ b/packages/frontend-embed/src/components/EmReactionsViewer.reaction.vue
@@ -0,0 +1,99 @@
+<!--
+SPDX-FileCopyrightText: syuilo and misskey-project
+SPDX-License-Identifier: AGPL-3.0-only
+-->
+
+<template>
+<button
+ class="_button"
+ :class="[$style.root, { [$style.reacted]: note.myReaction == reaction }]"
+>
+ <EmReactionIcon :class="$style.limitWidth" :reaction="reaction" :emojiUrl="note.reactionEmojis[reaction.substring(1, reaction.length - 1)]"/>
+ <span :class="$style.count">{{ count }}</span>
+</button>
+</template>
+
+<script lang="ts" setup>
+import { } from 'vue';
+import * as Misskey from 'misskey-js';
+import EmReactionIcon from '@/components/EmReactionIcon.vue';
+
+const props = defineProps<{
+ reaction: string;
+ count: number;
+ isInitial: boolean;
+ note: Misskey.entities.Note;
+}>();
+</script>
+
+<style lang="scss" module>
+.root {
+ display: inline-flex;
+ height: 42px;
+ margin: 2px;
+ padding: 0 6px;
+ font-size: 1.5em;
+ border-radius: 6px;
+ align-items: center;
+ justify-content: center;
+
+ &.canToggle {
+ background: var(--buttonBg);
+
+ &:hover {
+ background: rgba(0, 0, 0, 0.1);
+ }
+ }
+
+ &:not(.canToggle) {
+ cursor: default;
+ }
+
+ &.small {
+ height: 32px;
+ font-size: 1em;
+ border-radius: 4px;
+
+ > .count {
+ font-size: 0.9em;
+ line-height: 32px;
+ }
+ }
+
+ &.large {
+ height: 52px;
+ font-size: 2em;
+ border-radius: 8px;
+
+ > .count {
+ font-size: 0.6em;
+ line-height: 52px;
+ }
+ }
+
+ &.reacted, &.reacted:hover {
+ background: var(--accentedBg);
+ color: var(--accent);
+ box-shadow: 0 0 0 1px var(--accent) inset;
+
+ > .count {
+ color: var(--accent);
+ }
+
+ > .icon {
+ filter: drop-shadow(0 0 2px rgba(0, 0, 0, 0.5));
+ }
+ }
+}
+
+.limitWidth {
+ max-width: 70px;
+ object-fit: contain;
+}
+
+.count {
+ font-size: 0.7em;
+ line-height: 42px;
+ margin: 0 0 0 4px;
+}
+</style>
diff --git a/packages/frontend-embed/src/components/EmReactionsViewer.vue b/packages/frontend-embed/src/components/EmReactionsViewer.vue
new file mode 100644
index 0000000000..014dd1c935
--- /dev/null
+++ b/packages/frontend-embed/src/components/EmReactionsViewer.vue
@@ -0,0 +1,104 @@
+<!--
+SPDX-FileCopyrightText: syuilo and misskey-project
+SPDX-License-Identifier: AGPL-3.0-only
+-->
+
+<template>
+<div :class="$style.root">
+ <XReaction v-for="[reaction, count] in reactions" :key="reaction" :reaction="reaction" :count="count" :isInitial="initialReactions.has(reaction)" :note="note" @reactionToggled="onMockToggleReaction"/>
+ <slot v-if="hasMoreReactions" name="more"></slot>
+</div>
+</template>
+
+<script lang="ts" setup>
+import * as Misskey from 'misskey-js';
+import { inject, watch, ref } from 'vue';
+import XReaction from '@/components/EmReactionsViewer.reaction.vue';
+
+const props = withDefaults(defineProps<{
+ note: Misskey.entities.Note;
+ maxNumber?: number;
+}>(), {
+ maxNumber: Infinity,
+});
+
+const mock = inject<boolean>('mock', false);
+
+const emit = defineEmits<{
+ (ev: 'mockUpdateMyReaction', emoji: string, delta: number): void;
+}>();
+
+const initialReactions = new Set(Object.keys(props.note.reactions));
+
+const reactions = ref<[string, number][]>([]);
+const hasMoreReactions = ref(false);
+
+if (props.note.myReaction && !Object.keys(reactions.value).includes(props.note.myReaction)) {
+ reactions.value[props.note.myReaction] = props.note.reactions[props.note.myReaction];
+}
+
+function onMockToggleReaction(emoji: string, count: number) {
+ if (!mock) return;
+
+ const i = reactions.value.findIndex((item) => item[0] === emoji);
+ if (i < 0) return;
+
+ emit('mockUpdateMyReaction', emoji, (count - reactions.value[i][1]));
+}
+
+watch([() => props.note.reactions, () => props.maxNumber], ([newSource, maxNumber]) => {
+ let newReactions: [string, number][] = [];
+ hasMoreReactions.value = Object.keys(newSource).length > maxNumber;
+
+ for (let i = 0; i < reactions.value.length; i++) {
+ const reaction = reactions.value[i][0];
+ if (reaction in newSource && newSource[reaction] !== 0) {
+ reactions.value[i][1] = newSource[reaction];
+ newReactions.push(reactions.value[i]);
+ }
+ }
+
+ const newReactionsNames = newReactions.map(([x]) => x);
+ newReactions = [
+ ...newReactions,
+ ...Object.entries(newSource)
+ .sort(([, a], [, b]) => b - a)
+ .filter(([y], i) => i < maxNumber && !newReactionsNames.includes(y)),
+ ];
+
+ newReactions = newReactions.slice(0, props.maxNumber);
+
+ if (props.note.myReaction && !newReactions.map(([x]) => x).includes(props.note.myReaction)) {
+ newReactions.push([props.note.myReaction, newSource[props.note.myReaction]]);
+ }
+
+ reactions.value = newReactions;
+}, { immediate: true, deep: true });
+</script>
+
+<style lang="scss" module>
+.transition_x_move,
+.transition_x_enterActive,
+.transition_x_leaveActive {
+ transition: opacity 0.2s cubic-bezier(0,.5,.5,1), transform 0.2s cubic-bezier(0,.5,.5,1) !important;
+}
+.transition_x_enterFrom,
+.transition_x_leaveTo {
+ opacity: 0;
+ transform: scale(0.7);
+}
+.transition_x_leaveActive {
+ position: absolute;
+}
+
+.root {
+ display: flex;
+ flex-wrap: wrap;
+ align-items: center;
+ margin: 4px -2px 0 -2px;
+
+ &:empty {
+ display: none;
+ }
+}
+</style>
diff --git a/packages/frontend-embed/src/components/EmSubNoteContent.vue b/packages/frontend-embed/src/components/EmSubNoteContent.vue
new file mode 100644
index 0000000000..382e39e492
--- /dev/null
+++ b/packages/frontend-embed/src/components/EmSubNoteContent.vue
@@ -0,0 +1,113 @@
+<!--
+SPDX-FileCopyrightText: syuilo and misskey-project
+SPDX-License-Identifier: AGPL-3.0-only
+-->
+
+<template>
+<div :class="[$style.root, { [$style.collapsed]: collapsed }]">
+ <div>
+ <span v-if="note.isHidden" style="opacity: 0.5">({{ i18n.ts.private }})</span>
+ <span v-if="note.deletedAt" style="opacity: 0.5">({{ i18n.ts.deletedNote }})</span>
+ <EmA v-if="note.replyId" :class="$style.reply" :to="`/notes/${note.replyId}`"><i class="ti ti-arrow-back-up"></i></EmA>
+ <EmMfm v-if="note.text" :text="note.text" :author="note.user" :nyaize="'respect'" :emojiUrls="note.emojis"/>
+ <EmA v-if="note.renoteId" :class="$style.rp" :to="`/notes/${note.renoteId}`">RN: ...</EmA>
+ </div>
+ <details v-if="note.files && note.files.length > 0">
+ <summary>({{ i18n.tsx.withNFiles({ n: note.files.length }) }})</summary>
+ <EmMediaList :mediaList="note.files" :originalEntityUrl="`${url}/notes/${note.id}`"/>
+ </details>
+ <details v-if="note.poll">
+ <summary>{{ i18n.ts.poll }}</summary>
+ <EmPoll :noteId="note.id" :poll="note.poll"/>
+ </details>
+ <button v-if="isLong && collapsed" :class="$style.fade" class="_button" @click="collapsed = false">
+ <span :class="$style.fadeLabel">{{ i18n.ts.showMore }}</span>
+ </button>
+ <button v-else-if="isLong && !collapsed" :class="$style.showLess" class="_button" @click="collapsed = true">
+ <span :class="$style.showLessLabel">{{ i18n.ts.showLess }}</span>
+ </button>
+</div>
+</template>
+
+<script lang="ts" setup>
+import { ref } from 'vue';
+import * as Misskey from 'misskey-js';
+import EmMediaList from '@/components/EmMediaList.vue';
+import EmPoll from '@/components/EmPoll.vue';
+import { i18n } from '@/i18n.js';
+import { url } from '@/config.js';
+import { shouldCollapsed } from '@/to-be-shared/collapsed.js';
+import EmMfm from '@/components/EmMfm.js';
+
+const props = defineProps<{
+ note: Misskey.entities.Note;
+}>();
+
+const isLong = shouldCollapsed(props.note, []);
+
+const collapsed = ref(isLong);
+</script>
+
+<style lang="scss" module>
+.root {
+ overflow-wrap: break-word;
+
+ &.collapsed {
+ position: relative;
+ max-height: 9em;
+ overflow: clip;
+
+ > .fade {
+ display: block;
+ position: absolute;
+ bottom: 0;
+ left: 0;
+ width: 100%;
+ height: 64px;
+ background: linear-gradient(0deg, var(--panel), color(from var(--panel) srgb r g b / 0));
+
+ > .fadeLabel {
+ display: inline-block;
+ background: var(--panel);
+ padding: 6px 10px;
+ font-size: 0.8em;
+ border-radius: 999px;
+ box-shadow: 0 2px 6px rgb(0 0 0 / 20%);
+ }
+
+ &:hover {
+ > .fadeLabel {
+ background: var(--panelHighlight);
+ }
+ }
+ }
+ }
+}
+
+.reply {
+ margin-right: 6px;
+ color: var(--accent);
+}
+
+.rp {
+ margin-left: 4px;
+ font-style: oblique;
+ color: var(--renote);
+}
+
+.showLess {
+ width: 100%;
+ margin-top: 14px;
+ position: sticky;
+ bottom: calc(var(--stickyBottom, 0px) + 14px);
+}
+
+.showLessLabel {
+ display: inline-block;
+ background: var(--popup);
+ padding: 6px 10px;
+ font-size: 0.8em;
+ border-radius: 999px;
+ box-shadow: 0 2px 6px rgb(0 0 0 / 20%);
+}
+</style>
diff --git a/packages/frontend-embed/src/components/EmTime.vue b/packages/frontend-embed/src/components/EmTime.vue
new file mode 100644
index 0000000000..a8627e02c8
--- /dev/null
+++ b/packages/frontend-embed/src/components/EmTime.vue
@@ -0,0 +1,107 @@
+<!--
+SPDX-FileCopyrightText: syuilo and misskey-project
+SPDX-License-Identifier: AGPL-3.0-only
+-->
+
+<template>
+<time :title="absolute" :class="{ [$style.old1]: colored && (ago > 60 * 60 * 24 * 90), [$style.old2]: colored && (ago > 60 * 60 * 24 * 180) }">
+ <template v-if="invalid">{{ i18n.ts._ago.invalid }}</template>
+ <template v-else-if="mode === 'relative'">{{ relative }}</template>
+ <template v-else-if="mode === 'absolute'">{{ absolute }}</template>
+ <template v-else-if="mode === 'detail'">{{ absolute }} ({{ relative }})</template>
+</time>
+</template>
+
+<script lang="ts" setup>
+import { onMounted, onUnmounted, ref, computed } from 'vue';
+import { i18n } from '@/i18n.js';
+import { dateTimeFormat } from '@/to-be-shared/intl-const.js';
+
+const props = withDefaults(defineProps<{
+ time: Date | string | number | null;
+ origin?: Date | null;
+ mode?: 'relative' | 'absolute' | 'detail';
+ colored?: boolean;
+}>(), {
+ origin: null,
+ mode: 'relative',
+});
+
+function getDateSafe(n: Date | string | number) {
+ try {
+ if (n instanceof Date) {
+ return n;
+ }
+ return new Date(n);
+ } catch (err) {
+ return {
+ getTime: () => NaN,
+ };
+ }
+}
+
+// eslint-disable-next-line vue/no-setup-props-reactivity-loss
+const _time = props.time == null ? NaN : getDateSafe(props.time).getTime();
+const invalid = Number.isNaN(_time);
+const absolute = !invalid ? dateTimeFormat.format(_time) : i18n.ts._ago.invalid;
+
+// eslint-disable-next-line vue/no-setup-props-reactivity-loss
+const now = ref(props.origin?.getTime() ?? Date.now());
+const ago = computed(() => (now.value - _time) / 1000/*ms*/);
+
+const relative = computed<string>(() => {
+ if (props.mode === 'absolute') return ''; // absoluteではrelativeを使わないので計算しない
+ if (invalid) return i18n.ts._ago.invalid;
+
+ return (
+ ago.value >= 31536000 ? i18n.tsx._ago.yearsAgo({ n: Math.round(ago.value / 31536000).toString() }) :
+ ago.value >= 2592000 ? i18n.tsx._ago.monthsAgo({ n: Math.round(ago.value / 2592000).toString() }) :
+ ago.value >= 604800 ? i18n.tsx._ago.weeksAgo({ n: Math.round(ago.value / 604800).toString() }) :
+ ago.value >= 86400 ? i18n.tsx._ago.daysAgo({ n: Math.round(ago.value / 86400).toString() }) :
+ ago.value >= 3600 ? i18n.tsx._ago.hoursAgo({ n: Math.round(ago.value / 3600).toString() }) :
+ ago.value >= 60 ? i18n.tsx._ago.minutesAgo({ n: (~~(ago.value / 60)).toString() }) :
+ ago.value >= 10 ? i18n.tsx._ago.secondsAgo({ n: (~~(ago.value % 60)).toString() }) :
+ ago.value >= -3 ? i18n.ts._ago.justNow :
+ ago.value < -31536000 ? i18n.tsx._timeIn.years({ n: Math.round(-ago.value / 31536000).toString() }) :
+ ago.value < -2592000 ? i18n.tsx._timeIn.months({ n: Math.round(-ago.value / 2592000).toString() }) :
+ ago.value < -604800 ? i18n.tsx._timeIn.weeks({ n: Math.round(-ago.value / 604800).toString() }) :
+ ago.value < -86400 ? i18n.tsx._timeIn.days({ n: Math.round(-ago.value / 86400).toString() }) :
+ ago.value < -3600 ? i18n.tsx._timeIn.hours({ n: Math.round(-ago.value / 3600).toString() }) :
+ ago.value < -60 ? i18n.tsx._timeIn.minutes({ n: (~~(-ago.value / 60)).toString() }) :
+ i18n.tsx._timeIn.seconds({ n: (~~(-ago.value % 60)).toString() })
+ );
+});
+
+let tickId: number;
+let currentInterval: number;
+
+function tick() {
+ now.value = Date.now();
+ const nextInterval = ago.value < 60 ? 10000 : ago.value < 3600 ? 60000 : 180000;
+
+ if (currentInterval !== nextInterval) {
+ if (tickId) window.clearInterval(tickId);
+ currentInterval = nextInterval;
+ tickId = window.setInterval(tick, nextInterval);
+ }
+}
+
+if (!invalid && props.origin === null && (props.mode === 'relative' || props.mode === 'detail')) {
+ onMounted(() => {
+ tick();
+ });
+ onUnmounted(() => {
+ if (tickId) window.clearInterval(tickId);
+ });
+}
+</script>
+
+<style lang="scss" module>
+.old1 {
+ color: var(--warn);
+}
+
+.old1.old2 {
+ color: var(--error);
+}
+</style>
diff --git a/packages/frontend-embed/src/components/EmTimelineContainer.vue b/packages/frontend-embed/src/components/EmTimelineContainer.vue
new file mode 100644
index 0000000000..6c30b1102d
--- /dev/null
+++ b/packages/frontend-embed/src/components/EmTimelineContainer.vue
@@ -0,0 +1,39 @@
+<!--
+SPDX-FileCopyrightText: syuilo and misskey-project
+SPDX-License-Identifier: AGPL-3.0-only
+-->
+
+<template>
+<div :class="$style.timelineRoot">
+ <div v-if="showHeader" :class="$style.header"><slot name="header"></slot></div>
+ <div :class="$style.body"><slot name="body"></slot></div>
+</div>
+</template>
+
+<script setup lang="ts">
+withDefaults(defineProps<{
+ showHeader?: boolean;
+}>(), {
+ showHeader: true,
+});
+</script>
+
+<style module lang="scss">
+.timelineRoot {
+ background-color: var(--panel);
+ height: 100%;
+ max-height: var(--embedMaxHeight, none);
+ display: flex;
+ flex-direction: column;
+}
+
+.header {
+ flex-shrink: 0;
+ border-bottom: 1px solid var(--divider);
+}
+
+.body {
+ flex-grow: 1;
+ overflow-y: auto;
+}
+</style>
diff --git a/packages/frontend-embed/src/components/EmUrl.vue b/packages/frontend-embed/src/components/EmUrl.vue
new file mode 100644
index 0000000000..a96bfdb493
--- /dev/null
+++ b/packages/frontend-embed/src/components/EmUrl.vue
@@ -0,0 +1,96 @@
+<!--
+SPDX-FileCopyrightText: syuilo and misskey-project
+SPDX-License-Identifier: AGPL-3.0-only
+-->
+
+<template>
+<component
+ :is="self ? EmA : 'a'" ref="el" :class="$style.root" class="_link" :[attr]="self ? props.url.substring(local.length) : props.url" :rel="rel ?? 'nofollow noopener'" :target="target"
+ @contextmenu.stop="() => {}"
+>
+ <template v-if="!self">
+ <span :class="$style.schema">{{ schema }}//</span>
+ <span :class="$style.hostname">{{ hostname }}</span>
+ <span v-if="port != ''">:{{ port }}</span>
+ </template>
+ <template v-if="pathname === '/' && self">
+ <span :class="$style.self">{{ hostname }}</span>
+ </template>
+ <span v-if="pathname != ''" :class="$style.pathname">{{ self ? pathname.substring(1) : pathname }}</span>
+ <span :class="$style.query">{{ query }}</span>
+ <span :class="$style.hash">{{ hash }}</span>
+ <i v-if="target === '_blank'" :class="$style.icon" class="ti ti-external-link"></i>
+</component>
+</template>
+
+<script lang="ts" setup>
+import { ref } from 'vue';
+import { toUnicode as decodePunycode } from 'punycode/';
+import EmA from './EmA.vue';
+import { url as local } from '@/config.js';
+
+function safeURIDecode(str: string): string {
+ try {
+ return decodeURIComponent(str);
+ } catch {
+ return str;
+ }
+}
+
+const props = withDefaults(defineProps<{
+ url: string;
+ rel?: string;
+ showUrlPreview?: boolean;
+}>(), {
+ showUrlPreview: true,
+});
+
+const self = props.url.startsWith(local);
+const url = new URL(props.url);
+if (!['http:', 'https:'].includes(url.protocol)) throw new Error('invalid url');
+const el = ref();
+
+const schema = url.protocol;
+const hostname = decodePunycode(url.hostname);
+const port = url.port;
+const pathname = safeURIDecode(url.pathname);
+const query = safeURIDecode(url.search);
+const hash = safeURIDecode(url.hash);
+const attr = self ? 'to' : 'href';
+const target = self ? null : '_blank';
+</script>
+
+<style lang="scss" module>
+.root {
+ word-break: break-all;
+}
+
+.icon {
+ padding-left: 2px;
+ font-size: .9em;
+}
+
+.self {
+ font-weight: bold;
+}
+
+.schema {
+ opacity: 0.5;
+}
+
+.hostname {
+ font-weight: bold;
+}
+
+.pathname {
+ opacity: 0.8;
+}
+
+.query {
+ opacity: 0.5;
+}
+
+.hash {
+ font-style: italic;
+}
+</style>
diff --git a/packages/frontend-embed/src/components/EmUserName.vue b/packages/frontend-embed/src/components/EmUserName.vue
new file mode 100644
index 0000000000..c0c7c443ca
--- /dev/null
+++ b/packages/frontend-embed/src/components/EmUserName.vue
@@ -0,0 +1,21 @@
+<!--
+SPDX-FileCopyrightText: syuilo and misskey-project
+SPDX-License-Identifier: AGPL-3.0-only
+-->
+
+<template>
+<EmMfm :text="user.name ?? user.username" :author="user" :plain="true" :nowrap="nowrap" :emojiUrls="user.emojis"/>
+</template>
+
+<script lang="ts" setup>
+import { } from 'vue';
+import * as Misskey from 'misskey-js';
+import EmMfm from './EmMfm.js';
+
+const props = withDefaults(defineProps<{
+ user: Misskey.entities.User;
+ nowrap?: boolean;
+}>(), {
+ nowrap: true,
+});
+</script>
diff --git a/packages/frontend-embed/src/components/I18n.vue b/packages/frontend-embed/src/components/I18n.vue
new file mode 100644
index 0000000000..b621110ec9
--- /dev/null
+++ b/packages/frontend-embed/src/components/I18n.vue
@@ -0,0 +1,51 @@
+<!--
+SPDX-FileCopyrightText: syuilo and misskey-project
+SPDX-License-Identifier: AGPL-3.0-only
+-->
+
+<template>
+<render/>
+</template>
+
+<script setup lang="ts" generic="T extends string | ParameterizedString">
+import { computed, h } from 'vue';
+import type { ParameterizedString } from '../../../../locales/index.js';
+
+const props = withDefaults(defineProps<{
+ src: T;
+ tag?: string;
+ // eslint-disable-next-line vue/require-default-prop
+ textTag?: string;
+}>(), {
+ tag: 'span',
+});
+
+const slots = defineSlots<T extends ParameterizedString<infer R> ? { [K in R]: () => unknown } : NonNullable<unknown>>();
+
+const parsed = computed(() => {
+ let str = props.src as string;
+ const value: (string | { arg: string; })[] = [];
+ for (;;) {
+ const nextBracketOpen = str.indexOf('{');
+ const nextBracketClose = str.indexOf('}');
+
+ if (nextBracketOpen === -1) {
+ value.push(str);
+ break;
+ } else {
+ if (nextBracketOpen > 0) value.push(str.substring(0, nextBracketOpen));
+ value.push({
+ arg: str.substring(nextBracketOpen + 1, nextBracketClose),
+ });
+ }
+
+ str = str.substring(nextBracketClose + 1);
+ }
+
+ return value;
+});
+
+const render = () => {
+ return h(props.tag, parsed.value.map(x => typeof x === 'string' ? (props.textTag ? h(props.textTag, x) : x) : slots[x.arg]()));
+};
+</script>