manifold/web/components/editor/tweet-embed.tsx

20 lines
495 B
TypeScript
Raw Normal View History

import { NodeViewWrapper } from '@tiptap/react'
import { TwitterTweetEmbed } from 'react-twitter-embed'
export default function WrappedTwitterTweetEmbed(props: {
node: {
attrs: {
tweetId: string
}
}
}): JSX.Element {
// Remove the leading 't' from the tweet id
const tweetId = props.node.attrs.tweetId.slice(1)
return (
2022-09-14 20:19:12 +00:00
<NodeViewWrapper className="tiptap-tweet [&_.twitter-tweet]:mx-auto">
<TwitterTweetEmbed tweetId={tweetId} />
</NodeViewWrapper>
)
}