import { Add, Download, Print, Subtract, } from "components/apps/PDF//ControlIcons"; import StyledControls from "components/apps/PDF/StyledControls"; import { scales } from "components/apps/PDF/usePDF"; import type { ComponentProcessProps } from "components/system/Apps/RenderComponent"; import { useFileSystem } from "contexts/fileSystem"; import { useProcesses } from "contexts/process"; import { basename } from "path"; import Button from "styles/common/Button"; import { MILLISECONDS_IN_SECOND } from "utils/constants"; import { bufferToUrl, isSafari, label } from "utils/functions"; declare global { interface Window { InstallTrigger?: boolean; } } const Controls: FC = ({ id }) => { const { readFile } = useFileSystem(); const { argument, processes: { [id]: process } = {} } = useProcesses(); const { count = 0, page: currentPage = 1, componentWindow, scale = 1, subTitle = "", url = "", } = process || {}; return (
{subTitle || basename(url)}
    {count !== 0 && (
  1. { const newPage = Number(target.value); if (Number.isNaN(newPage) || newPage < 1 || newPage > count) { return; } argument(id, "page", newPage); componentWindow ?.querySelectorAll("li") [newPage - 1].scrollIntoView(); }} value={currentPage} />{" "} / {count}
  2. )}
  3. { if ( !target.value.endsWith("%") || target.value.length > 4 || target.value.length < 2 ) { return; } const newScale = Number(target.value.replace("%", "")) / 100; if ( Number.isNaN(newScale) || newScale > scales[scales.length - 1] || newScale < scales[0] ) { return; } argument( id, "scale", scales[scales.findIndex((s) => s >= newScale)] ); }} value={`${Math.round(scale * 100)}%`} />
); }; export default Controls;