Changes
This commit is contained in:
@@ -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:');
|
||||
|
||||
Reference in New Issue
Block a user