solr fix
This commit is contained in:
@@ -448,9 +448,15 @@ function EditorContent({
|
||||
);
|
||||
const [isScrollable, setIsScrollable] = useState(true); // Default to scrollable
|
||||
|
||||
// Sync HTML value with prop changes
|
||||
// Sync HTML value with prop changes (but not for internal changes)
|
||||
useEffect(() => {
|
||||
debug.log('🔄 Editor value changed:', { valueLength: value?.length, valuePreview: value?.substring(0, 100) });
|
||||
// Skip re-initialization if this change came from the editor itself
|
||||
if (isInternalChange.current) {
|
||||
debug.log('🔄 Skipping re-initialization for internal change');
|
||||
return;
|
||||
}
|
||||
|
||||
debug.log('🔄 Editor value changed externally:', { valueLength: value?.length, valuePreview: value?.substring(0, 100) });
|
||||
setPortableTextValue(htmlToPortableTextBlocks(value));
|
||||
}, [value]);
|
||||
|
||||
@@ -459,13 +465,23 @@ function EditorContent({
|
||||
debug.log('📝 Portable text blocks updated:', { blockCount: portableTextValue.length, blocks: portableTextValue });
|
||||
}, [portableTextValue]);
|
||||
|
||||
// Track if changes are coming from internal editor changes
|
||||
const isInternalChange = useRef(false);
|
||||
|
||||
// Handle content changes using the EventListenerPlugin
|
||||
const handleEditorChange = useCallback((event: any) => {
|
||||
if (event.type === 'mutation') {
|
||||
debug.log('📝 Editor content changed via EventListener:', { valueLength: event.value?.length });
|
||||
const html = portableTextToHtml(event.value);
|
||||
debug.log('📝 Converted to HTML:', { htmlLength: html.length, htmlPreview: html.substring(0, 200) });
|
||||
|
||||
// Mark this as an internal change to prevent re-initialization
|
||||
isInternalChange.current = true;
|
||||
onChange(html);
|
||||
// Reset flag after a short delay to allow external changes
|
||||
setTimeout(() => {
|
||||
isInternalChange.current = false;
|
||||
}, 100);
|
||||
}
|
||||
}, [onChange]);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user