feat(anatomy): parse data-anno-lateral attribute from SVG
Read data-anno-lateral from annotated SVG elements and expose it as
Bone.lateral ('bilateral' | 'unpaired' | undefined). Follows the same
merge logic used for data-anno-special.
Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
1 parent
2d5ff54b69
commit
db50c67bb6
3 files changed
+22
No files matched your search
@@ -53,6 +53,10 @@ export function parseSvgBones(svgRoot: SVGSVGElement): Map<string, Bone> {
|
||||
const opensDetail =
|
||||
el.getAttribute('data-anno-opens-detail') ?? undefined
|
||||
const special = el.getAttribute('data-anno-special') ?? undefined
|
||||
const lateral = (el.getAttribute('data-anno-lateral') ?? undefined) as
|
||||
| 'bilateral'
|
||||
| 'unpaired'
|
||||
| undefined
|
||||
|
||||
const existing = map.get(id)
|
||||
if (existing) {
|
||||
@@ -63,6 +67,9 @@ export function parseSvgBones(svgRoot: SVGSVGElement): Map<string, Bone> {
|
||||
if (special && !existing.special) {
|
||||
existing.special = special
|
||||
}
|
||||
if (lateral && !existing.lateral) {
|
||||
existing.lateral = lateral
|
||||
}
|
||||
if (!existing.fr && fr) existing.fr = fr
|
||||
if (!existing.en && en) existing.en = en
|
||||
} else {
|
||||
@@ -73,6 +80,7 @@ export function parseSvgBones(svgRoot: SVGSVGElement): Map<string, Bone> {
|
||||
category,
|
||||
opensDetail,
|
||||
special,
|
||||
lateral,
|
||||
els: [el],
|
||||
})
|
||||
}
|
||||
|
||||
@@ -33,6 +33,8 @@ export interface Bone {
|
||||
* Opaque to the parser; new values are accepted without code changes.
|
||||
*/
|
||||
special?: string
|
||||
/** Laterality hint from data-anno-lateral — bilateral or unpaired */
|
||||
lateral?: 'bilateral' | 'unpaired'
|
||||
/** All DOM elements carrying this annotation (used for colorization) */
|
||||
els: Element[]
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user