import { useEffect } from 'react'; import { Viewer, DocumentGate, usePageList } 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 { SelectionHandles, SelectionLayer, SelectionMenu, copySelection, selectionPlugin, useSelection, } from '@embedpdf/react/selection'; import { localEngine } from '@embedpdf/engine'; import './handles.css'; const engine = localEngine(); const plugins = [stagePlugin(), renderPlugin(), interactionPlugin(), selectionPlugin()]; const welcome = async (): Promise => { const response = await fetch('https://www.embedpdf.com/pdfs/welcome.pdf'); return { kind: 'bytes', id: 'welcome', bytes: new Uint8Array(await response.arrayBuffer()) }; }; function CopyButton() { const selection = useSelection(); return ( ); } // A word selected on load, as a long-press selects one: "Documents", on the cover. function SelectWord() { const selection = useSelection(); const cover = usePageList()[0]?.ref; useEffect(() => { if (cover) selection.select({ page: cover, start: 28, count: 9 }); }, [selection, cover]); return null; } export default function App() { return ( Loading…

}> {/* Clear of the start handle's grip, which sits above the first line. */} } > {() => ( <> )}
); }