fix: editor

This commit is contained in:
2026-04-22 20:20:09 +07:00
parent c828bf7767
commit 994a13da52
8 changed files with 286 additions and 127 deletions
+5 -6
View File
@@ -124,11 +124,10 @@ The editor adjusts the **scale and rotation** of asteroid images in each section
### Data flow
- Editor reads `.template.html` (via EditorCore)
- On load, fetches `.data.json` and applies transforms to DOM (`img.style.transform`)
- On Save, reads transforms FROM DOM → sync XHR POST → server writes `.data.json`
- Editor reads `.template.html` (via EditorCore) and `.data.json` (via `onDataLoaded`)
- On load, applies saved transforms to DOM (`img.style.transform`)
- Original transforms stored in Map for change detection and reset
- On Save, serializes transforms from DOM → async POST via EditorCore → server writes `.data.json`
- `generate.mjs` reads `.data.json`, applies `style="transform: ..."` to img elements in `.output.html`
### Status: BROKEN
The editor has a reliability problem with the save cycle. The server's save endpoint runs `generate.mjs` asynchronously after writing `data.json`. `generate.mjs` writes `.output.html`, which triggers browser-sync live-reload. The reload can interfere with the save flow, causing data loss or incomplete saves. This needs to be investigated and fixed before the editor can be used reliably.
This editor serves as the **reference implementation** for building new task-type editors (see root CLAUDE.md "Building a New Editor").