diff --git a/src/anatomy/svgConvention.ts b/src/anatomy/svgConvention.ts index 727d7701..53bbcce7 100644 --- a/src/anatomy/svgConvention.ts +++ b/src/anatomy/svgConvention.ts @@ -1,18 +1,17 @@ import { SvgConventionError } from './types' import type { Bone, BoneCategory } from './types' -const VALID_CATEGORIES: readonly BoneCategory[] = [ - 'articulations', - 'charni-res-vert-brales', - 'zone-colonne', - 'cadrans-du-cr-ne', - 'os', -] - -export function isValidCategory(value: string): value is BoneCategory { - return (VALID_CATEGORIES as readonly string[]).includes(value) -} - +/** + * Validates that an annotated SVG element carries the two attributes the + * application needs to wire it up: a stable id (`data-anno-id`) and a + * category bucket (`data-anno-category`). Labels (`data-anno-name-fr/en`) + * and the popup trigger (`data-anno-opens-detail`) are optional and + * checked only at use-site. + * + * The category value itself is opaque to the application — any non-empty + * string is accepted. New SVGs are free to introduce new categories + * without touching this parser. + */ export function validateBoneElement(el: Element): void { const boneId = el.getAttribute('data-anno-id') ?? '' if (!boneId) { @@ -30,26 +29,17 @@ export function validateBoneElement(el: Element): void { 'data-anno-category', ) } - if (!isValidCategory(cat)) { - throw new SvgConventionError( - `Element data-anno-id="${boneId}" has unknown data-anno-category="${cat}"`, - boneId, - 'data-anno-category', - ) - } } /** * Parses an SVG document and returns a map of `data-anno-id` → Bone. * * Every element carrying `data-anno-id` is collected. Multiple elements - * may share the same id (hitbox + visible pattern, or layered shapes); - * they end up grouped under the same Bone with all elements in `els`. + * may share the same id (e.g. hitbox + visible layer); they all end up + * grouped under the same Bone with all elements in `els`. * - * Throws `SvgConventionError` if any required attribute is missing or - * `data-anno-category` is unknown. `data-anno-name-fr/en` are optional — - * trigger-only zones (those carrying `data-anno-opens-detail`) typically - * skip them. + * Throws `SvgConventionError` only on the two required attributes + * (`data-anno-id`, `data-anno-category`). Labels are optional. */ export function parseSvgBones(svgRoot: SVGSVGElement): Map { const map = new Map() @@ -69,7 +59,6 @@ export function parseSvgBones(svgRoot: SVGSVGElement): Map { if (opensDetail && !existing.opensDetail) { existing.opensDetail = opensDetail } - // Prefer the first non-empty label we see. if (!existing.fr && fr) existing.fr = fr if (!existing.en && en) existing.en = en } else { diff --git a/src/anatomy/types.ts b/src/anatomy/types.ts index e43c30fb..c1257939 100644 --- a/src/anatomy/types.ts +++ b/src/anatomy/types.ts @@ -1,16 +1,12 @@ /** - * Valid data-anno-category values per the SVG convention. + * `data-anno-category` is a free-form string supplied by the SVG. * - * Categories are scoped to the kind of anatomical structure each - * annotation represents. Adding a new value here is the only place to - * touch when the source SVGs introduce one. + * The application never branches on category values — it treats every + * annotation the same way. Categories are kept around because they're + * useful for grouping and future filtering, but no code path here may + * rely on a closed set. */ -export type BoneCategory = - | 'articulations' - | 'charni-res-vert-brales' - | 'zone-colonne' - | 'cadrans-du-cr-ne' - | 'os' +export type BoneCategory = string /** * Logical annotation as parsed from an SVG. All DOM elements sharing the @@ -24,6 +20,7 @@ export interface Bone { fr: string /** English label from data-anno-name-en — may be empty */ en: string + /** Raw value from data-anno-category — opaque to the application */ category: BoneCategory /** Detail popup id from data-anno-opens-detail, if present */ opensDetail?: string diff --git a/src/app/routes/EditorRoute.tsx b/src/app/routes/EditorRoute.tsx index 76d0f51f..271f74f4 100644 --- a/src/app/routes/EditorRoute.tsx +++ b/src/app/routes/EditorRoute.tsx @@ -118,10 +118,6 @@ export default function EditorRoute() { ) : [...activeObs.zones, newZone] updateObservation(activeIndex, { ...activeObs, zones: nextZones }) - - if (!exists && bone.category === 'zone-colonne') { - setVertebraTarget(nextZones.length - 1) - } } async function onExport() { diff --git a/src/components/observation/ObservationCard.tsx b/src/components/observation/ObservationCard.tsx index b9ebc3c7..20b05c0d 100644 --- a/src/components/observation/ObservationCard.tsx +++ b/src/components/observation/ObservationCard.tsx @@ -187,20 +187,18 @@ export default function ObservationCard({
    {observation.zones.map((z, i) => { const b = bones.get(z.boneId) - const isSpine = b?.category === 'zone-colonne' return (
  • {describeZone(z, bones)} - {isSpine && ( - - )} +