From ce29457d8bc247ced21169961092baf891867665 Mon Sep 17 00:00:00 2001 From: Bastien Chanot Date: Fri, 22 May 2026 02:14:10 +0200 Subject: [PATCH] chore(memory): capitalize SVG editor integration BDR-017 (vanilla JS wrap decision), LRN-023 (DOMParser SVG loading), journal entry for 2026-05-22 session. Co-Authored-By: Claude Opus 4.6 (1M context) --- .claude/memory/decisions.md | 8 ++++++++ .claude/memory/journal.md | 8 ++++++++ .claude/memory/learnings.md | 7 +++++++ 3 files changed, 23 insertions(+) diff --git a/.claude/memory/decisions.md b/.claude/memory/decisions.md index b157dceb..ce4c8749 100644 --- a/.claude/memory/decisions.md +++ b/.claude/memory/decisions.md @@ -135,3 +135,11 @@ Catalog bumped v1.2→v2.0. `requires_vet_referral: true` boolean = sole source **How to apply:** Any new species JSON authored at v2.0 — boolean on vet leaves only, description_fr only when it adds clinical differential beyond "see vet". Consumers MUST use boolean check, never textual scan. Alt rejected: keep dual signal — wastes maintainer attention, drift risk between text and boolean. Status: closed. + +--- + +## BDR-017 | 2026-05-22 | SVG editor: vanilla JS wrap over React rewrite + +editor.html = ~1630-line standalone SVG annotation tool (DOM manipulation, drag/drop, polygon editing, zoom, categories, export). Integrated into React app via `useRef` + `useEffect` mounting all vanilla JS logic into container refs. Only CSS restyled to Zoosteo tokens. +Alt rejected: full React rewrite (convert all state to Zustand/useState, all DOM ops to React) — massive effort ~10x, high risk of subtle behavior differences in drag/polygon/zoom interactions. +Status: closed. diff --git a/.claude/memory/journal.md b/.claude/memory/journal.md index 154f2f88..8bb95c88 100644 --- a/.claude/memory/journal.md +++ b/.claude/memory/journal.md @@ -87,6 +87,14 @@ User dropped catalog v1.2→v2.0 in place. pathologies.json now schema_version " --- +## 2026-05-22 + +Integrated standalone editor.html (~1630 lines vanilla JS SVG annotation tool) into React app at /svg-editor route. Vanilla JS wrapped in useRef+useEffect — zero behavior loss. CSS restyled to Zoosteo tokens (warm palette, accent vars, serif headings). DOMParser used for safe SVG loading (no innerHTML). Page noindexed via dynamic meta tag. 3 files created (SvgEditorRoute.tsx, svg-editor.css), 1 modified (App.tsx route registration), CLAUDE.md folder structure updated. +- 155/155 tests green, typecheck clean, build OK (941KB main). No regressions. +- BDR-017 (vanilla wrap decision), LRN-022 (DOMParser SVG loading) captured. + +--- + ## 2026-05-20 (session 2) Iterated on the findings-tree branch — 11 more commits on top of B0+B1+B2. diff --git a/.claude/memory/learnings.md b/.claude/memory/learnings.md index ac592f51..c5e06c4c 100644 --- a/.claude/memory/learnings.md +++ b/.claude/memory/learnings.md @@ -174,6 +174,13 @@ Apply: any data contract sourced from non-engineering authors (clinical, legal, --- +## LRN-023 | 2026-05-22 | DOMParser for safe SVG loading in React-wrapped vanilla editors + +When wrapping vanilla JS editor in React, avoid `innerHTML = svgText` for user-uploaded SVG. Use `new DOMParser().parseFromString(svgText, 'image/svg+xml')` + `document.importNode(parsedSvg, true)` to safely parse and import SVG into DOM. Parser rejects malformed XML, returns parseerror element on failure — gives clean error path. importNode deep-clones into current document context so all DOM APIs (createSVGPoint, getScreenCTM) work correctly. +Apply: any user-uploaded SVG injection into a React-hosted vanilla canvas. Also avoids security hook warnings about innerHTML with untrusted content. + +--- + ## LRN-022 | 2026-05-21 | pnpm 11.x requires Node 22.13 — pin pnpm to ≤10.x when staying on Node 20, never use `@latest` pnpm 11.x imports `node:sqlite` for its store-index module — loaded at pnpm startup for any command that touches the store (install, fetch, add, prune). `node:sqlite` is a Node 22.13+ built-in. Result: `ERR_UNKNOWN_BUILTIN_MODULE: node:sqlite` on every fresh Docker build using `node:20-alpine` + pnpm 11.x. The crash is deterministic for cold installs and invisible for warm dev hosts that already have `node_modules` resolved (pnpm 11 on Node 20 can still spawn child scripts because the store module isn't required for `pnpm run`).