Skip to content

armgit / TREK

Public Imported from GitHub
0

The most complete open-source travel planner: real-time collaboration, bookings, budgets, packing lists, journals, offline PWA, SSO and an AI-ready MCP server, with planet-wide place search and routing built in.

fix(studio): a line keeps its own colour when a theme is applied, adopted or described

Mauricea32465ad32d9
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<E extends BookElement>(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}`);