|
|
|
@@ -1,28 +1,32 @@
|
|
|
|
|
<script lang="ts">
|
|
|
|
|
// One PDF tab: the toolbar, the status line, the password form, and one page with its text layer.
|
|
|
|
|
// One PDF tab: the toolbar, the status line, the password form, and all pages in one column that scrolls.
|
|
|
|
|
// Only the pages near the visible area have a canvas and a text layer. The other pages are empty sheets.
|
|
|
|
|
// The document and its worker live as long as the tab. `close` releases both.
|
|
|
|
|
import { onMount } from "svelte";
|
|
|
|
|
import { flushSync, onMount } from "svelte";
|
|
|
|
|
import { message, t } from "$lib/i18n";
|
|
|
|
|
import IconButton from "$lib/ui/IconButton.svelte";
|
|
|
|
|
import type { PluginDocumentContext } from "$lib/plugins/sdk";
|
|
|
|
|
import { openPdf, TextLayer, type OpenPdf, type PDFDocumentProxy, type RenderTask } from "./engine";
|
|
|
|
|
import { MAX_ZOOM, MIN_ZOOM, RESIZE_SETTLE_MS, ZOOM_STEP, nextRotation, outputScale, pageNumber, zoomLevel } from "./model";
|
|
|
|
|
import { MAX_ZOOM, MIN_ZOOM, PAGE_GAP, PAGE_MARGIN, RESIZE_SETTLE_MS, ZOOM_STEP, fitZoom, mostVisiblePage, nextRotation, outputScale, pageBoxes, pageNumber, pagesInRange, zoomFromText, zoomLevel, type PageSize } from "./model";
|
|
|
|
|
|
|
|
|
|
let { file, readBytes }: { file: PluginDocumentContext; readBytes: (path: string) => Promise<Uint8Array> } = $props();
|
|
|
|
|
|
|
|
|
|
type Status = { key: string; values?: Record<string, string | number>; alert?: boolean };
|
|
|
|
|
/** One page that has a drawing, or waits for one. `key` names the zoom, the rotation, and the pixel ratio. */
|
|
|
|
|
type Drawing = { key: string; done: boolean; cancel(): void };
|
|
|
|
|
|
|
|
|
|
let page = $state(1);
|
|
|
|
|
let count = $state(0);
|
|
|
|
|
let zoom = $state(1);
|
|
|
|
|
let rotation = $state(0);
|
|
|
|
|
let fit = $state(true);
|
|
|
|
|
let sizes = $state.raw<PageSize[]>([]);
|
|
|
|
|
let status = $state<Status>({ key: message("Loading PDF…") });
|
|
|
|
|
let asking = $state<"needed" | "incorrect" | null>(null);
|
|
|
|
|
let reloading = $state(false);
|
|
|
|
|
let failed = $state(false);
|
|
|
|
|
let scroller: HTMLDivElement;
|
|
|
|
|
let sheet: HTMLDivElement;
|
|
|
|
|
let sheets: HTMLDivElement[] = $state([]);
|
|
|
|
|
let pageInput: HTMLInputElement;
|
|
|
|
|
let passwordInput: HTMLInputElement | undefined = $state();
|
|
|
|
|
|
|
|
|
@@ -30,14 +34,20 @@
|
|
|
|
|
let pdf: PDFDocumentProxy | undefined;
|
|
|
|
|
let opened: OpenPdf | undefined;
|
|
|
|
|
let answer: ((password: string) => void) | undefined;
|
|
|
|
|
let render: RenderTask | undefined;
|
|
|
|
|
let text: TextLayer | undefined;
|
|
|
|
|
let revision = 0;
|
|
|
|
|
let generation = 0;
|
|
|
|
|
const drawings = new Map<number, Drawing>();
|
|
|
|
|
let queue: Promise<void> = Promise.resolve();
|
|
|
|
|
let loading: Promise<void> = Promise.resolve();
|
|
|
|
|
let closing: Promise<void> | undefined;
|
|
|
|
|
// The place in the document: a page and the part of its height above the top of the visible area.
|
|
|
|
|
let anchor = { index: 0, part: 0 };
|
|
|
|
|
// The scroll position that the viewer set. A scroll event at this position keeps the page number.
|
|
|
|
|
let settled = -1;
|
|
|
|
|
let frame = 0;
|
|
|
|
|
|
|
|
|
|
const ready = $derived(count > 0);
|
|
|
|
|
const boxes = $derived(pageBoxes(sizes, zoom, rotation));
|
|
|
|
|
const zoomText = $derived(ready ? `${Math.round(zoom * 100)}%` : "—");
|
|
|
|
|
|
|
|
|
|
function fail(reason: unknown) {
|
|
|
|
|
if (disposed) return;
|
|
|
|
@@ -45,53 +55,137 @@
|
|
|
|
|
status = { key: message("Cannot display this PDF. {reason}"), values: { reason: reason instanceof Error ? reason.message : String(reason) }, alert: true };
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/** Draw the current page again. A newer request cancels the older one. */
|
|
|
|
|
function schedule() {
|
|
|
|
|
const request = ++revision;
|
|
|
|
|
render?.cancel(); text?.cancel();
|
|
|
|
|
if (pdf && !disposed) status = { key: message("Loading page {page}…"), values: { page } };
|
|
|
|
|
const drawingKey = () => `${zoom}:${rotation}:${window.devicePixelRatio}`;
|
|
|
|
|
|
|
|
|
|
/** The status line names the current page when its drawing is complete. */
|
|
|
|
|
function report() {
|
|
|
|
|
if (disposed || failed || !pdf) return;
|
|
|
|
|
const drawing = drawings.get(page);
|
|
|
|
|
status = drawing?.done && drawing.key === drawingKey()
|
|
|
|
|
? { key: message("Page {page} of {count}"), values: { page, count } }
|
|
|
|
|
: { key: message("Loading page {page}…"), values: { page } };
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/** Draw one page. The jobs run one at a time. A cancelled job ends at its next step. */
|
|
|
|
|
function draw(number: number, key: string) {
|
|
|
|
|
let cancelled = false;
|
|
|
|
|
let render: RenderTask | undefined;
|
|
|
|
|
let text: TextLayer | undefined;
|
|
|
|
|
const drawing: Drawing = { key, done: false, cancel() { cancelled = true; render?.cancel(); text?.cancel(); } };
|
|
|
|
|
drawings.set(number, drawing);
|
|
|
|
|
const source = pdf;
|
|
|
|
|
queue = queue.then(async () => {
|
|
|
|
|
if (disposed || request !== revision || !pdf || scroller.clientWidth === 0) return;
|
|
|
|
|
const pdfPage = await pdf.getPage(page);
|
|
|
|
|
if (disposed || request !== revision) return;
|
|
|
|
|
const angle = (pdfPage.rotate + rotation) % 360;
|
|
|
|
|
if (fit) zoom = zoomLevel((scroller.clientWidth - 32) / pdfPage.getViewport({ scale: 1, rotation: angle }).width);
|
|
|
|
|
const viewport = pdfPage.getViewport({ scale: zoom, rotation: angle });
|
|
|
|
|
if (cancelled || disposed || !source) return;
|
|
|
|
|
const pdfPage = await source.getPage(number);
|
|
|
|
|
const sheet = sheets[number - 1];
|
|
|
|
|
if (cancelled || disposed || !sheet) return;
|
|
|
|
|
const viewport = pdfPage.getViewport({ scale: zoom, rotation: (pdfPage.rotate + rotation) % 360 });
|
|
|
|
|
const scale = outputScale(viewport.width, viewport.height, window.devicePixelRatio);
|
|
|
|
|
const canvas = document.createElement("canvas");
|
|
|
|
|
canvas.width = Math.max(1, Math.floor(viewport.width * scale));
|
|
|
|
|
canvas.height = Math.max(1, Math.floor(viewport.height * scale));
|
|
|
|
|
canvas.style.width = `${viewport.width}px`;
|
|
|
|
|
canvas.style.height = `${viewport.height}px`;
|
|
|
|
|
canvas.setAttribute("role", "img");
|
|
|
|
|
// The measurement tool and the smoke tests find the page by this English name. Keep "PDF page N".
|
|
|
|
|
canvas.setAttribute("aria-label", $t("PDF page {page}", { page }));
|
|
|
|
|
canvas.setAttribute("aria-label", $t("PDF page {page}", { page: number }));
|
|
|
|
|
const layer = document.createElement("div");
|
|
|
|
|
layer.className = "textLayer";
|
|
|
|
|
sheet.style.width = `${viewport.width}px`;
|
|
|
|
|
sheet.style.height = `${viewport.height}px`;
|
|
|
|
|
sheet.style.setProperty("--total-scale-factor", String(zoom));
|
|
|
|
|
sheet.replaceChildren(canvas, layer);
|
|
|
|
|
layer.style.setProperty("--total-scale-factor", String(viewport.scale));
|
|
|
|
|
render = pdfPage.render({ canvas, viewport, transform: scale === 1 ? undefined : [scale, 0, 0, scale, 0, 0] });
|
|
|
|
|
await render.promise;
|
|
|
|
|
if (disposed || request !== revision) return;
|
|
|
|
|
if (cancelled || disposed) return;
|
|
|
|
|
// The old drawing of the page stays until the new one is complete.
|
|
|
|
|
sheet.replaceChildren(canvas, layer);
|
|
|
|
|
text = new TextLayer({ textContentSource: pdfPage.streamTextContent(), container: layer, viewport });
|
|
|
|
|
await text.render();
|
|
|
|
|
if (disposed || request !== revision) return;
|
|
|
|
|
status = { key: message("Page {page} of {count}"), values: { page, count } };
|
|
|
|
|
if (cancelled || disposed) return;
|
|
|
|
|
drawing.done = true;
|
|
|
|
|
pdfPage.cleanup();
|
|
|
|
|
}).catch(reason => { if (!disposed && request === revision) fail(reason); });
|
|
|
|
|
report();
|
|
|
|
|
}).catch(reason => { if (!cancelled && !disposed) fail(reason); });
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/** Draw the pages near the visible area, the current page first. Empty the pages that are far from it. */
|
|
|
|
|
function refresh() {
|
|
|
|
|
if (!pdf || disposed || scroller.clientWidth === 0) return;
|
|
|
|
|
const key = drawingKey();
|
|
|
|
|
const height = scroller.clientHeight;
|
|
|
|
|
const wanted = pagesInRange(boxes, scroller.scrollTop - height, scroller.scrollTop + 2 * height);
|
|
|
|
|
for (const [number, drawing] of drawings) {
|
|
|
|
|
const keep = wanted.includes(number);
|
|
|
|
|
if (keep && drawing.key === key) continue;
|
|
|
|
|
drawing.cancel();
|
|
|
|
|
drawings.delete(number);
|
|
|
|
|
if (!keep) sheets[number - 1]?.replaceChildren();
|
|
|
|
|
}
|
|
|
|
|
for (const number of wanted.sort((a, b) => Math.abs(a - page) - Math.abs(b - page))) if (!drawings.has(number)) draw(number, key);
|
|
|
|
|
report();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/** Put the remembered place at the top of the visible area again, after the page boxes changed. */
|
|
|
|
|
function restore() {
|
|
|
|
|
flushSync();
|
|
|
|
|
const box = boxes[anchor.index];
|
|
|
|
|
if (!box || scroller.clientWidth === 0) return;
|
|
|
|
|
scroller.scrollTop = Math.max(0, box.top + anchor.part * box.height);
|
|
|
|
|
settled = scroller.scrollTop;
|
|
|
|
|
refresh();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function remember() {
|
|
|
|
|
const box = boxes[page - 1];
|
|
|
|
|
anchor = { index: page - 1, part: box ? (scroller.scrollTop - box.top) / box.height : 0 };
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function scrolled() {
|
|
|
|
|
if (frame) return;
|
|
|
|
|
frame = requestAnimationFrame(() => {
|
|
|
|
|
frame = 0;
|
|
|
|
|
if (disposed || !ready || scroller.clientWidth === 0) return;
|
|
|
|
|
if (scroller.scrollTop !== settled) {
|
|
|
|
|
settled = -1;
|
|
|
|
|
page = mostVisiblePage(boxes, scroller.scrollTop, scroller.scrollTop + scroller.clientHeight);
|
|
|
|
|
remember();
|
|
|
|
|
}
|
|
|
|
|
refresh();
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/** Show the top of a page. */
|
|
|
|
|
function go(value: number) {
|
|
|
|
|
if (!pdf) return;
|
|
|
|
|
page = pageNumber(value, pdf.numPages);
|
|
|
|
|
pageInput.value = String(page);
|
|
|
|
|
scroller.scrollTop = 0;
|
|
|
|
|
schedule();
|
|
|
|
|
// The first page shows with the margin above it. Each other page shows with half of the gap above it.
|
|
|
|
|
anchor = { index: page - 1, part: -(page === 1 ? PAGE_MARGIN : PAGE_GAP / 2) / (boxes[page - 1]?.height ?? 1) };
|
|
|
|
|
restore();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function setZoom(value: number) { fit = false; zoom = zoomLevel(value); schedule(); }
|
|
|
|
|
function applyFit() {
|
|
|
|
|
if (fit && scroller.clientWidth > 0 && sizes.length) zoom = fitZoom(sizes, rotation, scroller.clientWidth - 2 * PAGE_MARGIN);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function setZoom(value: number) { fit = false; zoom = zoomLevel(value); restore(); }
|
|
|
|
|
|
|
|
|
|
function typedZoom(input: HTMLInputElement) {
|
|
|
|
|
const value = zoomFromText(input.value);
|
|
|
|
|
if (value !== null && Math.round(value * 100) !== Math.round(zoom * 100)) setZoom(value);
|
|
|
|
|
input.value = zoomText;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/** Read the size of each page after the first. Until then, a page has the size of the first page. */
|
|
|
|
|
async function measure(source: PDFDocumentProxy, current: number) {
|
|
|
|
|
const next = [...sizes];
|
|
|
|
|
let changed = false;
|
|
|
|
|
for (let number = 2; number <= source.numPages; number++) {
|
|
|
|
|
const { width, height } = (await source.getPage(number)).getViewport({ scale: 1 });
|
|
|
|
|
if (disposed || current !== generation) return;
|
|
|
|
|
if (width !== next[number - 1].width || height !== next[number - 1].height) { next[number - 1] = { width, height }; changed = true; }
|
|
|
|
|
}
|
|
|
|
|
if (!changed) return;
|
|
|
|
|
sizes = next;
|
|
|
|
|
applyFit();
|
|
|
|
|
restore();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
async function load() {
|
|
|
|
|
failed = false;
|
|
|
|
@@ -105,20 +199,27 @@
|
|
|
|
|
status = reason === "incorrect" ? { key: message("Incorrect password. Try again.") } : { key: message("This PDF needs a password.") };
|
|
|
|
|
queueMicrotask(() => passwordInput?.focus());
|
|
|
|
|
});
|
|
|
|
|
pdf = await opened.promise;
|
|
|
|
|
const source = await opened.promise;
|
|
|
|
|
if (disposed) return;
|
|
|
|
|
page = pageNumber(page, pdf.numPages);
|
|
|
|
|
count = pdf.numPages;
|
|
|
|
|
schedule();
|
|
|
|
|
const current = ++generation;
|
|
|
|
|
const { width, height } = (await source.getPage(1)).getViewport({ scale: 1 });
|
|
|
|
|
if (disposed) return;
|
|
|
|
|
pdf = source;
|
|
|
|
|
sizes = Array.from({ length: source.numPages }, () => ({ width, height }));
|
|
|
|
|
count = source.numPages;
|
|
|
|
|
applyFit();
|
|
|
|
|
go(page);
|
|
|
|
|
report();
|
|
|
|
|
void measure(source, current).catch(reason => { if (current === generation) fail(reason); });
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
async function release() {
|
|
|
|
|
revision++;
|
|
|
|
|
render?.cancel(); text?.cancel();
|
|
|
|
|
generation++;
|
|
|
|
|
for (const drawing of drawings.values()) drawing.cancel();
|
|
|
|
|
drawings.clear();
|
|
|
|
|
await queue;
|
|
|
|
|
const current = opened;
|
|
|
|
|
opened = undefined; pdf = undefined; answer = undefined; asking = null; count = 0;
|
|
|
|
|
sheet?.replaceChildren();
|
|
|
|
|
opened = undefined; pdf = undefined; answer = undefined; asking = null; count = 0; sizes = [];
|
|
|
|
|
await current?.close();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
@@ -145,12 +246,11 @@
|
|
|
|
|
next(value);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function pageKey(event: KeyboardEvent) {
|
|
|
|
|
if (event.ctrlKey || event.metaKey || event.altKey || !ready) return;
|
|
|
|
|
if (event.key === "PageDown" || event.key === "PageUp") {
|
|
|
|
|
event.preventDefault();
|
|
|
|
|
go(page + (event.key === "PageDown" ? 1 : -1));
|
|
|
|
|
}
|
|
|
|
|
/** Ctrl and the wheel change the zoom. The wheel alone scrolls the pages. */
|
|
|
|
|
function wheel(event: WheelEvent) {
|
|
|
|
|
if (!(event.ctrlKey || event.metaKey) || !ready || event.deltaY === 0) return;
|
|
|
|
|
event.preventDefault();
|
|
|
|
|
setZoom(event.deltaY < 0 ? zoom * 1.1 : zoom / 1.1);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/** Stop the drawing, release the document, and stop its worker. The host calls it before it removes the tab. */
|
|
|
|
@@ -163,21 +263,23 @@
|
|
|
|
|
|
|
|
|
|
onMount(() => {
|
|
|
|
|
loading = load().catch(fail);
|
|
|
|
|
// A fit-width page follows the width of the tab. The first size draws at once. Later sizes wait until the size settles.
|
|
|
|
|
// Fit-width pages follow the width of the tab. A tab that shows again draws at once. Later sizes wait until the size settles.
|
|
|
|
|
let width = 0;
|
|
|
|
|
let timer: ReturnType<typeof setTimeout> | undefined;
|
|
|
|
|
const resized = () => { applyFit(); restore(); };
|
|
|
|
|
const observer = new ResizeObserver(() => {
|
|
|
|
|
const next = scroller.clientWidth;
|
|
|
|
|
if (next === 0 || next === width) return;
|
|
|
|
|
const first = width === 0;
|
|
|
|
|
if (next === width) return;
|
|
|
|
|
const shown = width === 0;
|
|
|
|
|
width = next;
|
|
|
|
|
clearTimeout(timer);
|
|
|
|
|
if (!fit) return;
|
|
|
|
|
if (first) schedule();
|
|
|
|
|
else timer = setTimeout(schedule, RESIZE_SETTLE_MS);
|
|
|
|
|
if (next === 0) return;
|
|
|
|
|
if (shown) resized();
|
|
|
|
|
else timer = setTimeout(resized, RESIZE_SETTLE_MS);
|
|
|
|
|
});
|
|
|
|
|
observer.observe(scroller);
|
|
|
|
|
return () => { observer.disconnect(); clearTimeout(timer); void close(); };
|
|
|
|
|
scroller.addEventListener("wheel", wheel, { passive: false });
|
|
|
|
|
return () => { observer.disconnect(); clearTimeout(timer); cancelAnimationFrame(frame); scroller.removeEventListener("wheel", wheel); void close(); };
|
|
|
|
|
});
|
|
|
|
|
</script>
|
|
|
|
|
|
|
|
|
@@ -191,10 +293,12 @@
|
|
|
|
|
<IconButton icon="down" label={$t("Next page")} disabled={!ready || page >= count} onclick={() => go(page + 1)} />
|
|
|
|
|
<span class="separator" aria-hidden="true"></span>
|
|
|
|
|
<IconButton icon="zoom-out" label={$t("Zoom out")} disabled={!ready || zoom <= MIN_ZOOM} onclick={() => setZoom(zoom / ZOOM_STEP)} />
|
|
|
|
|
<span class="zoom">{ready ? `${Math.round(zoom * 100)}%` : "—"}</span>
|
|
|
|
|
<input class="zoom" type="text" inputmode="decimal" value={zoomText} disabled={!ready} aria-label={$t("Zoom percent")}
|
|
|
|
|
onfocus={event => event.currentTarget.select()} onchange={event => typedZoom(event.currentTarget)}
|
|
|
|
|
onkeydown={event => { if (event.key === "Enter") typedZoom(event.currentTarget); }} />
|
|
|
|
|
<IconButton icon="zoom-in" label={$t("Zoom in")} disabled={!ready || zoom >= MAX_ZOOM} onclick={() => setZoom(zoom * ZOOM_STEP)} />
|
|
|
|
|
<IconButton icon="fit-width" label={$t("Fit width")} active={fit && ready} disabled={!ready} onclick={() => { fit = true; schedule(); }} />
|
|
|
|
|
<IconButton icon="rotate" label={$t("Rotate clockwise")} disabled={!ready} onclick={() => { rotation = nextRotation(rotation); schedule(); }} />
|
|
|
|
|
<IconButton icon="fit-width" label={$t("Fit width")} active={fit && ready} disabled={!ready} onclick={() => { fit = true; applyFit(); restore(); }} />
|
|
|
|
|
<IconButton icon="rotate" label={$t("Rotate clockwise")} disabled={!ready} onclick={() => { rotation = nextRotation(rotation); applyFit(); restore(); }} />
|
|
|
|
|
<IconButton icon="refresh" label={$t("Reload PDF")} disabled={reloading || (!ready && !failed)} onclick={() => void reload()} />
|
|
|
|
|
</div>
|
|
|
|
|
<p class="status" class:alert={status.alert} role={status.alert ? "alert" : "status"} aria-live={status.alert ? "assertive" : "polite"}>{$t(status.key, status.values)}</p>
|
|
|
|
@@ -204,32 +308,39 @@
|
|
|
|
|
<button class="text-button" type="submit">{$t("Unlock")}</button>
|
|
|
|
|
</form>
|
|
|
|
|
{/if}
|
|
|
|
|
<!-- The page area takes focus for Page Up and Page Down. -->
|
|
|
|
|
<!-- svelte-ignore a11y_no_noninteractive_tabindex, a11y_no_noninteractive_element_interactions -->
|
|
|
|
|
<div bind:this={scroller} class="scroll" tabindex="0" role="region" aria-label={$t("PDF page. Use Page Up and Page Down to change pages.")} onkeydown={pageKey}>
|
|
|
|
|
<div bind:this={sheet} class="sheet"></div>
|
|
|
|
|
<!-- The page area takes focus, so the keyboard scrolls the pages. The host gives it focus after a tab change by keyboard. -->
|
|
|
|
|
<!-- svelte-ignore a11y_no_noninteractive_tabindex -->
|
|
|
|
|
<div bind:this={scroller} class="scroll" tabindex="0" role="region" aria-label={$t("PDF pages")} data-tab-focus onscroll={scrolled}>
|
|
|
|
|
<div class="pages">
|
|
|
|
|
{#each boxes as box, index (index)}
|
|
|
|
|
<div bind:this={sheets[index]} class="sheet" data-page={index + 1} style:width={`${box.width}px`} style:height={`${box.height}px`}></div>
|
|
|
|
|
{/each}
|
|
|
|
|
</div>
|
|
|
|
|
</div>
|
|
|
|
|
</section>
|
|
|
|
|
|
|
|
|
|
<style>
|
|
|
|
|
.pdf-viewer { display: flex; flex-direction: column; height: 100%; min-height: 240px; min-width: 0; color: var(--rs-text); font-size: 13px; }
|
|
|
|
|
.toolbar { display: flex; flex-wrap: wrap; align-items: center; gap: 2px; padding: 4px 8px; border-bottom: 1px solid var(--rs-border); }
|
|
|
|
|
/* The toolbar, the status line, and the password form are opaque, so a background image never hides them. */
|
|
|
|
|
.toolbar { display: flex; flex-wrap: wrap; align-items: center; gap: 2px; padding: 4px 8px; border-bottom: 1px solid var(--rs-border); background: var(--rs-bg-elevated); }
|
|
|
|
|
.page { box-sizing: border-box; width: 64px; height: 28px; margin-left: 4px; padding: 2px 4px; border: 1px solid var(--rs-border); border-radius: var(--rs-control-radius); background: var(--rs-bg); color: var(--rs-text); font: inherit; text-align: right; }
|
|
|
|
|
.page:disabled { color: var(--rs-text-dim); }
|
|
|
|
|
.page:disabled, .zoom:disabled { color: var(--rs-text-dim); }
|
|
|
|
|
.count { margin: 0 4px; color: var(--rs-text-dim); white-space: nowrap; }
|
|
|
|
|
.separator { width: 1px; height: 18px; margin: 0 4px; background: var(--rs-border); }
|
|
|
|
|
.zoom { min-width: 44px; color: var(--rs-text-dim); text-align: center; white-space: nowrap; }
|
|
|
|
|
.status { margin: 0; padding: 4px 12px; font-size: 12px; color: var(--rs-text-dim); overflow-wrap: anywhere; }
|
|
|
|
|
.zoom { box-sizing: border-box; width: 60px; height: 28px; padding: 2px 4px; border: 1px solid var(--rs-border); border-radius: var(--rs-control-radius); background: var(--rs-bg); color: var(--rs-text); font: inherit; text-align: center; }
|
|
|
|
|
.status { margin: 0; padding: 4px 12px; border-bottom: 1px solid var(--rs-border); background: var(--rs-bg-elevated); font-size: 12px; color: var(--rs-text-dim); overflow-wrap: anywhere; }
|
|
|
|
|
.status.alert { color: var(--rs-error); }
|
|
|
|
|
.password { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; padding: 8px 12px; }
|
|
|
|
|
.password { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; padding: 8px 12px; border-bottom: 1px solid var(--rs-border); background: var(--rs-bg-elevated); }
|
|
|
|
|
.password input { box-sizing: border-box; height: 28px; margin-left: 4px; padding: 2px 6px; border: 1px solid var(--rs-border); border-radius: var(--rs-control-radius); background: var(--rs-bg); color: var(--rs-text); font: inherit; }
|
|
|
|
|
.text-button { min-height: 28px; padding: 3px 10px; border: 1px solid var(--rs-border); border-radius: var(--rs-control-radius); background: var(--rs-bg-elevated); color: var(--rs-text); font: inherit; }
|
|
|
|
|
.text-button:hover { background: var(--rs-hover-bg); }
|
|
|
|
|
.scroll { flex: 1; min-height: 0; overflow: auto; padding: 16px; }
|
|
|
|
|
.text-button { min-height: 28px; padding: 3px 10px; border: 1px solid var(--rs-border); border-radius: var(--rs-control-radius); background: var(--rs-bg); color: var(--rs-text); font: inherit; }
|
|
|
|
|
.text-button:hover { background: var(--rs-bg-active); }
|
|
|
|
|
/* The padding and the gap match PAGE_MARGIN and PAGE_GAP in model.ts. */
|
|
|
|
|
.scroll { flex: 1; min-height: 0; overflow: auto; padding: 16px; background: var(--rs-workarea-editor-bg); }
|
|
|
|
|
.scroll:focus-visible { outline-offset: -2px; }
|
|
|
|
|
.pages { display: flex; flex-direction: column; align-items: center; gap: 12px; width: max-content; min-width: 100%; }
|
|
|
|
|
/* A PDF page is paper: white in both themes. */
|
|
|
|
|
.sheet { position: relative; margin: 0 auto; background: white; box-shadow: 0 2px 10px #0003; }
|
|
|
|
|
.sheet :global(canvas) { display: block; }
|
|
|
|
|
.sheet { position: relative; flex: none; background: white; box-shadow: 0 2px 10px #0003; }
|
|
|
|
|
.sheet :global(canvas) { display: block; width: 100%; height: 100%; }
|
|
|
|
|
/* The text layer geometry follows the viewer styles of PDF.js 6 (Apache-2.0). See THIRD_PARTY_NOTICES.md. */
|
|
|
|
|
.sheet :global(.textLayer) { position: absolute; inset: 0; overflow: clip; text-align: initial; line-height: 1; letter-spacing: normal; word-spacing: normal; text-size-adjust: none; forced-color-adjust: none; transform-origin: 0 0; --min-font-size: 1; --text-scale-factor: calc(var(--total-scale-factor) * var(--min-font-size)); --min-font-size-inv: calc(1 / var(--min-font-size)); }
|
|
|
|
|
.sheet :global(.textLayer :is(span, br)) { position: absolute; color: transparent; white-space: pre; cursor: text; transform-origin: 0 0; user-select: text; }
|
|
|
|
|