I am trying to excess the html element and want to replace the inner content:- Here is the code i am trying:-
import { RichTextEditorComponent } from "@syncfusion/ej2-react-richtexteditor";
export const handleSignatureSelect = (
signature: string,
editorRef: React.RefObject<RichTextEditorComponent>
) => {
const currentSignature = document.getElementsByClassName("gmail_signature");
if (currentSignature) {
currentSignature.innerText = signature;
return;
}
editorRef.current?.executeCommand(
"insertHTML",
`<br><br clear="all"><div><br></div><br><div dir="ltr" class="gmail_signature"
data-smartmail="gmail_signature">${signature}</div>`
);
};
You code should be like this because after using
getElementByClassName
it return an array.