diff --git a/apps/ai-game-creator-shell/src/view/ui-editor/components/preview/PreviewWorkspace.tsx b/apps/ai-game-creator-shell/src/view/ui-editor/components/preview/PreviewWorkspace.tsx
index 8fbc37dbb..8ec753d09 100644
--- a/apps/ai-game-creator-shell/src/view/ui-editor/components/preview/PreviewWorkspace.tsx
+++ b/apps/ai-game-creator-shell/src/view/ui-editor/components/preview/PreviewWorkspace.tsx
@@ -141,6 +141,25 @@ export function PreviewWorkspace({
setViewportState(next);
}, []);
+ const fitToCanvas = useCallback(() => {
+ if (!logicalSize) return;
+ const element = viewportElementRef.current;
+ setViewport(
+ fitViewportToBounds({
+ bounds: {
+ x: 0,
+ y: 0,
+ width: logicalSize.width,
+ height: logicalSize.height,
+ },
+ canvasSize: {
+ width: element?.clientWidth || canvasSizeRef.current.width,
+ height: element?.clientHeight || canvasSizeRef.current.height,
+ },
+ }),
+ );
+ }, [logicalSize, setViewport]);
+
useEffect(() => {
if (!activeImageId || !logicalSize) return;
const element = viewportElementRef.current;
@@ -548,12 +567,14 @@ export function PreviewWorkspace({
zoomToDisplayScale(Number(event.target.value) / 100)
}
/>
-
+