9 Commits

Author SHA1 Message Date
Kunthawat Greethong
0f8d815d3f Fix Media Library: use data.data.items || data.items
The media list API returns { data: { items: [...] } } wrapped format.
Previously only checked data.items which would be undefined.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-05-04 14:05:45 +07:00
Kunthawat Greethong
4ea7016f2c Add comprehensive logging to handleImageUpload + fix saveField re-throw
Logging added at every step:
- handleImageUpload entry
- dimPromise resolution
- thumbPromise resolution
- Upload response status + ok flag + url
- r.json() resolution
- selectMediaItem call

Also: saveField now re-throws after logging so callers know save failed.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-05-04 13:21:58 +07:00
Kunthawat Greethong
65c876393c Fix: use data.data.item instead of data.item for upload response
EmDash API wraps success responses as { data: { item: ... } },
not { item: ... }. This was causing "Upload failed: no item returned"
even when the upload actually succeeded.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-05-04 11:58:35 +07:00
Kunthawat Greethong
8a6e268606 Use r.text() instead of r.json() for error responses in handleImageUpload
The error path was throwing at r.json() parsing — r.text() lets us log
the actual raw response before trying to parse it as JSON.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-05-04 11:21:02 +07:00
Kunthawat Greethong
881657c59a Add upload response status logging to handleImageUpload
Help diagnose why uploads succeed but show "Upload failed" error.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-05-04 11:04:04 +07:00
Kunthawat Greethong
73cce1b593 Add debug logging to media browser fetch
Log response status, raw data, and item count to diagnose
why uploaded images don't appear in media browser grid.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-05-04 09:51:08 +07:00
Kunthawat Greethong
2d77509f76 Fix saveField to properly reject on failure
Previously when the content API returned a non-ok response,
saveField would set error state but still resolve the promise.
This caused downstream code to think save succeeded when it failed.

Now properly extracts error message from response and throws.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-05-04 09:35:57 +07:00
2d1be52177 Emdash source with visual editor image upload fix
Fixes:
1. media.ts: wrap placeholder generation in try-catch
2. toolbar.ts: check r.ok, display error message in popover
2026-05-03 10:44:54 +07:00
78f81bebb6 Initial empty repo 2026-05-03 10:41:11 +07:00