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

This commit is contained in:
Maurice
2026-10-23 23:05:48 +02:00
parent 01abb90797
commit a32465ad32
4 changed files with 9 additions and 1 deletions
+2
View File
@@ -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);
@@ -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);
@@ -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);
+1 -1
View File
@@ -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}`);