From 1136046fc269935457a1eef450165176baf919f9 Mon Sep 17 00:00:00 2001 From: ngqile Date: Fri, 4 Dec 2026 10:10:15 +0800 Subject: [PATCH] feat(pages): upload an image from a Custom HTML block and copy its link Co-Authored-By: Claude Opus 5.5 Claude-Session: https://claude.ai/code/session_01EFUzfiCVCgCVJZq4NDEqZs --- docs/deployment.md | 2 + local/seed/04-zh-cn-messages.sql | 4 ++ .../add-html-image-upload/.openspec.yaml | 2 + .../changes/add-html-image-upload/proposal.md | 44 +++++++++++++++++++ .../specs/landing-pages/spec.md | 23 ++++++++++ .../sql/01-html-image-labels.sql | 7 +++ .../changes/add-html-image-upload/tasks.md | 34 ++++++++++++++ .../app/components/pages/BlockFields.tsx | 41 ++++++++++++++++- .../app/components/pages/CopyAddress.tsx | 6 +-- .../components/pages/PageEditor.html.test.tsx | 38 ++++++++++++++++ .../app/components/pages/PageEditor.tsx | 1 + .../app/components/pages/usePageDraft.ts | 16 ++++++- .../components/pages/visual/VisualEditor.tsx | 1 + .../app/lib/i18n/defaultMessages.ts | 2 + .../app/lib/i18n/zh_CN.seed.json | 2 + 15 files changed, 218 insertions(+), 5 deletions(-) create mode 100644 openspec/changes/add-html-image-upload/.openspec.yaml create mode 100644 openspec/changes/add-html-image-upload/proposal.md create mode 100644 openspec/changes/add-html-image-upload/specs/landing-pages/spec.md create mode 100644 openspec/changes/add-html-image-upload/sql/01-html-image-labels.sql create mode 100644 openspec/changes/add-html-image-upload/tasks.md diff --git a/docs/deployment.md b/docs/deployment.md index 7a34c06..12175b1 100644 --- a/docs/deployment.md +++ b/docs/deployment.md @@ -468,4 +468,6 @@ A form stops taking sign-ups when its event is disabled, its end date has passed **Release add-hero-full-width (SQL, in its OpenSpec change folder):** deploy services-counter, then the portal, then run `sql/01-hero-full-width-labels.sql` (labels only). Deploy services-counter first, because the portal's editor saves the new hero fields. A hero can now run full width, carry bullet points, and give its form card a heading. Custom HTML frames now shrink to fit short content and no longer leave a gap next to a full-width hero. Rollback: the previous images. Saved heroes keep the new fields in their JSON; the old code ignores them and shows the boxed hero. The old services-counter refuses to save a hero that has points or a form heading, so remove them before saving such a page. +**Release add-html-image-upload (SQL, in its OpenSpec change folder):** deploy the portal, then run `sql/01-html-image-labels.sql` (labels only). A Custom HTML block's panel can now upload an image and show its link to copy. Rollback: the previous portal image. + **New portal dependencies:** `@tiptap/react`, `@tiptap/pm`, `@tiptap/starter-kit` and `@tiptap/extension-text-align` (the editor, loaded only on the editor screens), and `sanitize-html` (cleans page text on the server before it reaches a visitor). The image build installs them from `package-lock.json`; nothing to do by hand. diff --git a/local/seed/04-zh-cn-messages.sql b/local/seed/04-zh-cn-messages.sql index b829b3c..6cb393c 100644 --- a/local/seed/04-zh-cn-messages.sql +++ b/local/seed/04-zh-cn-messages.sql @@ -1727,6 +1727,10 @@ INSERT INTO message (code, content, area) SELECT 'PagesFormHeading', JSON_OBJECT UPDATE message SET content = JSON_SET(COALESCE(content, JSON_OBJECT()), '$.zh_CN', '表单标题') WHERE LOWER(code) = LOWER('PagesFormHeading') AND area = 'A'; INSERT INTO message (code, content, area) SELECT 'PagesFormText', JSON_OBJECT('en_US', 'Form text', 'zh_CN', '表单说明'), 'A' FROM DUAL WHERE NOT EXISTS (SELECT 1 FROM message WHERE LOWER(code) = LOWER('PagesFormText') AND area = 'A'); UPDATE message SET content = JSON_SET(COALESCE(content, JSON_OBJECT()), '$.zh_CN', '表单说明') WHERE LOWER(code) = LOWER('PagesFormText') AND area = 'A'; +INSERT INTO message (code, content, area) SELECT 'PagesUploadImage', JSON_OBJECT('en_US', 'Upload image', 'zh_CN', '上传图片'), 'A' FROM DUAL WHERE NOT EXISTS (SELECT 1 FROM message WHERE LOWER(code) = LOWER('PagesUploadImage') AND area = 'A'); +UPDATE message SET content = JSON_SET(COALESCE(content, JSON_OBJECT()), '$.zh_CN', '上传图片') WHERE LOWER(code) = LOWER('PagesUploadImage') AND area = 'A'; +INSERT INTO message (code, content, area) SELECT 'PagesUploadImageHint', JSON_OBJECT('en_US', 'PNG, JPEG or WebP up to 2 MB. Paste the link into your HTML, for example in an img tag''s src.', 'zh_CN', 'PNG、JPEG 或 WebP,最大 2 MB。将链接粘贴到您的 HTML 中,例如 img 标签的 src。'), 'A' FROM DUAL WHERE NOT EXISTS (SELECT 1 FROM message WHERE LOWER(code) = LOWER('PagesUploadImageHint') AND area = 'A'); +UPDATE message SET content = JSON_SET(COALESCE(content, JSON_OBJECT()), '$.zh_CN', 'PNG、JPEG 或 WebP,最大 2 MB。将链接粘贴到您的 HTML 中,例如 img 标签的 src。') WHERE LOWER(code) = LOWER('PagesUploadImageHint') AND area = 'A'; INSERT INTO message (code, content, area) SELECT 'PagesToolbar', JSON_OBJECT('en_US', 'Formatting', 'zh_CN', '格式'), 'A' FROM DUAL WHERE NOT EXISTS (SELECT 1 FROM message WHERE LOWER(code) = LOWER('PagesToolbar') AND area = 'A'); UPDATE message SET content = JSON_SET(COALESCE(content, JSON_OBJECT()), '$.zh_CN', '格式') WHERE LOWER(code) = LOWER('PagesToolbar') AND area = 'A'; INSERT INTO message (code, content, area) SELECT 'PagesTextStyle', JSON_OBJECT('en_US', 'Text style', 'zh_CN', '文字样式'), 'A' FROM DUAL WHERE NOT EXISTS (SELECT 1 FROM message WHERE LOWER(code) = LOWER('PagesTextStyle') AND area = 'A'); diff --git a/openspec/changes/add-html-image-upload/.openspec.yaml b/openspec/changes/add-html-image-upload/.openspec.yaml new file mode 100644 index 0000000..2ad7578 --- /dev/null +++ b/openspec/changes/add-html-image-upload/.openspec.yaml @@ -0,0 +1,2 @@ +schema: spec-driven +created: 2026-12-04 diff --git a/openspec/changes/add-html-image-upload/proposal.md b/openspec/changes/add-html-image-upload/proposal.md new file mode 100644 index 0000000..7ed3e6c --- /dev/null +++ b/openspec/changes/add-html-image-upload/proposal.md @@ -0,0 +1,44 @@ +# Proposal + +## Why + +Custom HTML blocks hold whole designed sections, such as the INS Hotel technology page. Their images must be served from somewhere. Today the only way to get an image link is to upload it as a hero image and read its id back, or to ask a developer. Marketing staff need to upload an image from the Custom HTML block itself and get a link they can paste into their HTML. + +## What Changes + +- The Custom HTML block's panel gains an **Upload image** file picker. Choosing a file uploads it at once, for the page's company, with the same checks as every page image: + - PNG, JPEG or WebP; + - at most 2 MB; + - the type is checked by the file's content. +- Each upload made while the panel is open shows: + - a small preview; + - its link (`/api/public/page-images/`) in a read-only box; + - a **Copy link** button. +- A refused upload shows its reason under the picker. +- A new page with no company chosen yet asks for one first. +- The link is relative, so it works on the published page and inside the sealed frame. The INS top bar's logo already loads this way. + +Not changing: +- The server. The existing `POST /api/pages/images` upload and the public image address are used as they are. +- Saving. The upload does not touch the page's HTML; staff paste the link where they want it. +- Unused images. They stay stored, as an unused hero upload would. Clean-up is left for later. +- The list of uploads, which is not saved. It shows this session's uploads only. + +## Capabilities + +### New Capabilities + +None. + +### Modified Capabilities + +- `landing-pages`: adds "Image Upload For Custom HTML". + +## Impact + +- Portal: + - `BlockFields.tsx`, the HTML block panel; + - the editor passes the page's company to the panel (or the panel reads it from the draft hook); + - `uploadPageImage` already exists. +- New labels in `defaultMessages.ts` and `zh_CN.seed.json`, a regenerated local seed, and a SQL label file in this change folder. +- No server or schema change. diff --git a/openspec/changes/add-html-image-upload/specs/landing-pages/spec.md b/openspec/changes/add-html-image-upload/specs/landing-pages/spec.md new file mode 100644 index 0000000..cf04ff7 --- /dev/null +++ b/openspec/changes/add-html-image-upload/specs/landing-pages/spec.md @@ -0,0 +1,23 @@ +## ADDED Requirements + +### Requirement: Image Upload For Custom HTML + +A Custom HTML block's panel in the editor SHALL offer an image upload for the page's company, under the same checks as other page images. On success it SHALL show the image's preview and its public link with a copy button; on refusal it SHALL show the reason. The upload SHALL NOT change the block's HTML. + +#### Scenario: Upload an image for the HTML + +- **GIVEN** staff editing an INS page with a Custom HTML block +- **WHEN** they choose `lobby.webp` under "Upload image" in that block's panel +- **THEN** the image is stored for INS and the panel shows its preview and the link `/api/public/page-images/` +- **AND** "Copy link" copies that link, and the block's HTML is unchanged + +#### Scenario: Refused upload + +- **WHEN** staff choose a 3 MB JPEG under "Upload image" +- **THEN** the panel shows that the image is too large, and no link appears + +#### Scenario: New page without a company + +- **GIVEN** a super admin's new page with no company chosen +- **WHEN** they choose a file under "Upload image" +- **THEN** nothing is uploaded and the panel asks them to choose a company diff --git a/openspec/changes/add-html-image-upload/sql/01-html-image-labels.sql b/openspec/changes/add-html-image-upload/sql/01-html-image-labels.sql new file mode 100644 index 0000000..27636a1 --- /dev/null +++ b/openspec/changes/add-html-image-upload/sql/01-html-image-labels.sql @@ -0,0 +1,7 @@ +-- The labels added by add-html-image-upload, cut from the output of `npm run i18n:sql`. Run it only in an environment that already ran add-zh-cn-messages/sql/03-zh-cn-messages.sql; otherwise run that 03 file, which includes these labels. +SET NAMES utf8mb4; +USE `service-system`; +INSERT INTO message (code, content, area) SELECT 'PagesUploadImage', JSON_OBJECT('en_US', 'Upload image', 'zh_CN', '上传图片'), 'A' FROM DUAL WHERE NOT EXISTS (SELECT 1 FROM message WHERE LOWER(code) = LOWER('PagesUploadImage') AND area = 'A'); +UPDATE message SET content = JSON_SET(COALESCE(content, JSON_OBJECT()), '$.zh_CN', '上传图片') WHERE LOWER(code) = LOWER('PagesUploadImage') AND area = 'A'; +INSERT INTO message (code, content, area) SELECT 'PagesUploadImageHint', JSON_OBJECT('en_US', 'PNG, JPEG or WebP up to 2 MB. Paste the link into your HTML, for example in an img tag''s src.', 'zh_CN', 'PNG、JPEG 或 WebP,最大 2 MB。将链接粘贴到您的 HTML 中,例如 img 标签的 src。'), 'A' FROM DUAL WHERE NOT EXISTS (SELECT 1 FROM message WHERE LOWER(code) = LOWER('PagesUploadImageHint') AND area = 'A'); +UPDATE message SET content = JSON_SET(COALESCE(content, JSON_OBJECT()), '$.zh_CN', 'PNG、JPEG 或 WebP,最大 2 MB。将链接粘贴到您的 HTML 中,例如 img 标签的 src。') WHERE LOWER(code) = LOWER('PagesUploadImageHint') AND area = 'A'; diff --git a/openspec/changes/add-html-image-upload/tasks.md b/openspec/changes/add-html-image-upload/tasks.md new file mode 100644 index 0000000..a30cdec --- /dev/null +++ b/openspec/changes/add-html-image-upload/tasks.md @@ -0,0 +1,34 @@ +# 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/`, 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. diff --git a/solvway-admin-portal/app/components/pages/BlockFields.tsx b/solvway-admin-portal/app/components/pages/BlockFields.tsx index 5fbf669..d85342a 100644 --- a/solvway-admin-portal/app/components/pages/BlockFields.tsx +++ b/solvway-admin-portal/app/components/pages/BlockFields.tsx @@ -1,6 +1,6 @@ "use client"; -import type { ReactNode } from "react"; +import { useState, type ReactNode } from "react"; import { ArrowDown, ArrowUp, Plus, Trash2 } from "lucide-react"; import { BLOCK_LABELS, ICONS, LOOKS, imageSrc, type CmsBlock, type CmsCard, type Look } from "@/app/lib/cmsPages"; import { Button } from "@/app/components/ui/button"; @@ -10,6 +10,7 @@ import { Switch } from "@/app/components/ui/switch"; import { Textarea } from "@/app/components/ui/textarea"; import { useT } from "@/app/lib/i18n/MessagesProvider"; import { RichTextEditor } from "./RichTextEditor"; +import { CopyAddress } from "./CopyAddress"; // One block of the page editor, ported from babyboo's BlockFields: a fieldset with move/remove and its type's fields. @@ -79,6 +80,8 @@ export function BlockFields(props: { onMove: (delta: -1 | 1) => void; onRemove: () => void; onChooseImage: (file: File) => void; + /** Uploads an image for a Custom HTML block at once (add-html-image-upload); rejects with the reason to show. */ + onUploadImage?: (file: File) => Promise; }) { const { block, id, index, count, errors, saving, events, pendingImage, onChange, onMove, onRemove } = props; const t = useT(); @@ -98,6 +101,24 @@ export function BlockFields(props: { ); + // add-html-image-upload: this panel's uploads, newest first; their links are pasted into the HTML by hand. + const [uploads, setUploads] = useState([]); + const [uploadError, setUploadError] = useState(null); + const [uploading, setUploading] = useState(false); + async function upload(file: File) { + if (!props.onUploadImage) return; + setUploadError(null); + setUploading(true); + try { + const imageId = await props.onUploadImage(file); + setUploads((u) => [imageId, ...u]); + } catch (err) { + setUploadError(err instanceof Error ? err.message : String(err)); + } finally { + setUploading(false); + } + } + const preview = pendingImage?.preview ?? (block.imageId ? imageSrc(block.imageId) : undefined); // The FORM block's event, and the hero's optional sign-up form (add-hero-signup-form): the same picker and hint. const eventPicker = (labelCode: string, emptyCode: string) => ( @@ -274,6 +295,24 @@ export function BlockFields(props: {

