webapp: add "Edit on Canvas" lightbox button -> PageDraw

Open any image output in the image editor straight from the lightbox,
matching the existing Make Video / Recreate handoffs. Mirrors the Tauri
app handleEditFromGallery flow: RESET the lib store, seed the image as
base (and into history), then route to /edit-image.

Gated to images (hidden for video/3D), so it shows on create-image,
library, and task-queue lightboxes via the shared LightboxDetails.
This commit is contained in:
Tanish Manku
2026-06-15 17:09:57 -07:00
parent 8cfd579664
commit 5147752c45
3 changed files with 52 additions and 0 deletions
@@ -75,6 +75,7 @@ export interface LightboxDetailsProps {
onClose?: () => void;
onRecreate?: () => void;
onMakeVideo?: () => void;
onEditOnCanvas?: () => void;
onDelete?: () => void;
showDownloadAppCta?: boolean;
}
@@ -90,6 +91,7 @@ export function LightboxDetails({
onClose,
onRecreate,
onMakeVideo,
onEditOnCanvas,
onDelete,
showDownloadAppCta,
}: LightboxDetailsProps) {
@@ -474,6 +476,16 @@ export function LightboxDetails({
Make Video
</Button>
)}
{onEditOnCanvas && (
<Button
icon={faPencil}
className="w-full border border-ui-panel-border bg-ui-controls/40 hover:bg-ui-controls/60 text-white"
variant="secondary"
onClick={onEditOnCanvas}
>
Edit on Canvas
</Button>
)}
{onRecreate && promptData.hasToken && (
<Button
icon={faArrowRotateRight}
@@ -23,6 +23,7 @@ import {
type PromptData,
} from "./shared";
import { LightboxDetails } from "./LightboxDetails";
import { applyEditOnCanvasFromImage } from "../../pages/pagedraw/edit-on-canvas";
import {
applyMakeVideoFromImage,
applyRecreateFromMediaToken,
@@ -334,6 +335,13 @@ export function Lightbox({
applyMakeVideoFromImage(selectedMediaToken, selectedImageUrl, navigate);
}, [selectedMediaToken, selectedImageUrl, canMakeVideo, navigate, onClose]);
const canEditOnCanvas = !isVideo && !is3D;
const handleEditOnCanvas = useCallback(() => {
if (!selectedMediaToken || !selectedImageUrl || !canEditOnCanvas) return;
onClose();
applyEditOnCanvasFromImage(selectedMediaToken, selectedImageUrl, navigate);
}, [selectedMediaToken, selectedImageUrl, canEditOnCanvas, navigate, onClose]);
return (
<>
<Modal
@@ -505,6 +513,11 @@ export function Lightbox({
? handleMakeVideo
: undefined
}
onEditOnCanvas={
canEditOnCanvas && selectedMediaToken && selectedImageUrl
? handleEditOnCanvas
: undefined
}
onDelete={
selectedMediaToken
? () => setConfirmDeleteOpen(true)
@@ -0,0 +1,27 @@
// "Edit on Canvas" handoff: open an existing image in the PageDraw editor.
//
// Mirrors the Tauri app's handleEditFromGallery — RESET the editor, seed the
// chosen image as the base (and into history), then route to /edit-image.
// Seeding the lib's store before navigating means the editor mounts straight
// into the image, same store-based handoff the create-image/create-video
// "Recreate" and "Make Video" buttons use (see lib/recreate.ts).
import type { NavigateFunction } from "react-router-dom";
import { useSceneStore } from "@storyteller/ui-pagedraw";
export function applyEditOnCanvasFromImage(
mediaToken: string,
mediaUrl: string,
navigate: NavigateFunction,
): void {
const store = useSceneStore.getState();
const baseImage = {
url: mediaUrl,
mediaToken,
fullImageUrl: mediaUrl,
};
store.RESET();
store.addHistoryImageBundle({ images: [baseImage] });
store.setBaseImageInfo(baseImage);
navigate("/edit-image");
}