import { useEffect, useState } from 'react'; import { Viewer, DocumentGate } from '@embedpdf/react/runtime'; import type { OpenInput } from '@embedpdf/react/runtime'; import { Stage, stagePlugin } from '@embedpdf/react/stage'; import { RenderLayer, renderPlugin } from '@embedpdf/react/render'; import { interactionPlugin } from '@embedpdf/react/interaction'; import { actionsPlugin, useActionsUiAdapter } from '@embedpdf/react/actions'; import { LinkLayer, linkPlugin, useLink, useLinkEvent } from '@embedpdf/react/link'; import type { Link } from '@embedpdf/react/link'; import { cloudEngine } from '@cloudpdf/engine'; import './list.css'; const engine = cloudEngine(); // The actions plugin runs a link that names a viewer command, such as the footer's Next. const plugins = [stagePlugin(), renderPlugin(), interactionPlugin(), actionsPlugin(), linkPlugin()]; const links: OpenInput = { kind: 'grant', grant: 'shr_xs-9Y5qwuYrJ2BKtWzuo_2xy' }; // The browser's way to open a website, once for the viewer. function BrowserActions() { useActionsUiAdapter(); return null; } // The first page's links, read from the plugin, each with a button that follows it. function LinkList() { const link = useLink(); const [items, setItems] = useState([]); const [last, setLast] = useState(null); useEffect(() => { void link.ensureLoaded(0).then(() => setItems(link.listLinks(0))); }, [link]); // Every way of following a link ends up here: a click, a key, or code. useLinkEvent( (link) => link.onActivated, ({ target, activation }) => setLast(`${target.kind} → ${activation.status}`), ); return ( ); } export default function App() { return ( Loading…

}>
{() => ( <> )}
); }