refactor(anatomy): adapt parser to new SVG convention (categories + single-element)
User dropped new Horse.svg / Horse_head.svg that follow a simpler
convention:
- Categories renamed to longer human strings:
articulation → articulations
charniere → charni-res-vert-brales
spine-zone → zone-colonne
cadran-crane → cadrans-du-cr-ne
head, os-overlay → dropped (head zone is now category="os" + data-anno-opens-detail)
os → unchanged
- No more hitbox / visible class split; multiple elements may still share
the same data-anno-id but they all carry the same role.
- Trigger-only zones (`data-anno-opens-detail="head"`) may omit
`data-anno-name-fr/en`.
Changes:
- `Bone` now exposes a single `els: Element[]` instead of `hitboxEls +
visibleEls`.
- `parseSvgBones` accepts annotations without fr/en labels (defaults to
empty string) but still rejects unknown or missing categories.
- The "interactive vs decorative" filter is gone — every parsed
annotation is interactive, since the new SVGs only annotate the
clickable zones.
- Vertebra-picker trigger: `bone.category === 'zone-colonne'`
(EditorRoute + ObservationCard).
- PDF colorisation in `observationPage.colorizedSvgString` writes the
accent fill to every `els[]` entry (no more hitbox dual-pass).
- Dead `src/components/observation/ObservationEditor.tsx` removed (its
body lives inside ObservationCard since the accordion refactor).
- Tests rewritten for the new vocabulary; synthetic fixture uses the new
categories, real-SVG test asserts 18 + 9 unique zones.
92/92 tests pass, lint clean, build clean.
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
1 parent
1109e33383
commit
cad94a49db
10 files changed
+325
-428
No files matched your search
+21
-14
@@ -1,27 +1,34 @@
|
||||
/** Valid data-anno-category values per the SVG convention. */
|
||||
/**
|
||||
* Valid data-anno-category values per the SVG convention.
|
||||
*
|
||||
* 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.
|
||||
*/
|
||||
export type BoneCategory =
|
||||
| 'articulation'
|
||||
| 'charniere'
|
||||
| 'spine-zone'
|
||||
| 'articulations'
|
||||
| 'charni-res-vert-brales'
|
||||
| 'zone-colonne'
|
||||
| 'cadrans-du-cr-ne'
|
||||
| 'os'
|
||||
| 'os-overlay'
|
||||
| 'head'
|
||||
| 'cadran-crane'
|
||||
|
||||
/** A logical bone as parsed from an SVG — groups hitbox + visible elements. */
|
||||
/**
|
||||
* 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 */
|
||||
/** French label from data-anno-name-fr — may be empty for opens-detail-only triggers */
|
||||
fr: string
|
||||
/** English label from data-anno-name-en */
|
||||
/** English label from data-anno-name-en — may be empty */
|
||||
en: string
|
||||
category: BoneCategory
|
||||
/** Detail popup id from data-anno-opens-detail, if present */
|
||||
opensDetail?: string
|
||||
/** Elements with class containing "hitbox" */
|
||||
hitboxEls: Element[]
|
||||
/** Elements with class containing "visible" */
|
||||
visibleEls: Element[]
|
||||
/** All DOM elements carrying this annotation (used for colorization) */
|
||||
els: Element[]
|
||||
}
|
||||
|
||||
/** Visual state applied to SVG elements for multi-observation colorization. */
|
||||
|
||||
Reference in new issue
Block a user