Closed adamflorizone closed 3 years ago
You are using the newest version. The onInit function is missing. I am working on it. Please note that onInit is a function so you should not pass it as an array:
<GrapesjsReact
id='grapesjs-react'
// onInit={(e) => setTitle(e.target.value)}
// The next line
onInit={[onInit]}
// should be
onInit={onInit}
children={<div>test</div>}
plugins={[
'gjs-preset-newsletter',
'gjs-blocks-basic'
]}
/>
I need access to editor.getHtml(). Should onInit have access to the editor? I have seen #37, but I cant seem to access it.
My code:
<GrapesjsReact id='grapesjs-react' // onInit={(e) => setTitle(e.target.value)} onInit={[onInit]} children={<div>test</div>} plugins={[ 'gjs-preset-newsletter', 'gjs-blocks-basic' ]} />
This Is what I tried:
onInit={console.log(this)}:
Gives:
'editor' is not defined no-undef
Also would expect that onInit functions more like most callbacks (such as https://reactjs.org/docs/forms.html onChange) and takes a function:
function onInitFunc(editor){ console.log(editor.getHtml()); } ..... onInit={onInitFunc}
Gives:
undefined
Same this for:
onInit={(e) => console.log(e)}
Gives:
undefined
How do I access editor.getHtml()?
Please check the new published version v4.0.1-alpha
I need access to editor.getHtml(). Should onInit have access to the editor? I have seen https://github.com/thanhtunguet/grapesjs-react/issues/37, but I cant seem to access it.
My code:
This Is what I tried:
Gives:
Also would expect that onInit functions more like most callbacks (such as https://reactjs.org/docs/forms.html onChange) and takes a function:
Gives:
Same this for:
Gives:
How do I access editor.getHtml()?