Files
co-lite/openspec/changes/add-html-image-upload/tasks.md
T

35 lines
2.3 KiB
Markdown

# Tasks
## 1. Portal
- [x] 1.1 HTML block panel: an "Upload image" file picker (`image/png,image/jpeg,image/webp`) uploads at once through `uploadPageImage(companyId, base64)`.
- Each success adds a row: preview, a read-only link `/api/public/page-images/<id>`, and a "Copy link" button that uses the clipboard.
- A refusal shows the translated server reason under the picker.
- With no company, the panel shows "Choose a company." and does not upload.
- The block's HTML is never changed.
Verify: editor tests (success row and copy, refusal, no company, HTML unchanged) fail first, then pass; vitest exit 0; tsc; lint.
- [x] 1.2 Add the labels (`PagesUploadImage`, `PagesUploadImageHint`; the copy button reuses the page-address copy button) to `defaultMessages.ts`, `zh_CN.seed.json` and `sql/01-html-image-labels.sql`, and regenerate `local/seed/04-zh-cn-messages.sql`.
## 2. Verification
- [x] 2.1 Use Playwright on port 3001, signing in through the form and opening Hotel technology from Pages.
- In a Custom HTML block, upload an image, copy the link, and check that the panel shows the preview and the link.
- Upload a file that is not an image and see the refusal.
- Do not change the published page.
- [x] 2.2 Run the full portal vitest (exit 0), tsc, lint, and `openspec validate add-html-image-upload --strict`. Add a release note to `docs/deployment.md` (label SQL).
## Notes (2026-12-04)
- **Red first:** the success, refusal and no-company editor tests all failed, because there was no "Upload image" picker yet. They pass now.
- **Live check** (port 3001): signed in through the form, then opened Hotel technology from Pages.
- In block 3 (Custom HTML), uploaded `hero-bg.webp`. The panel showed the preview and `/api/public/page-images/7` with a copy button.
- A text file named `.png` was refused with "Use a PNG, JPEG or WebP image."
- The page was not saved or published.
- **Fix from the live check:** the link was shown twice (a read-only box and the copy button's text). It now shows once, beside its copy button, which reuses the page-address copy button with a `relative` option.
- **Results:** vitest 1997 passed (exit 0); tsc clean; lint 0 errors (the 4 warnings were already there).
## Workflow follow-up
- Open a PR to `main` and merge it. Archive the change on its own branch, with its own PR.