From a32465ad32d9a63c7622aec5fc4198efb1fe643b Mon Sep 17 00:00:00 2001 From: Maurice Date: Fri, 23 Oct 2026 23:05:48 +0200 Subject: [PATCH] fix(studio): a line keeps its own colour when a theme is applied, adopted or described --- shared/src/book/design/design-theme.ts | 2 ++ shared/src/book/theme/book-theme-adopt.ts | 4 ++++ shared/src/book/theme/book-theme-apply.ts | 2 ++ shared/src/book/theme/book-theme-describe.ts | 2 +- 4 files changed, 9 insertions(+), 1 deletion(-) diff --git a/shared/src/book/design/design-theme.ts b/shared/src/book/design/design-theme.ts index 5398bbc56..31f3e525d 100644 --- a/shared/src/book/design/design-theme.ts +++ b/shared/src/book/design/design-theme.ts @@ -111,6 +111,8 @@ function linkToLook(el: BookElement, spread: BookSpread, look: BookDesignLook): switch (el.kind) { case 'photo': case 'sticker': + // A line keeps the colour it was drawn in (book-line.schema.ts has no theme link). + case 'line': return el; case 'text': { const token = lookToken(el.color, look, true); diff --git a/shared/src/book/theme/book-theme-adopt.ts b/shared/src/book/theme/book-theme-adopt.ts index 2bec6450c..8ed36230a 100644 --- a/shared/src/book/theme/book-theme-adopt.ts +++ b/shared/src/book/theme/book-theme-adopt.ts @@ -61,6 +61,8 @@ function chromaticInks(el: BookElement): string[] { switch (el.kind) { case 'photo': case 'sticker': + // A line keeps the colour it was drawn in (book-line.schema.ts has no theme link). + case 'line': return []; case 'text': case 'icon': @@ -157,6 +159,8 @@ function adoptElement( // A sticker keeps the colours of its slots: they are a drawing, not the page's inks. case 'photo': case 'sticker': + // A line keeps the colour it was drawn in (book-line.schema.ts has no theme link). + case 'line': return el; case 'text': { const token = el.token ?? inkToken(el.color, ground, map, prev, el.size <= 9); diff --git a/shared/src/book/theme/book-theme-apply.ts b/shared/src/book/theme/book-theme-apply.ts index 727eac6f4..fde3d7447 100644 --- a/shared/src/book/theme/book-theme-apply.ts +++ b/shared/src/book/theme/book-theme-apply.ts @@ -66,6 +66,8 @@ export function themedElement(el: E, theme: BookTheme): E switch (el.kind) { case 'photo': case 'sticker': + // A line keeps the colour it was drawn in (book-line.schema.ts has no theme link). + case 'line': return el; case 'text': { tokenColour(next, theme, 'color', el.token); diff --git a/shared/src/book/theme/book-theme-describe.ts b/shared/src/book/theme/book-theme-describe.ts index 406582d2a..5f81e4c4b 100644 --- a/shared/src/book/theme/book-theme-describe.ts +++ b/shared/src/book/theme/book-theme-describe.ts @@ -23,7 +23,7 @@ export function bookThemeLine(theme: BookTheme | undefined): string { /** What an element follows of the theme, as words for its line ('' when nothing). */ export function themeLinkWords(el: BookElement): string { - if (el.kind === 'photo' || el.kind === 'sticker') return ''; + if (el.kind === 'photo' || el.kind === 'sticker' || el.kind === 'line') return ''; const parts: string[] = []; if (el.token) parts.push(`${el.kind === 'shape' ? 'fill' : 'colour'} ${el.token}`); if (el.kind === 'shape' && el.strokeToken) parts.push(`stroke ${el.strokeToken}`);