fix: edit-report
This commit is contained in:
parent
733a4188c1
commit
2edc56e8f0
@ -236,7 +236,20 @@ export default function EditarLaudoPage() {
|
|||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
if (content && editorRef.current && !loading) {
|
if (content && editorRef.current && !loading) {
|
||||||
console.log('[EditarLaudoPage] Injecting content into editor, length:', content.length);
|
console.log('[EditarLaudoPage] Injecting content into editor, length:', content.length);
|
||||||
editorRef.current.innerHTML = content;
|
// Só injetar se o conteúdo do editor estiver vazio ou muito diferente
|
||||||
|
const currentContent = editorRef.current.innerHTML;
|
||||||
|
if (!currentContent || currentContent.length === 0) {
|
||||||
|
editorRef.current.innerHTML = content;
|
||||||
|
// Mover cursor para o final
|
||||||
|
const range = document.createRange();
|
||||||
|
const sel = window.getSelection();
|
||||||
|
if (editorRef.current.childNodes.length > 0) {
|
||||||
|
range.selectNodeContents(editorRef.current);
|
||||||
|
range.collapse(false); // false = colapsar no final
|
||||||
|
sel?.removeAllRanges();
|
||||||
|
sel?.addRange(range);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}, [content, loading]);
|
}, [content, loading]);
|
||||||
|
|
||||||
@ -584,7 +597,10 @@ export default function EditarLaudoPage() {
|
|||||||
<div
|
<div
|
||||||
ref={editorRef}
|
ref={editorRef}
|
||||||
contentEditable
|
contentEditable
|
||||||
onInput={(e) => setContent(e.currentTarget.innerHTML)}
|
onInput={(e) => {
|
||||||
|
// Capturar conteúdo sem perder posição do cursor
|
||||||
|
setContent(e.currentTarget.innerHTML);
|
||||||
|
}}
|
||||||
onPaste={(e) => {
|
onPaste={(e) => {
|
||||||
e.preventDefault();
|
e.preventDefault();
|
||||||
const text = e.clipboardData.getData('text/plain');
|
const text = e.clipboardData.getData('text/plain');
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user