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 template's figures stay its design, never the next template's date line

Maurice589d3354eb31
diff --git a/shared/src/book/templates/data/new-field-notes.data.ts b/shared/src/book/templates/data/new-field-notes.data.ts
index 8b23297b7..422a53474 100644
--- a/shared/src/book/templates/data/new-field-notes.data.ts
+++ b/shared/src/book/templates/data/new-field-notes.data.ts
@@ -705,7 +705,7 @@ export const NEW_FIELD_NOTES: readonly BookDecoratedTemplate[] = [
opacity: 1,
locked: false,
kind: 'text',
- text: 'N° 01',
+ text: '01',
font: 'mono',
size: 0.0305,
weight: 400,
@@ -953,7 +953,7 @@ export const NEW_FIELD_NOTES: readonly BookDecoratedTemplate[] = [
opacity: 1,
locked: false,
kind: 'text',
- text: 'N° 01',
+ text: '01',
font: 'mono',
size: 0.0305,
weight: 400,
@@ -2667,7 +2667,7 @@ export const NEW_FIELD_NOTES: readonly BookDecoratedTemplate[] = [
locked: false,
group: 'sheet-01',
kind: 'text',
- text: 'N° 01',
+ text: '01',
font: 'mono',
size: 0.0305,
weight: 400,
@@ -2726,7 +2726,7 @@ export const NEW_FIELD_NOTES: readonly BookDecoratedTemplate[] = [
locked: false,
group: 'sheet-02',
kind: 'text',
- text: 'N° 02',
+ text: '02',
font: 'mono',
size: 0.0305,
weight: 400,
@@ -2785,7 +2785,7 @@ export const NEW_FIELD_NOTES: readonly BookDecoratedTemplate[] = [
locked: false,
group: 'sheet-03',
kind: 'text',
- text: 'N° 03',
+ text: '03',
font: 'mono',
size: 0.0305,
weight: 400,
@@ -2844,7 +2844,7 @@ export const NEW_FIELD_NOTES: readonly BookDecoratedTemplate[] = [
locked: false,
group: 'sheet-04',
kind: 'text',
- text: 'N° 04',
+ text: '04',
font: 'mono',
size: 0.0305,
weight: 400,
@@ -2903,7 +2903,7 @@ export const NEW_FIELD_NOTES: readonly BookDecoratedTemplate[] = [
locked: false,
group: 'sheet-05',
kind: 'text',
- text: 'N° 05',
+ text: '05',
font: 'mono',
size: 0.0305,
weight: 400,
@@ -2962,7 +2962,7 @@ export const NEW_FIELD_NOTES: readonly BookDecoratedTemplate[] = [
locked: false,
group: 'sheet-06',
kind: 'text',
- text: 'N° 06',
+ text: '06',
font: 'mono',
size: 0.0305,
weight: 400,
@@ -3021,7 +3021,7 @@ export const NEW_FIELD_NOTES: readonly BookDecoratedTemplate[] = [
locked: false,
group: 'sheet-07',
kind: 'text',
- text: 'N° 07',
+ text: '07',
font: 'mono',
size: 0.0305,
weight: 400,
@@ -3080,7 +3080,7 @@ export const NEW_FIELD_NOTES: readonly BookDecoratedTemplate[] = [
locked: false,
group: 'sheet-08',
kind: 'text',
- text: 'N° 08',
+ text: '08',
font: 'mono',
size: 0.0305,
weight: 400,
diff --git a/shared/src/book/templates/data/new-night-film.data.ts b/shared/src/book/templates/data/new-night-film.data.ts
index 2dd78e5fb..ed039c3cb 100644
--- a/shared/src/book/templates/data/new-night-film.data.ts
+++ b/shared/src/book/templates/data/new-night-film.data.ts
@@ -206,7 +206,7 @@ export const NEW_NIGHT_FILM: readonly BookDecoratedTemplate[] = [
locked: false,
group: 'rec',
kind: 'text',
- text: 'REC',
+ text: '●',
font: 'mono',
size: 0.0333,
weight: 400,
@@ -786,7 +786,7 @@ export const NEW_NIGHT_FILM: readonly BookDecoratedTemplate[] = [
locked: false,
group: 'rec',
kind: 'text',
- text: 'REC',
+ text: '●',
font: 'mono',
size: 0.0333,
weight: 400,
@@ -1103,7 +1103,7 @@ export const NEW_NIGHT_FILM: readonly BookDecoratedTemplate[] = [
locked: false,
group: 'rec',
kind: 'text',
- text: 'REC',
+ text: '●',
font: 'mono',
size: 0.0333,
weight: 400,
@@ -1305,7 +1305,7 @@ export const NEW_NIGHT_FILM: readonly BookDecoratedTemplate[] = [
locked: false,
group: 'rec',
kind: 'text',
- text: 'REC',
+ text: '●',
font: 'mono',
size: 0.0333,
weight: 400,
@@ -1982,7 +1982,7 @@ export const NEW_NIGHT_FILM: readonly BookDecoratedTemplate[] = [
locked: false,
group: 'rec',
kind: 'text',
- text: 'REC',
+ text: '●',
font: 'mono',
size: 0.0333,
weight: 400,
diff --git a/shared/src/book/templates/template-apply.ts b/shared/src/book/templates/template-apply.ts
index c1ddcef72..150e43ee8 100644
--- a/shared/src/book/templates/template-apply.ts
+++ b/shared/src/book/templates/template-apply.ts
@@ -24,7 +24,13 @@ import {
templatePage,
type LaidElement,
} from './template-lay';
-import { assignTemplateTexts, textRolesOf, type BookTemplateWord, type BookTemplateWords } from './template-words';
+import {
+ assignTemplateTexts,
+ isTemplateFigureText,
+ textRolesOf,
+ type BookTemplateWord,
+ type BookTemplateWords,
+} from './template-words';
/**
* Laying a page out on a decorated template.
@@ -146,7 +152,9 @@ function poolOf(spread: BookSpread): Pool {
const all = [...spread.elements.filter((e) => !e.locked), ...spread.parked];
return {
photos: all.filter((e): e is BookPhotoElement => e.kind === 'photo' && e.photoId != null),
- texts: all.filter((e): e is TextEl => e.kind === 'text' && !!e.text.trim() && !isBookOrnamentText(e)),
+ texts: all.filter(
+ (e): e is TextEl => e.kind === 'text' && !!e.text.trim() && !isBookOrnamentText(e) && !isTemplateFigureText(e),
+ ),
map: all.find((e): e is BookMapElement => e.kind === 'map'),
marks: all.filter((e): e is BookBadgeElement => e.kind === 'badge'),
};
diff --git a/shared/src/book/templates/template-words.ts b/shared/src/book/templates/template-words.ts
index b856884f3..0c6b98db9 100644
--- a/shared/src/book/templates/template-words.ts
+++ b/shared/src/book/templates/template-words.ts
@@ -59,6 +59,15 @@ const SPARE_ORDER: readonly BookTemplateTextRole[] = ['subtitle', 'date', 'capti
const DATE_LIKE = /\b(1[89]|20)\d{2}\b|\b\d{1,2}[./]\d{1,2}\b/;
const isText = (e: BookElement | null | undefined): e is TextEl => !!e && e.kind === 'text' && !!e.text.trim();
+
+/**
+ * Figures a template drew as its design (a film's timecode, frame numbers, a
+ * plate's number): no letters and not a date, and bound to nothing. They are
+ * not the page's words, so a template laid next never takes one for a title
+ * or a date line.
+ */
+export const isTemplateFigureText = (e: BookElement): boolean =>
+ e.kind === 'text' && !e.binding && !/\p{L}/u.test(e.text) && !DATE_LIKE.test(e.text);
const isLong = (t: TextEl) => t.text.trim().length > SHORT;
/** The role a short text reads as on its own: a date line when it says a date, else a subtitle. */