Compare commits
No commits in common. "5c97c62a7279e7db8586cbf2d331b25b24d74ad6" and "80dc09f2e3e5d87d062e5f8a82559e63b9543af4" have entirely different histories.
5c97c62a72
...
80dc09f2e3
@ -236,20 +236,7 @@ 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);
|
||||||
// Só injetar se o conteúdo do editor estiver vazio ou muito diferente
|
editorRef.current.innerHTML = content;
|
||||||
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]);
|
||||||
|
|
||||||
@ -597,10 +584,7 @@ export default function EditarLaudoPage() {
|
|||||||
<div
|
<div
|
||||||
ref={editorRef}
|
ref={editorRef}
|
||||||
contentEditable
|
contentEditable
|
||||||
onInput={(e) => {
|
onInput={(e) => setContent(e.currentTarget.innerHTML)}
|
||||||
// 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