Files
faunosteo/src/anatomy/types.ts
T
Bastien ChanotandClaude b9da4fa04a fix(anatomy,editor): detail-popup clicks + spine zones open VertebraPicker via data-anno-special
Three coupled bugs in zone interaction:
1. Clicks inside the head detail popup were ignored — EditorRoute
   looked up the clicked id in the main-SVG bones map only, so
   detail-only ids (point-mpbykomv et al.) returned undefined.
2. Spine zones did not open VertebraPicker on click; the picker was
   only reachable via the per-zone "Vertèbres…" button.
3. The new SVG hint data-anno-special="vertebral-precision" was
   present in Horse.svg but unread by the parser/UI.

Parser now reads data-anno-special into Bone.special. EditorRoute
parses the detail SVG on open and falls back to detailBones for id
lookups. When bone.special === 'vertebral-precision', clicking adds
the zone (if absent) and opens VertebraPicker for that zone index;
toggle-off via main click is disabled for these zones (use ✕). The
"Vertèbres…" button in ObservationCard is now shown only on zones
that support it. Convention doc updated.

Co-Authored-By: Claude <noreply@anthropic.com>
2026-05-19 04:58:04 +02:00

54 lines
1.8 KiB
TypeScript

/**
* `data-anno-category` is a free-form string supplied by the SVG.
*
* 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 = string
/**
* Logical annotation as parsed from an SVG. All DOM elements sharing the
* same `data-anno-id` are grouped into one Bone. `id` is the persisted
* identifier surfaced in the report JSON contract
* (`ObservationZone.boneId`); keep it stable across SVG renames.
*/
export interface Bone {
id: string
/** French label from data-anno-name-fr — may be empty for opens-detail-only triggers */
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
/**
* Free-form behavior hint from `data-anno-special`.
*
* Known values consumed by the application:
* - `vertebral-precision`: clicking the zone opens VertebraPicker.
*
* Opaque to the parser; new values are accepted without code changes.
*/
special?: string
/** All DOM elements carrying this annotation (used for colorization) */
els: Element[]
}
/** Visual state applied to SVG elements for multi-observation colorization. */
export type BoneState = 'current' | 'linked' | 'multi' | 'default'
/** Error thrown when SVG violates the convention. */
export class SvgConventionError extends Error {
constructor(
message: string,
public readonly boneId: string,
public readonly missingAttribute: string,
) {
super(message)
this.name = 'SvgConventionError'
}
}