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 { commandsPlugin, standardCommands, useCommand, useCommands, } from '@embedpdf/react/commands'; import { cloudEngine } from '@cloudpdf/engine'; import './palette.css'; const engine = cloudEngine(); const plugins = [ stagePlugin(), renderPlugin(), interactionPlugin(), commandsPlugin({ commands: standardCommands }), ]; const welcome: OpenInput = { kind: 'grant', grant: 'shr_gvpJcG1ULUMon19C0D1wODSY' }; // A result: its row follows the command, so it greys out the moment the command can't run. function Result({ id }: { id: string }) { const command = useCommand(id); if (!command.visible) return null; return (
  • ); } function CommandPalette() { const commands = useCommands(); const [query, setQuery] = useState('page'); const results = commands.searchCommands(query); return (
    setQuery(event.target.value)} onKeyDown={(event) => { // Enter runs the first result that can run now. const first = results.find((command) => commands.canExecute(command.id)); if (event.key === 'Enter' && first) void commands.execute(first.id); }} />
    ); } export default function App() { return ( Loading…

    }>
    {() => }
    ); }