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, useToolCursor, } from '@embedpdf/react/interaction'; import { AnnotationLayer, annotationPlugin, useAnnotation, useAnnotationDefaults, } from '@embedpdf/react/annotation'; import { cloudEngine } from '@cloudpdf/engine'; import './cursor.css'; const engine = cloudEngine(); // A standard cursor for the rectangle tool: any CSS cursor name. const plugins = [ stagePlugin(), renderPlugin(), interactionPlugin(), annotationPlugin({ tools: [{ id: 'square', cursor: 'cell' }] }), ]; const sketch: OpenInput = { kind: 'grant', grant: 'shr_IyOgSdO4AmJqV4BoMv5V0nYU' }; // A pen, 24 Ă— 24, in a color: its tip is the bottom-left corner. const penIcon = (color: string) => ``; // The pen cursor follows the pen's color. function InkCursor() { const { color } = useAnnotationDefaults('ink'); useToolCursor({ toolId: 'ink', cursors: { crosshair: { svg: penIcon(color ?? '#000000'), hotspot: { x: 2, y: 22 } } }, }); return null; } const COLORS = ['#e5484d', '#1e90ff', '#30a46c', '#1a2748']; function Toolbar() { const annotation = useAnnotation(); const interaction = useInteraction(); const { activeToolId } = useInteractionState(); const { color } = useAnnotationDefaults('ink'); // The pen is active on load: move the pointer over the page. useEffect(() => { interaction.activateTool('ink'); }, [interaction]); return (