From 5db3cbc2ceb8470b4e39060230fb34d5bfa426d0 Mon Sep 17 00:00:00 2001 From: Steven H Date: Thu, 25 Apr 2024 15:25:53 +0100 Subject: [PATCH] Render Embed blocks that can be handled by an integration in the Space. (#2302) --- bun.lockb | Bin 478189 -> 477805 bytes package.json | 2 +- packages/react-contentkit/package.json | 2 +- src/components/DocumentView/Embed.tsx | 42 ++++++++++++++++-- .../Integration/IntegrationBlock.tsx | 1 + 5 files changed, 41 insertions(+), 6 deletions(-) diff --git a/bun.lockb b/bun.lockb index 426c0b2910f11fe43ca266a38cbff80fe89ba178..cf322fbd63ef32621dce5cfc3599616726be1f02 100755 GIT binary patch delta 2657 zcmXxkdr%cs90%~-d-sB%;sY-tPfy_ zz^dp--`2rb{yyNoY;Wt+9R>HBZ`|!X=i~ccS4>*({zsMzv3WnHxhv9Is&j)as~cL% zE5baF;(nB(R6H(i^9)}f)>f4fxuT)hWC>(&k z$wp|oS{~-6VsN5|;a9F!hS~aVjKmIg=X%F^W#_i~q+>n4A4i4+Ha*?mys^>0S=%+r zKF~HQvAyA5Y)yTSTg<75CuNr8#@!u1MO-@jS;Eqs-|t0#<;=QK_|Zmtip8*}SeFIr zC#G3v>zxa&gN&#})~F(5)k*8yy|%k}8ZTX4XZ5d%t&AP4C`TGJJdC2$9n|z{m(5$> z)Tl-3?Ty+9=ZL-zMHz|;3vvk`+HjZ^xr86h4wILW2}5W;G#l>6(niwUaQ_U=mnI7x zYnnc5pElT;IKaH~V}S>59WoNlpXP}?ofZI-2OWsWparpR5Ns+fn1&@#N|8$&P4hy& z*365P5aJNvW_b;?F|?t`x6;PKWHp8%ijhkTXWek*E2R@{9L*bfnLhDz&D+@}tA-ZI zE<5s@wDGY1g}+6MqK!mdrgWl3bF44&d|C_*=TuqCb&Q4eZ(5pZPGvF+{ZaVHJnPD{ zv;bHMOcr?xOy&+myg`en1;H}8xQQ_QDZz*=S`uwEESr`LQx&IqTylZ3Ybii^!ZC>R z$YqC8`wGn?6v@FeX`$$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T+*rB~V6xS7(A{BD!oAF!i})0`vzB@DU@0_>d8x1j z+CEwuYz7P^bW!#b(}6LXVYEq?=aEJh2|y2E>11t}J|$Rzj0C zZqaTvB0!7!)_!%4D%DOjsNVY32G!GGh|nK2s{R8VCiT@F+f_fK^J?bJf2e)Zp!yk_ z^{lh%jR3zUOh1KnPNJ9Ko7#Zh0^9!3zV5ajJ@J8>Y&3-HHILMcCkBi5xXUy}3yU^Q z3^3z=Q~mMjE^XeFUX{D0(aDfIH8d;~pKNE3NuEw=zM~~{n_~3s-KJinbMGCyW?1!- i+ooU3v1n$RW55f|^Q@zn7MteiZnT7kX=SteJpT`Uwt4{o diff --git a/package.json b/package.json index 34d3c1a834..38d06167b4 100644 --- a/package.json +++ b/package.json @@ -20,7 +20,7 @@ ], "dependencies": { "@geist-ui/icons": "^1.0.2", - "@gitbook/api": "^0.43.0", + "@gitbook/api": "^0.46.0", "@radix-ui/react-checkbox": "^1.0.4", "@radix-ui/react-popover": "^1.0.7", "@sentry/nextjs": "^7.94.1", diff --git a/packages/react-contentkit/package.json b/packages/react-contentkit/package.json index 6e4a5ed661..2826bca3a4 100644 --- a/packages/react-contentkit/package.json +++ b/packages/react-contentkit/package.json @@ -3,7 +3,7 @@ "exports": "./src/index.ts", "dependencies": { "classnames": "^2.5.1", - "@gitbook/api": "^0.41.0", + "@gitbook/api": "^0.46.0", "assert-never": "^1.2.1" }, "peerDependencies": { diff --git a/src/components/DocumentView/Embed.tsx b/src/components/DocumentView/Embed.tsx index d118f2deaa..6066bf3cbf 100644 --- a/src/components/DocumentView/Embed.tsx +++ b/src/components/DocumentView/Embed.tsx @@ -1,4 +1,4 @@ -import { DocumentBlockEmbed } from '@gitbook/api'; +import * as gitbookAPI from '@gitbook/api'; import Script from 'next/script'; import { Card } from '@/components/primitives'; @@ -7,11 +7,14 @@ import { tcls } from '@/lib/tailwind'; import { BlockProps } from './Block'; import { Caption } from './Caption'; +import { IntegrationBlock } from './Integration'; -export async function Embed(props: BlockProps) { - const { block } = props; +export async function Embed(props: BlockProps) { + const { block, context, ...otherProps } = props; - const { data: embed } = await api().urls.getEmbedByUrl({ url: block.data.url }); + const { data: embed } = await (context.content + ? api().spaces.getEmbedByUrlInSpace(context.content.spaceId, { url: block.data.url }) + : api().urls.getEmbedByUrl({ url: block.data.url })); return ( @@ -25,6 +28,12 @@ export async function Embed(props: BlockProps) { {/* We load the iframely script to resize the embed iframes dynamically */}