suneditor-react Typescript getContent is not working

762 Views Asked by At

I'm using suneditor-react with typescript. I want to get the content of the editor to create a PDF. But the problem is when I try to access a ref of the SunEditor, I got the following error

Property 'ref' does not exist on type 'IntrinsicAttributes & SunEditorReactProps & { children?: ReactNode; }'. 

Further, I couldn't find a getContents() prop as well in the SunEditorReactProps. But it is in thier example page. enter image description here

Please give your ideas.

sunediotr-react

suneditor example page

2

There are 2 best solutions below

0
On
  1. Import SuneditorCore
import SunEditorCore from "suneditor/src/lib/core";

2)Declare and set value of given variable

private suneditor1!:SunEditorCore;
this.suneditor1=suneditor.create('sample', {
            
});

3)Call suneditor functions

const savedata=this.suneditor1.getContents(true); 
0
On

Hi I am the author of the SunEditor React Component you can learn how to attach ref to the suneditor react component (in typescript) here.