import { useEffect } 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, useInteraction, useInteractionState, } from '@embedpdf/react/interaction'; import { AnnotationDraftMenu, AnnotationLayer, annotationPlugin, useAnnotation, } from '@embedpdf/react/annotation'; import { cloudEngine } from '@cloudpdf/engine'; import './polygon.css'; const engine = cloudEngine(); const plugins = [stagePlugin(), renderPlugin(), interactionPlugin(), annotationPlugin()]; const layout: OpenInput = { kind: 'grant', grant: 'shr_d2E_LaTuddJbZR00d1CvkqLM' }; const TOOLS = [ { id: 'pointer', label: 'Select' }, { id: 'polygon', label: 'Polygon' }, { id: 'polyline', label: 'Polyline' }, ]; function Toolbar() { const interaction = useInteraction(); const { activeToolId } = useInteractionState(); // The polygon tool is active on load: click a few points on the page. useEffect(() => { interaction.activateTool('polygon'); }, [interaction]); return (
Delete removes the selection; Escape stops a shape