Pages now get a crisp 1 screen-px outline instead of a blurred shadow, and the canvas background shows faint world-anchored grid lines that pan and zoom with the pages (spacing steps up ×4 when zoomed out). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
75 lines
2 KiB
Svelte
75 lines
2 KiB
Svelte
<script lang="ts">
|
|
import type { Rect } from '$lib/model/layout';
|
|
import type { Stroke } from '$lib/model/types';
|
|
import type { PageModel } from '$lib/state/doc.svelte';
|
|
import MarkdownEditor from './MarkdownEditor.svelte';
|
|
import PdfBackground from './PdfBackground.svelte';
|
|
import InkLayer from './InkLayer.svelte';
|
|
|
|
interface Props {
|
|
page: PageModel;
|
|
rect: Rect;
|
|
active: boolean;
|
|
invert: boolean;
|
|
scale: number;
|
|
live: Stroke | null;
|
|
tick: number;
|
|
erasing: Set<string>;
|
|
onchange: () => void;
|
|
onactivate: () => void;
|
|
}
|
|
|
|
let { page, rect, active, invert, scale, live, tick, erasing, onchange, onactivate }: Props = $props();
|
|
</script>
|
|
|
|
<div
|
|
class="page"
|
|
class:active
|
|
data-page={page.id}
|
|
style="left:{rect.x}px; top:{rect.y}px; width:{rect.width}px; height:{rect.height}px"
|
|
>
|
|
<div class="paper" class:invert>
|
|
{#if page.origin}
|
|
<PdfBackground origin={page.origin} width={page.width} height={page.height} {scale} />
|
|
{/if}
|
|
<MarkdownEditor {page} {onchange} onfocus={onactivate} />
|
|
<InkLayer width={page.width} height={page.height} strokes={page.strokes} {live} {tick} {erasing} />
|
|
</div>
|
|
{#if page.origin && active}
|
|
<div class="origin" style="font-size:{11 / scale}px; top:{-18 / scale}px">{page.origin.name} · p. {page.origin.pageIndex + 1}</div>
|
|
{/if}
|
|
</div>
|
|
|
|
<style>
|
|
.page {
|
|
position: absolute;
|
|
}
|
|
.paper {
|
|
position: absolute;
|
|
inset: 0;
|
|
background: #ffffff;
|
|
overflow: hidden;
|
|
/* Crisp 1 screen-px outline, no blur. */
|
|
box-shadow: 0 0 0 calc(1px / var(--s)) var(--page-line);
|
|
}
|
|
.paper.invert {
|
|
filter: invert(0.88) hue-rotate(180deg);
|
|
}
|
|
.page.active::after {
|
|
content: '';
|
|
position: absolute;
|
|
/* --s is the zoom, set on the world layer: keep the ring 1.5 screen px. */
|
|
inset: calc(-3px / var(--s));
|
|
border: calc(1.5px / var(--s)) solid var(--accent);
|
|
border-radius: calc(3px / var(--s));
|
|
opacity: 0.55;
|
|
pointer-events: none;
|
|
}
|
|
.origin {
|
|
position: absolute;
|
|
left: 0;
|
|
white-space: nowrap;
|
|
color: var(--faint);
|
|
pointer-events: none;
|
|
}
|
|
</style>
|