From fa2f49116194a984f3a5ec5b5c7e48fe1849fedf Mon Sep 17 00:00:00 2001 From: besbara Date: Sat, 26 Sep 2026 19:55:24 +0000 Subject: [PATCH] New pages inherit the size of the page they are created from Blank pages added next to an existing page (via the "+" tile, Alt+Arrow or the page menu) now copy that page's width and height, including imported PDF pages, instead of always falling back to A4. The "+" preview tile uses the same size so it matches the page it will create. Co-Authored-By: Claude Opus 5.5 Claude-Session: https://claude.ai/code/session_01VsorPV3JeJRoZ1mD1pdvtL --- src/lib/components/CanvasView.svelte | 4 ++-- src/lib/state/doc.svelte.ts | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/lib/components/CanvasView.svelte b/src/lib/components/CanvasView.svelte index 35ad5a6..ad72c68 100644 --- a/src/lib/components/CanvasView.svelte +++ b/src/lib/components/CanvasView.svelte @@ -15,7 +15,7 @@ import { dirName, displayName } from '$lib/storage/vault.svelte'; import { bounds, intersects, rectBeside, type Rect } from '$lib/model/layout'; import { canInsert, freeSlots, freeSlotsOf, neighbor, type Dir, type Slot } from '$lib/model/tree'; - import { PAGE_PRESETS, type Stroke } from '$lib/model/types'; + import { A4, PAGE_PRESETS, type Stroke } from '$lib/model/types'; import { PalmRejector } from '$lib/ink/palm'; import { StrokeRecorder, hitStroke } from '$lib/ink/stroke'; import { pageCssVars } from '$lib/editor/pageStyle'; @@ -107,7 +107,7 @@ const a = doc.rectOf(slot.anchor); if (!a) return null; const page = doc.pages[slot.anchor]; - const s = size ?? (page && !page.origin ? { width: page.width, height: page.height } : { width: 595.28, height: 841.89 }); + const s = size ?? (page ? { width: page.width, height: page.height } : A4); return rectBeside(a, slot.dir, s); } diff --git a/src/lib/state/doc.svelte.ts b/src/lib/state/doc.svelte.ts index 53900df..4780fa2 100644 --- a/src/lib/state/doc.svelte.ts +++ b/src/lib/state/doc.svelte.ts @@ -161,8 +161,8 @@ export class CanvasDoc { addBlankPage(anchor: string, dir: Dir): string | null { const a = this.pages[anchor]; - // New pages default to A4, oriented like their neighbour when it's a plain page. - const size = a && !a.origin && a.width > a.height ? { width: A4.height, height: A4.width } : A4; + // New pages inherit the size of the page they grow from (A4 if it's missing). + const size = a ? { width: a.width, height: a.height } : A4; const id = newId(); return this.insertPages(anchor, dir, [{ id, ...size, markdown: '', strokes: [] }]) ? id : null; }