import { 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 { SelectionLayer, selectionPlugin } from '@embedpdf/react/selection'; import { AnnotationLayer, annotationPlugin } from '@embedpdf/react/annotation'; import { commandsPlugin, standardCommands } from '@embedpdf/react/commands'; import { Toolbar, group, item } from '@embedpdf/react/toolbar'; import type { BarSchema } from '@embedpdf/react/toolbar'; import { cloudEngine } from '@cloudpdf/engine'; import './basic.css'; const engine = cloudEngine(); const plugins = [ stagePlugin(), renderPlugin(), interactionPlugin(), selectionPlugin(), annotationPlugin(), commandsPlugin({ commands: standardCommands }), ]; const welcome: OpenInput = { kind: 'grant', grant: 'shr_gvpJcG1ULUMon19C0D1wODSY' }; // Your icons, by the names the standard commands give them. const ICONS: Record = { 'previous-page': '‹', 'next-page': '›', 'zoom-out': '−', 'zoom-in': '+', 'fit-width': '↔', pointer: '↖', pan: '✥', highlight: '▍', underline: 'U̲', ink: '〰', download: '↓', print: '⎙', }; const bar: BarSchema = { id: 'main', sections: { start: [group('pages', ['page:previous', 'page:next'])], center: [ group('zoom', [ 'zoom:out', item('zoom:in', { variants: ['icon+label', 'icon'] }), item('zoom:fit-width', { variants: ['icon+label', 'icon'], importance: 2 }), ]), ], end: [ group('tools', ['tool:pointer', 'tool:pan', 'tool:highlight', 'tool:underline', 'tool:ink'], { collapse: 'menu', }), group('document', [item('document:download', { importance: 5 }), 'document:print']), ], }, }; function MainToolbar() { return ( ( )} /> ); } export default function App() { // Narrow the toolbar to watch it make room: labels go first, then the tools fold, then "More". const [width, setWidth] = useState(100); return ( Loading…

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