mirror of
https://github.com/rgrgogu/new_starr.git
synced 2026-09-27 00:12:54 +08:00
@@ -13,10 +13,19 @@ import {
|
||||
} from "@/components/ui/select";
|
||||
import { RichTextEditor } from "./TextBlock"; // reuse the shared editor
|
||||
import { AssetPickerSheet } from "../../AssetPickerSheet";
|
||||
import { useAssetPreviewSrc } from "@/hooks/useAssetPreviewSrc";
|
||||
import { MediaFallback } from "@/components/generic/MediaFallback";
|
||||
|
||||
export function TextImageBlock({ content, onUpdate, blockId, readOnly = false }) {
|
||||
const [pickerOpen, setPickerOpen] = useState(false);
|
||||
|
||||
// content.url is redacted (null) server-side for S3 assets — re-resolve
|
||||
// through media.util.js instead of trusting the persisted url/thumbnail.
|
||||
const { src, loading } = useAssetPreviewSrc(
|
||||
{ asset_id: content?.asset_id, storage_provider: content?.storage_provider, file_url: content?.url, thumbnail_url: content?.url },
|
||||
{ scope: "admin" },
|
||||
);
|
||||
|
||||
return (
|
||||
<div className="space-y-4">
|
||||
|
||||
@@ -54,13 +63,15 @@ export function TextImageBlock({ content, onUpdate, blockId, readOnly = false })
|
||||
].join(" ")}>
|
||||
<Label>Image</Label>
|
||||
|
||||
{content.url ? (
|
||||
{loading ? (
|
||||
<MediaFallback className="w-full aspect-video rounded-lg" />
|
||||
) : src ? (
|
||||
<div
|
||||
className="relative rounded-lg overflow-hidden cursor-pointer group"
|
||||
onClick={() => setPickerOpen(true)}
|
||||
>
|
||||
<img
|
||||
src={content.url}
|
||||
src={src}
|
||||
alt={content.alt ?? ""}
|
||||
className="w-full aspect-video object-cover"
|
||||
/>
|
||||
@@ -79,7 +90,7 @@ export function TextImageBlock({ content, onUpdate, blockId, readOnly = false })
|
||||
</button>
|
||||
)}
|
||||
|
||||
{content.url && (
|
||||
{content.asset_id && (
|
||||
<div className="space-y-1.5">
|
||||
<Label>Alt Text</Label>
|
||||
<Input
|
||||
@@ -100,6 +111,7 @@ export function TextImageBlock({ content, onUpdate, blockId, readOnly = false })
|
||||
onSelect={(asset) => onUpdate({
|
||||
...content,
|
||||
asset_id: asset.asset_id,
|
||||
storage_provider: asset.storage_provider ?? null,
|
||||
url: asset.file_url,
|
||||
})}
|
||||
/>
|
||||
|
||||
Reference in New Issue
Block a user