From 6838c542f501ecca403d1e66f5f20392e4f41757 Mon Sep 17 00:00:00 2001 From: ct Date: Tue, 15 Jul 2025 02:06:05 +0800 Subject: [PATCH] Update --- resources/js/modules/editor/partials/text-sidebar.jsx | 6 ++++++ resources/js/stores/MediaStore.js | 5 +++++ 2 files changed, 11 insertions(+) diff --git a/resources/js/modules/editor/partials/text-sidebar.jsx b/resources/js/modules/editor/partials/text-sidebar.jsx index fad1018..d8e3bb8 100644 --- a/resources/js/modules/editor/partials/text-sidebar.jsx +++ b/resources/js/modules/editor/partials/text-sidebar.jsx @@ -5,6 +5,7 @@ import { Sheet, SheetContent, SheetHeader, SheetTitle } from '@/components/ui/sh import { Textarea } from '@/components/ui/textarea'; import { useMitt } from '@/plugins/MittContext'; import useVideoEditorStore from '@/stores/VideoEditorStore'; +import useMediaStore from '@/stores/MediaStore'; import { Bold, Italic, Minus, Plus, Type } from 'lucide-react'; import { useEffect, useState } from 'react'; @@ -13,6 +14,7 @@ import { DEFAULT_TEXT_CONFIG, getAvailableFonts, loadFonts } from '@/modules/edi export default function TextSidebar({ isOpen, onClose }) { const { selectedTextElement } = useVideoEditorStore(); + const { updateCurrentCaption } = useMediaStore(); const emitter = useMitt(); const [textValue, setTextValue] = useState(''); const [fontSize, setFontSize] = useState(24); @@ -77,10 +79,14 @@ export default function TextSidebar({ isOpen, onClose }) { setTextValue(newText); if (selectedTextElement) { + // Update the timeline element emitter.emit('text-update', { elementId: selectedTextElement.id, updates: { text: newText }, }); + + // Update MediaStore to maintain single source of truth + updateCurrentCaption(newText); } }; diff --git a/resources/js/stores/MediaStore.js b/resources/js/stores/MediaStore.js index 4c653a5..a419d93 100644 --- a/resources/js/stores/MediaStore.js +++ b/resources/js/stores/MediaStore.js @@ -38,6 +38,11 @@ const useMediaStore = create( set({ selectedBackground: background }); }, + // Update current caption when user edits text + updateCurrentCaption: (caption) => { + set({ currentCaption: caption }); + }, + // Clear selections clearSelectedMeme: () => { set({ selectedMeme: null });