This commit is contained in:
gpt-engineer-app[bot]
2025-12-19 14:43:28 +00:00
parent 04a140b305
commit b63da103cd
8 changed files with 265 additions and 35 deletions

View File

@@ -9,7 +9,7 @@ import {
Image as ImageIcon, Heading1, Heading2, Undo, Redo
} from 'lucide-react';
import { cn } from '@/lib/utils';
import { useCallback } from 'react';
import { useCallback, useEffect } from 'react';
import { supabase } from '@/integrations/supabase/client';
import { toast } from '@/hooks/use-toast';
@@ -45,6 +45,13 @@ export function RichTextEditor({ content, onChange, placeholder = 'Tulis konten.
},
});
// Sync content when it changes externally (e.g., when editing different items)
useEffect(() => {
if (editor && content !== editor.getHTML()) {
editor.commands.setContent(content || '');
}
}, [content, editor]);
const addLink = useCallback(() => {
if (!editor) return;
const url = window.prompt('Masukkan URL:');