{t("PagesHtmlHint")}

)} + {block.type === "HTML" && props.onUploadImage && ( + + { + const file = e.target.files?.[0]; + e.target.value = ""; + if (file) void upload(file); + }} /> +

{t("PagesUploadImageHint")}

+ {uploads.map((imageId) => ( +
+ {/* eslint-disable-next-line @next/next/no-img-element -- an uploaded image of unknown size */} + {t("PagesImagePreview")} + +
+ ))} +
+ )} {block.type === "FORM" && ( <> diff --git a/solvway-admin-portal/app/components/pages/CopyAddress.tsx b/solvway-admin-portal/app/components/pages/CopyAddress.tsx index 06e4f14..708c635 100644 --- a/solvway-admin-portal/app/components/pages/CopyAddress.tsx +++ b/solvway-admin-portal/app/components/pages/CopyAddress.tsx @@ -5,14 +5,14 @@ import { Check, Copy } from "lucide-react"; import { Button } from "@/app/components/ui/button"; import { useT } from "@/app/lib/i18n/MessagesProvider"; -/** A page address with a button that copies its full URL (this site's origin plus the path). */ -export function CopyAddress({ address }: { address: string }) { +/** A page address with a button that copies its full URL (this site's origin plus the path), or the path itself when `relative`. */ +export function CopyAddress({ address, relative }: { address: string; relative?: boolean }) { const t = useT(); const [state, setState] = useState<"idle" | "copied" | "failed">("idle"); async function copy() { try { - await navigator.clipboard.writeText(`${window.location.origin}${address}`); + await navigator.clipboard.writeText(relative ? address : `${window.location.origin}${address}`); setState("copied"); setTimeout(() => setState("idle"), 2000); } catch { diff --git a/solvway-admin-portal/app/components/pages/PageEditor.html.test.tsx b/solvway-admin-portal/app/components/pages/PageEditor.html.test.tsx index 1d2862a..8c8b633 100644 --- a/solvway-admin-portal/app/components/pages/PageEditor.html.test.tsx +++ b/solvway-admin-portal/app/components/pages/PageEditor.html.test.tsx @@ -64,4 +64,42 @@ describe("PageEditor: Custom HTML", () => { expect(box.closest("div")).toHaveTextContent("Too long."); expect(box).toHaveAttribute("aria-invalid", "true"); }); + + // add-html-image-upload: upload an image from the block's panel and copy its link; the HTML stays as it was. + it("uploads an image at once for the page's company and shows its link to copy", async () => { + mocks.uploadPageImage.mockResolvedValueOnce({ id: 42 }); + const user = userEvent.setup(); + render(); + await screen.findByLabelText("HTML"); + await user.upload(screen.getByLabelText("Upload image"), new File(["png"], "lobby.png", { type: "image/png" })); + expect(await screen.findByText("/api/public/page-images/42")).toBeInTheDocument(); + expect(mocks.uploadPageImage).toHaveBeenCalledWith(2, btoa("png")); + expect(screen.getByRole("img", { name: "Image preview" })).toHaveAttribute("src", "/api/public/page-images/42"); + const write = vi.spyOn(navigator.clipboard, "writeText"); + await user.click(screen.getByRole("button", { name: "Copy link /api/public/page-images/42" })); + expect(write).toHaveBeenCalledWith("/api/public/page-images/42"); + expect(screen.getByLabelText("HTML")).toHaveValue("

Designed

"); + expect(mocks.savePage).not.toHaveBeenCalled(); + }); + + it("shows a refused upload's reason and no link", async () => { + mocks.uploadPageImage.mockRejectedValueOnce(new ApiError("x", 422, { code: "PagesImageTooLarge" })); + const user = userEvent.setup(); + render(); + await screen.findByLabelText("HTML"); + await user.upload(screen.getByLabelText("Upload image"), new File(["big"], "big.jpg", { type: "image/jpeg" })); + expect(await screen.findByText("The image is larger than 2 MB.")).toBeInTheDocument(); + expect(screen.queryByText(/\/api\/public\/page-images\//)).not.toBeInTheDocument(); + }); + + it("asks a super admin's new page for a company before uploading", async () => { + mocks.useAdminAuth.mockReturnValue({ isSuper: true, companyCode: null }); + memoryRouter.reset("/pages/new"); + const user = userEvent.setup(); + render(); + await user.click(screen.getByRole("button", { name: "Add Custom HTML" })); + await user.upload(await screen.findByLabelText("Upload image"), new File(["png"], "lobby.png", { type: "image/png" })); + expect(await screen.findByText("Choose a company.")).toBeInTheDocument(); + expect(mocks.uploadPageImage).not.toHaveBeenCalled(); + }); }); diff --git a/solvway-admin-portal/app/components/pages/PageEditor.tsx b/solvway-admin-portal/app/components/pages/PageEditor.tsx index 2b260e4..cb5c32f 100644 --- a/solvway-admin-portal/app/components/pages/PageEditor.tsx +++ b/solvway-admin-portal/app/components/pages/PageEditor.tsx @@ -223,6 +223,7 @@ function FormEditor({ p, ask }: { p: Draft; ask: Ask }) { onMove={(delta) => p.moveBlock(index, delta)} onRemove={() => p.removeBlock(row.key)} onChooseImage={(file) => p.chooseImage(row.key, file)} + onUploadImage={p.uploadImage} /> ))} diff --git a/solvway-admin-portal/app/components/pages/usePageDraft.ts b/solvway-admin-portal/app/components/pages/usePageDraft.ts index b99c24a..294fdd4 100644 --- a/solvway-admin-portal/app/components/pages/usePageDraft.ts +++ b/solvway-admin-portal/app/components/pages/usePageDraft.ts @@ -325,6 +325,20 @@ export function usePageDraft({ pageId, fromId, initialBlocks }: { pageId?: numbe } } + /** + * add-html-image-upload: uploads an image for a Custom HTML block at once, for the page's company. Resolves to its id; + * rejects with the reason to show (no company yet, or the server's refusal). + */ + async function uploadImage(file: File): Promise { + if (isSuper && !draft.companyId) throw new Error(t("ChooseCompany")); + try { + return (await uploadPageImage(draft.companyId, (await readDataUrl(file)).split(",")[1])).id; + } catch (err) { + const code = err instanceof ApiError ? (err.data as { code?: string } | undefined)?.code : undefined; + throw new Error(t(code ?? "PagesSaveFailed")); + } + } + /** Saves the current edits, then makes the draft live. */ async function publishChanges() { if (draft.id == null || !(await save())) return; @@ -384,7 +398,7 @@ export function usePageDraft({ pageId, fromId, initialBlocks }: { pageId?: numbe selected, select: setSelected, revealed, frameVersion, stale, canUndo: past.length > 0, canRedo: future.length > 0, undo, redo, endTyping, patch, setTitle, changeCompany, updateBlock, text, html, moveBlock, moveBlockTo, removeBlock, addBlock, insertBlock, duplicateBlock, - chooseImage, blockErrors, + chooseImage, uploadImage, blockErrors, save, publishChanges, discardChanges, remove, }; } diff --git a/solvway-admin-portal/app/components/pages/visual/VisualEditor.tsx b/solvway-admin-portal/app/components/pages/visual/VisualEditor.tsx index 0662d28..ecd212e 100644 --- a/solvway-admin-portal/app/components/pages/visual/VisualEditor.tsx +++ b/solvway-admin-portal/app/components/pages/visual/VisualEditor.tsx @@ -198,6 +198,7 @@ export function VisualEditor({ p, ask }: { p: Draft; ask: Ask }) { onMove={(delta) => p.moveBlock(selected, delta)} onRemove={() => p.removeBlock(row.key)} onChooseImage={(f) => p.chooseImage(row.key, f)} + onUploadImage={p.uploadImage} /> ) : ( diff --git a/solvway-admin-portal/app/lib/i18n/defaultMessages.ts b/solvway-admin-portal/app/lib/i18n/defaultMessages.ts index d38975d..603edb1 100644 --- a/solvway-admin-portal/app/lib/i18n/defaultMessages.ts +++ b/solvway-admin-portal/app/lib/i18n/defaultMessages.ts @@ -875,6 +875,8 @@ export const DEFAULT_MESSAGES: Record = { PagesAddPoint: "Add point", PagesFormHeading: "Form heading", PagesFormText: "Form text", + PagesUploadImage: "Upload image", + PagesUploadImageHint: "PNG, JPEG or WebP up to 2 MB. Paste the link into your HTML, for example in an img tag's src.", PagesToolbar: "Formatting", PagesTextStyle: "Text style", PagesParagraph: "Paragraph", diff --git a/solvway-admin-portal/app/lib/i18n/zh_CN.seed.json b/solvway-admin-portal/app/lib/i18n/zh_CN.seed.json index 82abc16..da83e11 100644 --- a/solvway-admin-portal/app/lib/i18n/zh_CN.seed.json +++ b/solvway-admin-portal/app/lib/i18n/zh_CN.seed.json @@ -860,6 +860,8 @@ "PagesAddPoint": "添加要点", "PagesFormHeading": "表单标题", "PagesFormText": "表单说明", + "PagesUploadImage": "上传图片", + "PagesUploadImageHint": "PNG、JPEG 或 WebP,最大 2 MB。将链接粘贴到您的 HTML 中,例如 img 标签的 src。", "PagesToolbar": "格式", "PagesTextStyle": "文字样式", "PagesParagraph": "段落",