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 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01VsorPV3JeJRoZ1mD1pdvtL
This commit is contained in:
parent
0ad405c26e
commit
fa2f491161
2 changed files with 4 additions and 4 deletions
|
|
@ -15,7 +15,7 @@
|
||||||
import { dirName, displayName } from '$lib/storage/vault.svelte';
|
import { dirName, displayName } from '$lib/storage/vault.svelte';
|
||||||
import { bounds, intersects, rectBeside, type Rect } from '$lib/model/layout';
|
import { bounds, intersects, rectBeside, type Rect } from '$lib/model/layout';
|
||||||
import { canInsert, freeSlots, freeSlotsOf, neighbor, type Dir, type Slot } from '$lib/model/tree';
|
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 { PalmRejector } from '$lib/ink/palm';
|
||||||
import { StrokeRecorder, hitStroke } from '$lib/ink/stroke';
|
import { StrokeRecorder, hitStroke } from '$lib/ink/stroke';
|
||||||
import { pageCssVars } from '$lib/editor/pageStyle';
|
import { pageCssVars } from '$lib/editor/pageStyle';
|
||||||
|
|
@ -107,7 +107,7 @@
|
||||||
const a = doc.rectOf(slot.anchor);
|
const a = doc.rectOf(slot.anchor);
|
||||||
if (!a) return null;
|
if (!a) return null;
|
||||||
const page = doc.pages[slot.anchor];
|
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);
|
return rectBeside(a, slot.dir, s);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -161,8 +161,8 @@ export class CanvasDoc {
|
||||||
|
|
||||||
addBlankPage(anchor: string, dir: Dir): string | null {
|
addBlankPage(anchor: string, dir: Dir): string | null {
|
||||||
const a = this.pages[anchor];
|
const a = this.pages[anchor];
|
||||||
// New pages default to A4, oriented like their neighbour when it's a plain page.
|
// New pages inherit the size of the page they grow from (A4 if it's missing).
|
||||||
const size = a && !a.origin && a.width > a.height ? { width: A4.height, height: A4.width } : A4;
|
const size = a ? { width: a.width, height: a.height } : A4;
|
||||||
const id = newId();
|
const id = newId();
|
||||||
return this.insertPages(anchor, dir, [{ id, ...size, markdown: '', strokes: [] }]) ? id : null;
|
return this.insertPages(anchor, dir, [{ id, ...size, markdown: '', strokes: [] }]) ? id : null;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue