import React, { useLayoutEffect, useRef } from 'react' // Static-content text edited in place. The DOM is uncontrolled while the user types (React never rewrites // innerHTML during editing, so the caret does not jump) and the HTML is committed once, on blur. export default function EditableContent({ html, onCommit, style, className, onClick, elementRef }) { const ref = useRef(null) const editing = useRef(false) // Push outside changes (undo, panel edits) into the DOM, but never while the user is typing. useLayoutEffect(() => { if (!editing.current && ref.current && ref.current.innerHTML !== html) { ref.current.innerHTML = html } }, [html]) return (