import { useEffect } from 'react';
import { Viewer, DocumentGate } from '@embedpdf/react/runtime';
import type { OpenInput } from '@embedpdf/react/runtime';
import { Stage, StageToken, stagePlugin } from '@embedpdf/react/stage';
import { RenderLayer, renderPlugin } from '@embedpdf/react/render';
import {
commandsPlugin,
standardCommands,
useCommand,
useCommands,
useCommandsSettings,
} from '@embedpdf/react/commands';
import type { CommandDefinition } from '@embedpdf/react/commands';
import { localEngine } from '@embedpdf/engine';
import './custom.css';
const engine = localEngine();
// A command of your own: pressed while the pages show two at a time.
const twoPages: CommandDefinition = {
id: 'layout:two-pages',
label: 'Two pages',
categories: ['layout'],
active: ({ get }) => get(StageToken).getSettings().spread === 'odd',
run: ({ get }) => {
const stage = get(StageToken);
stage.updateSettings({ spread: stage.getSettings().spread === 'odd' ? 'none' : 'odd' });
},
};
const plugins = [
stagePlugin(),
renderPlugin(),
commandsPlugin({ commands: [...standardCommands, twoPages] }),
];
// [!doc-source welcome]
const welcome = async (): Promise