This commit is contained in:
ct
2025-07-15 02:06:05 +08:00
parent 593ea61576
commit 6838c542f5
2 changed files with 11 additions and 0 deletions

View File

@@ -5,6 +5,7 @@ import { Sheet, SheetContent, SheetHeader, SheetTitle } from '@/components/ui/sh
import { Textarea } from '@/components/ui/textarea'; import { Textarea } from '@/components/ui/textarea';
import { useMitt } from '@/plugins/MittContext'; import { useMitt } from '@/plugins/MittContext';
import useVideoEditorStore from '@/stores/VideoEditorStore'; import useVideoEditorStore from '@/stores/VideoEditorStore';
import useMediaStore from '@/stores/MediaStore';
import { Bold, Italic, Minus, Plus, Type } from 'lucide-react'; import { Bold, Italic, Minus, Plus, Type } from 'lucide-react';
import { useEffect, useState } from '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 }) { export default function TextSidebar({ isOpen, onClose }) {
const { selectedTextElement } = useVideoEditorStore(); const { selectedTextElement } = useVideoEditorStore();
const { updateCurrentCaption } = useMediaStore();
const emitter = useMitt(); const emitter = useMitt();
const [textValue, setTextValue] = useState(''); const [textValue, setTextValue] = useState('');
const [fontSize, setFontSize] = useState(24); const [fontSize, setFontSize] = useState(24);
@@ -77,10 +79,14 @@ export default function TextSidebar({ isOpen, onClose }) {
setTextValue(newText); setTextValue(newText);
if (selectedTextElement) { if (selectedTextElement) {
// Update the timeline element
emitter.emit('text-update', { emitter.emit('text-update', {
elementId: selectedTextElement.id, elementId: selectedTextElement.id,
updates: { text: newText }, updates: { text: newText },
}); });
// Update MediaStore to maintain single source of truth
updateCurrentCaption(newText);
} }
}; };

View File

@@ -38,6 +38,11 @@ const useMediaStore = create(
set({ selectedBackground: background }); set({ selectedBackground: background });
}, },
// Update current caption when user edits text
updateCurrentCaption: (caption) => {
set({ currentCaption: caption });
},
// Clear selections // Clear selections
clearSelectedMeme: () => { clearSelectedMeme: () => {
set({ selectedMeme: null }); set({ selectedMeme: null });