import { Viewer, DocumentGate } from '@embedpdf/react/runtime'; import type { OpenInput } from '@embedpdf/react/runtime'; import { Stage, stagePlugin } from '@embedpdf/react/stage'; import { RenderLayer, SnapshotLayer, renderPlugin } from '@embedpdf/react/render'; import { interactionPlugin, useInteraction, useInteractionState, } from '@embedpdf/react/interaction'; import { SelectionLayer, selectionPlugin } from '@embedpdf/react/selection'; import { cloudEngine } from '@cloudpdf/engine'; import './switch.css'; const engine = cloudEngine(); // The document opens with the hand tool. const plugins = [ stagePlugin(), renderPlugin(), interactionPlugin({ defaultTool: 'pan' }), selectionPlugin(), ]; const welcome: OpenInput = { kind: 'grant', grant: 'shr_gvpJcG1ULUMon19C0D1wODSY' }; const LABELS: Record = { pointer: 'Select', pan: 'Hand', zoom: 'Zoom', snapshot: 'Snapshot', }; const HINTS: Record = { pointer: 'A drag selects text', pan: 'A drag scrolls the pages', zoom: 'A drag zooms to the box, a click zooms in', snapshot: 'A drag takes part of a page as an image', }; // A button for every tool you can switch to, the active one pressed. function ToolSwitch() { const interaction = useInteraction(); const { activeToolId, tools } = useInteractionState(); return (
{tools.map((tool) => ( ))}
{activeToolId ? HINTS[activeToolId] : ''}
); } export default function App() { return ( Loading…

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