Create professional demos and 3D mockups in seconds, directly in your browser
fix: update
CristianOlivera18a9f646188da
diff --git a/app/[locale]/(editor)/editor/page.tsx b/app/[locale]/(editor)/editor/page.tsxindex 4a0c69a..2d2f036 100644--- a/app/[locale]/(editor)/editor/page.tsx+++ b/app/[locale]/(editor)/editor/page.tsx@@ -39,7 +39,8 @@ import { findValidFragmentPosition } from "@/app/components/ui/editor/ZoomFragmeimport { LoadingSpinner } from "@/components/ui/LoadingSpinner";import { TimelineSkeleton } from "@/app/components/ui/Skeleton";import { AudioTrimModal } from "@/app/components/ui/editor/AudioTrimModal";-import { useAuth } from "@/hooks/useAuth";+import { useAuth } from "@/app/contexts/useAuth";+import { useMotionContext } from "@/app/contexts/MotionContext";import { VIDEO_Z_INDEX } from "@/lib/constants";import { getWallpaperUrl } from "@/lib/wallpaper.utils";import Image from "next/image";@@ -59,6 +60,22 @@ export default function Editor() {// Auth — needed for building production-ready Recipe JSONconst { user } = useAuth();+ const {+ undoMotion, redoMotion, pushHistory,+ canUndoMotion, canRedoMotion,+ imagePhoneActive, setImagePhoneActive,+ imagePhoneX, setImagePhoneX,+ imagePhoneY, setImagePhoneY,+ imagePhoneScale, setImagePhoneScale,+ imagePhoneRotX, setImagePhoneRotX,+ imagePhoneRotY, setImagePhoneRotY,+ imagePhoneRotZ, setImagePhoneRotZ,+ imagePhonePerspective, setImagePhonePerspective,+ imagePhoneDevice, setImagePhoneDevice,+ imagePhoneOpening, setImagePhoneOpening,+ imagePhoneShadow, setImagePhoneShadow,+ imagePhoneShadowColor, setImagePhoneShadowColor,+ } = useMotionContext();// Undo/Redo system - centralized state managementconst {@@ -281,6 +298,18 @@ export default function Editor() {imagePreview3D: imageTransform,apply3DToBackground,imageMaskConfig,+ imagePhoneActive,+ imagePhoneX,+ imagePhoneY,+ imagePhoneScale,+ imagePhoneRotX,+ imagePhoneRotY,+ imagePhoneRotZ,+ imagePhonePerspective,+ imagePhoneDevice,+ imagePhoneOpening,+ imagePhoneShadow,+ imagePhoneShadowColor,});} catch (error) {console.error("Auto-save failed:", error);@@ -309,6 +338,18 @@ export default function Editor() {imageTransform,apply3DToBackground,imageMaskConfig,+ imagePhoneActive,+ imagePhoneX,+ imagePhoneY,+ imagePhoneScale,+ imagePhoneRotX,+ imagePhoneRotY,+ imagePhoneRotZ,+ imagePhonePerspective,+ imagePhoneDevice,+ imagePhoneOpening,+ imagePhoneShadow,+ imagePhoneShadowColor,]);useEffect(() => {@@ -334,6 +375,18 @@ export default function Editor() {imageTransform,apply3DToBackground,imageMaskConfig,+ imagePhoneActive,+ imagePhoneX,+ imagePhoneY,+ imagePhoneScale,+ imagePhoneRotX,+ imagePhoneRotY,+ imagePhoneRotZ,+ imagePhonePerspective,+ imagePhoneDevice,+ imagePhoneOpening,+ imagePhoneShadow,+ imagePhoneShadowColor,currentProject,isPhotoMode,autoSaveCurrentProject,@@ -381,10 +434,26 @@ export default function Editor() {height: currentProject.imageHeight,});+ // ── Restore motion / 3D device mockup state ────────────────────────+ if (currentProject.imagePhoneActive !== undefined) {+ setImagePhoneActive(currentProject.imagePhoneActive);+ }+ if (currentProject.imagePhoneX !== undefined) setImagePhoneX(currentProject.imagePhoneX);+ if (currentProject.imagePhoneY !== undefined) setImagePhoneY(currentProject.imagePhoneY);+ if (currentProject.imagePhoneScale !== undefined) setImagePhoneScale(currentProject.imagePhoneScale);+ if (currentProject.imagePhoneRotX !== undefined) setImagePhoneRotX(currentProject.imagePhoneRotX);+ if (currentProject.imagePhoneRotY !== undefined) setImagePhoneRotY(currentProject.imagePhoneRotY);+ if (currentProject.imagePhoneRotZ !== undefined) setImagePhoneRotZ(currentProject.imagePhoneRotZ);+ if (currentProject.imagePhonePerspective !== undefined) setImagePhonePerspective(currentProject.imagePhonePerspective);+ if (currentProject.imagePhoneDevice !== undefined) setImagePhoneDevice(currentProject.imagePhoneDevice);+ if (currentProject.imagePhoneOpening !== undefined) setImagePhoneOpening(currentProject.imagePhoneOpening);+ if (currentProject.imagePhoneShadow !== undefined) setImagePhoneShadow(currentProject.imagePhoneShadow);+ if (currentProject.imagePhoneShadowColor !== undefined) setImagePhoneShadowColor(currentProject.imagePhoneShadowColor);+setTimeout(() => {isRestoringProjectRef.current = false;- }, 500); //- }, [currentProject, isPhotoMode]);+ }, 500); //+ }, [currentProject, isPhotoMode, setImagePhoneActive, setImagePhoneX, setImagePhoneY, setImagePhoneScale, setImagePhoneRotX, setImagePhoneRotY, setImagePhoneRotZ, setImagePhonePerspective, setImagePhoneDevice, setImagePhoneOpening, setImagePhoneShadow, setImagePhoneShadowColor]);// Image project handlersconst handleSelectImageProject = useCallback(async (projectId: string) => {@@ -473,6 +542,20 @@ export default function Editor() {imagePreview3D: imageTransform,apply3DToBackground,imageMaskConfig,+ // ── Preserve current phone/device state in the new project ──+ // Without these, the restore useEffect resets the device to 'phone'+ imagePhoneActive,+ imagePhoneX,+ imagePhoneY,+ imagePhoneScale,+ imagePhoneRotX,+ imagePhoneRotY,+ imagePhoneRotZ,+ imagePhonePerspective,+ imagePhoneDevice,+ imagePhoneOpening,+ imagePhoneShadow,+ imagePhoneShadowColor,});@@ -503,6 +586,18 @@ export default function Editor() {imageTransform,apply3DToBackground,imageMaskConfig,+ imagePhoneActive,+ imagePhoneX,+ imagePhoneY,+ imagePhoneScale,+ imagePhoneRotX,+ imagePhoneRotY,+ imagePhoneRotZ,+ imagePhonePerspective,+ imagePhoneDevice,+ imagePhoneOpening,+ imagePhoneShadow,+ imagePhoneShadowColor,]);// Screen capture handler - now creates a project@@ -562,6 +657,20 @@ export default function Editor() {imagePreview3D: imageTransform,apply3DToBackground,imageMaskConfig,+ // ── Preserve current phone/device state in the new project ──+ // Without these, the restore useEffect resets the device to 'phone'+ imagePhoneActive,+ imagePhoneX,+ imagePhoneY,+ imagePhoneScale,+ imagePhoneRotX,+ imagePhoneRotY,+ imagePhoneRotZ,+ imagePhonePerspective,+ imagePhoneDevice,+ imagePhoneOpening,+ imagePhoneShadow,+ imagePhoneShadowColor,});@@ -592,6 +701,18 @@ export default function Editor() {imageTransform,apply3DToBackground,imageMaskConfig,+ imagePhoneActive,+ imagePhoneX,+ imagePhoneY,+ imagePhoneScale,+ imagePhoneRotX,+ imagePhoneRotY,+ imagePhoneRotZ,+ imagePhonePerspective,+ imagePhoneDevice,+ imagePhoneOpening,+ imagePhoneShadow,+ imagePhoneShadowColor,]);// Handler for drag & drop images on canvas (photo mode only)@@ -1988,6 +2109,21 @@ export default function Editor() {if (isInputFocused) return;+ // Motion-specific undo/redo when the motion tool is active+ if (activeTool === "motion") {+ if ((e.ctrlKey || e.metaKey) && e.key === 'z' && !e.shiftKey) {+ e.preventDefault();+ undoMotion();+ return;+ }+ if (((e.ctrlKey || e.metaKey) && e.key === 'y') ||+ ((e.ctrlKey || e.metaKey) && e.shiftKey && e.key === 'z')) {+ e.preventDefault();+ redoMotion();+ return;+ }+ }+if ((e.ctrlKey || e.metaKey) && e.key === 'z' && !e.shiftKey) {e.preventDefault();if (canUndo) {@@ -2006,7 +2142,7 @@ export default function Editor() {window.addEventListener('keydown', handleKeyDown);return () => window.removeEventListener('keydown', handleKeyDown);- }, [undo, redo, canUndo, canRedo]);+ }, [undo, redo, canUndo, canRedo, activeTool, undoMotion, redoMotion]);// Keyboard listener for Ctrl+V image paste (photo mode only)useEffect(() => {@@ -2931,6 +3067,11 @@ export default function Editor() {imageExportProgress={imageExportProgress}canvasWidth={customAspectRatio?.width || 1920}canvasHeight={customAspectRatio?.height || 1080}+ activeTool={activeTool}+ onUndoMotion={undoMotion}+ onRedoMotion={redoMotion}+ canUndoMotion={canUndoMotion}+ canRedoMotion={canRedoMotion}/>}ref={canvasRef}diff --git a/app/[locale]/(editor)/layout.tsx b/app/[locale]/(editor)/layout.tsxindex 30c0416..658ca7d 100644--- a/app/[locale]/(editor)/layout.tsx+++ b/app/[locale]/(editor)/layout.tsx@@ -1,9 +1,9 @@"use client";-import { AuthProvider } from "@/hooks/useAuth";-import { RecordingProvider } from "@/hooks/RecordingContext";+import { AuthProvider } from "@/app/contexts/useAuth";import RecordingOverlay from "../../components/ui/RecordingOverlay";import { MotionProvider } from "@/app/contexts/MotionContext";+import { RecordingProvider } from "@/app/contexts/RecordingContext";export default function EditorLayout({ children }: { children: React.ReactNode }) {return (diff --git a/app/[locale]/(home)/layout.tsx b/app/[locale]/(home)/layout.tsxindex 77da13c..1b12e3f 100644--- a/app/[locale]/(home)/layout.tsx+++ b/app/[locale]/(home)/layout.tsx@@ -3,8 +3,8 @@import Footer from "@/app/components/common/Footer";import Header from "@/app/components/common/Header";import RecordingOverlay from "@/app/components/ui/RecordingOverlay";-import { RecordingProvider } from "@/hooks/RecordingContext";-import { AuthProvider } from "@/hooks/useAuth";+import { RecordingProvider } from "@/app/contexts/RecordingContext";+import { AuthProvider } from "@/app/contexts/useAuth";import "../../globals.css";export default function HomeLayout({ children }: { children: React.ReactNode }) {diff --git a/app/[locale]/(legal)/layout.tsx b/app/[locale]/(legal)/layout.tsxindex f62ecb2..f49cf22 100644--- a/app/[locale]/(legal)/layout.tsx+++ b/app/[locale]/(legal)/layout.tsx@@ -1,7 +1,7 @@import Footer from "@/app/components/common/Footer";import Header from "@/app/components/common/Header";-import { AuthProvider } from "@/hooks/useAuth";-import { RecordingProvider } from "@/hooks/RecordingContext";+import { AuthProvider } from "@/app/contexts/useAuth";+import { RecordingProvider } from "@/app/contexts/RecordingContext";import type { Metadata } from 'next';export const metadata: Metadata = {diff --git a/app/[locale]/not-found.tsx b/app/[locale]/not-found.tsxindex 9e4ee93..2f2f142 100644--- a/app/[locale]/not-found.tsx+++ b/app/[locale]/not-found.tsx@@ -1,7 +1,7 @@"use client";import { useTranslations } from "next-intl";-import { AuthProvider } from "@/hooks/useAuth";+import { AuthProvider } from "@/app/contexts/useAuth";import { Link } from "@/navigation";import Footer from "../components/common/Footer";import Header from "../components/common/Header";diff --git a/app/components/common/Header.tsx b/app/components/common/Header.tsxindex 43c4b6d..c266c79 100644--- a/app/components/common/Header.tsx+++ b/app/components/common/Header.tsx@@ -9,7 +9,7 @@ import { LanguageSwitcher } from "./LanguageSwitcher";import { useTranslations } from "next-intl";import { Icon } from "@iconify/react";import { Button } from "@/components/ui/button";-import { useRecording } from "@/hooks/RecordingContext";+import { useRecording } from "@/app/contexts/RecordingContext";import RecordingSetupDialog from "../ui/RecordingSetupDialog";import { Alert, AlertTitle, AlertDescription } from "@/components/ui/alert";diff --git a/app/components/common/MobileMenu.tsx b/app/components/common/MobileMenu.tsxindex 14db2f8..4c21bba 100644--- a/app/components/common/MobileMenu.tsx+++ b/app/components/common/MobileMenu.tsx@@ -3,7 +3,7 @@import { useState, useEffect } from "react";import { Link } from "@/navigation";import { Icon } from "@iconify/react";-import { useAuth } from "@/hooks/useAuth";+import { useAuth } from "@/app/contexts/useAuth";import { hasAnyVideo } from "@/lib/video-cache-utils";import * as Dialog from "@radix-ui/react-dialog";import Image from "next/image";diff --git a/app/components/common/UserMenu.tsx b/app/components/common/UserMenu.tsxindex 359ed07..9c05e73 100644--- a/app/components/common/UserMenu.tsx+++ b/app/components/common/UserMenu.tsx@@ -3,7 +3,7 @@ import { useState } from "react";import Image from "next/image";import Link from "next/link";import { Icon } from "@iconify/react";-import { useAuth } from "@/hooks/useAuth";+import { useAuth } from "@/app/contexts/useAuth";import * as DropdownMenu from "@radix-ui/react-dropdown-menu";import { Button } from "@/components/ui/button";import { useTranslations } from "next-intl";diff --git a/app/components/ui/RecordingOverlay.tsx b/app/components/ui/RecordingOverlay.tsxindex cc9aef8..74dbc08 100644--- a/app/components/ui/RecordingOverlay.tsx+++ b/app/components/ui/RecordingOverlay.tsx@@ -1,6 +1,6 @@"use client";-import { useRecording } from "@/hooks/RecordingContext";+import { useRecording } from "@/app/contexts/RecordingContext";import FloatingCameraPreview from "./FloatingCameraPreview";import { useTranslations } from "next-intl";diff --git a/hooks/RecordingContext.tsx b/app/contexts/RecordingContext.tsxsimilarity index 95%rename from hooks/RecordingContext.tsxrename to app/contexts/RecordingContext.tsxindex e831cde..37fb6ab 100644--- a/hooks/RecordingContext.tsx+++ b/app/contexts/RecordingContext.tsx@@ -1,7 +1,7 @@"use client";import { createContext, useContext, ReactNode, useEffect } from "react";-import { useScreenRecording } from "./useScreenRecording";+import { useScreenRecording } from "../../hooks/useScreenRecording";import type { RecordingState, RecordingContextType } from "@/types";export type { RecordingState, RecordingContextType };diff --git a/hooks/useAuth.tsx b/app/contexts/useAuth.tsxsimilarity index 100%rename from hooks/useAuth.tsxrename to app/contexts/useAuth.tsx