import { useEffect, useRef } from 'react';
import { Viewer, DocumentGate } from '@embedpdf/react/runtime';
import type { OpenInput } from '@embedpdf/react/runtime';
import { Stage, stagePlugin, useStage } from '@embedpdf/react/stage';
import { RenderLayer, renderPlugin } from '@embedpdf/react/render';
import { interactionPlugin } from '@embedpdf/react/interaction';
import { searchPlugin } from '@embedpdf/react/search';
import {
AnnotationLayer,
annotationKey,
annotationPlugin,
useAnnotationState,
} from '@embedpdf/react/annotation';
import {
redactionPlugin,
usePendingRedactions,
useRedaction,
useRedactionState,
} from '@embedpdf/react/redaction';
import { localEngine } from '@embedpdf/engine';
import './review.css';
const engine = localEngine();
const plugins = [
stagePlugin(),
renderPlugin(),
interactionPlugin(),
searchPlugin(),
annotationPlugin(),
redactionPlugin(),
];
const welcome = async (): Promise => {
const response = await fetch('https://www.embedpdf.com/pdfs/welcome.pdf');
return { kind: 'bytes', id: 'welcome', bytes: new Uint8Array(await response.arrayBuffer()) };
};
// On load: the cover's subtitle, and every "Adobe" in the document.
function MarkSome() {
const redaction = useRedaction();
const ready = useAnnotationState((state) => state.status === 'ready');
const started = useRef(false);
useEffect(() => {
if (!ready || started.current) return;
started.current = true;
void redaction
.markArea(0, { x: 44, y: 318, width: 206, height: 50 })
.then(() => redaction.markMatches({ text: 'Adobe' }));
}, [redaction, ready]);
return null;
}
function PendingMarks() {
const stage = useStage();
const redaction = useRedaction();
const marks = usePendingRedactions(); // the marks not applied yet, in page order
const { pendingCount } = useRedactionState();
return (
{pendingCount} {pendingCount === 1 ? 'mark' : 'marks'}
{marks.map((mark) => (
-
))}
);
}
export default function App() {
return (
Loading…
}>
);
}