diff --git a/AGENTS.md b/AGENTS.md index 633aaa9..c9590ee 100644 --- a/AGENTS.md +++ b/AGENTS.md @@ -146,6 +146,7 @@ To add an email block type: add to `EmailBlockType` in `packages/shared/src/type - Section card: `rounded-box bg-base-100 p-5 shadow` with an `h2.text-2xl.font-bold` title (see Site design / globals). - Form field: ``; hints in ``. - Setting rows in editors: `SegmentedControl` (choices) and `ColorField` (colours) — label column on the left, like the block Background picker. + - Images: always `$lib/admin/editors/ImagePicker.svelte` (choose, drag in or paste an image, or pick an uploaded one from the library: `MediaLibrary.svelte`, `/api/media`; address and alt text). It uploads to `media` through `/api/upload`; `withUrl={false}` + `altHint=""` + the `id` from `onChange` where a field stores a media relation (Services & products). Store only `url`/`alt` from `onChange` elsewhere. - Create/edit forms open in `$lib/admin/Modal.svelte`; destructive submits use `confirmSubmit()` from `$lib/admin/confirm` (returning `false` from a handler does not cancel). - Server actions wrap PocketBase writes in `attempt()` from `$lib/server/actions` so failures show as an error banner, not a 500. - Editors with unsaved state use `use:enhance` + `warnOnUnsavedChanges()`. diff --git a/app-admin/src/lib/admin/editors/BlockEditor.svelte b/app-admin/src/lib/admin/editors/BlockEditor.svelte index d0a1f42..09787fc 100644 --- a/app-admin/src/lib/admin/editors/BlockEditor.svelte +++ b/app-admin/src/lib/admin/editors/BlockEditor.svelte @@ -2,7 +2,7 @@ import type { BlockType, ContentBlock } from '$lib/types'; import { blockLabels } from '$lib/admin/blockDefaults'; import RichTextEditor from './RichTextEditor.svelte'; - import ImageUploader from './ImageUploader.svelte'; + import ImagePicker from './ImagePicker.svelte'; import SegmentedControl from './SegmentedControl.svelte'; import ColorField from './ColorField.svelte'; import ShopBlockEditor from './ShopBlockEditor.svelte'; @@ -94,7 +94,7 @@ {:else if block.type === 'image_text'}
- updateData(image)} /> + updateData({ url: image.url, alt: image.alt })} /> updateData({ imagePosition: v })} /> updateData({ content })} />
@@ -199,7 +199,7 @@ {#if block.data.style !== 'numbered'} - updateArray('items', i, { imageUrl: image.url, imageAlt: image.alt })} /> + updateArray('items', i, { imageUrl: image.url, imageAlt: image.alt })} /> {/if}
{@render field('Title', card.title || '', (title) => updateArray('items', i, { title }))} @@ -255,7 +255,7 @@ {#if block.data._background?.type === 'color'} updateBackground({ color })} /> {:else if block.data._background?.type === 'image'} - updateBackground({ imageUrl: image.url, imageAlt: image.alt })} /> + updateBackground({ imageUrl: image.url, imageAlt: image.alt })} /> updateBackground({ attachment })} /> Use placeholders like {'{{customer_first_name}}'} — see the list above.

{:else if block.type === 'image'}
- updateData(image)} /> + updateData({ url: image.url, alt: image.alt })} /> updateData({ width: v })} formatLabel={(v) => `${v}%`} /> updateData({ alignment: v })} />
- {#if uploadError}{uploadError}{/if} + (draft = { ...draft, image: image.id ?? draft.image, imageUrl: image.url })}> +

The shop uses the name as the image’s alt text.

+