enhance(frontend): blueskyの投稿埋め込み表示に対応
This commit is contained in:
parent
e0a83e9c9e
commit
2ebe003b93
|
@ -2585,7 +2585,7 @@ export interface Locale extends ILocale {
|
||||||
/**
|
/**
|
||||||
* ポストを展開する
|
* ポストを展開する
|
||||||
*/
|
*/
|
||||||
"expandTweet": string;
|
"expandPost": string;
|
||||||
/**
|
/**
|
||||||
* テーマエディター
|
* テーマエディター
|
||||||
*/
|
*/
|
||||||
|
|
|
@ -641,7 +641,7 @@ poll: "アンケート"
|
||||||
useCw: "内容を隠す"
|
useCw: "内容を隠す"
|
||||||
enablePlayer: "プレイヤーを開く"
|
enablePlayer: "プレイヤーを開く"
|
||||||
disablePlayer: "プレイヤーを閉じる"
|
disablePlayer: "プレイヤーを閉じる"
|
||||||
expandTweet: "ポストを展開する"
|
expandPost: "ポストを展開する"
|
||||||
themeEditor: "テーマエディター"
|
themeEditor: "テーマエディター"
|
||||||
description: "説明"
|
description: "説明"
|
||||||
describeFile: "キャプションを付ける"
|
describeFile: "キャプションを付ける"
|
||||||
|
|
|
@ -27,9 +27,8 @@ SPDX-License-Identifier: AGPL-3.0-only
|
||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
<template v-else-if="tweetId && tweetExpanded">
|
<template v-else-if="tweetId && tweetExpanded">
|
||||||
<div ref="twitter">
|
<div>
|
||||||
<iframe
|
<iframe
|
||||||
ref="tweet"
|
|
||||||
allow="fullscreen;web-share"
|
allow="fullscreen;web-share"
|
||||||
sandbox="allow-popups allow-popups-to-escape-sandbox allow-scripts allow-same-origin"
|
sandbox="allow-popups allow-popups-to-escape-sandbox allow-scripts allow-same-origin"
|
||||||
scrolling="no"
|
scrolling="no"
|
||||||
|
@ -43,6 +42,22 @@ SPDX-License-Identifier: AGPL-3.0-only
|
||||||
</MkButton>
|
</MkButton>
|
||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
|
<template v-else-if="bskyDid && bskyPostRecordKey && bskyPostExpanded">
|
||||||
|
<div>
|
||||||
|
<iframe
|
||||||
|
allow="fullscreen;web-share"
|
||||||
|
sandbox="allow-popups allow-popups-to-escape-sandbox allow-scripts allow-same-origin"
|
||||||
|
scrolling="no"
|
||||||
|
:style="{ position: 'relative', width: '100%', height: `${bskyPostHeight}px`, border: 0 }"
|
||||||
|
:src="`https://embed.bsky.app/embed/${bskyDid}/app.bsky.feed.post/${bskyPostRecordKey}?id=${embedId}`"
|
||||||
|
></iframe>
|
||||||
|
</div>
|
||||||
|
<div :class="$style.action">
|
||||||
|
<MkButton :small="true" inline @click="bskyPostExpanded = false">
|
||||||
|
<i class="ti ti-x"></i> {{ i18n.ts.close }}
|
||||||
|
</MkButton>
|
||||||
|
</div>
|
||||||
|
</template>
|
||||||
<div v-else>
|
<div v-else>
|
||||||
<component :is="self ? 'MkA' : 'a'" :class="[$style.link, { [$style.compact]: compact }]" :[attr]="self ? url.substring(local.length) : url" rel="nofollow noopener" :target="target" :title="url">
|
<component :is="self ? 'MkA' : 'a'" :class="[$style.link, { [$style.compact]: compact }]" :[attr]="self ? url.substring(local.length) : url" rel="nofollow noopener" :target="target" :title="url">
|
||||||
<div v-if="thumbnail && !sensitive" :class="$style.thumbnail" :style="defaultStore.state.dataSaver.urlPreview ? '' : `background-image: url('${thumbnail}')`">
|
<div v-if="thumbnail && !sensitive" :class="$style.thumbnail" :style="defaultStore.state.dataSaver.urlPreview ? '' : `background-image: url('${thumbnail}')`">
|
||||||
|
@ -67,7 +82,12 @@ SPDX-License-Identifier: AGPL-3.0-only
|
||||||
<template v-if="showActions">
|
<template v-if="showActions">
|
||||||
<div v-if="tweetId" :class="$style.action">
|
<div v-if="tweetId" :class="$style.action">
|
||||||
<MkButton :small="true" inline @click="tweetExpanded = true">
|
<MkButton :small="true" inline @click="tweetExpanded = true">
|
||||||
<i class="ti ti-brand-x"></i> {{ i18n.ts.expandTweet }}
|
<i class="ti ti-brand-x"></i> {{ i18n.ts.expandPost }}
|
||||||
|
</MkButton>
|
||||||
|
</div>
|
||||||
|
<div v-if="bskyPostRecordKey" :class="$style.action">
|
||||||
|
<MkButton :small="true" inline @click="openBskyEmbed">
|
||||||
|
<i class="ti ti-brand-bluesky"></i> {{ i18n.ts.expandPost }}
|
||||||
</MkButton>
|
</MkButton>
|
||||||
</div>
|
</div>
|
||||||
<div v-if="!playerEnabled && player.url" :class="$style.action">
|
<div v-if="!playerEnabled && player.url" :class="$style.action">
|
||||||
|
@ -126,10 +146,19 @@ const player = ref({
|
||||||
height: null,
|
height: null,
|
||||||
} as SummalyResult['player']);
|
} as SummalyResult['player']);
|
||||||
const playerEnabled = ref(false);
|
const playerEnabled = ref(false);
|
||||||
|
|
||||||
|
const embedId = `embed${Math.random().toString().replace(/\D/, '')}`;
|
||||||
|
|
||||||
const tweetId = ref<string | null>(null);
|
const tweetId = ref<string | null>(null);
|
||||||
const tweetExpanded = ref(props.detail);
|
const tweetExpanded = ref(props.detail);
|
||||||
const embedId = `embed${Math.random().toString().replace(/\D/, '')}`;
|
|
||||||
const tweetHeight = ref(150);
|
const tweetHeight = ref(150);
|
||||||
|
|
||||||
|
const bskyHandleOrDid = ref<string | null>(null);
|
||||||
|
const bskyDid = ref<string | null>(null);
|
||||||
|
const bskyPostRecordKey = ref<string | null>(null);
|
||||||
|
const bskyPostExpanded = ref(props.detail);
|
||||||
|
const bskyPostHeight = ref(150);
|
||||||
|
|
||||||
const unknownUrl = ref(false);
|
const unknownUrl = ref(false);
|
||||||
|
|
||||||
onDeactivated(() => {
|
onDeactivated(() => {
|
||||||
|
@ -144,6 +173,19 @@ if (requestUrl.hostname === 'twitter.com' || requestUrl.hostname === 'mobile.twi
|
||||||
if (m) tweetId.value = m[1];
|
if (m) tweetId.value = m[1];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (requestUrl.hostname === 'bsky.app') {
|
||||||
|
const bskyPostPageUrl = requestUrl.pathname.slice(1).split('/');
|
||||||
|
|
||||||
|
if (bskyPostPageUrl[0] === 'profile' && bskyPostPageUrl[1] && bskyPostPageUrl[2] === 'post' && bskyPostPageUrl[3]) {
|
||||||
|
bskyHandleOrDid.value = bskyPostPageUrl[1];
|
||||||
|
bskyPostRecordKey.value = bskyPostPageUrl[3];
|
||||||
|
|
||||||
|
if (bskyPostExpanded.value) {
|
||||||
|
openBskyEmbed();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (requestUrl.hostname === 'music.youtube.com' && requestUrl.pathname.match('^/(?:watch|channel)')) {
|
if (requestUrl.hostname === 'music.youtube.com' && requestUrl.pathname.match('^/(?:watch|channel)')) {
|
||||||
requestUrl.hostname = 'www.youtube.com';
|
requestUrl.hostname = 'www.youtube.com';
|
||||||
}
|
}
|
||||||
|
@ -180,13 +222,23 @@ window.fetch(`/url?url=${encodeURIComponent(requestUrl.href)}&lang=${versatileLa
|
||||||
sensitive.value = info.sensitive ?? false;
|
sensitive.value = info.sensitive ?? false;
|
||||||
});
|
});
|
||||||
|
|
||||||
function adjustTweetHeight(message: MessageEvent) {
|
async function openBskyEmbed() {
|
||||||
if (message.origin !== 'https://platform.twitter.com') return;
|
if (bskyHandleOrDid.value == null || bskyPostRecordKey.value == null) return;
|
||||||
const embed = message.data?.['twttr.embed'];
|
|
||||||
if (embed?.method !== 'twttr.private.resize') return;
|
if (bskyDid.value == null) {
|
||||||
if (embed?.id !== embedId) return;
|
if (bskyHandleOrDid.value.startsWith('did:')) {
|
||||||
const height = embed?.params[0]?.height;
|
bskyDid.value = bskyHandleOrDid.value;
|
||||||
if (height) tweetHeight.value = height;
|
} else {
|
||||||
|
// handleで来ている場合はdidに変換
|
||||||
|
const bskyApiRes = await window.fetch(`https://public.api.bsky.app/xrpc/com.atproto.identity.resolveHandle?handle=${bskyHandleOrDid.value}`);
|
||||||
|
if (bskyApiRes.ok) {
|
||||||
|
const bskyApiData = await bskyApiRes.json() as { did: string };
|
||||||
|
bskyDid.value = bskyApiData.did;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
bskyPostExpanded.value = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
function openPlayer(): void {
|
function openPlayer(): void {
|
||||||
|
@ -199,10 +251,25 @@ function openPlayer(): void {
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
window.addEventListener('message', adjustTweetHeight);
|
function adjustSocialsEmbedHeight(message: MessageEvent) {
|
||||||
|
if (message.origin === 'https://platform.twitter.com') {
|
||||||
|
const embed = message.data?.['twttr.embed'];
|
||||||
|
if (embed?.method === 'twttr.private.resize' && embed?.id === embedId) {
|
||||||
|
const height = embed?.params[0]?.height;
|
||||||
|
if (height) tweetHeight.value = height;
|
||||||
|
}
|
||||||
|
} else if (message.origin === 'https://embed.bsky.app') {
|
||||||
|
if (message.data?.id === embedId) {
|
||||||
|
const height = message.data?.height;
|
||||||
|
if (height) bskyPostHeight.value = height;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
window.addEventListener('message', adjustSocialsEmbedHeight);
|
||||||
|
|
||||||
onUnmounted(() => {
|
onUnmounted(() => {
|
||||||
window.removeEventListener('message', adjustTweetHeight);
|
window.removeEventListener('message', adjustSocialsEmbedHeight);
|
||||||
});
|
});
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
|
|
|
@ -22,7 +22,7 @@
|
||||||
style-src 'self' 'unsafe-inline';
|
style-src 'self' 'unsafe-inline';
|
||||||
img-src 'self' data: blob: www.google.com xn--931a.moe localhost:3000 localhost:5173 127.0.0.1:5173 127.0.0.1:3000;
|
img-src 'self' data: blob: www.google.com xn--931a.moe localhost:3000 localhost:5173 127.0.0.1:5173 127.0.0.1:3000;
|
||||||
media-src 'self' localhost:3000 localhost:5173 127.0.0.1:5173 127.0.0.1:3000;
|
media-src 'self' localhost:3000 localhost:5173 127.0.0.1:5173 127.0.0.1:3000;
|
||||||
connect-src 'self' localhost:3000 localhost:5173 127.0.0.1:5173 127.0.0.1:3000 https://newassets.hcaptcha.com;
|
connect-src 'self' localhost:3000 localhost:5173 127.0.0.1:5173 127.0.0.1:3000 https://newassets.hcaptcha.com https://public.api.bsky.app;
|
||||||
frame-src *;"
|
frame-src *;"
|
||||||
/>
|
/>
|
||||||
<meta property="og:site_name" content="[DEV BUILD] Misskey" />
|
<meta property="og:site_name" content="[DEV BUILD] Misskey" />
|
||||||
|
|
Loading…
Reference in New Issue